summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Goergens <matthias.goergens@gmail.com>2023-03-28 17:45:55 +0800
committerNikolaus Rath <Nikolaus@rath.org>2023-03-28 21:31:18 +0100
commit1703ccb31c68ea883f909e188a9550adda5665c3 (patch)
tree5f2e10ce3cc491e38d58363aed67ca5eb13b5c78
parent055478f11dd4f3d46653f89ffe63f7c5a400b114 (diff)
downloadfuse-1703ccb31c68ea883f909e188a9550adda5665c3.tar.gz
Review feedback: rename and comments
-rw-r--r--util/fusermount.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/util/fusermount.c b/util/fusermount.c
index f752bfd..c59da75 100644
--- a/util/fusermount.c
+++ b/util/fusermount.c
@@ -1190,11 +1190,17 @@ static int send_fd(int sock_fd, int fd)
return 0;
}
-static int mnt_is_ENOTCONN_for_owner(const char *mnt)
+/* Helper for should_auto_unmount
+ *
+ * fusermount typically has the s-bit set - initial open of `mnt` was as root
+ * and got EACCESS as 'allow_other' was not specified.
+ * Try opening `mnt` again with uid and guid of the calling process.
+ */
+static int recheck_ENOTCONN_as_owner(const char *mnt)
{
int pid = fork();
if(pid == -1) {
- perror("fuse: mnt_is_ENOTCONN_for_owner can't fork");
+ perror("fuse: recheck_ENOTCONN_as_owner can't fork");
_exit(EXIT_FAILURE);
} else if(pid == 0) {
uid_t uid = getuid();
@@ -1268,7 +1274,7 @@ static int should_auto_unmount(const char *mnt, const char *type)
result = 1;
break;
case EACCES:
- result = mnt_is_ENOTCONN_for_owner(mnt);
+ result = recheck_ENOTCONN_as_owner(mnt);
break;
default:
result = 0;