X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=librunas%2Frunas.c;fp=librunas%2Frunas.c;h=1fc4116255b017ddeed25a2fa5dae414931b1e84;hp=cbb70ee193469dfe35439b8735fcbdda9ebad938;hb=1576d5822eea6a740b4bb26a2709c4ace248006e;hpb=8e0af1b4e36284b519bac6b13928a7589db4da11 diff --git a/librunas/runas.c b/librunas/runas.c index cbb70ee19..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.