From 467c1d137a2bfce2fedb3bc98e647e039073f13f Mon Sep 17 00:00:00 2001 From: Steve French Date: Thu, 4 Dec 2008 18:22:59 -0600 Subject: [PATCH] mount.cifs: make cifs mounts honor the USER environment variable 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/client/mount.cifs.c b/source/client/mount.cifs.c index da2f98bff86..0bc61ae38f7 100644 --- a/source/client/mount.cifs.c +++ b/source/client/mount.cifs.c @@ -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; } -- 2.25.1