[systemd-commits] 6 commits - src/journal src/login src/network src/shared src/systemctl src/tty-ask-password-agent src/udev TODO

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Fri Apr 4 21:56:33 PDT 2014


 TODO                                                |    2 ++
 src/journal/journalctl.c                            |    2 ++
 src/login/logind-seat.c                             |    4 ++--
 src/network/networkd-netdev.c                       |    2 +-
 src/network/networkd-network.c                      |    2 +-
 src/shared/logs-show.c                              |    7 ++++---
 src/shared/utf8.c                                   |    5 +++--
 src/shared/utf8.h                                   |    5 ++++-
 src/systemctl/systemctl.c                           |   14 +++++++-------
 src/tty-ask-password-agent/tty-ask-password-agent.c |    2 +-
 src/udev/net/link-config.c                          |   17 ++++++-----------
 11 files changed, 33 insertions(+), 29 deletions(-)

New commits:
commit ecb08ec6a5c52f2d940f3b8147e2a480affd46e1
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Thu Apr 3 14:05:01 2014 -0400

    Fix a few return codes in error paths

diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c
index 762eff2..92548d9 100644
--- a/src/network/networkd-netdev.c
+++ b/src/network/networkd-netdev.c
@@ -461,7 +461,7 @@ static int netdev_load_one(Manager *manager, const char *filename) {
                 if (errno == ENOENT)
                         return 0;
                 else
-                        return errno;
+                        return -errno;
         }
 
         netdev = new0(NetDev, 1);
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 47fab4e..bdf71e8 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -41,7 +41,7 @@ static int network_load_one(Manager *manager, const char *filename) {
                 if (errno == ENOENT)
                         return 0;
                 else
-                        return errno;
+                        return -errno;
         }
 
         network = new0(Network, 1);
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index 5bb6b02..0c563b2 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -139,7 +139,7 @@ void link_config_ctx_free(link_config_ctx *ctx) {
 }
 
 static int load_link(link_config_ctx *ctx, const char *filename) {
-        link_config *link;
+        _cleanup_free_ link_config *link = NULL;
         _cleanup_fclose_ FILE *file;
         int r;
 
@@ -151,14 +151,12 @@ static int load_link(link_config_ctx *ctx, const char *filename) {
                 if (errno == ENOENT)
                         return 0;
                 else
-                        return errno;
+                        return -errno;
         }
 
         link = new0(link_config, 1);
-        if (!link) {
-                r = log_oom();
-                goto failure;
-        }
+        if (!link)
+                return log_oom();
 
         link->mac_policy = _MACPOLICY_INVALID;
         link->wol = _WOL_INVALID;
@@ -168,19 +166,16 @@ static int load_link(link_config_ctx *ctx, const char *filename) {
                          (void*) link_config_gperf_lookup, false, false, link);
         if (r < 0) {
                 log_warning("Could not parse config file %s: %s", filename, strerror(-r));
-                goto failure;
+                return r;
         } else
                 log_debug("Parsed configuration file %s", filename);
 
         link->filename = strdup(filename);
 
         LIST_PREPEND(links, ctx->links, link);
+        link = NULL;
 
         return 0;
-
-failure:
-        free(link);
-        return r;
 }
 
 static bool enable_name_policy(void) {

commit ee0e4cca5ac37a094dfe1074907dae70c7b7701c
Author: Florian Albrechtskirchinger <falbrechtskirchinger at gmail.com>
Date:   Thu Apr 3 21:17:20 2014 +0200

    tty-ask-password-agent: return negative errno
    
    Return negative errno in wall_tty_block(). get_ctty_devnr() already
    returns a negative errno in case of failure, no need to negate it again.
    
    Reported-by: Simon <hwold at odai.homelinux.net>

diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c
index 1d067af..3203474 100644
--- a/src/tty-ask-password-agent/tty-ask-password-agent.c
+++ b/src/tty-ask-password-agent/tty-ask-password-agent.c
@@ -432,7 +432,7 @@ static int wall_tty_block(void) {
 
         r = get_ctty_devnr(0, &devnr);
         if (r < 0)
-                return -r;
+                return r;
 
         if (asprintf(&p, "/run/systemd/ask-password-block/%u:%u", major(devnr), minor(devnr)) < 0)
                 return -ENOMEM;

commit b3ae710c251d0ce5cf2cef63208e325497b5e323
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Tue Apr 1 20:43:15 2014 -0400

    systemctl: update NAME to PATTERN in help()
    
    Previously the man page was modified, but not help().

diff --git a/TODO b/TODO
index 4ff69ff..0343b94 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,6 @@
 Bugfixes:
+* Should systemctl status \* work on all unit types, not just .service?
+
 * enabling an instance unit creates a pointless link, and
   the unit will be started with getty at getty.service:
     $ systemctl enable getty at .service
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 6b88f85..653a324 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -5403,15 +5403,15 @@ static int systemctl_help(void) {
                "                                  otherwise restart if active\n"
                "  isolate NAME                    Start one unit and stop all others\n"
                "  kill NAME...                    Send signal to processes of a unit\n"
-               "  is-active NAME...               Check whether units are active\n"
-               "  is-failed NAME...               Check whether units are failed\n"
-               "  status [NAME...|PID...]         Show runtime status of one or more units\n"
-               "  show [NAME...|JOB...]           Show properties of one or more\n"
+               "  is-active PATTERN...            Check whether units are active\n"
+               "  is-failed PATTERN...            Check whether units are failed\n"
+               "  status [PATTERN...|PID...]      Show runtime status of one or more units\n"
+               "  show [PATTERN...|JOB...]        Show properties of one or more\n"
                "                                  units/jobs or the manager\n"
-               "  cat NAME...                     Show files and drop-ins of one or more units\n"
+               "  cat PATTERN...                  Show files and drop-ins of one or more units\n"
                "  set-property NAME ASSIGNMENT... Sets one or more properties of a unit\n"
-               "  help NAME...|PID...             Show manual for one or more units\n"
-               "  reset-failed [NAME...]          Reset failed state for all, one, or more\n"
+               "  help PATTERN...|PID...          Show manual for one or more units\n"
+               "  reset-failed [PATTERN...]       Reset failed state for all, one, or more\n"
                "                                  units\n"
                "  list-dependencies [NAME]        Recursively show units which are required\n"
                "                                  or wanted by this unit or by which this\n"

commit a08ac7e0f72a502564aae6b85a8821f6bd03493c
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Tue Apr 1 09:07:32 2014 -0400

    logind: remove one cast

diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c
index 3f5efdc..5350e77 100644
--- a/src/login/logind-seat.c
+++ b/src/login/logind-seat.c
@@ -120,9 +120,9 @@ int seat_save(Seat *s) {
 
                 fprintf(f,
                         "ACTIVE=%s\n"
-                        "ACTIVE_UID=%lu\n",
+                        "ACTIVE_UID="UID_FMT"\n",
                         s->active->id,
-                        (unsigned long) s->active->user->uid);
+                        s->active->user->uid);
         }
 
         if (s->sessions) {

commit 0ade5ffe2778e7b238bba8d979ca4d53dee1e702
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Mon Mar 31 08:57:28 2014 -0400

    journal: fix export of messages containing newlines
    
    In "export" format, newlines are significant, and messages containing
    newlines must be exported as "binary".

diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index 9d14933..b0b66f6 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -547,7 +547,9 @@ static int output_export(
                     startswith(data, "_BOOT_ID="))
                         continue;
 
-                if (!utf8_is_printable(data, length)) {
+                if (utf8_is_printable_newline(data, length, false))
+                        fwrite(data, length, 1, f);
+                else {
                         const char *c;
                         uint64_t le64;
 
@@ -562,8 +564,7 @@ static int output_export(
                         le64 = htole64(length - (c - (const char*) data) - 1);
                         fwrite(&le64, sizeof(le64), 1, f);
                         fwrite(c + 1, length - (c - (const char*) data) - 1, 1, f);
-                } else
-                        fwrite(data, length, 1, f);
+                }
 
                 fputc('\n', f);
         }
diff --git a/src/shared/utf8.c b/src/shared/utf8.c
index 0b524d8..c559c13 100644
--- a/src/shared/utf8.c
+++ b/src/shared/utf8.c
@@ -136,7 +136,7 @@ int utf8_encoded_to_unichar(const char *str) {
         return unichar;
 }
 
-bool utf8_is_printable(const char* str, size_t length) {
+bool utf8_is_printable_newline(const char* str, size_t length, bool newline) {
         const uint8_t *p;
 
         assert(str);
@@ -145,7 +145,8 @@ bool utf8_is_printable(const char* str, size_t length) {
                 int encoded_len = utf8_encoded_valid_unichar((const char *)p);
                 int val = utf8_encoded_to_unichar((const char*)p);
 
-                if (encoded_len < 0 || val < 0 || is_unicode_control(val))
+                if (encoded_len < 0 || val < 0 || is_unicode_control(val) ||
+                    (!newline && val == '\n'))
                         return false;
 
                 length -= encoded_len;
diff --git a/src/shared/utf8.h b/src/shared/utf8.h
index c0eb73a..c087995 100644
--- a/src/shared/utf8.h
+++ b/src/shared/utf8.h
@@ -31,7 +31,10 @@ const char *utf8_is_valid(const char *s) _pure_;
 char *ascii_is_valid(const char *s) _pure_;
 char *utf8_escape_invalid(const char *s);
 
-bool utf8_is_printable(const char* str, size_t length) _pure_;
+bool utf8_is_printable_newline(const char* str, size_t length, bool newline) _pure_;
+_pure_ static inline bool utf8_is_printable(const char* str, size_t length) {
+        return utf8_is_printable_newline(str, length, true);
+}
 
 char *utf16_to_utf8(const void *s, size_t length);
 

commit a36b8debe67f3a5515200dada75cf4dbc334c7f5
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Sat Mar 29 11:58:32 2014 -0400

    journalctl: free arg_file on exit

diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 0196290..86453e6 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -1937,5 +1937,7 @@ int main(int argc, char *argv[]) {
 finish:
         pager_close();
 
+        strv_free(arg_file);
+
         return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
 }



More information about the systemd-commits mailing list