From edec95cbc6a844b17aaad982e82df191490b049c Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Mon, 26 Sep 2005 10:22:22 +0000 Subject: [PATCH] fix --- ChangeLog | 5 +++++ util/fusermount.c | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 21cf029..c734e8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-09-26 Miklos Szeredi + + * 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 * 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; } } -- 2.30.2