[systemd-commits] 9 commits - src/cryptsetup src/journal src/libsystemd-bus src/modules-load src/nspawn src/shared

Lennart Poettering lennart at kemper.freedesktop.org
Wed Oct 2 10:48:20 PDT 2013


 src/cryptsetup/cryptsetup.c       |   11 ++++++-----
 src/journal/journal-file.c        |    2 ++
 src/libsystemd-bus/bus-internal.c |    4 ++--
 src/libsystemd-bus/sd-bus.c       |    4 ++--
 src/modules-load/modules-load.c   |    4 ++--
 src/nspawn/nspawn.c               |   12 +-----------
 src/shared/efivars.c              |    3 ++-
 src/shared/env-util.c             |    4 +++-
 src/shared/mkdir.c                |    2 +-
 src/shared/util.c                 |   16 ++++++----------
 src/shared/util.h                 |    2 +-
 11 files changed, 28 insertions(+), 36 deletions(-)

New commits:
commit 51045322c4c19638ba5588c722238220d096ca43
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 2 19:40:43 2013 +0200

    nspawn: always copy /etc/resolv.conf rather than bind mount
    
    We were already creating the file if it was missing, and this way
    containers can reconfigure the file without running into problems.
    
    This also makes resolv.conf handling more alike to handling of
    /etc/localtime, which is also not a bind mount.

diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index eb9605c..fc4a8a3 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -521,7 +521,6 @@ static int setup_timezone(const char *dest) {
 
 static int setup_resolv_conf(const char *dest) {
         char _cleanup_free_ *where = NULL;
-        _cleanup_close_ int fd = -1;
 
         assert(dest);
 
@@ -533,18 +532,9 @@ static int setup_resolv_conf(const char *dest) {
         if (!where)
                 return log_oom();
 
-        fd = open(where, O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW, 0644);
-
         /* We don't really care for the results of this really. If it
          * fails, it fails, but meh... */
-        if (mount("/etc/resolv.conf", where, "bind", MS_BIND, NULL) < 0)
-                log_warning("Failed to bind mount /etc/resolv.conf: %m");
-        else
-                if (mount("/etc/resolv.conf", where, "bind",
-                          MS_BIND|MS_REMOUNT|MS_RDONLY, NULL) < 0) {
-                        log_error("Failed to remount /etc/resolv.conf readonly: %m");
-                        return -errno;
-                }
+        copy_file("/etc/resolv.conf", where, O_TRUNC|O_NOFOLLOW);
 
         return 0;
 }
diff --git a/src/shared/util.c b/src/shared/util.c
index 9be6acf..82f4221 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -4056,8 +4056,9 @@ int vt_disallocate(const char *name) {
         return 0;
 }
 
-int copy_file(const char *from, const char *to) {
-        int r, fdf, fdt;
+int copy_file(const char *from, const char *to, int flags) {
+        _cleanup_close_ int fdf = -1;
+        int r, fdt;
 
         assert(from);
         assert(to);
@@ -4066,11 +4067,9 @@ int copy_file(const char *from, const char *to) {
         if (fdf < 0)
                 return -errno;
 
-        fdt = open(to, O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC|O_NOCTTY, 0644);
-        if (fdt < 0) {
-                close_nointr_nofail(fdf);
+        fdt = open(to, flags|O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, 0644);
+        if (fdt < 0)
                 return -errno;
-        }
 
         for (;;) {
                 char buf[PIPE_BUF];
@@ -4080,7 +4079,6 @@ int copy_file(const char *from, const char *to) {
                 if (n < 0) {
                         r = -errno;
 
-                        close_nointr_nofail(fdf);
                         close_nointr(fdt);
                         unlink(to);
 
@@ -4095,15 +4093,13 @@ int copy_file(const char *from, const char *to) {
                 if (n != k) {
                         r = k < 0 ? k : (errno ? -errno : -EIO);
 
-                        close_nointr_nofail(fdf);
                         close_nointr(fdt);
-
                         unlink(to);
+
                         return r;
                 }
         }
 
-        close_nointr_nofail(fdf);
         r = close_nointr(fdt);
 
         if (r < 0) {
diff --git a/src/shared/util.h b/src/shared/util.h
index 1b845b3..c2e6a68 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -448,7 +448,7 @@ int terminal_vhangup(const char *name);
 
 int vt_disallocate(const char *name);
 
-int copy_file(const char *from, const char *to);
+int copy_file(const char *from, const char *to, int flags);
 
 int symlink_atomic(const char *from, const char *to);
 

commit 69c2b6be8fc607412a13cd0ea03a629b4965c816
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 2 19:38:52 2013 +0200

    mkdir: pass a proper function pointer to mkdir_safe_internal

diff --git a/src/shared/mkdir.c b/src/shared/mkdir.c
index b7e5c6e..43c6ea6 100644
--- a/src/shared/mkdir.c
+++ b/src/shared/mkdir.c
@@ -53,7 +53,7 @@ int mkdir_safe_internal(const char *path, mode_t mode, uid_t uid, gid_t gid, mkd
 }
 
 int mkdir_safe(const char *path, mode_t mode, uid_t uid, gid_t gid) {
-        return mkdir_safe_internal(path, mode, uid, gid, false);
+        return mkdir_safe_internal(path, mode, uid, gid, mkdir);
 }
 
 static int is_dir(const char* path) {

commit 5b4fb02d890d5c9777e9a6e798e0b8922a8a9fd8
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 2 19:38:28 2013 +0200

    strv: don't access potentially NULL string arrays

diff --git a/src/shared/env-util.c b/src/shared/env-util.c
index 5e29629..7976881 100644
--- a/src/shared/env-util.c
+++ b/src/shared/env-util.c
@@ -405,7 +405,9 @@ char **strv_env_clean_log(char **e, const char *message) {
                 e[k++] = *p;
         }
 
-        e[k] = NULL;
+        if (e)
+                e[k] = NULL;
+
         return e;
 }
 

commit 62678deda2dcd43954bf02f783da01e48c7f8fce
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 2 19:38:09 2013 +0200

    efi: never call qsort on potentially NULL arrays

diff --git a/src/shared/efivars.c b/src/shared/efivars.c
index 1d5b6f9..c015b16 100644
--- a/src/shared/efivars.c
+++ b/src/shared/efivars.c
@@ -384,7 +384,8 @@ int efi_get_boot_options(uint16_t **options) {
                 list[count ++] = id;
         }
 
-        qsort(list, count, sizeof(uint16_t), cmp_uint16);
+        if (list)
+                qsort(list, count, sizeof(uint16_t), cmp_uint16);
 
         *options = list;
         return count;

commit b857193b1def5172e3641ca1d5bc9e08ae81aac4
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 2 19:37:44 2013 +0200

    modules-load: fix error handling

diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c
index 7b19ee0..49ee420 100644
--- a/src/modules-load/modules-load.c
+++ b/src/modules-load/modules-load.c
@@ -302,8 +302,8 @@ int main(int argc, char *argv[]) {
 
                 STRV_FOREACH(i, arg_proc_cmdline_modules) {
                         k = load_module(ctx, *i);
-                        if (k < 0)
-                                r = EXIT_FAILURE;
+                        if (k < 0 && r == 0)
+                                r = k;
                 }
 
                 r = conf_files_list_nulstr(&files, ".conf", NULL, conf_file_dirs);

commit 2e8d788c2f90d062f208f8c57a97e7b33cb29f7d
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 2 19:37:30 2013 +0200

    dbus: fix return value of dispatch_rqueue()

diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 3f766fb..db0880f 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -1215,11 +1215,11 @@ static int dispatch_rqueue(sd_bus *bus, sd_bus_message **m) {
                 if (r == 0)
                         return ret;
 
-                r = 1;
+                ret = 1;
         } while (!z);
 
         *m = z;
-        return 1;
+        return ret;
 }
 
 int sd_bus_send(sd_bus *bus, sd_bus_message *m, uint64_t *serial) {

commit f5f6e41a9ee008e1632f79ab3fa20beef7c2b613
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 2 19:37:11 2013 +0200

    bus: fix potentially uninitialized memory access

diff --git a/src/libsystemd-bus/bus-internal.c b/src/libsystemd-bus/bus-internal.c
index 0e66f3d..cac948e 100644
--- a/src/libsystemd-bus/bus-internal.c
+++ b/src/libsystemd-bus/bus-internal.c
@@ -63,7 +63,7 @@ bool object_path_is_valid(const char *p) {
 
 bool interface_name_is_valid(const char *p) {
         const char *q;
-        bool dot, found_dot;
+        bool dot, found_dot = false;
 
         if (isempty(p))
                 return false;
@@ -103,7 +103,7 @@ bool interface_name_is_valid(const char *p) {
 
 bool service_name_is_valid(const char *p) {
         const char *q;
-        bool dot, found_dot, unique;
+        bool dot, found_dot = false, unique;
 
         if (isempty(p))
                 return false;

commit 8c92d4bbc7a538ada11d7e85016cce141beb0e6c
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 2 19:36:43 2013 +0200

    journald: add missing error check

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 1236403..81c344f 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -907,6 +907,8 @@ static int journal_file_append_field(
 
         osize = offsetof(Object, field.payload) + size;
         r = journal_file_append_object(f, OBJECT_FIELD, osize, &o, &p);
+        if (r < 0)
+                return r;
 
         o->field.hash = htole64(hash);
         memcpy(o->field.payload, field, size);

commit 4b93637fd7dddb0a1518f35171998b2c7cd5c5bd
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 2 19:36:28 2013 +0200

    cryptsetup: fix OOM handling when parsing mount options

diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
index 22b5eea..769c3e4 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -74,7 +74,7 @@ static int parse_one_option(const char *option) {
 
                 t = strdup(option+7);
                 if (!t)
-                        return -ENOMEM;
+                        return log_oom();
 
                 free(opt_cipher);
                 opt_cipher = t;
@@ -89,9 +89,10 @@ static int parse_one_option(const char *option) {
         } else if (startswith(option, "tcrypt-keyfile=")) {
 
                 opt_type = CRYPT_TCRYPT;
-                if (path_is_absolute(option+15))
-                        opt_tcrypt_keyfiles = strv_append(opt_tcrypt_keyfiles, strdup(option+15));
-                else
+                if (path_is_absolute(option+15)) {
+                        if (strv_extend(&opt_tcrypt_keyfiles, option + 15) < 0)
+                                return log_oom();
+                } else
                         log_error("Key file path '%s' is not absolute. Ignoring.", option+15);
 
         } else if (startswith(option, "keyfile-size=")) {
@@ -113,7 +114,7 @@ static int parse_one_option(const char *option) {
 
                 t = strdup(option+5);
                 if (!t)
-                        return -ENOMEM;
+                        return log_oom();
 
                 free(opt_hash);
                 opt_hash = t;



More information about the systemd-commits mailing list