pam_mount’ing CIFS volume with a different user

With the latest Linux tools, mounting CIFS volumes giving a different user name than one’s login name does no longer work. I.e. OpenSUSE 12.2 ships a version of pam_mount that by default includes a “user=%(USER)” mount option, which collides with a manually added “user=someotheruser” option. There’s a patch available for pam_mount, but recompiling pam_mount is not everybody’s cup of tea.

If you take a closer look at the patch, you see it only changes the compiled-in default for the CIFS mount command. So rather than compiling from the sources, you can as well configure pam_mount to use that new mount:

    <mntoptions allow="nosuid,nodev,loop,encryption,fsck,nonempty,allow_root,allow_other,user" />
    <cifsmount>mount -t cifs %(COMBOPATH) %(MNTPT) -o uid=%(USERID),gid=%(USERGID)%(if %(OPTIONS),",%(OPTIONS)")</cifsmount>
    <volume fstype="cifs" user="loginuser" options="user=someotheruser" mountpoint="//server/base/DFSRoot" path="/media/mountpoint" />

Please note that you have to add all required manual options to the “<mntoptions allow=…>” attribute, in the above case at least “user”.

Once you update your system with an accordingly patched version of pam_mount, you can of course remove the manual “<cifsmount>” override. As long as it works for you, it should do no harm to leave it in, you’ll just not profit from other enhancing changes to the default that may be incorporated at a later time.


This entry was posted in Linux. Bookmark the permalink.

Leave a Reply