Move hash table to common/ directory
[lttng-tools.git] / librunas / runas.c
index ba361d6d63156a3361816a83bc1c0ae1b3a692da..f612ccc7554590a44fdeca167a33f29d4b0ee0d0 100644 (file)
@@ -149,14 +149,14 @@ int child_run_as(void *_data)
                ret = setegid(data->gid);
                if (ret < 0) {
                        perror("setegid");
-                       exit(EXIT_FAILURE);
+                       return EXIT_FAILURE;
                }
        }
        if (data->uid != geteuid()) {
                ret = seteuid(data->uid);
                if (ret < 0) {
                        perror("seteuid");
-                       exit(EXIT_FAILURE);
+                       return EXIT_FAILURE;
                }
        }
        /*
@@ -172,13 +172,12 @@ int child_run_as(void *_data)
                                writeleft);
                if (writelen < 0) {
                        perror("write");
-                       exit(EXIT_FAILURE);
+                       return EXIT_FAILURE;
                }
                writeleft -= writelen;
                index += writelen;
        } while (writeleft > 0);
-
-       exit(EXIT_SUCCESS);
+       return EXIT_SUCCESS;
 }
 
 static
@@ -231,7 +230,7 @@ int run_as(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid)
         * where the stack grows up (HPPA).
         */
        pid = clone(child_run_as, child_stack + (CHILD_STACK_SIZE / 2),
-               CLONE_FILES | SIGCHLD,
+               CLONE_FILES | SIGCHLD | CLONE_VM,
                &run_as_data, NULL);
        if (pid < 0) {
                perror("clone");
@@ -256,7 +255,7 @@ int run_as(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid)
         * Parent: wait for child to return, in which case the
         * shared memory map will have been created.
         */
-       pid = wait(&status);
+       pid = waitpid(pid, &status, 0);
        if (pid < 0 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) {
                perror("wait");
                ret = -1;
@@ -303,6 +302,8 @@ int open_run_as(const char *path, int flags, mode_t mode, uid_t uid, gid_t gid)
 {
        struct open_data data;
 
+       DBG3("open() %s with flags %X mode %d for uid %d and gid %d",
+                       path, flags, mode, uid, gid);
        data.path = path;
        data.flags = flags;
        data.mode = mode;
This page took 0.025281 seconds and 4 git commands to generate.