maindavfs2 - Support: sr #108774, davfs mount is owned by root

 
 

sr #108774: davfs mount is owned by root

Submitter:  None
Submitted:  Sun 22 Mar 2015 10:35:31 PM UTC
   
 
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Done
Privacy:  Public Assigned to:  _71007
Originator Email:  -email is unavailable- Open/Closed:  Closed
Operating System:  GNU/Linux
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 14 Apr 2015 07:01:49 PM UTC, comment #11: 

It's working! :-D
Man, what a relief! This has been such a huge bummer.
Thanks a lot.
I hope others can benefit from looking through my trials and tribulations.
Btw what's the best way to support your project? Do you accept donations?

Ben Opp <bennypr0fane>
Tue 14 Apr 2015 08:15:39 AM UTC, comment #10: 

Remove directory /var/cache/davfs2. It remained from one of your previous trial and error tests where you - for whatever reason - forced davfs2 to use a non-default cache directory.
davfs2 will create the cachedirectory with correct owner and permissions. Be sure you removed anything from davfs2.conf that changes the defaults for caching.

Of course you must be root for command "mount -a -t davfs". This test tries to do approximately the same as is done at system initialitzation. I'm never sure whether sudo will do exactly the same as when I act as root. Because of this I prefer to switch to user root with the "su" command.

Werner

- <_71007>
Mon 13 Apr 2015 10:20:27 PM UTC, comment #9: 

P.S:
ben@hermann:~$ ls -l /var/cache/davfs2/
total 24
drwx------ 2 ben    davfs2  4096 Apr 13 02:14 oc.benopp.org-remote.php-webdav+home-ben-Owncloud+ben
drwx------ 2 davfs2 davfs2 20480 Mär  7 14:31 oc.benopp.org-remote.php-webdav+home-ben-Owncloud+root
ben@hermann:~$ groups ben
ben : ben adm cdrom sudo audio dip www-data plugdev netdev lpadmin sambashare davfs2

Ben Opp <bennypr0fane>
Mon 13 Apr 2015 10:14:42 PM UTC, comment #8: 

Thanks, I followed all your instructions.
Now there is no davfs share. /home/ben/Owncloud is emtpy.

Here's the terminal output of:
ben@hermann:~$ mount -a -t davfs
mount: only root can do that
ben@hermann:~$ sudo mount -a -t davfs
/sbin/mount.davfs: das Cacheverzeichnis /var/cache/davfs2/oc.benopp.org-remote.php-webdav+home-ben-Owncloud+ben hat den falschen Besitzer

See attached the log file with "debug most" option.

(file #33668)

Ben Opp <bennypr0fane>
Mon 13 Apr 2015 04:46:31 PM UTC, comment #7: 

"2. If the share is mounted by root, regular users do not get read/write access.
3. Hence, if I want a user to get rw access, I need the mount operation to be performed as that user."

This is where you get it wrong. The user option is to allow nonprivelged users to mount. It does not alter the fact that the file system is by default owned by the mounting user.
But you may remember that superuser root is allowed to do anything. So if root is the mounting user he can change the owner of the file system. That is what options uid and gid are for.

There is nothing davfs2 specific about this. Option user has the same purpose and the same meaning for all file systems. Options uid and gid are known by many file system (e.g. FAT).

Please read the man pages of mount, mount.davfs and davfs2.conf for first hand information.

When the file systems are automatically mounted during system initialization then root is the mounting user. So you should

  • edit fstab.

https://my.webdav.org/remote.php/webdav /home/ben/Owncloud davfs uid=ben,gid=ben,_netdev 0 0

  • Undo the changes you made in /etc/davfs2/davfs2.conf.


  • Add a mount specific section at the end of this config file with line "[/home/ben/Owncloud)".


  • Add option "servercert /etc/davfs2/certs/apache.crt" at the end of the config file.


  • Store apache.crt in /etc/davfs2/certs/


  • Add your WebDAV credentials at the end of /etc/davfs2/secrets.

/home/ben/Owncloud mywebdavuser mysecretpassword


You can test your configuration by issuing the command "mount -a -t davfs".

If it works then shut down your system and start it again and test wether the file system is mounted.

If anything goes wrong you may add option "debug most" at the end of davfs2.conf and send a complete report.

"You mentioned deleting ~/.davfs2, should I do this in /etc/davfs2 also?"
No you need it and the system wide configuration file will not be recreated.

Werner

- <_71007>
Mon 13 Apr 2015 01:35:49 PM UTC, comment #6: 

For configuring davfs, I followed the procedure decribed here: http://wiki.ubuntuusers.de/WebDAV, starting by making an entry in /etc/fstab.
+ I initially went with configuring everything system-wide under /etc/davfs2, and
+ after that didn't work I tried in the user space under ~/.davfs2
+ Because that didn't get me automounted either, I used the script suggested under "davfs automatisch betreiben" (the one I named davfs-mount) including the login credentials in that script, and made it autostart by Xfce.
This succeeded to automount, but the share was owned by root.

That was when I first posted here.

+ "Your first message gives the impression, that automounting worked, but the owner of the mount was root. I gave you instructions about how to change this. Why did you not follow this route but instead switched to something else?"
That's what I thought I was doing. Obviously, I got it all wrong.
You gave me some rules, some hints, and instructions on what I should read - not instructions in the sense of "do this and that". I just tried to figure out whatever I could from rules, hints and manuals. So here's how I continued:

+ At some point, I also tried to do chown -R user for the whole volume. That is undone at the next reboot.

+ At this point, I was taking it to work like this: in fstab, webdav mounting by a user was enabled. Davfs2 would take care of performing login. The mount script should do the actual mounting as user.
I thought if davfs2 is taking care of the login, I shouldn't need to provide the credentials in the mount script, so I changed the script to contain just the bare mount command.

The status now is: webdav volume is owned by user, but it won't automount.

I am obviously still very unclear about what happens in fstab.
To understand how I should proceed from here, I need to get a clearer picture.
It should help me a lot if you can answer the following questions:

- Is it possible at all to use the fstab approach for automounting and get the webdav read-/writable by user (if yes, that's how I want to do it)?

- If so, are the following things correct?
1. The share will be owned by the mounting user.
2. If the share is mounted by root, regular users do not get read/write access.
3. Hence, if I want a user to get rw access, I need the mount operation to be performed as that user.
4. This can be done in fstab.
5. 3.) also means I need to configure davfs in ~/.davfs2, not in /etc/davfs2. "only the configuration in /etc/davfs2 will be used. Your WebDAV credentials must be in /etc/davfs2/secrets." If I do this, I will get the result of "owned by root".

If you follow my line of reasoning (specifically, 3.), you can see why this confuses me: "The mounting user will be root. You will have to set options uid and gid in fstab."
So in this setup, what happens? Root is the mounting user, but uid and gid achieve... what? Are you saying that root is mounting, but user ben will be the owner?

"The combination of the options "user,uid=ben,gid=ben" in fstab makes no sense.If the mounting user is root, you don't need option user."
Why not? I thought "user" was the option used to make the mounting user not root, but a regular user. uid and gid specify which one. I thought.
Anyhow, this was my effort to make everything "user-spaced", so I don't get "owned by root" again.

When we can rectify the wrong part of my assumptions above and I manage to get a clear picture, what is the best way to get davfs back to it's default state, so I can start fresh with one simple and seriously documented test? You mentioned deleting ~/.davfs2, should I do this in /etc/davfs2 also?

"I'm not interested in logs of owncloud. I don't understand them. "
Did you look at syslog? It's all messages from davfs.

Thanks for everything so far. Please don't think I'm lazy. I'm trying my best.

Ben Opp <bennypr0fane>
Mon 13 Apr 2015 09:57:22 AM UTC, comment #5: 

"but it seems really weird that I should have to use davfs to mount the webdav volume and use autofs to acutally mount davfs... "

This isn't weird, this is how computers work. Nothing is startet by magic, it must be started by some other process that is already running. It all starts with some firmware that is executed when you switch on your computer.
To mount a davfs2 file system some already running process must invoke the mount program which in turn will invoke the mount.davfs daemon.

If you want to automount, some process that is startet during the initialization process of your computer must call the mount program.

"I don't think it'll be useful if I describe all the steps I took"
I think it is necessary. Of course I'm not interested in when you had breakfast. But what I need in order to see what is going on on what is going wrong is one simple and seriously documented test.

  • First of all: what kind of automounting facility do you want to use. Don't jump from on to another. Just decide for one way and then we will test this way untill we have a definite result.
  • What did you configure to make this happen.
  • What do you expect will happen.
  • What did you do to start this automounting process.
  • What did really happen. All details that are related to the mounting process.
  • If you have logging for davfs2 enabled: only do one or two simple file system actions to keep the log files small. But include the complete logs. Use option "debug most" unless there is a reason to do differently.


What is really confusing:
Your first message gives the impression, that automounting worked, but the owner of the mount was root. I gave you instructions about how to change this. Why did you not follow this route but instead switched to something else?

I would suggest that you try to make this way of automounting work:

  • if the line in fstab is without option "noauto" then the file system will be mounted during system initialization (and unmounted at shutdown).
  • the mounting user will be root. You will have to set options uid and gid in fstab.
  • only the configuration in /etc/davfs2 will be used. Your WebDAV credentials must be in /etc/davfs2/secrets. You may completely remove directory ~/.davfs2 (if you need it some time later it will be recreated in a clean state by davfs2).


Some remarks on yur config files:

  • the combination of the options "user,uid=ben,gid=ben" in fstab makes no sense.If the mounting user is root, you don't need option user. If the mounting user is ben then the file system will be owned by ben and you can't change this.
  • Don't uncomment options in davfs2.conf. They are there to show you a list of all options and their default values. If the default values are fine you don't need to do anything. If you want to change the value then add this option at the end of the file, preferable in a mount specific section as described in "man davfs.conf".
  • Don't change option dav_user unless you really know what you are doing. If you want some nonpriveleged user to be able to mount then add this user to group davfs2. (You don't need this when the file system is mounted by root during system initialization.)
  • "https://my.webdav.org/remote.php/webdav mywebdavuser mysecretpassword". This is old style and deprecated. There is a description in the secrets file about how to do this.


I'm not interested in logs of owncloud. I don't understand them.

Werner

- <_71007>
Sun 12 Apr 2015 10:52:30 PM UTC, comment #4: 

You are right, those messages were actually written by php to the Owncloud log file (Owncloud is the webdav volume I am trying to automount).
By "I enabled debugging to syslog", I meant that in davfs2.conf, I set the debug option to config, http, httpauth
As a result, there are a lot of messages from mount.davfs in /var/log/syslog.
I don't think it'll be useful if I describe all the steps I took after reviewing the mount.davfs and davfs2.conf manuals, but rather share the result, i.e. all the relevant config files (with the personal information replaced by generic strings).
The only long one is the syslog because I enabled the three debugging options. I am hoping you might know what to look/grep for. I would be great If you could take a look.
I wouldn't be asking you this if had any more idea how to go about it more efficiently.

I am attaching:
+ user-space and system-wide davfs.conf
+ user-space secrets file
+ php owncloud.log (most recent portion)
+ /var/log/syslog (today's portion, mount-davfs debug messages)
+ the mount script that should be executed at login (.davfs-mount)

To recap, I want it to automount.
Like you mentioned, I would expect that to happen (provided that everything is configured correctly) if the appropriate line is present in /etc/fstab, without the "noauto" option.
However, it does not automount. I can mount it manually, without problems, by launching the mount command (or accessing the volume in the file manager, which does the exact same thing).
That's why I made a mount script that should be automatically run at login.
This script fails to do the trick, too.
I am at my wit's end.
You suggested pam_mount and/or some other kind of automount - there is a thing called autofs for Linux. I haven't tried either but it seems really weird that I should have to use davfs to mount the webdav volume and use autofs to acutally mount davfs...
Are you sure that e.g. pam_mount can handle davfs?

(file #33656)

Ben Opp <bennypr0fane>
Wed 08 Apr 2015 10:42:18 AM UTC, comment #3: 

I have no idea either. This are not messages from davfs2 and you gave no hint about where they come from.

It might be a good idea if you told the whole story. What exactly do you do? What exactly happens. This should include all the changes you made to any config file.

Messages from davfs2 in your log files should be preceded by "mount.davfs",

"It only mounts after I click it in the file manager". Does your file manager promise to do something else? Please consult the manuals of your file manager.

I am not much interested in automounting. But there are different ways. The ones I heard of:
- mounting during system initialization of all mounts in fstab that are not marked "noauto".
- mounting at log in time using pam_mount.
- mounting on first use by some kind of automount. I dont know much about this, but it is probably what your file manager is doing.

Werner

P.S.: Please don't tell me things like "I enabled debugging to syslog". Tell instead exactly what you did, like "I prayed to god to make logging work".

- <_71007>
Mon 06 Apr 2015 11:29:38 PM UTC, comment #2: 

I looked through your hints and recommendations thoroughly.
I still can't get the share mounted at startup. It only mounts after I click it in the file manager or run the mount command manually.
I enabled debugging to syslog,
here is a fatal error report from the most recent mount:

"
Fatal webdav
Exception: {"Message":"","Code":0,"Trace":"#0 \/var\/www\/owncloud\/lib\/private\/connector\/sabre\/directory.php(84): OC_Connector_Sabre_File->put(Resource id #87)\n#1 \/var\/www\/owncloud\/3rdparty\/sabre\/dav\/lib\/Sabre\/DAV\/Server.php(1647): OC_Connector_Sabre_Directory->createFile('img_0003_scan_c...', Resource id #87)\n#2 \/var\/www\/owncloud\/3rdparty\/sabre\/dav\/lib\/Sabre\/DAV\/Server.php(900): Sabre\\DAV\\Server->createFile('Jolla\/img_0003_...', Resource id #87, NULL)\n#3 [internal function]: Sabre\\DAV\\Server->httpPut('Jolla\/img_0003_...')\n#4 \/var\/www\/owncloud\/3rdparty\/sabre\/dav\/lib\/Sabre\/DAV\/Server.php(474): call_user_func(Array, 'Jolla\/img_0003_...')\n#5 \/var\/www\/owncloud\/3rdparty\/sabre\/dav\/lib\/Sabre\/DAV\/Server.php(214): Sabre\\DAV\\Server->invokeMethod('PUT', 'Jolla\/img_0003_...')\n#6 \/var\/www\/owncloud\/apps\/files\/appinfo\/remote.php(61): Sabre\\DAV\\Server->exec()\n#7 \/var\/www\/owncloud\/remote.php(54): require_once('\/var\/www\/ownclo...')\n#8 {main}","File":"\/var\/www\/owncloud\/lib\/private\/connector\/sabre\/file.php","Line":69}
"

Unfortunately, I have no idea what it means, for lack of plain English. Can you suggest anthing else?

Ben Opp <bennypr0fane>
Mon 23 Mar 2015 10:25:45 AM UTC, comment #1: 

Though davfs2 is not a normal file system it tries to behave as much as possible like other file systems in GNU/Linux. So here are some rules:

  • By default a file system is owned by the mounting user. (This may be different with file systems where owner and group are stored in the file system, but this is not the case with WebDAV.)
  • The "user" option does not change the owner. It just allows nonpriveleged users to mount this file system.
  • If the mounting user is root, but you want the file system to be owned by some other user, you must use options "uid=" and "gid=" in fstab.


Some other hints:

  • If you use "sudo" then you are acting as root (that's what sudo is for).
  • Username and password are the credentials to authenticate with the server. They are completely independent from the local users. This is also true when your server runs on the same machine.
  • If the mounting user is root, it will only use the configuration and secrets file in /etc/davfs2 (or /usr/local/etc/davfs2).
  • When mounting as nonprivileged user it will use the files in ~/.davfs2 but will additinally lookup files in /etc/davfs2. The options in ~/.davfs2 have precedence.


There are different ways of automounting and I don't know the details. You should lookup the respective manual. But most of them will mount as root. You should set the uid and gid options in fstab. When automounting is done by root you must put the WebDAV-credentials in /etc/davfs2/secrets (or /usr/local/etc/davfs2/secrets).

Please also note:
Even when automounting works it is not sure whether auto-un-mounting works. This may leave dvfs2's cache in an inconsistent state. You should check this before relying on it.

Please also have a look at "man mount.davfs" and "man davfs2.conf".

Werner

- <_71007>
Sun 22 Mar 2015 10:35:31 PM UTC, original submission:  

Hello,
When I mount an Owncloud webdav share with davfs in fstab, the mount point /home/ben/Owncloud is owned by root. I posted a detailed description here:
http://www.linuxquestions.org/questions/linux-desktop-74/webdav-mount-is-owned-by-root-4175535997/
With the mount options I provided in fstab, it should be owned by my user, which is the way I want it.
By registering the login credentials in ~/.davfs2/secrets, I can achieve the mount point being owned by my user, but not actually mounted at login. In that case, I still have to mount it manually.
I should note that I am trying to mount this webdav share on the server that it origninates from.
Other methods I unsuccessfully tried are: gvfs, fusedav.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #33668:  syslog added by bennypr0fane (116KiB - application/octet-stream)
file #33656:  mount.davfs-files.tar.gz added by bennypr0fane (8KiB - application/gzip)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bennypr0fane (Posted a comment)
  • -email is unavailable- added by _71007 (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-04-15 _71007 StatusIn Progress Done
        Open/ClosedOpen Closed
    2015-04-13 bennypr0fane Attached File- Added syslog, #33668
    2015-04-12 bennypr0fane Attached File- Added mount.davfs-files.tar.gz, #33656
    2015-03-23 _71007 StatusNone In Progress
        Assigned toNone _71007

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code