Fix code syntax
[lttng-tools.git] / lttng-sessiond / main.c
index 845ec0684ba69b2a85848d2c3a450889cd078d2c..4828f1c179a914c87c5db77c2413cf9284536ed8 100644 (file)
@@ -44,7 +44,7 @@
 #include <lttng/lttng-consumer.h>
 
 #include <lttngerr.h>
-#include <runas.h>
+#include "common/runas.h"
 
 #include "channel.h"
 #include "compat/poll.h"
@@ -174,14 +174,10 @@ static struct ltt_session_list *session_list_ptr;
 int ust_consumerd64_fd = -1;
 int ust_consumerd32_fd = -1;
 
-static const char *consumerd32_bin =
-       __stringify(CONFIG_CONSUMERD32_BIN);
-static const char *consumerd64_bin =
-       __stringify(CONFIG_CONSUMERD64_BIN);
-static const char *consumerd32_libdir =
-       __stringify(CONFIG_CONSUMERD32_LIBDIR);
-static const char *consumerd64_libdir =
-       __stringify(CONFIG_CONSUMERD64_LIBDIR);
+static const char *consumerd32_bin = CONFIG_CONSUMERD32_BIN;
+static const char *consumerd64_bin = CONFIG_CONSUMERD64_BIN;
+static const char *consumerd32_libdir = CONFIG_CONSUMERD32_LIBDIR;
+static const char *consumerd64_libdir = CONFIG_CONSUMERD64_LIBDIR;
 
 static
 void setup_consumerd_path(void)
@@ -1157,7 +1153,7 @@ static void *thread_manage_apps(void *data)
                                         */
                                        update_ust_app(ust_cmd.sock);
 
-                                       ret = ustctl_register_done(ust_cmd.sock);
+                                       ret = ust_app_register_done(ust_cmd.sock);
                                        if (ret < 0) {
                                                /*
                                                 * If the registration is not possible, we simply
@@ -1527,7 +1523,7 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data)
                /*
                 * Exec consumerd.
                 */
-               if (opt_verbose > 1 || opt_verbose_consumer) {
+               if (opt_verbose_consumer) {
                        verbosity = "--verbose";
                } else {
                        verbosity = "--quiet";
@@ -1535,18 +1531,25 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data)
                switch (consumer_data->type) {
                case LTTNG_CONSUMER_KERNEL:
                        /*
-                        * Find out which consumerd to execute. We will
-                        * first try the 64-bit path, then the
-                        * sessiond's installation directory, and
-                        * fallback on the 32-bit one, 
+                        * Find out which consumerd to execute. We will first try the
+                        * 64-bit path, then the sessiond's installation directory, and
+                        * fallback on the 32-bit one,
                         */
+                       DBG3("Looking for a kernel consumer at these locations:");
+                       DBG3("  1) %s", consumerd64_bin);
+                       DBG3("  2) %s/%s", INSTALL_BIN_PATH, CONSUMERD_FILE);
+                       DBG3("  3) %s", consumerd32_bin);
                        if (stat(consumerd64_bin, &st) == 0) {
+                               DBG3("Found location #1");
                                consumer_to_use = consumerd64_bin;
                        } else if (stat(INSTALL_BIN_PATH "/" CONSUMERD_FILE, &st) == 0) {
+                               DBG3("Found location #2");
                                consumer_to_use = INSTALL_BIN_PATH "/" CONSUMERD_FILE;
                        } else if (stat(consumerd32_bin, &st) == 0) {
+                               DBG3("Found location #3");
                                consumer_to_use = consumerd32_bin;
                        } else {
+                               DBG("Could not find any valid consumerd executable");
                                break;
                        }
                        DBG("Using kernel consumer at: %s",  consumer_to_use);
@@ -1745,7 +1748,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;
@@ -1900,7 +1903,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) {
@@ -1950,7 +1953,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) {
@@ -1966,14 +1969,12 @@ error:
 }
 
 /*
- * Check if the UID or GID match the session. Root user has access to
- * all sessions.
+ * Check if the UID or GID match the session. Root user has access to all
+ * sessions.
  */
-static int session_access_ok(struct ltt_session *session,
-        uid_t uid, gid_t gid)
+static int session_access_ok(struct ltt_session *session, uid_t uid, gid_t gid)
 {
-       if (uid != session->uid && gid != session->gid
-                       && uid != 0) {
+       if (uid != session->uid && gid != session->gid && uid != 0) {
                return 0;
        } else {
                return 1;
@@ -2006,8 +2007,8 @@ static unsigned int lttng_sessions_count(uid_t uid, gid_t gid)
  * The session list lock MUST be acquired before calling this function. Use
  * session_lock_list() and session_unlock_list().
  */
-static void list_lttng_sessions(struct lttng_session *sessions,
-               uid_t uid, gid_t gid)
+static void list_lttng_sessions(struct lttng_session *sessions, uid_t uid,
+               gid_t gid)
 {
        unsigned int i = 0;
        struct ltt_session *session;
@@ -2916,7 +2917,7 @@ static int cmd_stop_trace(struct ltt_session *session)
        usess = session->ust_session;
 
        if (!session->enabled) {
-               ret = LTTCOMM_UST_START_FAIL;
+               ret = LTTCOMM_UST_STOP_FAIL;
                goto error;
        }
 
@@ -2953,7 +2954,7 @@ static int cmd_stop_trace(struct ltt_session *session)
 
                ret = ust_app_stop_trace_all(usess);
                if (ret < 0) {
-                       ret = LTTCOMM_UST_START_FAIL;
+                       ret = LTTCOMM_UST_STOP_FAIL;
                        goto error;
                }
        }
This page took 0.025214 seconds and 4 git commands to generate.