1

My use case seems very simple. I want to automount CIFS folder CIFS1 and CIFS2 which exist for all users on my fileserver in each user home during login on this multi-user 18.04 Ubuntu machine.

So if user1 login, i mount :

  • /home/user1/CIFS1
  • /home/user1/CIFS2.

If user2 login, i mount :

  • /home/user2/CIFS1
  • /home/user2/CIFS2.

I have an already a working mounting command to do this, using Kerberos ticket / SSSD to authenticate :

sudo mount -v -t cifs -o user=${USER},cruid=${USER},sec=krb5,uid=${UID} //isilon.mydataserver/CIFS1/${USER} /home/${USER}/CIFS1

sudo mount -v -t cifs -o user=${USER},cruid=${USER},sec=krb5,uid=${UID} //isilon.mydataserver/CIFS2/${USER} /home/${USER}/CIFS2

Works well, but now i want to automount these folders directly after login, with correct ${USER} information injected into autofs configuration.

And ... it seems impossible, i try many things, direct or indirect mapping, executable automap, without success.

The [mountpoint] [option] [location] pattern of autoconf files accept injection of environnement variable (USERS, UID, etc.) only in the option/location part.

In sudo nano /etc/auto.master i have :

/- /etc/auto.cifs --ghost

Following the sun autofs pattern for direct mounting : [mountpoint] [option] [location], my /etc/auto.cifs config contain :

/home/${USER}/CIFS1 -fstype=cifs,user=${USER},cruid=${UID},sec=krb5,uid=${UID} ://isilon.mydataserver/CIFS1/${USER}

/home/${USER}/CIFS2  -fstype=cifs,user=${USER},cruid=${UID},sec=krb5,uid=${UID} ://isilon.mydataserver/CIFS2/${USER}

Reloading configuration :

sudo systemctl reload autofs

During users login, this configuration create litteraly a /home/${USER}/CIFS1 folder and not an /home/user1/CIFS1 or /home/user2/CIFS1 folder ...

Is there a way to obtain this behavior (mounting CIFS folder into multi-users environment : /home/$USER with $USER = user1, user2, ...) using autofs, or another method compatible with Kerberos / SSSD / CIFS authentification ?

Edit1 : I precise to readers that i cannot modify the Active Directory schema in place to use the automounting function of SSSD/AutoFS :(

Edit2 : I also try to run bash program from auto.master with program:/etc/auto.cifs , but it seems that doesn't answer to this problem because program could only return the [option][location] and not the [mountpoint] part.

3
  • Have you already explored a pam_mount solution ?
    – LL3
    Apr 20, 2019 at 20:07
  • Nop, i see that also possible to do something similar with pam_mount but i first try to see if it's possible with auto fs :)
    – reyman64
    Apr 24, 2019 at 20:36
  • I see. Perhaps you can use your already-working autofs mount commands via pam_exec then. Unless autofs has some special requirements (I know very little about it) it might be possible to adjust those commands to work within pam's environment.
    – LL3
    Apr 26, 2019 at 14:15

1 Answer 1

-1

@reyman64 - did you find a solution to your issue? I'm currently in the same situation you described above and have been scouring the interwebs but haven't found a solution. If I can figure out how to set the user variable as part of the mount point it would be golden.

Based on the detailed response here, the user variable in the key position is set to the user that runs the autofs daemon which is always root. Looks like the only possible solution is to have auto.master execute a script.

1
  • This is not a solution or answer, it is much more of a comment.
    – number9
    Jun 30 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.