[systemd-commits] 3 commits - TODO src/core src/hostname src/journal src/nspawn src/shared

Lennart Poettering lennart at kemper.freedesktop.org
Tue May 7 11:57:05 PDT 2013


 TODO                           |    2 -
 src/core/hostname-setup.c      |    2 -
 src/hostname/hostnamectl.c     |   47 +++++++++++++----------------------------
 src/journal/journal-gatewayd.c |    2 -
 src/journal/journalctl.c       |    2 -
 src/nspawn/nspawn.c            |    2 -
 src/shared/util.c              |   17 +++++++++-----
 src/shared/util.h              |    2 -
 8 files changed, 32 insertions(+), 44 deletions(-)

New commits:
commit cdf173349c73c9a097ec63eec56772ec47f496cc
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue May 7 20:56:30 2013 +0200

    update TODO

diff --git a/TODO b/TODO
index 269e7f8..4f5af14 100644
--- a/TODO
+++ b/TODO
@@ -29,8 +29,6 @@ Fedora 19:
 
 Features:
 
-* journald: user journals get the wrong ACL mask?
-
 * Introduce a way how we can kill the main process of a service with KillSignal, but all processes with SIGKILL later on
   https://bugzilla.redhat.com/show_bug.cgi?id=952634
 

commit c0b21b9669a86a5e404b73865080494063ee8351
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue May 7 20:56:05 2013 +0200

    hostnamectl: suppress outputting of pretty hostname field in status if empty

diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c
index a1e1bd8..064581a 100644
--- a/src/hostname/hostnamectl.c
+++ b/src/hostname/hostnamectl.c
@@ -79,14 +79,18 @@ static void print_status_info(StatusInfo *i) {
         printf("   Static hostname: %s\n",
                strna(i->static_hostname));
 
-        if (!streq_ptr(i->hostname, i->static_hostname))
+        if (!isempty(i->pretty_hostname) &&
+            !streq_ptr(i->pretty_hostname, i->static_hostname))
+                printf("   Pretty hostname: %s\n",
+                       strna(i->pretty_hostname));
+
+        if (!isempty(i->hostname) &&
+            !streq_ptr(i->hostname, i->static_hostname))
                 printf("Transient hostname: %s\n",
                        strna(i->hostname));
 
-        printf("   Pretty hostname: %s\n"
-               "         Icon name: %s\n"
+        printf("         Icon name: %s\n"
                "           Chassis: %s\n",
-               strna(i->pretty_hostname),
                strna(i->icon_name),
                strna(i->chassis));
 

commit e724b0639c43c2821613fc4f7f755f87c49a22e8
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue May 7 20:55:11 2013 +0200

    hostname: only suppress setting of pretty hostname if it is non-equal to the static hostname and if the static hostname is set, too
    
    https://bugzilla.redhat.com/show_bug.cgi?id=957814

diff --git a/src/core/hostname-setup.c b/src/core/hostname-setup.c
index ac508af..8aa1cff 100644
--- a/src/core/hostname-setup.c
+++ b/src/core/hostname-setup.c
@@ -42,7 +42,7 @@ static int read_and_strip_hostname(const char *path, char **hn) {
         if (r < 0)
                 return r;
 
-        hostname_cleanup(s);
+        hostname_cleanup(s, false);
 
         if (isempty(s)) {
                 free(s);
diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c
index 1c90435..a1e1bd8 100644
--- a/src/hostname/hostnamectl.c
+++ b/src/hostname/hostnamectl.c
@@ -213,26 +213,6 @@ static int show_status(DBusConnection *bus, char **args, unsigned n) {
         return 0;
 }
 
-static char* hostname_simplify(char *s) {
-        char *p, *d;
-
-        for (p = s, d = s; *p; p++) {
-                if ((*p >= 'a' && *p <= 'z') ||
-                    (*p >= '0' && *p <= '9') ||
-                    *p == '-' || *p == '_')
-                        *(d++) = *p;
-                else if (*p >= 'A' && *p <= 'Z')
-                        *(d++) = *p - 'A' + 'a';
-                else if (*p == ' ')
-                        *(d++) = '-';
-        }
-
-        *d = 0;
-
-        strshorten(s, HOST_NAME_MAX);
-        return s;
-}
-
 static int set_hostname(DBusConnection *bus, char **args, unsigned n) {
         _cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
         dbus_bool_t interactive = true;
@@ -254,16 +234,17 @@ static int set_hostname(DBusConnection *bus, char **args, unsigned n) {
                  * just set the passed hostname as static/dynamic
                  * hostname. */
 
-                if (hostname_is_valid(hostname))
+                h = strdup(hostname);
+                if (!h)
+                        return log_oom();
+
+                hostname_cleanup(h, true);
+
+                if (arg_set_static && streq(h, hostname))
                         p = "";
                 else {
                         p = hostname;
-
-                        h = strdup(hostname);
-                        if (!h)
-                                return log_oom();
-
-                        hostname = hostname_simplify(h);
+                        hostname = h;
                 }
 
                 r = bus_method_call_with_reply(
diff --git a/src/journal/journal-gatewayd.c b/src/journal/journal-gatewayd.c
index 51a938b..745f45f 100644
--- a/src/journal/journal-gatewayd.c
+++ b/src/journal/journal-gatewayd.c
@@ -839,7 +839,7 @@ static int request_handler_machine(
                      "\"cutoff_to_realtime\" : \"%llu\" }\n",
                      SD_ID128_FORMAT_VAL(mid),
                      SD_ID128_FORMAT_VAL(bid),
-                     hostname_cleanup(hostname),
+                     hostname_cleanup(hostname, false),
                      os_name ? os_name : "Linux",
                      v ? v : "bare",
                      (unsigned long long) usage,
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index d1b201b..409f082 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -835,7 +835,7 @@ static int setup_keys(void) {
                 hn = gethostname_malloc();
 
                 if (hn) {
-                        hostname_cleanup(hn);
+                        hostname_cleanup(hn, false);
                         fprintf(stderr, "\nThe keys have been generated for host %s/" SD_ID128_FORMAT_STR ".\n", hn, SD_ID128_FORMAT_VAL(machine));
                 } else
                         fprintf(stderr, "\nThe keys have been generated for host " SD_ID128_FORMAT_STR ".\n", SD_ID128_FORMAT_VAL(machine));
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index a58cbec..09153c8 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -1267,7 +1267,7 @@ int main(int argc, char *argv[]) {
                         goto finish;
                 }
 
-                hostname_cleanup(arg_machine);
+                hostname_cleanup(arg_machine, false);
                 if (isempty(arg_machine)) {
                         log_error("Failed to determine machine name automatically, please use -M.");
                         goto finish;
diff --git a/src/shared/util.c b/src/shared/util.c
index 00d3ace..673e0da 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -3838,24 +3838,29 @@ bool hostname_is_valid(const char *s) {
         return true;
 }
 
-char* hostname_cleanup(char *s) {
+char* hostname_cleanup(char *s, bool lowercase) {
         char *p, *d;
         bool dot;
 
         for (p = s, d = s, dot = true; *p; p++) {
                 if (*p == '.') {
-                        if (dot || p[1] == 0)
+                        if (dot)
                                 continue;
 
+                        *(d++) = '.';
                         dot = true;
-                } else
+                } else if (hostname_valid_char(*p)) {
+                        *(d++) = lowercase ? tolower(*p) : *p;
                         dot = false;
+                }
 
-                if (hostname_valid_char(*p))
-                        *(d++) = *p;
         }
 
-        *d = 0;
+        if (dot && d > s)
+                d[-1] = 0;
+        else
+                *d = 0;
+
         strshorten(s, HOST_NAME_MAX);
 
         return s;
diff --git a/src/shared/util.h b/src/shared/util.h
index 7ef46e8..64e63b8 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -411,7 +411,7 @@ bool nulstr_contains(const char*nulstr, const char *needle);
 bool plymouth_running(void);
 
 bool hostname_is_valid(const char *s) _pure_;
-char* hostname_cleanup(char *s);
+char* hostname_cleanup(char *s, bool lowercase);
 
 char* strshorten(char *s, size_t l);
 



More information about the systemd-commits mailing list