[systemd-commits] 5 commits - man/journald.conf.xml src/hostname src/journal src/nss-myhostname

Lennart Poettering lennart at kemper.freedesktop.org
Fri Jul 11 06:39:08 PDT 2014


 man/journald.conf.xml               |   10 +++++-----
 src/hostname/hostnamed.c            |   27 +++++----------------------
 src/journal/journald-server.c       |    1 -
 src/journal/journald-syslog.c       |    6 +++---
 src/journal/journald.conf           |    2 +-
 src/nss-myhostname/nss-myhostname.c |   23 ++++++++---------------
 6 files changed, 22 insertions(+), 47 deletions(-)

New commits:
commit 1e5b1aaa4c8531ef531ec46f6ecbb28fb2f81008
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Jul 11 15:38:17 2014 +0200

    hostnamed: drop nss-myhostname check
    
    The check only cares about whether the module is installed, not enabled.
    But installation we should know anyway, after all we ship the module
    with systemd these days...

diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index d826a31..8b6aebf 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -22,7 +22,6 @@
 #include <errno.h>
 #include <string.h>
 #include <unistd.h>
-#include <dlfcn.h>
 #include <sys/utsname.h>
 
 #include "util.h"
@@ -125,18 +124,6 @@ static int context_read_data(Context *c) {
         return 0;
 }
 
-static bool check_nss(void) {
-        void *dl;
-
-        dl = dlopen("libnss_myhostname.so.2", RTLD_LAZY);
-        if (dl) {
-                dlclose(dl);
-                return true;
-        }
-
-        return false;
-}
-
 static bool valid_chassis(const char *chassis) {
         assert(chassis);
 
@@ -708,9 +695,6 @@ int main(int argc, char *argv[]) {
                 goto finish;
         }
 
-        if (!check_nss())
-                log_warning("Warning: nss-myhostname is not installed. Changing the local hostname might make it unresolveable. Please install nss-myhostname!");
-
         if (argc != 1) {
                 log_error("This program takes no arguments.");
                 r = -EINVAL;

commit c2142cf1d1276f4f220bdd9af4ff7a716cc7a305
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Jul 11 15:37:11 2014 +0200

    hostnamed: make use of in_charset() to verify charset

diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index 19ab500..d826a31 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -155,7 +155,7 @@ static bool valid_chassis(const char *chassis) {
 static bool valid_deployment(const char *deployment) {
         assert(deployment);
 
-        return strspn(deployment, VALID_DEPLOYMENT_CHARS) == strlen(deployment);
+        return in_charset(deployment, VALID_DEPLOYMENT_CHARS);
 }
 
 static const char* fallback_chassis(void) {

commit d4c9895d93700d20b7d092244a278009789d8e74
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Jul 11 15:34:18 2014 +0200

    nss-myhostname: simplify array building a bit

diff --git a/src/nss-myhostname/nss-myhostname.c b/src/nss-myhostname/nss-myhostname.c
index 06bd842..23646e6 100644
--- a/src/nss-myhostname/nss-myhostname.c
+++ b/src/nss-myhostname/nss-myhostname.c
@@ -184,9 +184,8 @@ static enum nss_status fill_in_hostent(
                 int32_t *ttlp,
                 char **canonp) {
 
-        size_t l_canonical, l_additional, idx, ms;
+        size_t l_canonical, l_additional, idx, ms, alen;
         char *r_addr, *r_name, *r_aliases, *r_alias = NULL, *r_addr_list;
-        size_t alen;
         struct local_address *a;
         unsigned n, c;
 
@@ -208,7 +207,7 @@ static enum nss_status fill_in_hostent(
                 (additional ? ALIGN(l_additional+1) : 0) +
                 sizeof(char*) +
                 (additional ? sizeof(char*) : 0) +
-                (c > 0 ? c : 1) * ALIGN(alen)+
+                (c > 0 ? c : 1) * ALIGN(alen) +
                 (c > 0 ? c+1 : 2) * sizeof(char*);
 
         if (buflen < ms) {
@@ -266,24 +265,18 @@ static enum nss_status fill_in_hostent(
         /* Fourth, add address pointer array */
         r_addr_list = buffer + idx;
         if (c > 0) {
-                unsigned i = 0;
+                unsigned i;
 
-                for (a = addresses, n = 0; n < n_addresses; a++, n++) {
-                        if (af != a->family)
-                                continue;
+                for (i = 0; i < c; i++)
+                        ((char**) r_addr_list)[i] = r_addr + i*ALIGN(alen);
 
-                        ((char**) r_addr_list)[i] = (r_addr + i*ALIGN(alen));
-                        i++;
-                }
-
-                assert(i == c);
-                ((char**) r_addr_list)[c] = NULL;
-                idx += (c+1)*sizeof(char*);
+                ((char**) r_addr_list)[i] = NULL;
+                idx += (c+1) * sizeof(char*);
 
         } else {
                 ((char**) r_addr_list)[0] = r_addr;
                 ((char**) r_addr_list)[1] = NULL;
-                idx += 2*sizeof(char*);
+                idx += 2 * sizeof(char*);
         }
 
         /* Verify the size matches */

commit d77ab3f7e3e56a4fd370caff6347bf4e56e51dec
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Jul 11 15:31:49 2014 +0200

    hostnamed: minor modernization

diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index a4849b3..19ab500 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -336,7 +336,8 @@ static int context_write_data_machine_info(Context *c) {
                 return r;
 
         for (p = PROP_PRETTY_HOSTNAME; p <= PROP_DEPLOYMENT; p++) {
-                char *t, **u;
+                _cleanup_free_ char *t = NULL;
+                char **u;
 
                 assert(name[p]);
 
@@ -345,12 +346,11 @@ static int context_write_data_machine_info(Context *c) {
                         continue;
                 }
 
-                if (asprintf(&t, "%s=%s", name[p], strempty(c->data[p])) < 0)
+                t = strjoin(name[p], "=", c->data[p], NULL);
+                if (!t)
                         return -ENOMEM;
 
                 u = strv_env_set(l, t);
-                free(t);
-
                 if (!u)
                         return -ENOMEM;
 
@@ -359,7 +359,6 @@ static int context_write_data_machine_info(Context *c) {
         }
 
         if (strv_isempty(l)) {
-
                 if (unlink("/etc/machine-info") < 0)
                         return errno == ENOENT ? 0 : -errno;
 

commit 46b131574fdd7d77c15a0919ca9010cad7aa6ac7
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Jul 11 13:30:16 2014 +0200

    journald: turn ForwardToSyslog= off by default
    
    After all, rsyslog and friends nowadays read their data directly from
    the journal, hence the forwarding is unnecessary in most cases.

diff --git a/man/journald.conf.xml b/man/journald.conf.xml
index 046609e..5538b96 100644
--- a/man/journald.conf.xml
+++ b/man/journald.conf.xml
@@ -395,8 +395,8 @@
                                 forwarding to syslog is enabled but no
                                 syslog daemon is running, the
                                 respective option has no effect. By
-                                default, only forwarding to syslog and
-                                wall is enabled. These settings may be
+                                default, only forwarding wall is
+                                enabled. These settings may be
                                 overridden at boot time with the
                                 kernel command line options
                                 <literal>systemd.journald.forward_to_syslog=</literal>,
@@ -405,9 +405,9 @@
                                 and
                                 <literal>systemd.journald.forward_to_wall=</literal>.
                                 When forwarding to the console, the
-                                TTY to log to can be changed
-                                with <varname>TTYPath=</varname>,
-                                described below.</para></listitem>
+                                TTY to log to can be changed with
+                                <varname>TTYPath=</varname>, described
+                                below.</para></listitem>
                         </varlistentry>
 
                         <varlistentry>
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 58410a2..f8da4da 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -1473,7 +1473,6 @@ int server_init(Server *s) {
         s->rate_limit_interval = DEFAULT_RATE_LIMIT_INTERVAL;
         s->rate_limit_burst = DEFAULT_RATE_LIMIT_BURST;
 
-        s->forward_to_syslog = true;
         s->forward_to_wall = true;
 
         s->max_file_usec = DEFAULT_MAX_FILE_USEC;
diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c
index b826e23..afeb8bd 100644
--- a/src/journal/journald-syslog.c
+++ b/src/journal/journald-syslog.c
@@ -37,14 +37,14 @@
 
 static void forward_syslog_iovec(Server *s, const struct iovec *iovec, unsigned n_iovec, struct ucred *ucred, struct timeval *tv) {
 
-        union sockaddr_union sa = {
+        static const union sockaddr_union sa = {
                 .un.sun_family = AF_UNIX,
                 .un.sun_path = "/run/systemd/journal/syslog",
         };
         struct msghdr msghdr = {
                 .msg_iov = (struct iovec *) iovec,
                 .msg_iovlen = n_iovec,
-                .msg_name = &sa,
+                .msg_name = (struct sockaddr*) &sa.sa,
                 .msg_namelen = offsetof(union sockaddr_union, un.sun_path)
                                + strlen("/run/systemd/journal/syslog"),
         };
@@ -426,7 +426,7 @@ int server_open_syslog_socket(Server *s) {
         assert(s);
 
         if (s->syslog_fd < 0) {
-                union sockaddr_union sa = {
+                static const union sockaddr_union sa = {
                         .un.sun_family = AF_UNIX,
                         .un.sun_path = "/run/systemd/journal/dev-log",
                 };
diff --git a/src/journal/journald.conf b/src/journal/journald.conf
index cded4a9..2073f1b 100644
--- a/src/journal/journald.conf
+++ b/src/journal/journald.conf
@@ -23,7 +23,7 @@
 #RuntimeMaxFileSize=
 #MaxRetentionSec=
 #MaxFileSec=1month
-#ForwardToSyslog=yes
+#ForwardToSyslog=no
 #ForwardToKMsg=no
 #ForwardToConsole=no
 #ForwardToWall=yes



More information about the systemd-commits mailing list