projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Only seteuid/setegid if they differ from current values
[lttng-tools.git]
/
librunas
/
runas.c
diff --git
a/librunas/runas.c
b/librunas/runas.c
index 12327c1111fd15715174d41947f5e41db26beca3..1fc4116255b017ddeed25a2fa5dae414931b1e84 100644
(file)
--- 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.
*/
* 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.
}
/*
* 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;
}
uid, geteuid());
return -EPERM;
}
- return (*cmd)(data);
}
child_stack = malloc(CHILD_STACK_SIZE * 2);
}
child_stack = malloc(CHILD_STACK_SIZE * 2);
This page took
0.031136 seconds
and
4
git commands to generate.