]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #1216 from poettering/coccinelle-fixes-2
authorDaniel Mack <github@zonque.org>
Wed, 9 Sep 2015 13:12:28 +0000 (15:12 +0200)
committerDaniel Mack <github@zonque.org>
Wed, 9 Sep 2015 13:12:28 +0000 (15:12 +0200)
Coccinelle fixes 2

src/basic/smack-util.c
src/basic/smack-util.h
src/core/main.c
src/core/mount-setup.c
src/libsystemd/sd-bus/sd-bus.c
src/libsystemd/sd-daemon/sd-daemon.c

index 6d5c205117ba5b9845edceb77bcb984ff74fd4e0..9e221d6eab3879eb40c07e404a4932141fab6f02 100644 (file)
@@ -185,6 +185,23 @@ int mac_smack_fix(const char *path, bool ignore_enoent, bool ignore_erofs) {
         return r;
 }
 
+int mac_smack_copy(const char *dest, const char *src) {
+        int r = 0;
+        _cleanup_free_ char *label = NULL;
+
+        assert(dest);
+        assert(src);
+
+        r = mac_smack_read(src, SMACK_ATTR_ACCESS, &label);
+        if (r < 0)
+                return r;
+
+        r = mac_smack_apply(dest, SMACK_ATTR_ACCESS, label);
+        if (r < 0)
+                return r;
+
+        return r;
+}
 
 #else
 bool mac_smack_use(void) {
@@ -214,4 +231,8 @@ int mac_smack_apply_pid(pid_t pid, const char *label) {
 int mac_smack_fix(const char *path, bool ignore_enoent, bool ignore_erofs) {
         return 0;
 }
+
+int mac_smack_copy(const char *dest, const char *src) {
+        return 0;
+}
 #endif
index 1052cecf4c9295a518f01eda80d604c91652f9b9..b3aa55eb8a1fdc0dbef27c3ccb4c436479c2e2bf 100644 (file)
@@ -48,5 +48,5 @@ int mac_smack_read(const char *path, SmackAttr attr, char **label);
 int mac_smack_read_fd(int fd, SmackAttr attr, char **label);
 int mac_smack_apply(const char *path, SmackAttr attr, const char *label);
 int mac_smack_apply_fd(int fd, SmackAttr attr, const char *label);
-
 int mac_smack_apply_pid(pid_t pid, const char *label);
+int mac_smack_copy(const char *dest, const char *src);
index 8cf1bebc6761504d7a0e723cdd08929a93e5befe..48b5057a85d629bd6dc890afc2a5d5db47b1ec42 100644 (file)
@@ -1118,9 +1118,10 @@ static void test_mtab(void) {
         if (r >= 0 && nulstr_contains(ok, p))
                 return;
 
-        log_warning("/etc/mtab is not a symlink or not pointing to /proc/self/mounts. "
-                    "This is not supported anymore. "
-                    "Please make sure to replace this file by a symlink to avoid incorrect or misleading mount(8) output.");
+        log_error("/etc/mtab is not a symlink or not pointing to /proc/self/mounts. "
+                  "This is not supported anymore. "
+                  "Please make sure to replace this file by a symlink to avoid incorrect or misleading mount(8) output.");
+        freeze();
 }
 
 static void test_usr(void) {
index e84f80b61b48d12230d48cd2179fc3948e574afc..65f3d06ad0599c91a5d6ad83e3055c0925ce20df 100644 (file)
@@ -303,6 +303,11 @@ int mount_cgroup_controllers(char ***join_controllers) {
                                 r = symlink(options, t);
                                 if (r < 0 && errno != EEXIST)
                                         return log_error_errno(errno, "Failed to create symlink %s: %m", t);
+#ifdef SMACK_RUN_LABEL
+                                r = mac_smack_copy(t, options);
+                                if (r < 0 && r != -EOPNOTSUPP)
+                                        return log_error_errno(r, "Failed to copy smack label from %s to %s: %m", options, t);
+#endif
                         }
                 }
         }
index 2ac4b9be8e9d6d8f051e285851264d6ccc4d1fb3..25fd3b5c525f994e47fd0e50fe5d72d3f1c3fd3d 100644 (file)
@@ -1023,7 +1023,6 @@ static int bus_start_address(sd_bus *b) {
 
                 if (b->exec_path)
                         r = bus_socket_exec(b);
-
                 else if ((b->nspid > 0 || b->machine) && b->kernel) {
                         r = bus_container_connect_kernel(b);
                         if (r < 0 && !IN_SET(r, -ENOENT, -ESOCKTNOSUPPORT))
@@ -1045,7 +1044,6 @@ static int bus_start_address(sd_bus *b) {
                                 r = bus_socket_connect(b);
                         else
                                 skipped = true;
-
                 } else
                         skipped = true;
 
index d230a48dafbb99d6bfc6b8d03a2417c4962eb1c4..9ec73406c6b44f2f6713ccc57f26d90c2aafd9d5 100644 (file)
@@ -395,8 +395,9 @@ _public_ int sd_pid_notify_with_fds(pid_t pid, int unset_environment, const char
         have_pid = pid != 0 && pid != getpid();
 
         if (n_fds > 0 || have_pid) {
-                msghdr.msg_controllen = CMSG_SPACE(sizeof(int) * n_fds) +
-                                        CMSG_SPACE(sizeof(struct ucred) * have_pid);
+                /* CMSG_SPACE(0) may return value different then zero, which results in miscalculated controllen. */
+                msghdr.msg_controllen = (n_fds ? CMSG_SPACE(sizeof(int) * n_fds) : 0) +
+                                        CMSG_SPACE(sizeof(struct ucred)) * have_pid;
                 msghdr.msg_control = alloca(msghdr.msg_controllen);
 
                 cmsg = CMSG_FIRSTHDR(&msghdr);