1

First off let me say that this is a repost of a question I posted in AskUbuntu. If this is against the rules then please remove this. Honestly, after further consideration of the topic I realized that since autofs works basically the same across various distros, that this was more of an autofs/linux question than an Ubuntu-specific question. Of course, this is my justification because I'm also hoping to get more exposure for this question: it seems like autofs and WebDAV is a rather uncommon combination, so I have more of a chance of finding someone else who has done it successfully if I try in this more general forum.


I am using placeholders for real server names and folders, however, I have tried to make them as representative of the real names as possible, so please do pay attention to my capitalization and punctuation just in case that has anything to do with my problem.

I'm running Ubuntu 16.04.
I've installed autofs and davfs2.

The following command successfully mounts:

mount -t davfs https://servername.mydomain.com:3333/Shared.Folder /testmount

It asks me for a username and password, which are username@mydomain.com and myypassword and then results in a succesful mount.

This tells me several things:

  1. My WebDAV server is working and configured correctly.
  2. HTTPS works fine.
  3. My credentials authenticate succesfully.

So now I'm trying to get this working with autofs.

Here are my files:

/etc/auto.master

/Server.mount /etc/auto.Servername.mount

/etc/auto.Servername.mount

storage-folder -fstype=davfs,ro :https://servername.mydomain.com:3333/Shared.Folder

/etc/davfs2/secrets

https://servername.mydomain.com:3333/Shared.Folder username@domain.com mypassword

With this setup, if I try to browse to /Servername.mount/storage-folder, I get a No such file or directory error.

Now I'm like 95% sure that my problem is a syntax error or an authentication error. There are not a lot of examples to be found on the web for WebDAV-based implementations of autofs, and some of them show conflicting syntax. Nevertheless, I've tried everything I could think of.

I think it is likely that the colon in the auto.Servername.mount file is screwing up the parsing, so I've tried all the following combinations:

storage-folder -fstype=davfs,ro https://servername.mydomain.com:3333/Shared.Folder
storage-folder -fstype=davfs,ro https\://servername.mydomain.com\:3333/Shared.Folder
storage-folder -fstype=davfs,ro :https\://servername.mydomain.com\:3333/Shared.Folder
storage-folder -fstype=davfs,ro https\://servername.mydomain.com\:3333:/Shared.Folder

If that is not causing the problem, then I think it might be something to do with the secrets file. So I've also tried this for my secrets:

/Servername.mount/storage-folder username@domain.com mypassword

Since I'm used to using a credentials file with cifs-based autofs mounts, I also tried, just for fun, in my auto.Servername.mount file:

storage-folder -fstype=davfs,ro,credentials=/etc/credentials.Servername.mount https://servername.mydomain.com:3333/Shared.Folder

Where credentials.Servername.mount was simply:

Username=username@mydomain.com  
Password=mypassword  

I also tried with 'credentials.Servername.mount` as:

https://servername.mydomain.com:3333/Shared.Folder username@domain.com mypassword

Nothing works.

So I feel like I'm missing some small but crucial piece of syntax or config here. I come to you desperate. Any help would be appreciated!

Daniel
  • 1,594
  • 8
  • 26
  • 44

1 Answers1

2

I got it working.

For reference, here is a working autofs with WebDAV setup

Install prereqs

$ sudo apt-get install autofs
$ sudo apt-get install davfs2

/etc/auto.master

/Server.mount /etc/auto.Servername.mount

/etc/auto.Servername.mount

storage-folder -fstype=davfs,ro :https\://servername.mydomain.com\:3333/Shared.Folder

Note: change "ro" [read only] to "rw" [read-write] depending on your needs.

/etc/davfs2/secrets

/Server.mount/storage-folder "username@domain.com" "mypassword"

How I fixed it:

I had several problems.

  1. I found a "definitive" guide to the parsing question for auto.Servername.mount on the fourth page of google results: [url]https://freetz.org/wiki/packages/autofs[/url] So you do indeed need to escape the other colons using a backslash.
  2. I had to turn on verbose logging to find my second problem (which was embarrassingly bad). Open /etc/autofs.conf and find the line that says logging = none. Uncomment it and change none to verbose. Reload autofs : $ sudo /etc/init.d/autofs reload and then check for errors in /var/log/syslog (log file location and name will vary by distro).
  3. syslog was telling me key "storage-folder" not found in map source(s). Now to be fair, my storage-folder name is somewhat long and complex. But I had checked it and checked it many times and again and again I missed that it was actually misspelled by one letter. So that was my second problem, in /etc/auto.Servername.mount I had actually written something like storage-foldr instead of storage-folder, so obviously when I was trying to access /Servername.mount/storage-folder it was not finding any references to that in the config files.
  4. After I fixed this, verbose logging gave me my next lead, as it was now showing the error Could not authenticate to server: rejected Basic challenge. So this told me I was now down to an authentication error. I opened /etc/davfs2/secrets and started poking around, and this time I actually RTFM because the answers were right there in the documentation contained within the secrets file. It spells out exactly which characters need to be escaped with backslash, and it turns out that the @ in my username wasn't the problem, but I did have a problematic character in my password! It turns out that putting the password in quotes is an alternate and easier way around the issue, and I put the username@domain in quotes too just for good measure.

Everything works now!

Daniel
  • 1,594
  • 8
  • 26
  • 44