eric6630
09-12-2011, 02:33 AM
#!/bin/bash
### Database Informations
DBUSER='user'
DBPASS='pass'
DBHOST='localhost' #use ip kng external ang mysql server nyo if not localhost lng
DBNAME='dbase'
user_name=`head -n1 $1 | tail -1` #first line -> Username
pass_word=`head -n2 $1 | tail -1 ` #second line -> Password
user_query=`mysql -u $DBUSER -p$DBPASS -D $DBNAME -h $DBHOST --skip-column-name -e "SELECT username FROM user WHERE ( (active = '1') AND (username = '$user_name') AND (password = PASSWORD('$pass_word')) );" $DBNAME`
if [ "$user_query" == "$user_name" ]; then
exit 0
else
exit 1
fi
hi
im using this kind of script for authentication process
the problem is, no one could connect authentication failed
does anyone know what was the problem?
in using ubuntu 10.10, mysql and phpmyadmin
i hope someone could help me
thank you
almanox
09-12-2011, 03:21 AM
Maybe try
"$user_name" instead of '$user_name'
"$pass_word" instead of '$pass_word'
in the query so that the variables get substituted.
eric6630
09-12-2011, 03:32 AM
Hi
Still not working i change from single to double quote
do i need to put
user is my table name on database
username one of my column
do i need to put user.username = "$user_name" ????
but i tried nothing happened.
do i need to put table?
how?
almanox
09-12-2011, 04:30 AM
First try to check from command line if the credentials are OK for example
DBHOST=localhost; DBNAME=root; DBPASS=xxx; mysql -u $DBNAME -p$DBPASS -h $HOST $DBNAME
if you can connect then continue with the query in your script or from command line
DBHOST=localhost; DBNAME=root; DBPASS=xxx; mysql -u $DBNAME -p$DBPASS -h $HOST --skip-column-name -e "SELECT username FROM user WHERE active = 1 AND username = \"$user_name\" AND password = PASSWORD(\"$pass_word\");" $DBNAME
eric6630
09-12-2011, 04:51 AM
Hi
ok sir ill try it now
for clarification
username = \"$user_name\"
and
password = PASSWORD(\"$pass_word\")
do i need to put close parenthesis on username?
eric6630
09-12-2011, 05:30 AM
Hi
same problem
but if im using this
plugin /etc/openvpn/openvpn-auth-pam.so openvpn
auth sufficient pam_mysql.so \
user=user passwd=pass host=localhost db=openvpn \
table=user usercolumn=username passwdcolumn=password \
where=active>online sqllog=0 crypt=1
account required pam_mysql.so \
user=user passwd=pass host=localhost db=openvpn \
table=user usercolumn=username passwdcolumn=password \
where=active>online sqllog=0 crypt=1
successfully login if i created on root sql
but if on phpmyadmin created successfully but auth failed.
if im using this
auth-user-pass-verify "/etc/openvpn/auth_vpn.sh" via-file
#!/bin/bash
### Database Informations
DBPASS=xxxx;
DBHOST=localhost;
DBNAME=root;
user_name=`head -n1 $1 | tail -1` #first line -> Username
pass_word=`head -n2 $1 | tail -1 ` #second line -> Password
user_query=mysql -u $DBNAME -p$DBPASS -h $DBHOST --skip-column-name -e "SELECT username FROM user WHERE active = 1 AND username = (\"$user_name\") AND password = PASSWORD(\"$pass_word\");" $DBNAME
if [ "$user_query" == "$user_name" ]; then
exit 0
else
exit 1
fi
authentication failed both created on sql and phpmyadmin.
is there anything i missed?
almanox
09-12-2011, 06:02 AM
In the previous examples DBNAME was used for DBUSER. Let's separate them
to avoid confusion.
Make sure you are using valid MySQL username and password
i.e. replace root, xxx and mydb with your values
and try connecting in simplest form
DBNAME=mydb; DBHOST=localhost; DBUSER=root; DBPASS=xxx; mysql -u $DBUSER -p$DBPASS -h $DBHOST $DBNAME
You may also skip host parameter to use default socket connection like
DBNAME=mydb; DBUSER=root; DBPASS=xxx; mysql -u $DBUSER -p$DBPASS $DBNAME
or even provide password interactively like
DBNAME=mydb; DBUSER=root; mysql -u $DBUSER -p $DBNAME
Only if the above succeed you can try debugging the script.
eric6630
09-12-2011, 06:47 AM
Hi
all parameter's working ok even try to insert using .php
when i trying to execute it was perfectly fine
why i got always auth failed
saslauthd[3745]: do_auth : auth failure: [user=test] [service=smtp] [realm=xxxx.com] [mech=pam] [reason=PAM auth error]
got this error
dont know how to fixed it.
im noob
did you know how to fix that error?