Fix runas namespace
authorDavid Goulet <dgoulet@efficios.com>
Mon, 16 Jan 2012 17:15:18 +0000 (12:15 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 16 Jan 2012 17:15:18 +0000 (12:15 -0500)
Signed-off-by: David Goulet <dgoulet@efficios.com>
common/runas.c
common/runas.h
liblttng-kconsumer/lttng-kconsumer.c
liblttng-ustconsumer/lttng-ustconsumer.c
lttng-sessiond/main.c
lttng-sessiond/session.c
lttng-sessiond/ust-app.c

index 22bd2fe8fab208ba6fdc00fc9d37cb91c0cf1244..8ec7dc6b35010fe837676d361e2ad71fdd7774eb 100644 (file)
@@ -34,7 +34,7 @@
 
 #include "runas.h"
 
-#define CHILD_STACK_SIZE       10485760
+#define RUNAS_CHILD_STACK_SIZE 10485760
 
 struct run_as_data {
        int (*cmd)(void *data);
@@ -44,12 +44,12 @@ struct run_as_data {
        int retval_pipe;
 };
 
-struct mkdir_data {
+struct run_as_mkdir_data {
        const char *path;
        mode_t mode;
 };
 
-struct open_data {
+struct run_as_open_data {
        const char *path;
        int flags;
        mode_t mode;
@@ -61,7 +61,7 @@ struct open_data {
 static
 int _mkdir_recursive(void *_data)
 {
-       struct mkdir_data *data = _data;
+       struct run_as_mkdir_data *data = _data;
        const char *path;
        char *p, tmp[PATH_MAX];
        struct stat statbuf;
@@ -118,14 +118,14 @@ error:
 static
 int _mkdir(void *_data)
 {
-       struct mkdir_data *data = _data;
+       struct run_as_mkdir_data *data = _data;
        return mkdir(data->path, data->mode);
 }
 
 static
 int _open(void *_data)
 {
-       struct open_data *data = _data;
+       struct run_as_open_data *data = _data;
        return open(data->path, data->flags, data->mode);
 }
 
@@ -218,7 +218,7 @@ int run_as(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid)
        run_as_data.uid = uid;
        run_as_data.gid = gid;
        run_as_data.retval_pipe = retval_pipe[1];       /* write end */
-       child_stack = mmap(NULL, CHILD_STACK_SIZE,
+       child_stack = mmap(NULL, RUNAS_CHILD_STACK_SIZE,
                PROT_WRITE | PROT_READ,
                MAP_PRIVATE | MAP_GROWSDOWN | MAP_ANONYMOUS | MAP_STACK,
                -1, 0);
@@ -231,7 +231,7 @@ int run_as(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid)
         * Pointing to the middle of the stack to support architectures
         * where the stack grows up (HPPA).
         */
-       pid = clone(child_run_as, child_stack + (CHILD_STACK_SIZE / 2),
+       pid = clone(child_run_as, child_stack + (RUNAS_CHILD_STACK_SIZE / 2),
                CLONE_FILES | SIGCHLD,
                &run_as_data, NULL);
        if (pid < 0) {
@@ -263,7 +263,7 @@ int run_as(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid)
                ret = -1;
        }
 unmap_stack:
-       ret = munmap(child_stack, CHILD_STACK_SIZE);
+       ret = munmap(child_stack, RUNAS_CHILD_STACK_SIZE);
        if (ret < 0) {
                perror("munmap");
        }
@@ -274,9 +274,9 @@ end:
        return retval.i;
 }
 
-int mkdir_recursive_run_as(const char *path, mode_t mode, uid_t uid, gid_t gid)
+int run_as_mkdir_recursive(const char *path, mode_t mode, uid_t uid, gid_t gid)
 {
-       struct mkdir_data data;
+       struct run_as_mkdir_data data;
 
        DBG3("mkdir() recursive %s with mode %d for uid %d and gid %d",
                        path, mode, uid, gid);
@@ -285,9 +285,9 @@ int mkdir_recursive_run_as(const char *path, mode_t mode, uid_t uid, gid_t gid)
        return run_as(_mkdir_recursive, &data, uid, gid);
 }
 
-int mkdir_run_as(const char *path, mode_t mode, uid_t uid, gid_t gid)
+int run_as_mkdir(const char *path, mode_t mode, uid_t uid, gid_t gid)
 {
-       struct mkdir_data data;
+       struct run_as_mkdir_data data;
 
        DBG3("mkdir() %s with mode %d for uid %d and gid %d",
                        path, mode, uid, gid);
@@ -300,9 +300,9 @@ int mkdir_run_as(const char *path, mode_t mode, uid_t uid, gid_t gid)
  * Note: open_run_as is currently not working. We'd need to pass the fd
  * opened in the child to the parent.
  */
-int open_run_as(const char *path, int flags, mode_t mode, uid_t uid, gid_t gid)
+int run_as_open(const char *path, int flags, mode_t mode, uid_t uid, gid_t gid)
 {
-       struct open_data data;
+       struct run_as_open_data data;
 
        DBG3("open() %s with flags %X mode %d for uid %d and gid %d",
                        path, flags, mode, uid, gid);
index 544653d6567a07c6a7d54eb2f2fafe348693a962..c8c485c1f22357d8ee6eb6c7fdd78b3ce5b1b683 100644 (file)
@@ -22,8 +22,8 @@
 
 #include <unistd.h>
 
-int mkdir_recursive_run_as(const char *path, mode_t mode, uid_t uid, gid_t gid);
-int mkdir_run_as(const char *path, mode_t mode, uid_t uid, gid_t gid);
-int open_run_as(const char *path, int flags, mode_t mode, uid_t uid, gid_t gid);
+int run_as_mkdir_recursive(const char *path, mode_t mode, uid_t uid, gid_t gid);
+int run_as_mkdir(const char *path, mode_t mode, uid_t uid, gid_t gid);
+int run_as_open(const char *path, int flags, mode_t mode, uid_t uid, gid_t gid);
 
 #endif /* _RUNAS_H */
index 2b69438cadb2b1e7d469ecd5c9f671b5aa36e670..488d6b859ada46d9e898337b5cd642e46de7d463 100644 (file)
@@ -397,7 +397,7 @@ int lttng_kconsumer_on_recv_stream(struct lttng_consumer_stream *stream)
 
        /* Opening the tracefile in write mode */
        if (stream->path_name != NULL) {
-               ret = open_run_as(stream->path_name,
+               ret = run_as_open(stream->path_name,
                                O_WRONLY|O_CREAT|O_TRUNC,
                                S_IRWXU|S_IRWXG|S_IRWXO,
                                stream->uid, stream->gid);
index bc262572aa5ed4840063f0ee33295f6f8564460c..10213c1c97dcb8b4d93a80895a0e56d7ed9297db 100644 (file)
@@ -395,7 +395,7 @@ int lttng_ustconsumer_on_recv_stream(struct lttng_consumer_stream *stream)
 
        /* Opening the tracefile in write mode */
        if (stream->path_name != NULL) {
-               ret = open_run_as(stream->path_name,
+               ret = run_as_open(stream->path_name,
                                O_WRONLY|O_CREAT|O_TRUNC,
                                S_IRWXU|S_IRWXG|S_IRWXO,
                                stream->uid, stream->gid);
index 6f34bb72262f37b307406499af6832fcc525b75d..a2532d0479463c6152c895efe90e5f8d3546080c 100644 (file)
@@ -1749,7 +1749,7 @@ static int mount_debugfs(char *path)
        int ret;
        char *type = "debugfs";
 
-       ret = mkdir_recursive_run_as(path, S_IRWXU | S_IRWXG, geteuid(), getegid());
+       ret = run_as_mkdir_recursive(path, S_IRWXU | S_IRWXG, geteuid(), getegid());
        if (ret < 0) {
                PERROR("Cannot create debugfs path");
                goto error;
@@ -1904,7 +1904,7 @@ static int create_ust_session(struct ltt_session *session,
                goto error;
        }
 
-       ret = mkdir_recursive_run_as(lus->pathname, S_IRWXU | S_IRWXG,
+       ret = run_as_mkdir_recursive(lus->pathname, S_IRWXU | S_IRWXG,
                        session->uid, session->gid);
        if (ret < 0) {
                if (ret != -EEXIST) {
@@ -1954,7 +1954,7 @@ static int create_kernel_session(struct ltt_session *session)
                session->kernel_session->consumer_fd = kconsumer_data.cmd_sock;
        }
 
-       ret = mkdir_recursive_run_as(session->kernel_session->trace_path,
+       ret = run_as_mkdir_recursive(session->kernel_session->trace_path,
                        S_IRWXU | S_IRWXG, session->uid, session->gid);
        if (ret < 0) {
                if (ret != -EEXIST) {
index 050942ceee3457ce02ee8091541af2df640f780c..1a79fd564b40da5d7d26d29c1ba276003cedeac0 100644 (file)
@@ -217,7 +217,7 @@ int session_create(char *name, char *path, uid_t uid, gid_t gid)
        new_session->uid = uid;
        new_session->gid = gid;
 
-       ret = mkdir_recursive_run_as(new_session->path, S_IRWXU | S_IRWXG,
+       ret = run_as_mkdir_recursive(new_session->path, S_IRWXU | S_IRWXG,
                        new_session->uid, new_session->gid);
        if (ret < 0) {
                if (ret != -EEXIST) {
index 209a7fed47fa83b8fa685ad7af848b50fe09aa7b..a9c1c764c0359ca3a81dbb22aa088c093e456eda 100644 (file)
@@ -1192,7 +1192,7 @@ static int create_ust_app_metadata(struct ust_app_session *ua_sess,
                        goto error;
                }
 
-               ret = mkdir_run_as(ua_sess->path, S_IRWXU | S_IRWXG,
+               ret = run_as_mkdir(ua_sess->path, S_IRWXU | S_IRWXG,
                                ua_sess->uid, ua_sess->gid);
                if (ret < 0) {
                        PERROR("mkdir UST metadata");
This page took 0.031504 seconds and 5 git commands to generate.