summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2005-09-26 10:22:22 +0000
committerMiklos Szeredi <miklos@szeredi.hu>2005-09-26 10:22:22 +0000
commitedec95cbc6a844b17aaad982e82df191490b049c (patch)
tree2fa17d924d97764d3e63ee291d70fb8c796fc167
parent217042f6403ad727b8ab85839b99ae15987be892 (diff)
downloadfuse-edec95cbc6a844b17aaad982e82df191490b049c.tar.gz
fix
-rw-r--r--ChangeLog5
-rw-r--r--util/fusermount.c13
2 files changed, 17 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 21cf029..c734e8b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-09-26 Miklos Szeredi <miklos@szeredi.hu>
+
+ * fusermount: allow user umount in the case when /etc/mtab is a
+ symlink to /proc/mounts. Reported by Balázs Pozsár.
+
2005-09-23 Miklos Szeredi <miklos@szeredi.hu>
* Check for special node ID values in lookup and creation
diff --git a/util/fusermount.c b/util/fusermount.c
index 4c92b46..6ccc58e 100644
--- a/util/fusermount.c
+++ b/util/fusermount.c
@@ -160,6 +160,8 @@ static int remove_mount(const char *mnt, int quiet, const char *mtab,
FILE *fp;
FILE *newfp;
const char *user = NULL;
+ char uidstr[32];
+ unsigned uidlen = 0;
int found;
fp = setmntent(mtab, "r");
@@ -180,6 +182,8 @@ static int remove_mount(const char *mnt, int quiet, const char *mtab,
user = get_user_name();
if (user == NULL)
return -1;
+
+ uidlen = sprintf(uidstr, "%u", getuid());
}
found = 0;
@@ -191,7 +195,14 @@ static int remove_mount(const char *mnt, int quiet, const char *mtab,
removed = 1;
else {
char *p = strstr(entp->mnt_opts, "user=");
- if (p != NULL && strcmp(p + 5, user) == 0)
+ if (p && (p == entp->mnt_opts || *(p-1) == ',') &&
+ strcmp(p + 5, user) == 0)
+ removed = 1;
+ /* /etc/mtab is a link pointing to /proc/mounts: */
+ else if ((p = strstr(entp->mnt_opts, "user_id=")) &&
+ (p == entp->mnt_opts || *(p-1) == ',') &&
+ strncmp(p + 8, uidstr, uidlen) == 0 &&
+ (*(p+8+uidlen) == ',' || *(p+8+uidlen) == '\0'))
removed = 1;
}
}