1
0
Fork 0
mirror of synced 2024-11-22 00:55:34 -05:00

Add check commnad; Fixes

This commit is contained in:
Ilya Sosnovsky 2021-02-05 21:19:54 +03:00
parent 2659cce1f7
commit 43c0962f25
2 changed files with 15 additions and 5 deletions

View file

@ -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
```

View file

@ -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 {