summaryrefslogtreecommitdiffstats
path: root/glusterfsd/src
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2011-07-30 16:45:50 +0300
committerVijay Bellur <vijay@gluster.com>2011-09-12 06:22:51 -0700
commit78170472e6c7f0bce95ab035cc4ed86ec662e80d (patch)
tree336328e8359b21bb41bf2f293100745410e87e5f /glusterfsd/src
parent32b96d66890a16fd23c8ae065297c7a98097d340 (diff)
add --user-map-root option
This makes client fake that given user is a superuser, by changing FUSE requests coming with uid of user so that uid is set to 0. User can be given in numeric form, in which case it's treated as an uid directly, or else it's tried to be resolved to an uid with getpwnam(3). Implies --acl. Change-Id: I2d5a3d3e178be7ffdf22b46a56f33a7eeaaa7fe1 BUG: 3242 Reviewed-on: http://review.gluster.com/127 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'glusterfsd/src')
-rw-r--r--glusterfsd/src/glusterfsd.c24
-rw-r--r--glusterfsd/src/glusterfsd.h1
2 files changed, 25 insertions, 0 deletions
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index b79753519..42d3916d9 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -39,6 +39,7 @@
#include <time.h>
#include <semaphore.h>
#include <errno.h>
+#include <pwd.h>
#ifndef _CONFIG_H
#define _CONFIG_H
@@ -176,6 +177,8 @@ static struct argp_option gf_options[] = {
"[default: 1]"},
{"client-pid", ARGP_CLIENT_PID_KEY, "PID", OPTION_HIDDEN,
"client will authenticate itself with process id PID to server"},
+ {"user-map-root", ARGP_USER_MAP_ROOT_KEY, "USER", OPTION_HIDDEN,
+ "replace USER with root in messages"},
{"dump-fuse", ARGP_DUMP_FUSE_KEY, "PATH", 0,
"Dump fuse traffic to PATH"},
{"volfile-check", ARGP_VOLFILE_CHECK_KEY, 0, 0,
@@ -276,6 +279,17 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
}
}
+ if (cmd_args->uid_map_root) {
+ ret = dict_set_int32 (master->options, "uid-map-root",
+ cmd_args->uid_map_root);
+ if (ret < 0) {
+ gf_log ("glusterfsd", GF_LOG_ERROR,
+ "failed to set dict value for key %s",
+ "uid-map-root");
+ goto err;
+ }
+ }
+
if (cmd_args->volfile_check) {
ret = dict_set_int32 (master->options, ZR_STRICT_VOLFILE_CHECK,
cmd_args->volfile_check);
@@ -485,6 +499,7 @@ parse_opts (int key, char *arg, struct argp_state *state)
char tmp_buf[2048] = {0,};
char *tmp_str = NULL;
char *port_str = NULL;
+ struct passwd *pw = NULL;
cmd_args = state->input;
@@ -678,6 +693,15 @@ parse_opts (int key, char *arg, struct argp_state *state)
"unknown client pid %s", arg);
break;
+ case ARGP_USER_MAP_ROOT_KEY:
+ pw = getpwnam (arg);
+ if (pw)
+ cmd_args->uid_map_root = pw->pw_uid;
+ else
+ argp_failure (state, -1, 0,
+ "user %s does not exist", arg);
+ break;
+
case ARGP_VOLFILE_CHECK_KEY:
cmd_args->volfile_check = 1;
break;
diff --git a/glusterfsd/src/glusterfsd.h b/glusterfsd/src/glusterfsd.h
index 847cfb63f..5106559c1 100644
--- a/glusterfsd/src/glusterfsd.h
+++ b/glusterfsd/src/glusterfsd.h
@@ -78,6 +78,7 @@ enum argp_option_keys {
ARGP_CLIENT_PID_KEY = 153,
ARGP_ACL_KEY = 154,
ARGP_WORM_KEY = 155,
+ ARGP_USER_MAP_ROOT_KEY = 156,
};
int glusterfs_mgmt_pmap_signout (glusterfs_ctx_t *ctx);