X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=librunas%2Frunas.c;h=1fc4116255b017ddeed25a2fa5dae414931b1e84;hb=1576d5822eea6a740b4bb26a2709c4ace248006e;hp=12327c1111fd15715174d41947f5e41db26beca3;hpb=c2b75c490235d87f8a8040f3ddff6b0addceea21;p=lttng-tools.git diff --git a/librunas/runas.c b/librunas/runas.c index 12327c111..1fc411625 100644 --- a/librunas/runas.c +++ b/librunas/runas.c @@ -148,15 +148,19 @@ int child_run_as(void *_data) * cannot attach to this process with, e.g. ptrace, nor map this * process memory. */ - ret = setegid(data->gid); - if (ret < 0) { - perror("setegid"); - exit(EXIT_FAILURE); + if (data->gid != getegid()) { + ret = setegid(data->gid); + if (ret < 0) { + perror("setegid"); + exit(EXIT_FAILURE); + } } - ret = seteuid(data->uid); - if (ret < 0) { - perror("seteuid"); - exit(EXIT_FAILURE); + if (data->uid != geteuid()) { + ret = seteuid(data->uid); + if (ret < 0) { + perror("seteuid"); + exit(EXIT_FAILURE); + } } /* * Also set umask to 0 for mkdir executable bit. @@ -204,7 +208,6 @@ int run_as(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid) uid, geteuid()); return -EPERM; } - return (*cmd)(data); } child_stack = malloc(CHILD_STACK_SIZE * 2);