projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: add missing rcu read lock across RCU HT iteration
[lttng-tools.git]
/
src
/
common
/
runas.c
diff --git
a/src/common/runas.c
b/src/common/runas.c
index bee107951d8664e6f111ed5ff260574407f0c3a3..60e02a2bf85a4e22ff363d2a6ede3cfc1a0fd277 100644
(file)
--- a/
src/common/runas.c
+++ b/
src/common/runas.c
@@
-28,11
+28,9
@@
#include <unistd.h>
#include <fcntl.h>
#include <sched.h>
#include <unistd.h>
#include <fcntl.h>
#include <sched.h>
-#include <sys/
signal
.h>
+#include <sys/
mman
.h>
#include <common/error.h>
#include <common/error.h>
-#include <common/compat/mman.h>
-#include <common/compat/clone.h>
#include "runas.h"
#include "runas.h"
@@
-156,14
+154,14
@@
int child_run_as(void *_data)
if (data->gid != getegid()) {
ret = setegid(data->gid);
if (ret < 0) {
if (data->gid != getegid()) {
ret = setegid(data->gid);
if (ret < 0) {
-
perror
("setegid");
+
PERROR
("setegid");
return EXIT_FAILURE;
}
}
if (data->uid != geteuid()) {
ret = seteuid(data->uid);
if (ret < 0) {
return EXIT_FAILURE;
}
}
if (data->uid != geteuid()) {
ret = seteuid(data->uid);
if (ret < 0) {
-
perror
("seteuid");
+
PERROR
("seteuid");
return EXIT_FAILURE;
}
}
return EXIT_FAILURE;
}
}
@@
-179,7
+177,7
@@
int child_run_as(void *_data)
writelen = write(data->retval_pipe, &sendret.c[index],
writeleft);
if (writelen < 0) {
writelen = write(data->retval_pipe, &sendret.c[index],
writeleft);
if (writelen < 0) {
-
perror
("write");
+
PERROR
("write");
return EXIT_FAILURE;
}
writeleft -= writelen;
return EXIT_FAILURE;
}
writeleft -= writelen;
@@
-216,7
+214,8
@@
int run_as(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid)
ret = pipe(retval_pipe);
if (ret < 0) {
ret = pipe(retval_pipe);
if (ret < 0) {
- perror("pipe");
+ PERROR("pipe");
+ retval.i = ret;
goto end;
}
run_as_data.data = data;
goto end;
}
run_as_data.data = data;
@@
-229,8
+228,8
@@
int run_as(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid)
MAP_PRIVATE | MAP_GROWSDOWN | MAP_ANONYMOUS | MAP_STACK,
-1, 0);
if (child_stack == MAP_FAILED) {
MAP_PRIVATE | MAP_GROWSDOWN | MAP_ANONYMOUS | MAP_STACK,
-1, 0);
if (child_stack == MAP_FAILED) {
-
perror
("mmap");
- ret = -ENOMEM;
+
PERROR
("mmap");
+ ret
val.i
= -ENOMEM;
goto close_pipe;
}
/*
goto close_pipe;
}
/*
@@
-241,8
+240,8
@@
int run_as(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid)
CLONE_FILES | SIGCHLD,
&run_as_data, NULL);
if (pid < 0) {
CLONE_FILES | SIGCHLD,
&run_as_data, NULL);
if (pid < 0) {
-
perror
("clone");
- ret = pid;
+
PERROR
("clone");
+ ret
val.i
= pid;
goto unmap_stack;
}
/* receive return value */
goto unmap_stack;
}
/* receive return value */
@@
-251,7
+250,7
@@
int run_as(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid)
do {
readlen = read(retval_pipe[0], &retval.c[index], readleft);
if (readlen < 0) {
do {
readlen = read(retval_pipe[0], &retval.c[index], readleft);
if (readlen < 0) {
-
perror
("read");
+
PERROR
("read");
ret = -1;
break;
}
ret = -1;
break;
}
@@
-265,17
+264,24
@@
int run_as(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid)
*/
pid = waitpid(pid, &status, 0);
if (pid < 0 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) {
*/
pid = waitpid(pid, &status, 0);
if (pid < 0 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) {
-
perror
("wait");
- ret = -1;
+
PERROR
("wait");
+ ret
val.i
= -1;
}
unmap_stack:
ret = munmap(child_stack, RUNAS_CHILD_STACK_SIZE);
if (ret < 0) {
}
unmap_stack:
ret = munmap(child_stack, RUNAS_CHILD_STACK_SIZE);
if (ret < 0) {
- perror("munmap");
+ PERROR("munmap");
+ retval.i = ret;
}
close_pipe:
}
close_pipe:
- close(retval_pipe[0]);
- close(retval_pipe[1]);
+ ret = close(retval_pipe[0]);
+ if (ret) {
+ PERROR("close");
+ }
+ ret = close(retval_pipe[1]);
+ if (ret) {
+ PERROR("close");
+ }
end:
return retval.i;
}
end:
return retval.i;
}
This page took
0.024838 seconds
and
4
git commands to generate.