[systemd-commits] 7 commits - man/systemd.network.xml src/core src/journal-remote src/libsystemd src/libudev src/login src/machine src/network src/shared
Zbigniew Jędrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Sun Mar 15 14:27:12 PDT 2015
man/systemd.network.xml | 8 +++++
src/core/main.c | 2 -
src/core/manager.c | 3 +-
src/journal-remote/journal-gatewayd.c | 44 +++++++++++++++++++------------
src/libsystemd/sd-resolve/sd-resolve.c | 2 -
src/libudev/libudev-monitor.c | 33 +++++++++++------------
src/login/logind-dbus.c | 4 ++
src/login/logind-session.c | 18 +++++++-----
src/login/logind-session.h | 2 -
src/machine/machine.c | 4 +-
src/network/networkd-network-gperf.gperf | 1
src/shared/util.c | 41 ++++++++++++++--------------
12 files changed, 93 insertions(+), 69 deletions(-)
New commits:
commit 301f4073fe1c2757e602aef24cee9ccf5f81a3a3
Author: Michael Marineau <michael.marineau at coreos.com>
Date: Fri Mar 13 12:01:29 2015 -0700
network: add UseNTP DHCP option
Despite having the internal logic in place to enable/disable using NTP
servers provided by DHCP the network config didn't expose the option.
diff --git a/man/systemd.network.xml b/man/systemd.network.xml
index ed0b2eb..087e9e2 100644
--- a/man/systemd.network.xml
+++ b/man/systemd.network.xml
@@ -515,6 +515,14 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><varname>UseNTP=</varname></term>
+ <listitem>
+ <para>When true (the default), the NTP servers received
+ from the DHCP server will be used by systemd-timesyncd
+ and take precedence over any statically configured ones.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><varname>UseMTU=</varname></term>
<listitem>
<para>When true, the interface maximum transmission unit
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
index 93df83a..8abf5bc 100644
--- a/src/network/networkd-network-gperf.gperf
+++ b/src/network/networkd-network-gperf.gperf
@@ -60,6 +60,7 @@ Route.Metric, config_parse_route_priority, 0,
Route.Scope, config_parse_route_scope, 0, 0
DHCP.ClientIdentifier, config_parse_dhcp_client_identifier,0, offsetof(Network, dhcp_client_identifier)
DHCP.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_dns)
+DHCP.UseNTP, config_parse_bool, 0, offsetof(Network, dhcp_ntp)
DHCP.UseMTU, config_parse_bool, 0, offsetof(Network, dhcp_mtu)
DHCP.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_hostname)
DHCP.UseDomains, config_parse_bool, 0, offsetof(Network, dhcp_domains)
commit e62d9b81926e22f7a1d8a117fd85bb735d3cead2
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sun Mar 15 17:17:24 2015 -0400
Add (void) where we don't care about return value
diff --git a/src/core/main.c b/src/core/main.c
index 3ec70f9..2d393de 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -156,7 +156,7 @@ noreturn static void crash(int sig) {
setrlimit(RLIMIT_CORE, &rl);
/* Just to be sure... */
- chdir("/");
+ (void) chdir("/");
/* Raise the signal again */
pid = raw_getpid();
diff --git a/src/libsystemd/sd-resolve/sd-resolve.c b/src/libsystemd/sd-resolve/sd-resolve.c
index 8aec75a..b0dc822 100644
--- a/src/libsystemd/sd-resolve/sd-resolve.c
+++ b/src/libsystemd/sd-resolve/sd-resolve.c
@@ -653,7 +653,7 @@ static void resolve_free(sd_resolve *resolve) {
/* Send one termination packet for each worker */
for (i = 0; i < resolve->n_valid_workers; i++)
- send(resolve->fds[REQUEST_SEND_FD], &req, req.length, MSG_NOSIGNAL);
+ (void) send(resolve->fds[REQUEST_SEND_FD], &req, req.length, MSG_NOSIGNAL);
}
/* Now terminate them and wait until they are gone. */
diff --git a/src/machine/machine.c b/src/machine/machine.c
index 182430d..048607f 100644
--- a/src/machine/machine.c
+++ b/src/machine/machine.c
@@ -212,9 +212,9 @@ int machine_save(Machine *m) {
/* Create a symlink from the unit name to the machine
* name, so that we can quickly find the machine for
- * each given unit */
+ * each given unit. Ignore error. */
sl = strjoina("/run/systemd/machines/unit:", m->unit);
- symlink(m->name, sl);
+ (void) symlink(m->name, sl);
}
finish:
commit cc02a7b3304975e39ad5863983b16ef149b7f9e9
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sun Mar 15 17:13:43 2015 -0400
journal-gatewayd: factor out opening of temp file
Also use our own mkostemp wrapper, which tries to use O_TMPFILE.
diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c
index b4bc8cc..6efc9b3 100644
--- a/src/journal-remote/journal-gatewayd.c
+++ b/src/journal-remote/journal-gatewayd.c
@@ -121,6 +121,26 @@ static int open_journal(RequestMeta *m) {
return sd_journal_open(&m->journal, SD_JOURNAL_LOCAL_ONLY|SD_JOURNAL_SYSTEM);
}
+static int request_meta_ensure_tmp(RequestMeta *m) {
+ if (m->tmp)
+ rewind(m->tmp);
+ else {
+ int fd;
+
+ fd = open_tmpfile("/tmp", O_RDWR|O_CLOEXEC);
+ if (fd < 0)
+ return fd;
+
+ m->tmp = fdopen(fd, "rw");
+ if (!m->tmp) {
+ safe_close(fd);
+ return -errno;
+ }
+ }
+
+ return 0;
+}
+
static ssize_t request_reader_entries(
void *cls,
uint64_t pos,
@@ -194,14 +214,10 @@ static ssize_t request_reader_entries(
m->n_skip = 0;
- if (m->tmp)
- rewind(m->tmp);
- else {
- m->tmp = tmpfile();
- if (!m->tmp) {
- log_error_errno(errno, "Failed to create temporary file: %m");
- return MHD_CONTENT_READER_END_WITH_ERROR;
- }
+ r = request_meta_ensure_tmp(m);
+ if (r < 0) {
+ log_error_errno(r, "Failed to create temporary file: %m");
+ return MHD_CONTENT_READER_END_WITH_ERROR;
}
r = output_journal(m->tmp, m->journal, m->mode, 0, OUTPUT_FULL_WIDTH, NULL);
@@ -555,14 +571,10 @@ static ssize_t request_reader_fields(
if (m->n_fields_set)
m->n_fields -= 1;
- if (m->tmp)
- rewind(m->tmp);
- else {
- m->tmp = tmpfile();
- if (!m->tmp) {
- log_error_errno(errno, "Failed to create temporary file: %m");
- return MHD_CONTENT_READER_END_WITH_ERROR;
- }
+ r = request_meta_ensure_tmp(m);
+ if (r < 0) {
+ log_error_errno(r, "Failed to create temporary file: %m");
+ return MHD_CONTENT_READER_END_WITH_ERROR;
}
r = output_field(m->tmp, m->mode, d, l);
commit ad8780c96999c99f5aefb00193f2e3d68b1db217
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sun Mar 15 16:37:39 2015 -0400
logind: check return value of session_release
It allocates memory, so it can fail.
CID #1237527.
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index b28d280..a3d49ef 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -827,7 +827,9 @@ static int method_release_session(sd_bus *bus, sd_bus_message *message, void *us
if (r < 0)
return r;
- session_release(session);
+ r = session_release(session);
+ if (r < 0)
+ return r;
return sd_bus_reply_method_return(message, NULL);
}
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 8d33579..59f7657 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -701,18 +701,20 @@ static int release_timeout_callback(sd_event_source *es, uint64_t usec, void *us
return 0;
}
-void session_release(Session *s) {
+int session_release(Session *s) {
assert(s);
if (!s->started || s->stopping)
- return;
+ return 0;
+
+ if (s->timer_event_source)
+ return 0;
- if (!s->timer_event_source)
- sd_event_add_time(s->manager->event,
- &s->timer_event_source,
- CLOCK_MONOTONIC,
- now(CLOCK_MONOTONIC) + RELEASE_USEC, 0,
- release_timeout_callback, s);
+ return sd_event_add_time(s->manager->event,
+ &s->timer_event_source,
+ CLOCK_MONOTONIC,
+ now(CLOCK_MONOTONIC) + RELEASE_USEC, 0,
+ release_timeout_callback, s);
}
bool session_is_active(Session *s) {
diff --git a/src/login/logind-session.h b/src/login/logind-session.h
index 0505f7f..9305dca 100644
--- a/src/login/logind-session.h
+++ b/src/login/logind-session.h
@@ -137,7 +137,7 @@ int session_create_fifo(Session *s);
int session_start(Session *s);
int session_stop(Session *s, bool force);
int session_finalize(Session *s);
-void session_release(Session *s);
+int session_release(Session *s);
int session_save(Session *s);
int session_load(Session *s);
int session_kill(Session *s, KillWho who, int signo);
commit 0daa5666da6fab8864e313dd594a2648d882e0cf
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sun Mar 15 15:59:23 2015 -0400
util: check asprintf return value
CID #1237546.
diff --git a/src/shared/util.c b/src/shared/util.c
index f1f7a5d..5cbbe8f 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -2926,31 +2926,30 @@ int get_ctty(pid_t pid, dev_t *_devnr, char **r) {
/* This is an ugly hack */
if (major(devnr) == 136) {
- asprintf(&b, "pts/%u", minor(devnr));
- goto finish;
- }
+ if (asprintf(&b, "pts/%u", minor(devnr)) < 0)
+ return -ENOMEM;
+ } else {
+ /* Probably something like the ptys which have no
+ * symlink in /dev/char. Let's return something
+ * vaguely useful. */
- /* Probably something like the ptys which have no
- * symlink in /dev/char. Let's return something
- * vaguely useful. */
+ b = strdup(fn + 5);
+ if (!b)
+ return -ENOMEM;
+ }
+ } else {
+ if (startswith(s, "/dev/"))
+ p = s + 5;
+ else if (startswith(s, "../"))
+ p = s + 3;
+ else
+ p = s;
- b = strdup(fn + 5);
- goto finish;
+ b = strdup(p);
+ if (!b)
+ return -ENOMEM;
}
- if (startswith(s, "/dev/"))
- p = s + 5;
- else if (startswith(s, "../"))
- p = s + 3;
- else
- p = s;
-
- b = strdup(p);
-
-finish:
- if (!b)
- return -ENOMEM;
-
*r = b;
if (_devnr)
*_devnr = devnr;
commit cc3bc3e6203e0c615e31b8b68796362e1385f28a
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sun Mar 15 12:12:19 2015 -0400
core: remove useless debug message
Mar 13 19:48:28 adam.happyassassin.net systemd[1]: Collecting (null)
Mar 13 19:48:28 adam.happyassassin.net systemd[1]: Collecting (null)
Mar 13 19:48:28 adam.happyassassin.net systemd[1]: Collecting (null)
Mar 13 19:48:28 adam.happyassassin.net systemd[1]: Collecting (null)
Mar 13 19:48:28 adam.happyassassin.net systemd[1]: Collecting (null)
Mar 13 19:48:28 adam.happyassassin.net systemd[1]: Collecting (null)
Mar 13 19:48:28 adam.happyassassin.net systemd[1]: Collecting (null)
diff --git a/src/core/manager.c b/src/core/manager.c
index d92e048..d33112d 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -838,7 +838,8 @@ static unsigned manager_dispatch_gc_queue(Manager *m) {
if (u->gc_marker == gc_marker + GC_OFFSET_BAD ||
u->gc_marker == gc_marker + GC_OFFSET_UNSURE) {
- log_unit_debug(u->id, "Collecting %s", u->id);
+ if (u->id)
+ log_unit_debug(u->id, "Collecting %s", u->id);
u->gc_marker = gc_marker + GC_OFFSET_BAD;
unit_add_to_cleanup_queue(u);
}
commit 81b9fe5440a95a2be209131f1315df6a263a1c48
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sun Mar 15 07:31:20 2015 -0400
libudev-monitor: use initialization
diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c
index 0c554bb..3925852 100644
--- a/src/libudev/libudev-monitor.c
+++ b/src/libudev/libudev-monitor.c
@@ -694,13 +694,20 @@ retry:
int udev_monitor_send_device(struct udev_monitor *udev_monitor,
struct udev_monitor *destination, struct udev_device *udev_device)
{
- const char *buf;
- ssize_t blen;
- ssize_t count;
- struct msghdr smsg;
- struct iovec iov[2];
- const char *val;
- struct udev_monitor_netlink_header nlh;
+ const char *buf, *val;
+ ssize_t blen, count;
+ struct udev_monitor_netlink_header nlh = {
+ .prefix = "libudev",
+ .magic = htonl(UDEV_MONITOR_MAGIC),
+ .header_size = sizeof nlh,
+ };
+ struct iovec iov[2] = {
+ { .iov_base = &nlh, .iov_len = sizeof nlh },
+ };
+ struct msghdr smsg = {
+ .msg_iov = iov,
+ .msg_iovlen = 2,
+ };
struct udev_list_entry *list_entry;
uint64_t tag_bloom_bits;
@@ -708,18 +715,13 @@ int udev_monitor_send_device(struct udev_monitor *udev_monitor,
if (blen < 32)
return -EINVAL;
- /* add versioned header */
- memzero(&nlh, sizeof(struct udev_monitor_netlink_header));
- memcpy(nlh.prefix, "libudev", 8);
- nlh.magic = htonl(UDEV_MONITOR_MAGIC);
- nlh.header_size = sizeof(struct udev_monitor_netlink_header);
+ /* fill in versioned header */
val = udev_device_get_subsystem(udev_device);
nlh.filter_subsystem_hash = htonl(util_string_hash32(val));
+
val = udev_device_get_devtype(udev_device);
if (val != NULL)
nlh.filter_devtype_hash = htonl(util_string_hash32(val));
- iov[0].iov_base = &nlh;
- iov[0].iov_len = sizeof(struct udev_monitor_netlink_header);
/* add tag bloom filter */
tag_bloom_bits = 0;
@@ -736,9 +738,6 @@ int udev_monitor_send_device(struct udev_monitor *udev_monitor,
iov[1].iov_base = (char *)buf;
iov[1].iov_len = blen;
- memzero(&smsg, sizeof(struct msghdr));
- smsg.msg_iov = iov;
- smsg.msg_iovlen = 2;
/*
* Use custom address for target, or the default one.
*
More information about the systemd-commits
mailing list