[linux-cifs-client] patch to mount.cifs to allow it to handle USER env variable

Steve French smfrench at gmail.com
Thu Dec 4 16:22:21 GMT 2008


Although the USER env variable is usually set to the same thing as
getuid returns, the user may want to override it (and mount.cifs man
page, like smbfs, says it is supposed to honor the ENV variable $USER.
 Patch follows to fix that:

diff --git a/source/client/mount.cifs.c b/source/client/mount.cifs.c
index 3b56e5f..8e4d521 100644
--- a/source/client/mount.cifs.c
+++ b/source/client/mount.cifs.c
@@ -1269,7 +1269,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;
        }



-- 
Thanks,

Steve


More information about the linux-cifs-client mailing list