Ubuntu – Mounting a webDAV share for all users

davfs2mountpermissionswebdav

I'm trying to mount a webDAV share with this fstab line:

myserverip /media/myserver/ davfs noauto,user,rw 0 0

I have added the secret credentials to ~/.davfs2/secrets.

Also done sudo dpkg-reconfigure davfs2 to allow mounting by non-root users.

This all works fine if I have the following in /etc/davfs2/davfs2.conf:

dav_user        myusername         # system wide config file only
dav_group       myusername         # system wide config file only

But this obviously only works for one user, however if I leave it at the default:

dav_user        davfs2           # system wide config file only
dav_group       davfs2           # system wide config file only

and add my user account to the group davfs2 via

sudo usermod -aG davfs2 myusername

which is successful as shown by the output of groups myusername:

myusername : myusername davfs2

However when I now try to mount the share I get the following error:

/sbin/mount.davfs: user myusername must be a member of group davfs2

So how do I get it to mount by group and why does it not recognize that I’m in the correct group.

Best Answer

Your running login session might not be updated with the new group yet. Try just calling groups and see if that lists davfs2.

$ sudo useradd foo -M
$ groups
myuser adm cdrom sudo dip plugdev lpadmin sambashare
$ sudo usermod -aG foo myuser
$ groups
myuser adm cdrom sudo dip plugdev lpadmin sambashare
$ su -l myuser
$ groups
myuser myuser adm cdrom sudo dip plugdev lpadmin sambashare foo
Related Question