#include "alloc-util.h"
#include "architecture.h"
+#include "env-file.h"
#include "env-util.h"
#include "errno-util.h"
#include "escape.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
+#include "hostname-util.h"
#include "locale-util.h"
#include "log.h"
#include "macro.h"
#include "missing_sched.h"
#include "missing_syscall.h"
#include "namespace-util.h"
+#include "parse-util.h"
#include "path-util.h"
#include "process-util.h"
#include "raw-clone.h"
return 0;
}
+int container_get_leader(const char *machine, pid_t *pid) {
+ _cleanup_free_ char *s = NULL, *class = NULL;
+ const char *p;
+ pid_t leader;
+ int r;
+
+ assert(machine);
+ assert(pid);
+
+ if (streq(machine, ".host")) {
+ *pid = 1;
+ return 0;
+ }
+
+ if (!hostname_is_valid(machine, 0))
+ return -EINVAL;
+
+ p = strjoina("/run/systemd/machines/", machine);
+ r = parse_env_file(NULL, p,
+ "LEADER", &s,
+ "CLASS", &class);
+ if (r == -ENOENT)
+ return -EHOSTDOWN;
+ if (r < 0)
+ return r;
+ if (!s)
+ return -EIO;
+
+ if (!streq_ptr(class, "container"))
+ return -EIO;
+
+ r = parse_pid(s, &leader);
+ if (r < 0)
+ return r;
+ if (leader <= 1)
+ return -EIO;
+
+ *pid = leader;
+ return 0;
+}
+
static int update_argv(const char name[], size_t l) {
static int can_do = -1;
int get_process_ppid(pid_t pid, pid_t *ret);
int get_process_umask(pid_t pid, mode_t *ret);
+int container_get_leader(const char *machine, pid_t *pid);
+
int wait_for_terminate(pid_t pid, siginfo_t *status);
typedef enum WaitFlags {
int saved_argc = 0;
char **saved_argv = NULL;
-int container_get_leader(const char *machine, pid_t *pid) {
- _cleanup_free_ char *s = NULL, *class = NULL;
- const char *p;
- pid_t leader;
- int r;
-
- assert(machine);
- assert(pid);
-
- if (streq(machine, ".host")) {
- *pid = 1;
- return 0;
- }
-
- if (!hostname_is_valid(machine, 0))
- return -EINVAL;
-
- p = strjoina("/run/systemd/machines/", machine);
- r = parse_env_file(NULL, p,
- "LEADER", &s,
- "CLASS", &class);
- if (r == -ENOENT)
- return -EHOSTDOWN;
- if (r < 0)
- return r;
- if (!s)
- return -EIO;
-
- if (!streq_ptr(class, "container"))
- return -EIO;
-
- r = parse_pid(s, &leader);
- if (r < 0)
- return r;
- if (leader <= 1)
- return -EIO;
-
- *pid = leader;
- return 0;
-}
-
int version(void) {
printf("systemd " STRINGIFY(PROJECT_VERSION) " (" GIT_VERSION ")\n%s\n",
systemd_features);
return log2u(x - 1) + 1;
}
-int container_get_leader(const char *machine, pid_t *pid);
-
int version(void);
void disable_coredumps(void);
#include "namespace-util.h"
#include "process-util.h"
#include "string-util.h"
-#include "util.h"
int bus_container_connect_socket(sd_bus *b) {
_cleanup_close_pair_ int pair[2] = { -1, -1 };
#include "terminal-util.h"
#include "time-util.h"
#include "utf8.h"
-#include "util.h"
#include "web-util.h"
/* up to three lines (each up to 100 characters) or 300 characters, whichever is less */