diff options
author | Anand Avati <avati@gluster.com> | 2011-07-01 16:54:45 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-07-01 15:58:15 -0700 |
commit | 4722d0000a5c6e87728958d7a50416440bc5c064 (patch) | |
tree | 81137ec1455047698192865a3685c0f39d11d4fb /xlators | |
parent | 6d877a2f8f400a35bb99289082ba21dbdd35d2e5 (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
Diffstat (limited to 'xlators')
-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 cd35d7192..d0dad29a4 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; |