mount.cifs: make cifs mounts honor the USER environment variable
authorSteve French <stevef@smfhomehp.(none)>
Fri, 5 Dec 2008 00:22:59 +0000 (18:22 -0600)
committerSteve French <stevef@smfhomehp.(none)>
Fri, 5 Dec 2008 00:22:59 +0000 (18:22 -0600)
If the user is not specified in the mount command or in a credential
file, then we are supposed to look for the USER environment variable
(this is usually, but not always set to the username of the current
uid, but it can be overridden by the user, which we were not checking)

Fixes samba bugzilla bug# 5934

source/client/mount.cifs.c

index da2f98bff86e8f1f9ac19962a19cd688165b447c..0bc61ae38f720954716543a35a17bb3e3b8923a3 100644 (file)
@@ -1293,7 +1293,13 @@ int main(int argc, char ** argv)
        }
 
        if(got_user == 0) {
-               user_name = getusername();
+               /* Note that the password will not be retrieved from the
+                  USER env variable (ie user%password form) as there is
+                  already a PASSWD environment varaible */
+               if (getenv("USER"))
+                       user_name = strdup(getenv("USER"));
+               if (user_name == NULL)
+                       user_name = getusername();
                got_user = 1;
        }