summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/dbus-unit.c32
-rw-r--r--src/core/execute.h2
-rw-r--r--src/machine/machinectl.c2
-rw-r--r--src/resolve/resolved-dns-packet.c43
-rw-r--r--src/resolve/resolved-dns-packet.h18
-rw-r--r--src/resolve/resolved-dns-scope.c1
-rw-r--r--src/resolve/resolved-dns-transaction.c16
-rw-r--r--src/resolve/resolved-dns-transaction.h6
-rw-r--r--src/systemctl/systemctl.c11
9 files changed, 78 insertions, 53 deletions
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index 1892725f91..0a9effda71 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -697,10 +697,40 @@ static int property_get_cpu_usage(
return sd_bus_message_append(reply, "t", ns);
}
+static int property_get_cgroup(
+ sd_bus *bus,
+ const char *path,
+ const char *interface,
+ const char *property,
+ sd_bus_message *reply,
+ void *userdata,
+ sd_bus_error *error) {
+
+ Unit *u = userdata;
+ const char *t;
+
+ assert(bus);
+ assert(reply);
+ assert(u);
+
+ /* Three cases: a) u->cgroup_path is NULL, in which case the
+ * unit has no control group, which we report as the empty
+ * string. b) u->cgroup_path is the empty string, which
+ * indicates the root cgroup, which we report as "/". c) all
+ * other cases we report as-is. */
+
+ if (u->cgroup_path)
+ t = isempty(u->cgroup_path) ? "/" : u->cgroup_path;
+ else
+ t = "";
+
+ return sd_bus_message_append(reply, "s", t);
+}
+
const sd_bus_vtable bus_unit_cgroup_vtable[] = {
SD_BUS_VTABLE_START(0),
SD_BUS_PROPERTY("Slice", "s", property_get_slice, 0, 0),
- SD_BUS_PROPERTY("ControlGroup", "s", NULL, offsetof(Unit, cgroup_path), 0),
+ SD_BUS_PROPERTY("ControlGroup", "s", property_get_cgroup, 0, 0),
SD_BUS_PROPERTY("MemoryCurrent", "t", property_get_current_memory, 0, 0),
SD_BUS_PROPERTY("CPUUsageNSec", "t", property_get_cpu_usage, 0, 0),
SD_BUS_VTABLE_END
diff --git a/src/core/execute.h b/src/core/execute.h
index 5d46bf154c..8d14fe23d0 100644
--- a/src/core/execute.h
+++ b/src/core/execute.h
@@ -43,7 +43,7 @@ typedef enum ExecUtmpMode {
EXEC_UTMP_LOGIN,
EXEC_UTMP_USER,
_EXEC_UTMP_MODE_MAX,
- _EXEC_UTMP_MODE_INVALID,
+ _EXEC_UTMP_MODE_INVALID = -1
} ExecUtmpMode;
typedef enum ExecInput {
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index 6b29e61642..f9f49ee892 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -1225,7 +1225,7 @@ static int process_forward(sd_event *event, PTYForward **forward, int master, bo
}
static int login_machine(int argc, char *argv[], void *userdata) {
- _cleanup_bus_message_unref_ sd_bus_message *reply = NULL, *m = NULL;
+ _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(pty_forward_freep) PTYForward *forward = NULL;
_cleanup_bus_slot_unref_ sd_bus_slot *slot = NULL;
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
index 784d949cce..bebd1ee4a6 100644
--- a/src/resolve/resolved-dns-packet.c
+++ b/src/resolve/resolved-dns-packet.c
@@ -64,7 +64,7 @@ int dns_packet_new(DnsPacket **ret, DnsProtocol protocol, size_t mtu) {
int dns_packet_new_query(DnsPacket **ret, DnsProtocol protocol, size_t mtu) {
DnsPacket *p;
DnsPacketHeader *h;
- int r, rd;
+ int r;
assert(ret);
@@ -74,27 +74,26 @@ int dns_packet_new_query(DnsPacket **ret, DnsProtocol protocol, size_t mtu) {
h = DNS_PACKET_HEADER(p);
- switch (protocol) {
- case DNS_PROTOCOL_LLMNR:
- /* no recursion for link-local resolving protocols */
- rd = 0;
- break;
-
- default:
- /* ask for recursion */
- rd = 1;
- break;
- }
-
- h->flags = htobe16(DNS_PACKET_MAKE_FLAGS(0 /* qr */,
- 0 /* opcode */,
- 0 /* aa */,
- 0 /* tc */,
- rd /* rd */,
- 0 /* ra */,
- 0 /* ad */,
- 0 /* cd */,
- 0 /* rcode */));
+ if (protocol == DNS_PROTOCOL_LLMNR)
+ h->flags = htobe16(DNS_PACKET_MAKE_FLAGS(0 /* qr */,
+ 0 /* opcode */,
+ 0 /* c */,
+ 0 /* tc */,
+ 0 /* t */,
+ 0 /* ra */,
+ 0 /* ad */,
+ 0 /* cd */,
+ 0 /* rcode */));
+ else
+ h->flags = htobe16(DNS_PACKET_MAKE_FLAGS(0 /* qr */,
+ 0 /* opcode */,
+ 0 /* aa */,
+ 0 /* tc */,
+ 1 /* rd (ask for recursion) */,
+ 0 /* ra */,
+ 0 /* ad */,
+ 0 /* cd */,
+ 0 /* rcode */));
*ret = p;
return 0;
diff --git a/src/resolve/resolved-dns-packet.h b/src/resolve/resolved-dns-packet.h
index 8a72b898da..5628e579ad 100644
--- a/src/resolve/resolved-dns-packet.h
+++ b/src/resolve/resolved-dns-packet.h
@@ -121,15 +121,15 @@ static inline uint8_t* DNS_PACKET_DATA(DnsPacket *p) {
#define DNS_PACKET_ARCOUNT(p) be16toh(DNS_PACKET_HEADER(p)->arcount)
#define DNS_PACKET_MAKE_FLAGS(qr, opcode, aa, tc, rd, ra, ad, cd, rcode) \
- (((uint16_t) !!qr << 15) | \
- ((uint16_t) (opcode & 15) << 11) | \
- ((uint16_t) !!aa << 10) | \
- ((uint16_t) !!tc << 9) | \
- ((uint16_t) !!rd << 8) | \
- ((uint16_t) !!ra << 7) | \
- ((uint16_t) !!ad << 5) | \
- ((uint16_t) !!cd << 4) | \
- ((uint16_t) (rcode & 15)))
+ (((uint16_t) !!(qr) << 15) | \
+ ((uint16_t) ((opcode) & 15) << 11) | \
+ ((uint16_t) !!(aa) << 10) | /* on LLMNR: c */ \
+ ((uint16_t) !!(tc) << 9) | \
+ ((uint16_t) !!(rd) << 8) | /* on LLMNR: t */ \
+ ((uint16_t) !!(ra) << 7) | \
+ ((uint16_t) !!(ad) << 5) | \
+ ((uint16_t) !!(cd) << 4) | \
+ ((uint16_t) ((rcode) & 15)))
static inline unsigned DNS_PACKET_RRCOUNT(DnsPacket *p) {
return
diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c
index 77034a0be8..eaa099341f 100644
--- a/src/resolve/resolved-dns-scope.c
+++ b/src/resolve/resolved-dns-scope.c
@@ -362,6 +362,7 @@ DnsScopeMatch dns_scope_good_domain(DnsScope *s, int ifindex, uint64_t flags, co
(dns_name_endswith(domain, "local") > 0 && /* only resolve names ending in .local via mDNS */
dns_name_equal(domain, "local") == 0 && /* but not the single-label "local" name itself */
manager_is_own_hostname(s->manager, domain) <= 0)) /* never resolve the local hostname via mDNS */
+ return DNS_SCOPE_MAYBE;
return DNS_SCOPE_NO;
diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c
index 7b84c1bab8..8092bb514d 100644
--- a/src/resolve/resolved-dns-transaction.c
+++ b/src/resolve/resolved-dns-transaction.c
@@ -39,8 +39,8 @@ DnsTransaction* dns_transaction_free(DnsTransaction *t) {
dns_packet_unref(t->received);
dns_answer_unref(t->cached);
- sd_event_source_unref(t->dns_event_source);
- safe_close(t->dns_fd);
+ sd_event_source_unref(t->dns_udp_event_source);
+ safe_close(t->dns_udp_fd);
dns_server_unref(t->server);
dns_stream_free(t->stream);
@@ -98,7 +98,7 @@ int dns_transaction_new(DnsTransaction **ret, DnsScope *s, DnsResourceKey *key)
if (!t)
return -ENOMEM;
- t->dns_fd = -1;
+ t->dns_udp_fd = -1;
t->key = dns_resource_key_ref(key);
/* Find a fresh, unused transaction id */
@@ -328,8 +328,8 @@ static void dns_transaction_next_dns_server(DnsTransaction *t) {
assert(t);
t->server = dns_server_unref(t->server);
- t->dns_event_source = sd_event_source_unref(t->dns_event_source);
- t->dns_fd = safe_close(t->dns_fd);
+ t->dns_udp_event_source = sd_event_source_unref(t->dns_udp_event_source);
+ t->dns_udp_fd = safe_close(t->dns_udp_fd);
dns_scope_next_dns_server(t->scope);
}
@@ -500,16 +500,16 @@ static int dns_transaction_emit(DnsTransaction *t) {
if (fd < 0)
return fd;
- r = sd_event_add_io(t->scope->manager->event, &t->dns_event_source, fd, EPOLLIN, on_dns_packet, t);
+ r = sd_event_add_io(t->scope->manager->event, &t->dns_udp_event_source, fd, EPOLLIN, on_dns_packet, t);
if (r < 0)
return r;
- t->dns_fd = fd;
+ t->dns_udp_fd = fd;
fd = -1;
t->server = dns_server_ref(server);
}
- r = dns_scope_emit(t->scope, t->dns_fd, t->sent);
+ r = dns_scope_emit(t->scope, t->dns_udp_fd, t->sent);
if (r < 0)
return r;
diff --git a/src/resolve/resolved-dns-transaction.h b/src/resolve/resolved-dns-transaction.h
index 4db9352a04..acf6a6f651 100644
--- a/src/resolve/resolved-dns-transaction.h
+++ b/src/resolve/resolved-dns-transaction.h
@@ -62,10 +62,10 @@ struct DnsTransaction {
sd_event_source *timeout_event_source;
unsigned n_attempts;
- int dns_fd;
- sd_event_source *dns_event_source;
+ int dns_udp_fd;
+ sd_event_source *dns_udp_event_source;
- /* the active server */
+ /* The active server */
DnsServer *server;
/* TCP connection logic, if we need it */
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 587793fb17..3cb5f61868 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -3635,14 +3635,7 @@ static int status_property(const char *name, sd_bus_message *m, UnitStatusInfo *
if (r < 0)
return bus_log_parse_error(r);
- if (streq(name, "ControlGroup"))
- i->control_group = s;
- else if (!isempty(s)) {
- /* For all but the cgroup path (see above) we
- * consider the empty string as unset. For the
- * cgroup path the empty string refers to the
- * root of the cgroup tree. */
-
+ if (!isempty(s)) {
if (streq(name, "Id"))
i->id = s;
else if (streq(name, "LoadState"))
@@ -3665,6 +3658,8 @@ static int status_property(const char *name, sd_bus_message *m, UnitStatusInfo *
i->control_group = e;
}
#endif
+ else if (streq(name, "ControlGroup"))
+ i->control_group = s;
else if (streq(name, "StatusText"))
i->status_text = s;
else if (streq(name, "PIDFile"))