Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auth.sh #183

Closed
SkazochnikZlodey opened this issue Dec 28, 2022 · 5 comments
Closed

auth.sh #183

SkazochnikZlodey opened this issue Dec 28, 2022 · 5 comments

Comments

@SkazochnikZlodey
Copy link

SkazochnikZlodey commented Dec 28, 2022

auth.sh not working correclty.

working version is:

`#!/usr/bin/env bash

PATH=$PATH:/usr/local/bin
set -e

env

readarray -t lines < $1
auth_usr=${lines[0]}
auth_passwd=${lines[1]}

if [ $common_name = $auth_usr ]; then

openvpn-user auth --db.path /etc/openvpn/easyrsa/pki/users.db --user ${auth_usr} --password ${auth_passwd}

   if [ $? -eq 0 ]; then
      echo "User " ${auth_usr} "autorized successfully. continue... "
   else
      echo "Authorization falied for user: "  ${auth_usr}
      exit 1
   fi

else
echo "Authorization failed."
exit 1
fi
`

auth.sh.txt

@pashcovich
Copy link
Contributor

And what exactly is working wrong?

@SkazochnikZlodey
Copy link
Author

auth_usr=$(head -1 $1)
auth_passwd=$(tail -1 $1)
not working
switch to bash and change code a little
Yes it` looks wired but ... .

@pashcovich
Copy link
Contributor

and why doesn't it work for you?
we have many working installations with this setup

@SkazochnikZlodey
Copy link
Author

Hmm, just make some test inside container:
bash-5.1# ./test_sh.sh user.txt
sh example
source file :
john
dow
Results :
1st --- john ------- 2nd dow
bash-5.1# ./test_bash.sh user.txt
bash example
source file :
john
dow
Results :
1st --- john ------- 2nd dow
looks like it`s working.

@SkazochnikZlodey
Copy link
Author

Just check again and look like your version is working. I dont know why its not working before

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants