[systemd-commits] 3 commits - src/core src/nspawn src/shared

Lennart Poettering lennart at kemper.freedesktop.org
Sat Apr 21 16:47:01 PDT 2012


 src/core/mount-setup.c |   27 +++++++++++++++++++--------
 src/nspawn/nspawn.c    |   31 ++++++++++++++++++++++++++-----
 src/shared/log.c       |    4 +++-
 3 files changed, 48 insertions(+), 14 deletions(-)

New commits:
commit d29b05a4619c000918cbb9f1b9661bc53659c0b2
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Apr 22 01:01:54 2012 +0200

    log: include syslog identifier in default log properties, to avoid comm truncation

diff --git a/src/shared/log.c b/src/shared/log.c
index a648b83..da53098 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -466,12 +466,14 @@ static int write_to_journal(
                  "CODE_FILE=%s\n"
                  "CODE_LINE=%i\n"
                  "CODE_FUNCTION=%s\n"
+                 "SYSLOG_IDENTIFIER=%s\n"
                  "MESSAGE=",
                  LOG_PRI(level),
                  LOG_FAC(level),
                  file,
                  line,
-                 func);
+                 func,
+                 program_invocation_short_name);
 
         char_array_0(header);
 

commit 3a74cea5e4cea6d6f852a2a7118efe0e339b78c7
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Apr 22 01:01:22 2012 +0200

    nspawn: be more careful when initializing the hostname from the directory name

diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 71cdd3f..50f2c59 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -101,8 +101,9 @@ static int parse_argv(int argc, char *argv[]) {
 
                 case 'D':
                         free(arg_directory);
-                        if (!(arg_directory = strdup(optarg))) {
-                                log_error("Failed to duplicate root directory.");
+                        arg_directory = canonicalize_file_name(optarg);
+                        if (!arg_directory) {
+                                log_error("Failed to canonicalize root directory.");
                                 return -ENOMEM;
                         }
 
@@ -474,6 +475,28 @@ finish:
         return r;
 }
 
+static int setup_hostname(void) {
+        char *hn;
+        int r = 0;
+
+        hn = file_name_from_path(arg_directory);
+        if (hn) {
+                hn = strdup(hn);
+                if (!hn)
+                        return -ENOMEM;
+
+                hostname_cleanup(hn);
+
+                if (!isempty(hn))
+                        if (sethostname(hn, strlen(hn)) < 0)
+                                r = -errno;
+
+                free(hn);
+        }
+
+        return r;
+}
+
 static int drop_capabilities(void) {
         static const unsigned long retain[] = {
                 CAP_CHOWN,
@@ -872,7 +895,6 @@ int main(int argc, char *argv[]) {
         if (pid == 0) {
                 /* child */
 
-                const char *hn;
                 const char *home = NULL;
                 uid_t uid = (uid_t) -1;
                 gid_t gid = (gid_t) -1;
@@ -1000,8 +1022,7 @@ int main(int argc, char *argv[]) {
                     goto child_fail;
                 }
 
-                if ((hn = file_name_from_path(arg_directory)))
-                        sethostname(hn, strlen(hn));
+                setup_hostname();
 
                 if (argc > optind)
                         execvpe(argv[optind], argv + optind, (char**) envp);

commit eaeb18dba95403b5f619d192c5a915546b5ace47
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Apr 22 01:00:57 2012 +0200

    mount-setup: ignore common container bind mounts

diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c
index d902211..6d37bbd 100644
--- a/src/core/mount-setup.c
+++ b/src/core/mount-setup.c
@@ -72,11 +72,22 @@ static const MountPoint mount_table[] = {
 /* These are API file systems that might be mounted by other software,
  * we just list them here so that we know that we should ignore them */
 
-static const char * const ignore_paths[] = {
-        "/sys/fs/selinux",
-        "/selinux",
-        "/proc/bus/usb"
-};
+static const char ignore_paths[] =
+        /* SELinux file systems */
+        "/sys/fs/selinux\0"
+        "/selinux\0"
+        /* Legacy cgroup mount points */
+        "/dev/cgroup\0"
+        "/cgroup\0"
+        /* Legacy kernel file system */
+        "/proc/bus/usb\0"
+        /* Container bind mounts */
+        "/proc/sys\0"
+        "/dev/console\0"
+        "/proc/kmsg\0"
+        "/etc/localtime\0"
+        "/etc/timezone\0"
+        "/etc/machine-id\0";
 
 bool mount_point_is_api(const char *path) {
         unsigned i;
@@ -92,10 +103,10 @@ bool mount_point_is_api(const char *path) {
 }
 
 bool mount_point_ignore(const char *path) {
-        unsigned i;
+        const char *i;
 
-        for (i = 0; i < ELEMENTSOF(ignore_paths); i++)
-                if (path_equal(path, ignore_paths[i]))
+        NULSTR_FOREACH(i, ignore_paths)
+                if (path_equal(path, i))
                         return true;
 
         return false;



More information about the systemd-commits mailing list