Compare commits

...

8 Commits

Author SHA1 Message Date
Anita Zhang b12a67ae14 man: save pull-raw example file without underscores
Destination file needs to be a valid hostname and underscores
are not valid hostname characters.

Closes #13542
2019-11-06 10:45:03 +09:00
Anita Zhang 7792d9cdd4 man: small grammatical/word choice fixes to crypttab man page
Closes #13608
2019-11-06 10:38:53 +09:00
Anita Zhang f03378805f
Merge pull request #13936 from keszybz/format-table-uninhibited
Output tables at full width if piped
2019-11-05 15:03:15 -08:00
Anita Zhang 9087384d39
Merge pull request #13944 from yuwata/network-split-struct-prefix
network: split struct Prefix into Prefix and RoutePrefix
2019-11-05 15:02:01 -08:00
Yu Watanabe 3126d64e5f sd-device-enumerator: do not return error when a device is removed
Fixes #13814.
2019-11-05 22:13:11 +01:00
Zbigniew Jędrzejewski-Szmek 0db41a8f1f shared/format-table: disable ellipsization when piped
Fixes #13461.

Before:
$ systemd-inhibit --no-pager
WHO            UID  USER    PID   COMM           WHAT                                  WHY          MODE
ModemManager   0    root    1093  ModemManager   sleep                                 ModemManage… delay
NetworkManager 0    root    1400  NetworkManager sleep                                 NetworkMana… delay
UPower         0    root    5141  upowerd        sleep                                 Pause devic… delay
zbyszek        1000 zbyszek 10036 gsd-power      handle-lid-switch                     External mo… block
zbyszek        1000 zbyszek 10035 gsd-media-keys handle-power-key:handle-suspend-key:… GNOME handl… block
zbyszek        1000 zbyszek 10035 gsd-media-keys sleep                                 GNOME handl… delay
zbyszek        1000 zbyszek 10036 gsd-power      sleep                                 GNOME needs… delay

7 inhibitors listed.
$ systemd-inhibit --no-pager|grep suspend
$ systemd-inhibit --no-pager|cat
WHO            UID  USER    PID   COMM           WHAT                WHY   MODE
ModemManager   0    root    1093  ModemManager   sleep               Mode… delay
NetworkManager 0    root    1400  NetworkManager sleep               Netw… delay
UPower         0    root    5141  upowerd        sleep               Paus… delay
zbyszek        1000 zbyszek 10036 gsd-power      handle-lid-switch   Exte… block
zbyszek        1000 zbyszek 10035 gsd-media-keys handle-power-key:h… GNOM… block
zbyszek        1000 zbyszek 10035 gsd-media-keys sleep               GNOM… delay
zbyszek        1000 zbyszek 10036 gsd-power      sleep               GNOM… delay

After:
$ build/systemd-inhibit --no-pager
(same as above)

$ build/systemd-inhibit --no-pager|grep suspend
zbyszek        1000 zbyszek 10035 gsd-media-keys handle-power-key:handle-suspend-key:handle-hibernate-key GNOME handling keypresses                                   block
$ build/systemd-inhibit --no-pager|cat
WHO            UID  USER    PID   COMM           WHAT                                                     WHY                                                         MODE
ModemManager   0    root    1093  ModemManager   sleep                                                    ModemManager needs to reset devices                         delay
NetworkManager 0    root    1400  NetworkManager sleep                                                    NetworkManager needs to turn off networks                   delay
UPower         0    root    5141  upowerd        sleep                                                    Pause device polling                                        delay
zbyszek        1000 zbyszek 10036 gsd-power      handle-lid-switch                                        External monitor attached or configuration changed recently block
zbyszek        1000 zbyszek 10035 gsd-media-keys handle-power-key:handle-suspend-key:handle-hibernate-key GNOME handling keypresses                                   block
zbyszek        1000 zbyszek 10035 gsd-media-keys sleep                                                    GNOME handling keypresses                                   delay
zbyszek        1000 zbyszek 10036 gsd-power      sleep                                                    GNOME needs to lock the screen                              delay

7 inhibitors listed.

Note that this affect all tools that use format-table.c: machinectl, busctl,
loginctl, systemd-analyze, networkctl, portablectl.
2019-11-05 17:50:09 +01:00
Yu Watanabe 95081e08d7 network: split struct Prefix into Prefix and RoutePrefix 2019-11-05 22:31:20 +09:00
Zbigniew Jędrzejewski-Szmek 08e82b84ca basic/signal-util: drop unnecessary parens 2019-11-02 11:56:03 +01:00
10 changed files with 72 additions and 44 deletions

View File

@ -208,11 +208,11 @@
<term><option>nofail</option></term> <term><option>nofail</option></term>
<listitem><para>This device will not be a hard dependency of <listitem><para>This device will not be a hard dependency of
<filename>cryptsetup.target</filename>. It'll be still pulled in and started, but the system <filename>cryptsetup.target</filename>. It'll still be pulled in and started, but the system
will not wait for the device to show up and be unlocked, and boot will not fail if this is will not wait for the device to show up and be unlocked, and boot will not fail if this is
unsuccessful. Note that other units that depend on the unlocked device may still fail. In unsuccessful. Note that other units that depend on the unlocked device may still fail. In
particular, if the device is used for a mount point, the mount point itself is also needs to particular, if the device is used for a mount point, the mount point itself also needs to
have <option>noauto</option> option, or the boot will fail if the device is not unlocked have the <option>nofail</option> option, or the boot will fail if the device is not unlocked
successfully.</para></listitem> successfully.</para></listitem>
</varlistentry> </varlistentry>

View File

@ -1348,8 +1348,9 @@
<ulink url="https://getfedora.org">Fedora</ulink> image and start a shell in it</title> <ulink url="https://getfedora.org">Fedora</ulink> image and start a shell in it</title>
<programlisting># machinectl pull-raw --verify=no \ <programlisting># machinectl pull-raw --verify=no \
https://download.fedoraproject.org/pub/fedora/linux/releases/&fedora_latest_version;/Cloud/x86_64/images/Fedora-Cloud-Base-&fedora_latest_version;-&fedora_cloud_release;.x86_64.raw.xz https://download.fedoraproject.org/pub/fedora/linux/releases/&fedora_latest_version;/Cloud/x86_64/images/Fedora-Cloud-Base-&fedora_latest_version;-&fedora_cloud_release;.x86_64.raw.xz \
# systemd-nspawn -M Fedora-Cloud-Base-&fedora_latest_version;-&fedora_cloud_release;.x86_64</programlisting> Fedora-Cloud-Base-&fedora_latest_version;-&fedora_cloud_release;.x86-64
# systemd-nspawn -M Fedora-Cloud-Base-&fedora_latest_version;-&fedora_cloud_release;.x86-64</programlisting>
<para>This downloads an image using <para>This downloads an image using
<citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry> <citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>

View File

@ -25,7 +25,7 @@ int reset_all_signal_handlers(void) {
/* On Linux the first two RT signals are reserved by /* On Linux the first two RT signals are reserved by
* glibc, and sigaction() will return EINVAL for them. */ * glibc, and sigaction() will return EINVAL for them. */
if ((sigaction(sig, &sa, NULL) < 0)) if (sigaction(sig, &sa, NULL) < 0)
if (errno != EINVAL && r >= 0) if (errno != EINVAL && r >= 0)
r = -errno; r = -errno;
} }

View File

@ -506,7 +506,10 @@ static int enumerator_scan_dir_and_add_devices(sd_device_enumerator *enumerator,
initialized = sd_device_get_is_initialized(device); initialized = sd_device_get_is_initialized(device);
if (initialized < 0) { if (initialized < 0) {
if (initialized != -ENOENT)
/* this is necessarily racey, so ignore missing devices */
r = initialized; r = initialized;
continue; continue;
} }
@ -639,6 +642,8 @@ static int enumerator_scan_devices_tag(sd_device_enumerator *enumerator, const c
k = sd_device_get_subsystem(device, &subsystem); k = sd_device_get_subsystem(device, &subsystem);
if (k < 0) { if (k < 0) {
if (k != -ENOENT)
/* this is necessarily racy, so ignore missing devices */
r = k; r = k;
continue; continue;
} }

View File

@ -145,6 +145,7 @@ static int network_resolve_stacked_netdevs(Network *network) {
} }
int network_verify(Network *network) { int network_verify(Network *network) {
RoutePrefix *route_prefix, *route_prefix_next;
RoutingPolicyRule *rule, *rule_next; RoutingPolicyRule *rule, *rule_next;
Neighbor *neighbor, *neighbor_next; Neighbor *neighbor, *neighbor_next;
AddressLabel *label, *label_next; AddressLabel *label, *label_next;
@ -304,9 +305,9 @@ int network_verify(Network *network) {
if (section_is_invalid(prefix->section)) if (section_is_invalid(prefix->section))
prefix_free(prefix); prefix_free(prefix);
LIST_FOREACH_SAFE(prefixes, prefix, prefix_next, network->static_route_prefixes) LIST_FOREACH_SAFE(route_prefixes, route_prefix, route_prefix_next, network->static_route_prefixes)
if (section_is_invalid(prefix->section)) if (section_is_invalid(route_prefix->section))
route_prefix_free(prefix); route_prefix_free(route_prefix);
LIST_FOREACH_SAFE(rules, rule, rule_next, network->rules) LIST_FOREACH_SAFE(rules, rule, rule_next, network->rules)
if (routing_policy_rule_section_verify(rule) < 0) if (routing_policy_rule_section_verify(rule) < 0)
@ -577,10 +578,11 @@ failure:
static Network *network_free(Network *network) { static Network *network_free(Network *network) {
IPv6ProxyNDPAddress *ipv6_proxy_ndp_address; IPv6ProxyNDPAddress *ipv6_proxy_ndp_address;
RoutePrefix *route_prefix;
RoutingPolicyRule *rule; RoutingPolicyRule *rule;
AddressLabel *label;
FdbEntry *fdb_entry; FdbEntry *fdb_entry;
Neighbor *neighbor; Neighbor *neighbor;
AddressLabel *label;
Address *address; Address *address;
NextHop *nexthop; NextHop *nexthop;
Prefix *prefix; Prefix *prefix;
@ -654,8 +656,8 @@ static Network *network_free(Network *network) {
while ((prefix = network->static_prefixes)) while ((prefix = network->static_prefixes))
prefix_free(prefix); prefix_free(prefix);
while ((prefix = network->static_route_prefixes)) while ((route_prefix = network->static_route_prefixes))
route_prefix_free(prefix); route_prefix_free(route_prefix);
while ((rule = network->rules)) while ((rule = network->rules))
routing_policy_rule_free(rule); routing_policy_rule_free(rule);

View File

@ -245,7 +245,7 @@ struct Network {
LIST_HEAD(Neighbor, neighbors); LIST_HEAD(Neighbor, neighbors);
LIST_HEAD(AddressLabel, address_labels); LIST_HEAD(AddressLabel, address_labels);
LIST_HEAD(Prefix, static_prefixes); LIST_HEAD(Prefix, static_prefixes);
LIST_HEAD(Prefix, static_route_prefixes); LIST_HEAD(RoutePrefix, static_route_prefixes);
LIST_HEAD(RoutingPolicyRule, rules); LIST_HEAD(RoutingPolicyRule, rules);
unsigned n_static_addresses; unsigned n_static_addresses;

View File

@ -36,7 +36,7 @@ void prefix_free(Prefix *prefix) {
free(prefix); free(prefix);
} }
int prefix_new(Prefix **ret) { static int prefix_new(Prefix **ret) {
_cleanup_(prefix_freep) Prefix *prefix = NULL; _cleanup_(prefix_freep) Prefix *prefix = NULL;
prefix = new0(Prefix, 1); prefix = new0(Prefix, 1);
@ -101,10 +101,10 @@ static int prefix_new_static(Network *network, const char *filename,
return 0; return 0;
} }
int route_prefix_new(Prefix **ret) { static int route_prefix_new(RoutePrefix **ret) {
_cleanup_(prefix_freep) Prefix *prefix = NULL; _cleanup_(route_prefix_freep) RoutePrefix *prefix = NULL;
prefix = new0(Prefix, 1); prefix = new0(RoutePrefix, 1);
if (!prefix) if (!prefix)
return -ENOMEM; return -ENOMEM;
@ -116,12 +116,12 @@ int route_prefix_new(Prefix **ret) {
return 0; return 0;
} }
void route_prefix_free(Prefix *prefix) { void route_prefix_free(RoutePrefix *prefix) {
if (!prefix) if (!prefix)
return; return;
if (prefix->network) { if (prefix->network) {
LIST_REMOVE(prefixes, prefix->network->static_route_prefixes, prefix); LIST_REMOVE(route_prefixes, prefix->network->static_route_prefixes, prefix);
assert(prefix->network->n_static_route_prefixes > 0); assert(prefix->network->n_static_route_prefixes > 0);
prefix->network->n_static_route_prefixes--; prefix->network->n_static_route_prefixes--;
@ -137,9 +137,9 @@ void route_prefix_free(Prefix *prefix) {
} }
static int route_prefix_new_static(Network *network, const char *filename, static int route_prefix_new_static(Network *network, const char *filename,
unsigned section_line, Prefix **ret) { unsigned section_line, RoutePrefix **ret) {
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL; _cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
_cleanup_(prefix_freep) Prefix *prefix = NULL; _cleanup_(route_prefix_freep) RoutePrefix *prefix = NULL;
int r; int r;
assert(network); assert(network);
@ -166,7 +166,7 @@ static int route_prefix_new_static(Network *network, const char *filename,
return r; return r;
prefix->network = network; prefix->network = network;
LIST_APPEND(prefixes, network->static_route_prefixes, prefix); LIST_APPEND(route_prefixes, network->static_route_prefixes, prefix);
network->n_static_route_prefixes++; network->n_static_route_prefixes++;
if (filename) { if (filename) {
@ -331,7 +331,7 @@ int config_parse_route_prefix(const char *unit,
void *userdata) { void *userdata) {
Network *network = userdata; Network *network = userdata;
_cleanup_(route_prefix_free_or_set_invalidp) Prefix *p = NULL; _cleanup_(route_prefix_free_or_set_invalidp) RoutePrefix *p = NULL;
uint8_t prefixlen = 64; uint8_t prefixlen = 64;
union in_addr_union in6addr; union in_addr_union in6addr;
int r; int r;
@ -373,7 +373,7 @@ int config_parse_route_prefix_lifetime(const char *unit,
void *data, void *data,
void *userdata) { void *userdata) {
Network *network = userdata; Network *network = userdata;
_cleanup_(route_prefix_free_or_set_invalidp) Prefix *p = NULL; _cleanup_(route_prefix_free_or_set_invalidp) RoutePrefix *p = NULL;
usec_t usec; usec_t usec;
int r; int r;
@ -549,8 +549,9 @@ int radv_emit_dns(Link *link) {
} }
int radv_configure(Link *link) { int radv_configure(Link *link) {
int r; RoutePrefix *q;
Prefix *p; Prefix *p;
int r;
assert(link); assert(link);
assert(link->network); assert(link->network);
@ -609,8 +610,8 @@ int radv_configure(Link *link) {
return r; return r;
} }
LIST_FOREACH(prefixes, p, link->network->static_route_prefixes) { LIST_FOREACH(route_prefixes, q, link->network->static_route_prefixes) {
r = sd_radv_add_route_prefix(link->radv, p->radv_route_prefix, false); r = sd_radv_add_route_prefix(link->radv, q->radv_route_prefix, false);
if (r == -EEXIST) if (r == -EEXIST)
continue; continue;
if (r < 0) if (r < 0)

View File

@ -11,6 +11,7 @@
#include "networkd-util.h" #include "networkd-util.h"
typedef struct Prefix Prefix; typedef struct Prefix Prefix;
typedef struct RoutePrefix RoutePrefix;
typedef enum RADVPrefixDelegation { typedef enum RADVPrefixDelegation {
RADV_PREFIX_DELEGATION_NONE, RADV_PREFIX_DELEGATION_NONE,
@ -26,21 +27,26 @@ struct Prefix {
NetworkConfigSection *section; NetworkConfigSection *section;
sd_radv_prefix *radv_prefix; sd_radv_prefix *radv_prefix;
sd_radv_route_prefix *radv_route_prefix;
LIST_FIELDS(Prefix, prefixes); LIST_FIELDS(Prefix, prefixes);
LIST_FIELDS(Prefix, route_prefixes);
}; };
int prefix_new(Prefix **ret); struct RoutePrefix {
Network *network;
NetworkConfigSection *section;
sd_radv_route_prefix *radv_route_prefix;
LIST_FIELDS(RoutePrefix, route_prefixes);
};
void prefix_free(Prefix *prefix); void prefix_free(Prefix *prefix);
DEFINE_NETWORK_SECTION_FUNCTIONS(Prefix, prefix_free); DEFINE_NETWORK_SECTION_FUNCTIONS(Prefix, prefix_free);
int route_prefix_new(Prefix **ret); void route_prefix_free(RoutePrefix *prefix);
void route_prefix_free(Prefix *prefix);
DEFINE_NETWORK_SECTION_FUNCTIONS(Prefix, route_prefix_free); DEFINE_NETWORK_SECTION_FUNCTIONS(RoutePrefix, route_prefix_free);
int radv_emit_dns(Link *link); int radv_emit_dns(Link *link);
int radv_configure(Link *link); int radv_configure(Link *link);

View File

@ -2,6 +2,7 @@
#include <ctype.h> #include <ctype.h>
#include <net/if.h> #include <net/if.h>
#include <unistd.h>
#include "alloc-util.h" #include "alloc-util.h"
#include "fd-util.h" #include "fd-util.h"
@ -1611,10 +1612,12 @@ int table_print(Table *t, FILE *f) {
} }
/* Calculate effective table width */ /* Calculate effective table width */
if (t->width == (size_t) -1) if (t->width != (size_t) -1)
table_effective_width = pager_have() ? table_requested_width : MIN(table_requested_width, columns());
else
table_effective_width = t->width; table_effective_width = t->width;
else if (pager_have() || !isatty(STDOUT_FILENO))
table_effective_width = table_requested_width;
else
table_effective_width = MIN(table_requested_width, columns());
if (table_maximum_width != (size_t) -1 && table_effective_width > table_maximum_width) if (table_maximum_width != (size_t) -1 && table_effective_width > table_maximum_width)
table_effective_width = table_maximum_width; table_effective_width = table_maximum_width;

View File

@ -1,5 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1+ */ /* SPDX-License-Identifier: LGPL-2.1+ */
#include <unistd.h>
#include "alloc-util.h" #include "alloc-util.h"
#include "format-table.h" #include "format-table.h"
#include "string-util.h" #include "string-util.h"
@ -154,12 +156,20 @@ int main(int argc, char *argv[]) {
assert_se(table_format(t, &formatted) >= 0); assert_se(table_format(t, &formatted) >= 0);
printf("%s\n", formatted); printf("%s\n", formatted);
if (isatty(STDOUT_FILENO))
assert_se(streq(formatted, assert_se(streq(formatted,
" no a long f… no a long f… a long fi…\n" " no a long f… no a long f… a long fi…\n"
" no fäää no fäää fäää \n" " no fäää no fäää fäää \n"
" yes fäää yes fäää fäää \n" " yes fäää yes fäää fäää \n"
" yes xxx yes xxx xxx \n" " yes xxx yes xxx xxx \n"
"5min 5min \n")); "5min 5min \n"));
else
assert_se(streq(formatted,
" no a long field no a long field a long field\n"
" no fäää no fäää fäää \n"
" yes fäää yes fäää fäää \n"
" yes xxx yes xxx xxx \n"
"5min 5min \n"));
test_issue_9549(); test_issue_9549();