r21736: Fix the smbclient test to do something more interesting with the last
authorAndrew Bartlett <abartlet@samba.org>
Wed, 7 Mar 2007 04:20:10 +0000 (04:20 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:49:20 +0000 (14:49 -0500)
few authentication tests.  Now that the tests correctly 'fail', I was
able to fix the credentials subsystem to honour USER and PASSWD.

To get --machine-pass working, I needed ldb to always load it's static
modules, so I put this in ldb_connect().

Andrew Bartlett
(This used to be commit 3430d8c072407a1c33c32229095fc9db2142b6fa)

source4/auth/credentials/credentials.c
source4/auth/credentials/credentials.h
source4/auth/credentials/credentials_files.c
source4/lib/ldb/common/ldb.c
testprogs/blackbox/test_smbclient.sh

index 6f740d95c30ac52dab92230c0202f59a7d3f545a..55ada8e5a5496aed1bdd2956df3cb69cea38c64e 100644 (file)
@@ -648,8 +648,9 @@ void cli_credentials_guess(struct cli_credentials *cred)
                cli_credentials_parse_password_fd(cred, atoi(getenv("PASSWD_FD")), CRED_GUESS_FILE);
        }
        
                cli_credentials_parse_password_fd(cred, atoi(getenv("PASSWD_FD")), CRED_GUESS_FILE);
        }
        
-       if (getenv("PASSWD_FILE")) {
-               cli_credentials_parse_password_file(cred, getenv("PASSWD_FILE"), CRED_GUESS_FILE);
+       p = getenv("PASSWD_FILE");
+       if (p && p[0]) {
+               cli_credentials_parse_password_file(cred, p, CRED_GUESS_FILE);
        }
        
        if (cli_credentials_get_kerberos_state(cred) != CRED_DONT_USE_KERBEROS) {
        }
        
        if (cli_credentials_get_kerberos_state(cred) != CRED_DONT_USE_KERBEROS) {
index b71539c2eb431778659a2159307252b1e631c456..ce63a55bb3c6eff72aaeb3a0f6e5686b4ef701e4 100644 (file)
@@ -30,8 +30,8 @@ struct ccache_container;
 /* In order of priority */
 enum credentials_obtained { 
        CRED_UNINITIALISED = 0,  /* We don't even have a guess yet */
 /* In order of priority */
 enum credentials_obtained { 
        CRED_UNINITIALISED = 0,  /* We don't even have a guess yet */
-       CRED_GUESS_ENV,          /* Current value should be used, which was guessed */
        CRED_CALLBACK,           /* Callback should be used to obtain value */
        CRED_CALLBACK,           /* Callback should be used to obtain value */
+       CRED_GUESS_ENV,          /* Current value should be used, which was guessed */
        CRED_GUESS_FILE,         /* A guess from a file (or file pointed at in env variable) */
        CRED_CALLBACK_RESULT,    /* Value was obtained from a callback */
        CRED_SPECIFIED           /* Was explicitly specified on the command-line */
        CRED_GUESS_FILE,         /* A guess from a file (or file pointed at in env variable) */
        CRED_CALLBACK_RESULT,    /* Value was obtained from a callback */
        CRED_SPECIFIED           /* Was explicitly specified on the command-line */
index 023dc904077a46dda1d9422d437f93de6c69f6b9..fe8e9aff974c0a2316713678b15348775e99a290 100644 (file)
@@ -89,7 +89,7 @@ BOOL cli_credentials_parse_password_file(struct cli_credentials *credentials, co
        BOOL ret;
 
        if (fd < 0) {
        BOOL ret;
 
        if (fd < 0) {
-               fprintf(stderr, "Error opening PASSWD_FILE %s: %s\n",
+               fprintf(stderr, "Error opening password file %s: %s\n",
                                file, strerror(errno));
                return False;
        }
                                file, strerror(errno));
                return False;
        }
index 268756dc9344fa23324d8be52675241ac0dee8b2..5b3520766dd17480573071d6c2579b3e93e33f71 100644 (file)
@@ -232,6 +232,9 @@ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, co
 {
        int ret;
 
 {
        int ret;
 
+       /* We seem to need to do this here, or else some utilities don't get ldb backends */
+       ldb_global_init();
+
        ldb->flags = flags;
 
        ret = ldb_connect_backend(ldb, url, options, &ldb->modules);
        ldb->flags = flags;
 
        ret = ldb_connect_backend(ldb, url, options, &ldb->modules);
index 211f0f3c48797ea88bd66b4be4e2e17c0257bef8..e8f90060de834e51ca59f513bc2f8d61345a5ab0 100755 (executable)
@@ -59,13 +59,10 @@ echo rm tmpfile | runcmd "Removing file" || failed=`expr $failed + 1`
 # compare locally
 testit "Comparing files" diff tmpfile-old tmpfile || failed=`expr $failed + 1`
 # create directory
 # compare locally
 testit "Comparing files" diff tmpfile-old tmpfile || failed=`expr $failed + 1`
 # create directory
-echo mkdir bla | runcmd "Creating directory" || failed=`expr $failed + 1`
 # cd to directory
 # cd to directory
-echo cd bla | runcmd "Changing directory" || failed=`expr $failed + 1`
 # cd to top level directory
 # cd to top level directory
-echo cd .. | runcmd "Going back" || failed=`expr $failed + 1`
 # remove directory
 # remove directory
-echo rmdir bla | runcmd "Removing directory"  || failed=`expr $failed + 1`
+echo "mkdir bla; cd bla; cd ..; rmdir bla" | runcmd "Creating directory, Changing directory, Going back, " || failed=`expr $failed + 1`
 # enable recurse, create nested directory
 echo "recurse; echo mkdir bla/bloe; exit" | runcmd "Creating nested directory" || failed=`expr $failed + 1`
 # remove parent directory
 # enable recurse, create nested directory
 echo "recurse; echo mkdir bla/bloe; exit" | runcmd "Creating nested directory" || failed=`expr $failed + 1`
 # remove parent directory
@@ -97,17 +94,37 @@ echo rm tmpfilex | runcmd "Removing file" || failed=`expr $failed + 1`
 echo ls | runcmd "List directory with LANMAN1" -m LANMAN1 || failed=`expr $failed + 1`
 echo ls | runcmd "List directory with LANMAN2" -m LANMAN2 || failed=`expr $failed + 1`
 
 echo ls | runcmd "List directory with LANMAN1" -m LANMAN1 || failed=`expr $failed + 1`
 echo ls | runcmd "List directory with LANMAN2" -m LANMAN2 || failed=`expr $failed + 1`
 
-echo ls | testit "Test login with --machine-pass" $VALGRIND bin/smbclient $CONFIGURATION //$SERVER/tmp --machine-pass
-
-echo "password=$PASSWORD\nusername=$USERNAME\ndomain=$DOMAIN" > tmpauthfile
-
-echo ls | testit "Test login with --authentication-file" $VALGRIND bin/smbclient $CONFIGURATION //$SERVER/tmp --authentication-file=tmpauthfile 
-
-echo "$PASSWORD" > tmppassfile
-
-echo ls | PASSWD_FILE="tmppassfile" testit "Test login with PASSWD_FILE" $VALGRIND bin/smbclient $CONFIGURATION //$SERVER/tmp -W "$DOMAIN" -U"$USERNAME"
-
+echo ls | testit "Test login with --machine-pass" $VALGRIND bin/smbclient $CONFIGURATION //$SERVER/tmp --machine-pass  || failed=`expr $failed + 1`
+
+(
+    echo "password=$PASSWORD"
+    echo "username=$USERNAME"
+    echo "domain=$DOMAIN"
+) > tmpauthfile
+
+echo ls | testit "Test login with --authentication-file" $VALGRIND bin/smbclient $CONFIGURATION //$SERVER/tmp --authentication-file=tmpauthfile  || failed=`expr $failed + 1`
+
+PASSWD_FILE="tmppassfile" 
+echo "$PASSWORD" > $PASSWD_FILE
+export PASSWD_FILE
+echo ls | testit "Test login with PASSWD_FILE" $VALGRIND bin/smbclient $CONFIGURATION //$SERVER/tmp -W "$DOMAIN" -U"$USERNAME" || failed=`expr $failed + 1`
+PASSWD_FILE=""
+export PASSWD_FILE
+unset PASSWD_FILE
+
+PASSWD="$PASSWORD" 
+export PASSWD
+echo ls | testit "Test login with PASSWD" $VALGRIND bin/smbclient $CONFIGURATION //$SERVER/tmp -W "$DOMAIN" -U"$USERNAME" || failed=`expr $failed + 1`
+
+oldUSER=$USER
+USER="$USERNAME" 
+export USER
+echo ls | testit "Test login with USER and PASSWD" $VALGRIND bin/smbclient $CONFIGURATION //$SERVER/tmp -W "$DOMAIN" | failed=`expr $failed + 1`
+PASSWD=
+export PASSWD
+unset PASSWD
+USER=$oldUSER
+export USER
 
 rm -f tmpfile tmpfile-old tmpfilex tmpauthfile tmppassfile
 
 rm -f tmpfile tmpfile-old tmpfilex tmpauthfile tmppassfile
-
 exit $failed
 exit $failed