From 1703ccb31c68ea883f909e188a9550adda5665c3 Mon Sep 17 00:00:00 2001 From: Matthias Goergens Date: Tue, 28 Mar 2023 17:45:55 +0800 Subject: Review feedback: rename and comments --- util/fusermount.c | 12 +++++++++--- 1 file 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; -- cgit v1.2.1