aboutsummaryrefslogtreecommitdiffstats
path: root/util
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 /util
parent217042f6403ad727b8ab85839b99ae15987be892 (diff)
downloadlibfuse-edec95cbc6a844b17aaad982e82df191490b049c.tar.gz
fix
Diffstat (limited to 'util')
-rw-r--r--util/fusermount.c13
1 files changed, 12 insertions, 1 deletions
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;
}
}