]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
mount.cifs: if mount user not specified use USER environment variable
authorSteve French <stevef@smf-t60p.smfdom>
Fri, 5 Dec 2008 14:33:39 +0000 (08:33 -0600)
committerKarolin Seeger <kseeger@samba.org>
Thu, 11 Dec 2008 09:27:16 +0000 (10:27 +0100)
    smbfs also would use the USER environment variable if the user was not
    specified on the mount command and no credential file specified, and
    mount.cifs man page says that we will use this environment variable
    (in most cases this will not cause a behavior change, because
    we were doing getuid of the current process which will usually be
    the same name).

    Fixes Samba bug #5934

Acked-by: Jeff Layton
(cherry picked from commit a679d0e96ec54f4660537966b31ce2f56d5a1ea9)

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;
        }