diff --git a/README.md b/README.md index 4169d38..66ea715 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ # openvpn-user -### disclaimer -Not tested in production environments! +## Disclaimer +```diff +- Not tested in production environments! +``` + Use it on your own risk =) @@ -9,14 +12,16 @@ Use it on your own risk =) A simple tool to use with openvpn when you need to use `–auth-user-pass-verify` or wherever you want ### Example +make sure `openvpn-user` binary available through `PATH` variable and you have `auth.sh` script with `+x` rights available to openvpn server + +i.e. put binary to `/usr/local/sbin/` and auth script to `/etc/openvpn/scripts/` dir part of openvpn server config ```bash +script-security 2 auth-user-pass-verify /etc/openvpn/scripts/auth.sh via-file ``` -make sure `openvpn-user` binary available through `PATH` variable -i.e. put it in `/usr/local/sbin/openvpn-user` ### Usage ``` diff --git a/openvpn-user.go b/openvpn-user.go index 49c3d93..1bd759a 100644 --- a/openvpn-user.go +++ b/openvpn-user.go @@ -32,6 +32,9 @@ var ( listCommand = kingpin.Command("list", "List active users.") listAll = listCommand.Flag("all", "Show all users include revoked and deleted.").Default("false").Bool() + checkCommand = kingpin.Command("check", "check user existent.") + checkCommandUserFlag = checkCommand.Flag("user", "Username.").Required().String() + authCommand = kingpin.Command("auth", "Auth user.") authCommandUserFlag = authCommand.Flag("user", "Username.").Required().String() authCommandPasswordFlag = authCommand.Flag("password", "Password.").Required().String() @@ -66,6 +69,8 @@ func main() { restoreUser(*restoreCommandUserFlag) case listCommand.FullCommand(): printUsers() + case checkCommand.FullCommand(): + _ = checkUserExistent(*checkCommandUserFlag) case authCommand.FullCommand(): authUser(*authCommandUserFlag, *authCommandPasswordFlag) case changePasswordCommand.FullCommand(): @@ -128,7 +133,7 @@ func restoreUser(username string) { func checkUserExistent(username string) bool { // we need to check if there is already such a user - + // return true if user exist var c int _ = getDb().QueryRow("SELECT count(*) FROM users WHERE username = $1", username).Scan(&c) if c == 1 {