diff options
author | Anand Avati <avati@gluster.com> | 2011-07-01 17:17:11 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-07-08 02:25:54 -0700 |
commit | 8af1177029b7103ba84bc59eb58d7c5c8635e6cd (patch) | |
tree | 94a02bcdb971aa4e71de1c063103fab44d580c54 | |
parent | 14d65cb9e0c6f5a6176014701c86760a392d3a44 (diff) |
fuse: fill frame->root->groups with aux gids of the process
Pick the groups in /proc/<pid>/status from the line starting
with "Groups: " by parsing the list of integers which follow
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2815 (Server-enforced ACLs)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2815
-rw-r--r-- | xlators/mount/fuse/src/fuse-helpers.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/xlators/mount/fuse/src/fuse-helpers.c b/xlators/mount/fuse/src/fuse-helpers.c index cd35d719214..d0dad29a409 100644 --- a/xlators/mount/fuse/src/fuse-helpers.c +++ b/xlators/mount/fuse/src/fuse-helpers.c @@ -134,6 +134,57 @@ get_fuse_state (xlator_t *this, fuse_in_header_t *finh) } +void +frame_fill_groups (call_frame_t *frame) +{ + char filename[128]; + char line[128]; + char *ptr = NULL; + int ret = 0; + FILE *fp = NULL; + int idx = 0; + long int id = 0; + char *saveptr = NULL; + char *endptr = NULL; + + ret = snprintf (filename, 128, "/proc/%d/status", frame->root->pid); + if (ret == 128) + goto out; + + fp = fopen (filename, "r"); + if (!fp) + goto out; + + while ((ptr = fgets (line, 128, fp))) { + if (strncmp (ptr, "Groups:", 7) != 0) + continue; + + ptr = line + 8; + + for (ptr = strtok_r (ptr, " \t\r\n", &saveptr); + ptr; + ptr = strtok_r (NULL, " \t\r\n", &saveptr)) { + errno = 0; + id = strtol (ptr, &endptr, 0); + if (errno == ERANGE) + break; + if (!endptr || *endptr) + break; + frame->root->groups[idx++] = id; + if (idx == GF_REQUEST_MAXGROUPS) + break; + } + + frame->root->ngrps = idx; + break; + } +out: + if (fp) + fclose (fp); + return; +} + + call_frame_t * get_call_frame_for_req (fuse_state_t *state) { @@ -160,6 +211,8 @@ get_call_frame_for_req (fuse_state_t *state) frame->root->unique = finh->unique; } + frame_fill_groups (frame); + if (priv && priv->client_pid_set) frame->root->pid = priv->client_pid; |