1
0
mirror of https://github.com/systemd/systemd synced 2026-04-25 08:25:12 +02:00

Compare commits

..

No commits in common. "7be87278a36710e634096277752c6c8f3ddf96a0" and "c905eb45deb998eef0a4a133793b0961ac3b8530" have entirely different histories.

8 changed files with 61 additions and 127 deletions

View File

@ -270,7 +270,7 @@ int sd_netlink_sendv(
return -ENOMEM; return -ENOMEM;
} }
for (size_t i = 0; i < msgcount; i++) { for (unsigned i = 0; i < msgcount; i++) {
assert_return(!messages[i]->sealed, -EPERM); assert_return(!messages[i]->sealed, -EPERM);
netlink_seal_message(nl, messages[i]); netlink_seal_message(nl, messages[i]);

View File

@ -2491,11 +2491,11 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
pager_open(arg_pager_flags); pager_open(arg_pager_flags);
table = table_new("link", table = table_new("link",
"chassis-id", "chassis id",
"system-name", "system name",
"caps", "caps",
"port-id", "port id",
"port-description"); "port description");
if (!table) if (!table)
return log_oom(); return log_oom();
@ -2504,9 +2504,24 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
table_set_header(table, arg_legend); table_set_header(table, arg_legend);
assert_se(cell = table_get_cell(table, 0, 0));
table_set_minimum_width(table, cell, 16);
assert_se(cell = table_get_cell(table, 0, 1));
table_set_minimum_width(table, cell, 17);
assert_se(cell = table_get_cell(table, 0, 2));
table_set_minimum_width(table, cell, 16);
assert_se(cell = table_get_cell(table, 0, 3)); assert_se(cell = table_get_cell(table, 0, 3));
table_set_minimum_width(table, cell, 11); table_set_minimum_width(table, cell, 11);
assert_se(cell = table_get_cell(table, 0, 4));
table_set_minimum_width(table, cell, 17);
assert_se(cell = table_get_cell(table, 0, 5));
table_set_minimum_width(table, cell, 16);
for (int i = 0; i < c; i++) { for (int i = 0; i < c; i++) {
_cleanup_fclose_ FILE *f = NULL; _cleanup_fclose_ FILE *f = NULL;
@ -2519,9 +2534,9 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
} }
for (;;) { for (;;) {
_cleanup_free_ char *cid = NULL, *pid = NULL, *sname = NULL, *pdesc = NULL, *capabilities = NULL;
const char *chassis_id = NULL, *port_id = NULL, *system_name = NULL, *port_description = NULL; const char *chassis_id = NULL, *port_id = NULL, *system_name = NULL, *port_description = NULL;
_cleanup_(sd_lldp_neighbor_unrefp) sd_lldp_neighbor *n = NULL; _cleanup_(sd_lldp_neighbor_unrefp) sd_lldp_neighbor *n = NULL;
_cleanup_free_ char *capabilities = NULL;
uint16_t cc; uint16_t cc;
r = next_lldp_neighbor(f, &n); r = next_lldp_neighbor(f, &n);
@ -2537,6 +2552,30 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
(void) sd_lldp_neighbor_get_system_name(n, &system_name); (void) sd_lldp_neighbor_get_system_name(n, &system_name);
(void) sd_lldp_neighbor_get_port_description(n, &port_description); (void) sd_lldp_neighbor_get_port_description(n, &port_description);
if (chassis_id) {
cid = ellipsize(chassis_id, 17, 100);
if (cid)
chassis_id = cid;
}
if (port_id) {
pid = ellipsize(port_id, 17, 100);
if (pid)
port_id = pid;
}
if (system_name) {
sname = ellipsize(system_name, 16, 100);
if (sname)
system_name = sname;
}
if (port_description) {
pdesc = ellipsize(port_description, 16, 100);
if (pdesc)
port_description = pdesc;
}
if (sd_lldp_neighbor_get_enabled_capabilities(n, &cc) >= 0) { if (sd_lldp_neighbor_get_enabled_capabilities(n, &cc) >= 0) {
capabilities = lldp_capabilities_to_string(cc); capabilities = lldp_capabilities_to_string(cc);
all |= cc; all |= cc;

View File

@ -29,16 +29,13 @@
#define UDP_DPORT_OFFSET 2 #define UDP_DPORT_OFFSET 2
static int nfnl_netlink_sendv( static int nfnl_netlink_sendv(sd_netlink *nfnl,
sd_netlink *nfnl, sd_netlink_message *messages[],
sd_netlink_message **messages, size_t msgcount) {
size_t msgcount) {
_cleanup_free_ uint32_t *serial = NULL; _cleanup_free_ uint32_t *serial = NULL;
size_t i;
int r; int r;
assert(nfnl);
assert(messages);
assert(msgcount > 0); assert(msgcount > 0);
r = sd_netlink_sendv(nfnl, messages, msgcount, &serial); r = sd_netlink_sendv(nfnl, messages, msgcount, &serial);
@ -46,7 +43,7 @@ static int nfnl_netlink_sendv(
return r; return r;
r = 0; r = 0;
for (size_t i = 1; i < msgcount - 1; i++) { for (i = 1; i < msgcount - 1; i++) {
int tmp; int tmp;
/* If message is an error, this returns embedded errno */ /* If message is an error, this returns embedded errno */

View File

@ -2825,7 +2825,7 @@ static int normalize_linked_files(
return r; return r;
const char *p = NULL; const char *p = NULL;
if (i && i->path && i->root) if (i && i->path)
/* Use startswith here, because we know that paths are normalized, and /* Use startswith here, because we know that paths are normalized, and
* path_startswith() would give us a relative path, but we need an absolute path * path_startswith() would give us a relative path, but we need an absolute path
* relative to i->root. * relative to i->root.

View File

@ -2657,7 +2657,7 @@ static int item_compare(const Item *a, const Item *b) {
return CMP(a->type, b->type); return CMP(a->type, b->type);
} }
static bool item_compatible(const Item *a, const Item *b) { static bool item_compatible(Item *a, Item *b) {
assert(a); assert(a);
assert(b); assert(b);
assert(streq(a->path, b->path)); assert(streq(a->path, b->path));
@ -2896,26 +2896,6 @@ static int parse_age_by_from_arg(const char *age_by_str, Item *item) {
return 0; return 0;
} }
static bool is_duplicated_item(ItemArray *existing, const Item *i) {
assert(existing);
assert(i);
for (size_t n = 0; n < existing->n_items; n++) {
const Item *e = existing->items + n;
if (item_compatible(e, i))
continue;
/* Only multiple 'w+' lines for the same path are allowed. */
if (e->type != WRITE_FILE || !e->append_or_force ||
i->type != WRITE_FILE || !i->append_or_force)
return true;
}
return false;
}
static int parse_line( static int parse_line(
const char *fname, const char *fname,
unsigned line, unsigned line,
@ -3267,10 +3247,13 @@ static int parse_line(
existing = ordered_hashmap_get(h, i.path); existing = ordered_hashmap_get(h, i.path);
if (existing) { if (existing) {
if (is_duplicated_item(existing, &i)) { size_t n;
log_syntax(NULL, LOG_NOTICE, fname, line, 0,
"Duplicate line for path \"%s\", ignoring.", i.path); for (n = 0; n < existing->n_items; n++) {
return 0; if (!item_compatible(existing->items + n, &i) && !i.append_or_force) {
log_syntax(NULL, LOG_NOTICE, fname, line, 0, "Duplicate line for path \"%s\", ignoring.", i.path);
return 0;
}
} }
} else { } else {
existing = new0(ItemArray, 1); existing = new0(ItemArray, 1);

View File

@ -1869,7 +1869,7 @@ install_pam() {
paths+=(/lib*/security) paths+=(/lib*/security)
fi fi
for d in /etc/pam.d /{usr/,}etc/security /usr/{etc,lib}/pam.d; do for d in /etc/pam.d /etc/security /usr/{etc,lib}/pam.d; do
[ -d "$d" ] && paths+=("$d") [ -d "$d" ] && paths+=("$d")
done done

View File

@ -186,7 +186,6 @@ test ! -e /tmp/F/daemon/unsafe-symlink/exploit
# 'w' # 'w'
# #
touch /tmp/w/overwritten touch /tmp/w/overwritten
touch /tmp/w/appended
### nop if the target does not exist. ### nop if the target does not exist.
systemd-tmpfiles --create - <<EOF systemd-tmpfiles --create - <<EOF
@ -206,22 +205,13 @@ EOF
test -f /tmp/w/overwritten test -f /tmp/w/overwritten
test "$(< /tmp/w/overwritten)" = "old content" test "$(< /tmp/w/overwritten)" = "old content"
### old content is overwritten ### new content is overwritten
systemd-tmpfiles --create - <<EOF systemd-tmpfiles --create - <<EOF
w /tmp/w/overwritten 0644 - - - new content w /tmp/w/overwritten 0644 - - - new content
EOF EOF
test -f /tmp/w/overwritten test -f /tmp/w/overwritten
test "$(< /tmp/w/overwritten)" = "new content" test "$(< /tmp/w/overwritten)" = "new content"
### append lines
systemd-tmpfiles --create - <<EOF
w+ /tmp/w/appended 0644 - - - 1
w+ /tmp/w/appended 0644 - - - 2\n
w+ /tmp/w/appended 0644 - - - 3
EOF
test -f /tmp/w/appended
test "$(< /tmp/w/appended)" = "$(echo -ne '12\n3')"
### writing into an 'exotic' file should be allowed. ### writing into an 'exotic' file should be allowed.
systemd-tmpfiles --create - <<EOF systemd-tmpfiles --create - <<EOF
w /dev/null - - - - new content w /dev/null - - - - new content

View File

@ -1,75 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Tests for configuration directory and file precedences
#
set -eux
rm -f /{usr/lib,etc}/tmpfiles.d/{L,w}-*.conf
rm -fr /tmp/precedence/{L,w}
mkdir -p /{usr/lib,etc}/tmpfiles.d
mkdir -p /tmp/precedence/{L,w}
#
# 'L'
#
ln -s /dev/null /tmp/precedence/L
# Overwrite the existing symlink
cat >/usr/lib/tmpfiles.d/L-z.conf<<EOF
L+ /tmp/precedence/L - - - - /usr/lib/tmpfiles.d/L-z.conf
EOF
systemd-tmpfiles --create
test "$(readlink /tmp/precedence/L)" = "/usr/lib/tmpfiles.d/L-z.conf"
# Files in /etc should override those in /usr
cat >/etc/tmpfiles.d/L-z.conf<<EOF
L+ /tmp/precedence/L - - - - /etc/tmpfiles.d/L-z.conf
EOF
systemd-tmpfiles --create
test "$(readlink /tmp/precedence/L)" = "/etc/tmpfiles.d/L-z.conf"
# /usr/…/L-a.conf has higher prio than /etc/…/L-z.conf
cat >/usr/lib/tmpfiles.d/L-a.conf<<EOF
L+ /tmp/precedence/L - - - - /usr/lib/tmpfiles.d/L-a.conf
EOF
systemd-tmpfiles --create
test "$(readlink /tmp/precedence/L)" = "/usr/lib/tmpfiles.d/L-a.conf"
# Files in /etc should override those in /usr
cat >/etc/tmpfiles.d/L-a.conf<<EOF
L+ /tmp/precedence/L - - - - /etc/tmpfiles.d/L-a.conf
EOF
systemd-tmpfiles --create
test "$(readlink /tmp/precedence/L)" = "/etc/tmpfiles.d/L-a.conf"
#
# 'w'
#
touch /tmp/precedence/w/f
# Multiple configuration files specifying 'w+' for the same path is allowed.
for i in a c; do
cat >/usr/lib/tmpfiles.d/w-$i.conf<<EOF
w+ /tmp/precedence/w/f - - - - /usr/lib/tmpfiles.d/w-$i.conf\n
EOF
cat >/etc/tmpfiles.d/w-$i.conf<<EOF
w+ /tmp/precedence/w/f - - - - /etc/tmpfiles.d/w-$i.conf\n
EOF
done
cat >/usr/lib/tmpfiles.d/w-b.conf<<EOF
w+ /tmp/precedence/w/f - - - - /usr/lib/tmpfiles.d/w-b.conf\n
EOF
systemd-tmpfiles --create
cmp /tmp/precedence/w/f <<EOF
/etc/tmpfiles.d/w-a.conf
/usr/lib/tmpfiles.d/w-b.conf
/etc/tmpfiles.d/w-c.conf
EOF