]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #2392 from poettering/dnssec18
authorTom Gundersen <teg@jklm.no>
Mon, 25 Jan 2016 19:28:38 +0000 (20:28 +0100)
committerTom Gundersen <teg@jklm.no>
Mon, 25 Jan 2016 19:28:38 +0000 (20:28 +0100)
eightteenth dnssec patch

src/journal/coredump.c
src/systemctl/systemctl.c

index 869c8fea03e472cfc28ee3e6fbf24acc3e33eed1..7df59fe29be2c2be916414861cb27411c0f03708 100644 (file)
@@ -297,7 +297,8 @@ static int save_external_coredump(
                 const char *info[_INFO_LEN],
                 uid_t uid,
                 char **ret_filename,
-                int *ret_fd,
+                int *ret_node_fd,
+                int *ret_data_fd,
                 uint64_t *ret_size) {
 
         _cleanup_free_ char *fn = NULL, *tmp = NULL;
@@ -307,7 +308,8 @@ static int save_external_coredump(
 
         assert(info);
         assert(ret_filename);
-        assert(ret_fd);
+        assert(ret_node_fd);
+        assert(ret_data_fd);
         assert(ret_size);
 
         r = make_filename(info, &fn);
@@ -386,11 +388,12 @@ static int save_external_coredump(
                 unlink_noerrno(tmp);
 
                 *ret_filename = fn_compressed;     /* compressed */
-                *ret_fd = fd;                      /* uncompressed */
+                *ret_node_fd = fd_compressed;      /* compressed */
+                *ret_data_fd = fd;                 /* uncompressed */
                 *ret_size = (uint64_t) st.st_size; /* uncompressed */
 
                 fn_compressed = NULL;
-                fd = -1;
+                fd = fd_compressed = -1;
 
                 return 0;
 
@@ -400,12 +403,14 @@ static int save_external_coredump(
 
 uncompressed:
 #endif
+
         r = fix_permissions(fd, tmp, fn, info, uid);
         if (r < 0)
                 goto fail;
 
         *ret_filename = fn;
-        *ret_fd = fd;
+        *ret_data_fd = fd;
+        *ret_node_fd = -1;
         *ret_size = (uint64_t) st.st_size;
 
         fn = NULL;
@@ -554,7 +559,7 @@ int main(int argc, char* argv[]) {
         _cleanup_free_ char *exe = NULL, *comm = NULL, *filename = NULL;
         const char *info[_INFO_LEN];
 
-        _cleanup_close_ int coredump_fd = -1;
+        _cleanup_close_ int coredump_fd = -1, coredump_node_fd = -1;
 
         struct iovec iovec[26];
         uint64_t coredump_size;
@@ -633,7 +638,7 @@ int main(int argc, char* argv[]) {
                         if (arg_storage != COREDUMP_STORAGE_NONE)
                                 arg_storage = COREDUMP_STORAGE_EXTERNAL;
 
-                        r = save_external_coredump(info, uid, &filename, &coredump_fd, &coredump_size);
+                        r = save_external_coredump(info, uid, &filename, &coredump_node_fd, &coredump_fd, &coredump_size);
                         if (r < 0)
                                 goto finish;
 
@@ -795,7 +800,7 @@ int main(int argc, char* argv[]) {
         coredump_vacuum(-1, arg_keep_free, arg_max_use);
 
         /* Always stream the coredump to disk, if that's possible */
-        r = save_external_coredump(info, uid, &filename, &coredump_fd, &coredump_size);
+        r = save_external_coredump(info, uid, &filename, &coredump_node_fd, &coredump_fd, &coredump_size);
         if (r < 0)
                 /* skip whole core dumping part */
                 goto log;
@@ -815,7 +820,7 @@ int main(int argc, char* argv[]) {
         }
 
         /* Vacuum again, but exclude the coredump we just created */
-        coredump_vacuum(coredump_fd, arg_keep_free, arg_max_use);
+        coredump_vacuum(coredump_node_fd >= 0 ? coredump_node_fd : coredump_fd, arg_keep_free, arg_max_use);
 
         /* Now, let's drop privileges to become the user who owns the
          * segfaulted process and allocate the coredump memory under
index 0199f28eba5024720b871f18be9d0df86f2c4e7c..94c99c4d91fdb053170515823dda57986bc0e36f 100644 (file)
@@ -3153,6 +3153,7 @@ static int check_unit_generic(int code, const char *good_states, char **args) {
         sd_bus *bus;
         char **name;
         int r;
+        bool found = false;
 
         r = acquire_bus(BUS_MANAGER, &bus);
         if (r < 0)
@@ -3168,11 +3169,13 @@ static int check_unit_generic(int code, const char *good_states, char **args) {
                 state = check_one_unit(bus, *name, good_states, arg_quiet);
                 if (state < 0)
                         return state;
-                if (state == 0)
-                        r = code;
+                if (state > 0)
+                        found = true;
         }
 
-        return r;
+        /* use the given return code for the case that we won't find
+         * any unit which matches the list */
+        return found ? 0 : code;
 }
 
 static int check_unit_active(int argc, char *argv[], void *userdata) {