Miklos Szeredi | 5 Mar 2012 17:02
Picon

Re: sshfs fails in NFS-mounted home

Daniel Böhmer <boehmer <at> tropos.de> writes:

> Thank you for your reply. It's been a while since the last message but we've 
> been busy with other things and then my coworker was on vacation. So now 
> here's what the terminal says:
>
> user <at> host:~$ ls mount_point/
> some_local_files.txt
> user <at> host:~$ sshfs -o nonempty server: mount_point/
> user <at> host:~$ ls mount_point/
> some_remote_files.txt
> user <at> host:~$ killall sshfs
> user <at> host:~$ ls mount_point/
> ls: cannot access mount_point: Transport endpoint is not connected
> user <at> host:~$ fusermount -u mount_point/
> fusermount: failed to chdir to /home/user: Permission denied

I think it's because the "root_squash" option on the NFS server will map
"root" to "nobody".

So this is not an sshfs specific issue, but something in fusermount.
The following patch to should fix it, but I haven't tested it yet.  It
would be great if you could give feedback about the patch.

Thanks,
Miklos

diff --git a/util/fusermount.c b/util/fusermount.c
index b2e87d9..cfd43a6 100644
--- a/util/fusermount.c
+++ b/util/fusermount.c
 <at>  <at>  -352,6 +352,7  <at>  <at>  static int chdir_to_parent(char *copy, const char **lastp)
 	const char *parent;
 	char buf[65536];
 	int res;
+	int errno_save;

 	tmp = strrchr(copy, '/');
 	if (tmp == NULL || tmp[1] == '\0') {
 <at>  <at>  -371,10 +372,13  <at>  <at>  static int chdir_to_parent(char *copy, const char **lastp)
 		parent = "/";
 	}

+	drop_privs();
 	res = chdir(parent);
+	errno_save = errno;
+	restore_privs();
 	if (res == -1) {
 		fprintf(stderr, "%s: failed to chdir to %s: %s\n",
-			progname, parent, strerror(errno));
+			progname, parent, strerror(errno_save));
 		return -1;
 	}

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Fuse-sshfs mailing list
Fuse-sshfs <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fuse-sshfs

Gmane