Revert stubbing of runas functions
[lttng-tools.git] / src / common / runas.c
index 33462958f2e4b85b66976495b17873c2ce71ef1a..d727cf4179380b094e98259f4dfa477bf41038f8 100644 (file)
@@ -218,7 +218,7 @@ int _open(struct run_as_data *data, struct run_as_ret *ret_value)
        ret_value->u.open.ret = open(data->u.open.path, data->u.open.flags, data->u.open.mode);
        ret_value->fd = ret_value->u.open.ret;
        ret_value->_errno = errno;
-       ret_value->_error = (ret_value->u.open.ret) ? true : false;
+       ret_value->_error = ret_value->u.open.ret < 0;
        return ret_value->u.open.ret;
 }
 
@@ -240,6 +240,7 @@ int _rmdir_recursive(struct run_as_data *data, struct run_as_ret *ret_value)
        return ret_value->u.rmdir_recursive.ret;
 }
 
+#ifdef HAVE_ELF_H
 static
 int _extract_elf_symbol_offset(struct run_as_data *data,
                struct run_as_ret *ret_value)
@@ -298,6 +299,23 @@ free_offset:
 end:
        return ret;
 }
+#else
+static
+int _extract_elf_symbol_offset(struct run_as_data *data,
+               struct run_as_ret *ret_value)
+{
+       ERR("Unimplemented runas command RUN_AS_EXTRACT_ELF_SYMBOL_OFFSET");
+       return -1;
+}
+
+static
+int _extract_sdt_probe_offsets(struct run_as_data *data,
+               struct run_as_ret *ret_value)
+{
+       ERR("Unimplemented runas command RUN_AS_EXTRACT_SDT_PROBE_OFFSETS");
+       return -1;
+}
+#endif
 
 static
 run_as_fct run_as_enum_to_fct(enum run_as_cmd cmd)
@@ -877,7 +895,7 @@ int run_as_create_worker_no_lock(const char *procname)
        worker->procname = strdup(procname);
        if (!worker->procname) {
                ret = -ENOMEM;
-               goto end;
+               goto error_procname_alloc;
        }
        /* Create unix socket. */
        if (lttcomm_create_anon_unix_socketpair(worker->sockpair) < 0) {
@@ -921,6 +939,8 @@ int run_as_create_worker_no_lock(const char *procname)
                        ret = -1;
                }
                worker->sockpair[1] = -1;
+               free(worker->procname);
+               free(worker);
                LOG(ret ? PRINT_ERR : PRINT_DBG, "run_as worker exiting (ret = %d)", ret);
                exit(ret ? EXIT_FAILURE : EXIT_SUCCESS);
        } else {
@@ -960,6 +980,8 @@ error_fork:
                worker->sockpair[i] = -1;
        }
 error_sock:
+       free(worker->procname);
+error_procname_alloc:
        free(worker);
        return ret;
 }
This page took 0.023576 seconds and 4 git commands to generate.