Bug 5934 - mount.cifs doesn't honor $USER environment variable
mount.cifs doesn't honor $USER environment variable
Status: RESOLVED FIXED
Product: CifsVFS
Classification: Unclassified
Component: user space tools
2.6
x86 Linux
: P3 normal
: ---
Assigned To: Steve French
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-12-02 17:57 UTC by Mahdi
Modified: 2008-12-05 08:16 UTC (History)
0 users

See Also:


Attachments
patch to allow mount.cifs to use USER environment variable (601 bytes, patch)
2008-12-04 10:14 UTC, Steve French
no flags Details
current mount.cifs source code which includes patch (38.05 KB, text/plain)
2008-12-04 10:16 UTC, Steve French
no flags Details
minor update (38.04 KB, text/plain)
2008-12-04 10:20 UTC, Steve French
no flags Details
minor update to patch (596 bytes, patch)
2008-12-04 10:21 UTC, Steve French
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mahdi 2008-12-02 17:57:32 UTC
I'm trying to mount a share and passing credentials through environment variables. This used to work correctly with smbfs

root@dev:~# mount.cifs -V
mount.cifs version: 1.10-3.0.26a
root@vslad-dev:~# uname -a
Linux dev 2.6.22-14-generic #1 SMP Tue Feb 12 07:42:25 UTC 2008 i686 GNU/Linux
root@dev:~# export USER=dummyUser
root@dev:~# export PASSWD=pass1
root@dev:~# mkdir /tmp/mountpoint

mount --verbose shows that user is set to root whereas I set USER to something different.

root@dev:~# mount --verbose -t cifs //10.0.0.2/public /tmp/mountpoint
parsing options: rw

mount.cifs kernel mount options unc=//10.0.0.2\public,ip=10.0.0.2,user=root,pass=pass1,ver=1,rw
mount error 13 = Permission denied
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)

PASSWD is correctly picked up though

root@dev:~# export PASSWD=pass2
root@dev:~# mount --verbose -t cifs //10.0.0.2/public /tmp/m
parsing options: rw

mount.cifs kernel mount options unc=//10.0.0.2\public,ip=10.0.0.2,user=root,pass=pass2,ver=1,rw
mount error 13 = Permission denied
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)

-o user= works as well

root@dev:~# mount --verbose -t cifs //10.0.0.2/public /tmp/mountpoint -o user=test
parsing options: rw,user=test

mount.cifs kernel mount options unc=//10.0.0.2\public,ip=10.0.0.2,pass=pass2,ver=1,rw,user=test
mount error 13 = Permission denied
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)
root@dev:~# mount --verbose -t cifs //10.0.0.2/public /tmp/mountpoint -o user=test,password=pass3
parsing options: rw,user=test,password=pass3

mount.cifs warning - password specified twice

mount.cifs kernel mount options unc=//10.0.0.2\public,ip=10.0.0.2,pass=pass2,ver=1,rw,user=test,password=pass3
mount error 13 = Permission denied
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)
Comment 1 Steve French 2008-12-04 10:14:25 UTC
Created attachment 3776 [details]
patch to allow mount.cifs to use USER environment variable
Comment 2 Steve French 2008-12-04 10:16:35 UTC
Created attachment 3777 [details]
current mount.cifs source code which includes patch

To compile this you can do:

gcc -o mount.cifs mount.cifs.c

and then save the file /sbin/mount.cifs, and put the mount.cifs that you just built in the /sbin directory
Comment 3 Steve French 2008-12-04 10:20:33 UTC
Created attachment 3778 [details]
minor update
Comment 4 Steve French 2008-12-04 10:21:19 UTC
Created attachment 3779 [details]
minor update to patch
Comment 5 Steve French 2008-12-04 10:23:44 UTC
If it works for you let me know, so I can check it in
Comment 6 Mahdi 2008-12-04 19:56:22 UTC
It works as expected with the patch.
Comment 7 Steve French 2008-12-05 08:16:48 UTC
pushed to Samba git (master branch)