Compare commits

..

20 Commits

Author SHA1 Message Date
Yu Watanabe e06d7d0fb0 po: update Japanese translation 2020-02-02 20:48:17 +01:00
Piotr Drąg 10f58ad015 po: update Polish translation 2020-02-02 20:46:57 +01:00
Lennart Poettering 9a4940bf92 update NEWS 2020-02-02 18:17:24 +01:00
Lennart Poettering d58f31793a
Merge pull request #14645 from keszybz/sd-bus-message-dump
sd_bus_message_dump
2020-02-02 17:27:50 +01:00
Lennart Poettering ddb10d8ccd
Merge pull request #14699 from yuwata/dhcp6-fix-t1-t2
dhcp6: do not use T1 and T2 longer than one provided by the lease
2020-02-02 17:16:31 +01:00
Yu Watanabe 60d0a5098b util: uid_t, gid_t, and pid_t must be 32bit
We already have assert_cc(sizeof(uid_t) == sizeof(uint32_t)) or friends
at various places.
2020-02-02 17:13:08 +01:00
Yu Watanabe c757517d98 meson: fix feature list 2020-02-02 17:09:28 +01:00
Lennart Poettering a754993d9c
Merge pull request #14719 from yuwata/sd-boot-fix-warnings
sd-boot: fix warnings
2020-02-02 16:57:17 +01:00
David Michael 649916d356 sysusers: support creating users with a specific primary group
This extends the "uid:gid" syntax for "u" lines so that a group
name can be given instead of a GID.  This requires that the group
is either queued for creation by sysusers, or it is already defined
on the system.

Closes #14340
2020-02-02 16:53:22 +01:00
Yu Watanabe 4e3132d6d6
Merge pull request #14672 from yuwata/network-routing-policy-uidrange
network: support UID based routing policy
2020-02-02 22:46:04 +09:00
Yu Watanabe 6be8e78e32 test-network: add test for UID based routing policy 2020-02-02 22:43:38 +09:00
Yu Watanabe ea471a4695 network: support UID based routing policy
Closes #14666.
2020-02-02 22:43:38 +09:00
Yu Watanabe 03de302a31 util: add parse_uid_range() helper function 2020-02-02 22:43:38 +09:00
Yu Watanabe efda8aebcb sd-boot: fix -Wpointer-sign warning 2020-01-31 19:59:34 +09:00
Yu Watanabe a614aa1985 sd-boot: fix warning about comparison is always true 2020-01-31 19:20:34 +09:00
Yu Watanabe 3ae01632f2 dhcp6: coding style fixes 2020-01-31 14:44:40 +09:00
Yu Watanabe 9de8a4259e dhcp6: do not use T1 and T2 longer than one provided by the lease
Fixes #12623.
2020-01-31 14:44:32 +09:00
Zbigniew Jędrzejewski-Szmek f770b7e084 man: document man/sd_bus_message_dump.xml 2020-01-30 14:33:05 +01:00
Zbigniew Jędrzejewski-Szmek 2b4a65b668 sd-bus: export sd_bus_message_dump
Fixes #14640.
2020-01-23 23:38:20 +01:00
Zbigniew Jędrzejewski-Szmek 27cf4c18c7 sd-bus: make dump flags public 2020-01-23 23:38:20 +01:00
47 changed files with 624 additions and 124 deletions

50
NEWS
View File

@ -49,6 +49,45 @@ CHANGES WITH 245 in spe:
https://systemd.io/GROUP_RECORD
https://systemd.io/USER_GROUP_API
* A small new service systemd-homed.service has been added, that may be
used to securely manage home directories, with built-in encryption
and unifying the user's own home directory data together with
complete user record data in a single place, thus making home
directories naturally migratable. Its primary back-end is based on
LUKS volumes, but it also supports fscrypt, plain directories and
more. It solves a couple of problems we saw with traditional ways to
manage home directories, in particular when it comes to
encryption. For further discussion of this, see the video of
Lennart's talk at AllSystemsGo! 2019:
https://media.ccc.de/v/ASG2019-164-reinventing-home-directories
For further details about the format and expectations on home
directories this new daemon makes, see:
https://systemd.io/HOME_DIRECTORY
* systemd-journald is now multi-instantiable. In addition to the main
instance systemd-journald.service there's now a template unit
systemd-journald@.service that can be instantiated multiple times,
each time defining a new named log 'namespace' (whose name is
specified via the instance part of the instance unit name). A new
unit file setting LogNamespace= has been added, taking such a
namespace name, that allows assigning services to such log
namespaces. As each log namespace is serviced by its own, independent
journal daemon this functionality may be use to improve performance
and increase isolation of applications, at the price of losing global
message ordering. Each daemon may have a separate set of
configuration files, with possibly different disk space settings and
such. journalctl has been updated to take a new option --namespace=
which allows viewing logs from a specific log namespace. The
sd-journal.h API gained sd_journal_open_namespace() for opening the
log stream of a specific log namespace. systemd-journald also gained
the ability to exit on idle, which is useful in the context of log
namespaces, as this means log daemons for log namespaces can be
activated automatically on demand and stop automatically when no
longer used, minimizing resource usage.
* When systemd-tmpfiles copies a file tree using the 'C' line type it
will now implicitly label every copied file matching the SELinux
database.
@ -112,6 +151,10 @@ CHANGES WITH 245 in spe:
support for a special new value "dhcp". If set the configured static
route uses the gateway host configured via DHCP.
* A new User= setting has been implemented for the [RoutingPolicyRule]
section of .network files for configuring source routing based on UID
ranges.
* sd-bus gained a new API call sd_bus_message_sensitive() for marking a
D-Bus message object as "sensitive". Objects that are marked that way
are erased from memory when they are freed. This concept is intended
@ -121,6 +164,13 @@ CHANGES WITH 245 in spe:
vtables like this, so that this new message flag is implicitly set
for incoming and outgoing messages of specific methods.
* sd-bus gained a new API call sd_bus_message_dump() for dumping the
contents of a message (or parts thereof) onto standard output, for
debugging purposes.
* systemd-sysusers gained support for creating users with primary
groups named differently than the user itself.
* systemd-resolved's DNS-over-TLS support gained SNI validation.
* systemd-growfs (i.e. the x-systemd.growfs mount option in /etc/fstab)

View File

@ -233,6 +233,7 @@ manpages = [
''],
['sd_bus_message_append_strv', '3', [], ''],
['sd_bus_message_copy', '3', [], ''],
['sd_bus_message_dump', '3', [], ''],
['sd_bus_message_get_cookie', '3', ['sd_bus_message_get_reply_cookie'], ''],
['sd_bus_message_get_monotonic_usec',
'3',

View File

@ -58,6 +58,7 @@
<citerefentry><refentrytitle>sd_bus_message_append_string_memfd</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append_strv</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_copy</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_dump</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_cookie</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_monotonic_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_signature</refentrytitle><manvolnum>3</manvolnum></citerefentry>,

107
man/sd_bus_message_dump.xml Normal file
View File

@ -0,0 +1,107 @@
<?xml version='1.0'?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!-- SPDX-License-Identifier: LGPL-2.1+ -->
<refentry id="sd_bus_message_dump"
xmlns:xi="http://www.w3.org/2001/XInclude">
<refentryinfo>
<title>sd_bus_message_dump</title>
<productname>systemd</productname>
</refentryinfo>
<refmeta>
<refentrytitle>sd_bus_message_dump</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_bus_message_dump</refname>
<refpurpose>Produce a string representation of a message for debugging purposes</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int sd_bus_message_dump</funcdef>
<paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
<paramdef>FILE *<parameter>f</parameter></paramdef>
<paramdef>uint64_t <parameter>flags</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<constant>SD_BUS_MESSAGE_DUMP_WITH_HEADER</constant>,
<constant>SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY</constant>
</para>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>The <function>sd_bus_message_dump()</function> function writes a textual representation of the
message <parameter>m</parameter> to the stream <parameter>f</parameter>. This function is intended to be
used for debugging purposes, and the output is neither stable nor designed to be machine readable.
</para>
<para>The <parameter>flags</parameter> parameter may be used to modify the output. With
<constant>SD_BUS_MESSAGE_DUMP_WITH_HEADER</constant>, a header that specifies the message type and flags
and some additional metadata is printed. When <constant>SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY</constant> is
not passed, the contents of the whole message are printed. When it <emphasis>is</emphasis> passed,
only the current container in printed.</para>
<para>Note that this function moves the read pointer of the message. It may be necessary to reset the
position afterwards, for example with
<citerefentry><refentrytitle>sd_bus_message_rewind</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
</para>
</refsect1>
<refsect1>
<title>Examples</title>
<para>Output for a signal message (with <constant>SD_BUS_MESSAGE_DUMP_WITH_HEADER</constant>):
<programlisting>
‣ Type=signal Endian=l Flags=1 Version=1 Priority=0 Cookie=22
Path=/value/a Interface=org.freedesktop.DBus.Properties Member=PropertiesChanged
MESSAGE "sa{sv}as" {
STRING "org.freedesktop.systemd.ValueTest";
ARRAY "{sv}" {
DICT_ENTRY "sv" {
STRING "Value";
VARIANT "s" {
STRING "object 0x1e, path /value/a";
};
};
};
ARRAY "s" {
STRING "Value2";
STRING "AnExplicitProperty";
};
};
</programlisting>
</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>On success, this function returns 0 or a positive integer. On failure, it returns a negative
errno-style error code. No error codes are currently defined.</para>
</refsect1>
<xi:include href="libsystemd-pkgconfig.xml" />
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@ -1084,6 +1084,13 @@
<literal>ipv4</literal>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>User=</varname></term>
<listitem>
<para>Takes a username, a user ID, or a range of user IDs separated by a dash. Defaults to
unset.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

View File

@ -101,8 +101,8 @@ u root 0 "Superuser" /root /bin/zsh</pro
<term><varname>u</varname></term>
<listitem><para>Create a system user and group of the specified name should
they not exist yet. The user's primary group will be set to the group
bearing the same name. The account will be created disabled, so that logins
are not allowed.</para></listitem>
bearing the same name unless the ID field specifies it. The account will be
created disabled, so that logins are not allowed.</para></listitem>
</varlistentry>
<varlistentry>
@ -166,9 +166,10 @@ u root 0 "Superuser" /root /bin/zsh</pro
path's owner/group. This is useful to create users whose UID/GID
match the owners of pre-existing files (such as SUID or SGID
binaries).
The syntax <literal><replaceable>uid</replaceable>:<replaceable>gid</replaceable></literal> is also supported to
allow creating user and group pairs with different numeric UID and GID values. The group with the indicated GID must get created explicitly before or it must already exist. Specifying <literal>-</literal> for the UID in this syntax
is also supported.
The syntaxes <literal><replaceable>uid</replaceable>:<replaceable>gid</replaceable></literal> and
<literal><replaceable>uid</replaceable>:<replaceable>groupname</replaceable></literal> are supported to
allow creating users with specific primary groups. The given group must be created explicitly, or it
must already exist. Specifying <literal>-</literal> for the UID in these syntaxes is also supported.
</para>
<para>For <varname>m</varname> lines, this field should contain

View File

@ -449,9 +449,6 @@ conf.set('_GNU_SOURCE', true)
conf.set('__SANE_USERSPACE_TYPES__', true)
conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)
conf.set('SIZEOF_PID_T', cc.sizeof('pid_t', prefix : '#include <sys/types.h>'))
conf.set('SIZEOF_UID_T', cc.sizeof('uid_t', prefix : '#include <sys/types.h>'))
conf.set('SIZEOF_GID_T', cc.sizeof('gid_t', prefix : '#include <sys/types.h>'))
conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
@ -3385,7 +3382,7 @@ foreach tuple : [
['libcryptsetup'],
['PAM'],
['pwquality'],
['fdisk'],
['libfdisk'],
['p11kit'],
['AUDIT'],
['IMA'],

View File

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: systemd\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-09-21 20:13+0900\n"
"POT-Creation-Date: 2020-02-02 23:20+0900\n"
"PO-Revision-Date: 2018-10-27 07:41+0900\n"
"Last-Translator: Yu Watanabe <watanabe.yu+github@gmail.com>\n"
"Language-Team: \n"
@ -60,6 +60,55 @@ msgstr "systemdの状態の再読込"
msgid "Authentication is required to reload the systemd state."
msgstr "systemdの状態を再読込するには認証が必要です。"
#: src/home/org.freedesktop.home1.policy:13
msgid "Create a home"
msgstr "ホームディレクトリの作成"
#: src/home/org.freedesktop.home1.policy:14
msgid "Authentication is required for creating a user's home."
msgstr "ユーザのホームディレクトリを作成するには認証が必要です。"
#: src/home/org.freedesktop.home1.policy:23
msgid "Remove a home"
msgstr "ホームディレクトリの削除"
#: src/home/org.freedesktop.home1.policy:24
msgid "Authentication is required for removing a user's home."
msgstr "ユーザのホームディレクトリの削除には認証が必要です。"
#: src/home/org.freedesktop.home1.policy:33
msgid "Check credentials of a home"
msgstr "ホームディレクトリの認証情報の確認"
#: src/home/org.freedesktop.home1.policy:34
msgid ""
"Authentication is required for checking credentials against a user's home."
msgstr "ユーザのホームディレクトリに対する認証情報の確認には認証が必要です。"
#: src/home/org.freedesktop.home1.policy:43
msgid "Update a home"
msgstr "ホームディレクトリの更新"
#: src/home/org.freedesktop.home1.policy:44
msgid "Authentication is required for updating a user's home."
msgstr "ユーザのホームディレクトリの更新には認証が必要です。"
#: src/home/org.freedesktop.home1.policy:53
msgid "Resize a home"
msgstr "ホームディレクトリのサイズ変更"
#: src/home/org.freedesktop.home1.policy:54
msgid "Authentication is required for resizing a user's home."
msgstr "ユーザのホームディレクトリのサイズ変更には認証が必要です。"
#: src/home/org.freedesktop.home1.policy:63
msgid "Change password of a home"
msgstr "ホームディレクトリのパスワード変更"
#: src/home/org.freedesktop.home1.policy:64
msgid "Authentication is required for changing the password of a user's home."
msgstr "ユーザのホームディレクトリのパスワードを変更するには認証が必要です。"
#: src/hostname/org.freedesktop.hostname1.policy:20
msgid "Set host name"
msgstr "ホスト名の設定"
@ -481,6 +530,14 @@ msgstr "全ユーザへのメッセージの設定"
msgid "Authentication is required to set a wall message"
msgstr "全ユーザへのメッセージを設定するには認証が必要です。"
#: src/login/org.freedesktop.login1.policy:395
msgid "Change Session"
msgstr "セッションの変更"
#: src/login/org.freedesktop.login1.policy:396
msgid "Authentication is required to change the virtual terminal."
msgstr "仮想ターミナルを変更するには認証が必要です。"
#: src/machine/org.freedesktop.machine1.policy:22
msgid "Log into a local container"
msgstr "ローカルなコンテナへログイン"
@ -653,6 +710,30 @@ msgstr "DNSの設定を破棄"
msgid "Authentication is required to reset DNS settings."
msgstr "DNSの設定を破棄するには認証が必要です。"
#: src/network/org.freedesktop.network1.policy:143
msgid "Renew dynamic addresses"
msgstr "動的アドレスの更新"
#: src/network/org.freedesktop.network1.policy:144
msgid "Authentication is required to renew dynamic addresses."
msgstr "動的アドレスの更新には認証が必要です。"
#: src/network/org.freedesktop.network1.policy:154
msgid "Reload network settings"
msgstr "ネットワークの設定の再読み込み"
#: src/network/org.freedesktop.network1.policy:155
msgid "Authentication is required to reload network settings."
msgstr "ネットワークの設定を再読み込みするには認証が必要です。"
#: src/network/org.freedesktop.network1.policy:165
msgid "Reconfigure network interface"
msgstr "ネットワークインターフェイスの再設定"
#: src/network/org.freedesktop.network1.policy:166
msgid "Authentication is required to reconfigure network interface."
msgstr "ネットワークインターフェイスの再設定には認証が必要です。"
#: src/portable/org.freedesktop.portable1.policy:13
msgid "Inspect a portable service image"
msgstr "ポータブルサービスイメージの読み込み"
@ -741,37 +822,37 @@ msgid ""
"shall be enabled."
msgstr "ネットワーク経由の時刻同期を有効もしくは無効にするには認証が必要です。"
#: src/core/dbus-unit.c:354
#: src/core/dbus-unit.c:355
msgid "Authentication is required to start '$(unit)'."
msgstr "'$(unit)'を開始するには認証が必要です。"
#: src/core/dbus-unit.c:355
#: src/core/dbus-unit.c:356
msgid "Authentication is required to stop '$(unit)'."
msgstr "'$(unit)'を停止するには認証が必要です。"
#: src/core/dbus-unit.c:356
#: src/core/dbus-unit.c:357
msgid "Authentication is required to reload '$(unit)'."
msgstr "'$(unit)'を再読込するには認証が必要です。"
#: src/core/dbus-unit.c:357 src/core/dbus-unit.c:358
#: src/core/dbus-unit.c:358 src/core/dbus-unit.c:359
msgid "Authentication is required to restart '$(unit)'."
msgstr "'$(unit)'を再起動するには認証が必要です。"
#: src/core/dbus-unit.c:530
#: src/core/dbus-unit.c:531
msgid ""
"Authentication is required to send a UNIX signal to the processes of "
"'$(unit)'."
msgstr "'$(unit)'のプロセスにUNIXシグナルを送るには認証が必要です。"
#: src/core/dbus-unit.c:561
#: src/core/dbus-unit.c:562
msgid "Authentication is required to reset the \"failed\" state of '$(unit)'."
msgstr "'$(unit)'の「失敗」状態をリセットするには認証が必要です。"
#: src/core/dbus-unit.c:594
#: src/core/dbus-unit.c:595
msgid "Authentication is required to set properties on '$(unit)'."
msgstr "'$(unit)'のプロパティを設定するには認証が必要です。"
#: src/core/dbus-unit.c:703
#: src/core/dbus-unit.c:704
msgid ""
"Authentication is required to delete files and directories associated with "
"'$(unit)'."

View File

@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: systemd\n"
"Report-Msgid-Bugs-To: https://github.com/systemd/systemd/issues\n"
"POT-Creation-Date: 2020-01-29 16:25+0000\n"
"PO-Revision-Date: 2020-01-29 17:28+0100\n"
"POT-Creation-Date: 2020-01-30 15:31+0000\n"
"PO-Revision-Date: 2020-02-02 13:20+0100\n"
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
"Language-Team: Polish <trans-pl@lists.fedoraproject.org>\n"
"Language: pl\n"
@ -69,6 +69,63 @@ msgstr "Ponowne wczytanie stanu systemd"
msgid "Authentication is required to reload the systemd state."
msgstr "Wymagane jest uwierzytelnienie, aby ponownie wczytać stan systemd."
#: src/home/org.freedesktop.home1.policy:13
msgid "Create a home"
msgstr "Utworzenie katalogu domowego"
#: src/home/org.freedesktop.home1.policy:14
msgid "Authentication is required for creating a user's home."
msgstr ""
"Wymagane jest uwierzytelnienie, aby utworzyć katalog domowy użytkownika."
#: src/home/org.freedesktop.home1.policy:23
msgid "Remove a home"
msgstr "Usunięcie katalogu domowego"
#: src/home/org.freedesktop.home1.policy:24
msgid "Authentication is required for removing a user's home."
msgstr "Wymagane jest uwierzytelnienie, aby usunąć katalog domowy użytkownika."
#: src/home/org.freedesktop.home1.policy:33
msgid "Check credentials of a home"
msgstr "Sprawdzenie danych uwierzytelniających katalogu domowego"
#: src/home/org.freedesktop.home1.policy:34
msgid ""
"Authentication is required for checking credentials against a user's home."
msgstr ""
"Wymagane jest uwierzytelnienie, aby sprawdzić dane uwierzytelniające "
"katalogu domowego użytkownika."
#: src/home/org.freedesktop.home1.policy:43
msgid "Update a home"
msgstr "Aktualizacja katalogu domowego"
#: src/home/org.freedesktop.home1.policy:44
msgid "Authentication is required for updating a user's home."
msgstr ""
"Wymagane jest uwierzytelnienie, aby zaktualizować katalog domowy użytkownika."
#: src/home/org.freedesktop.home1.policy:53
msgid "Resize a home"
msgstr "Zmiana rozmiaru katalogu domowego"
#: src/home/org.freedesktop.home1.policy:54
msgid "Authentication is required for resizing a user's home."
msgstr ""
"Wymagane jest uwierzytelnienie, aby zmienić rozmiar katalogu domowego "
"użytkownika."
#: src/home/org.freedesktop.home1.policy:63
msgid "Change password of a home"
msgstr "Zmiana hasła katalogu domowego"
#: src/home/org.freedesktop.home1.policy:64
msgid "Authentication is required for changing the password of a user's home."
msgstr ""
"Wymagane jest uwierzytelnienie, aby zmienić hasło katalogu domowego "
"użytkownika."
#: src/hostname/org.freedesktop.hostname1.policy:20
msgid "Set host name"
msgstr "Ustawienie nazwy komputera"

View File

@ -5,30 +5,17 @@
#include <net/if.h>
#include <stdbool.h>
#if SIZEOF_PID_T == 4
#include "macro.h"
assert_cc(sizeof(pid_t) == sizeof(int32_t));
#define PID_PRI PRIi32
#elif SIZEOF_PID_T == 2
# define PID_PRI PRIi16
#else
# error Unknown pid_t size
#endif
#define PID_FMT "%" PID_PRI
#if SIZEOF_UID_T == 4
assert_cc(sizeof(uid_t) == sizeof(uint32_t));
#define UID_FMT "%" PRIu32
#elif SIZEOF_UID_T == 2
# define UID_FMT "%" PRIu16
#else
# error Unknown uid_t size
#endif
#if SIZEOF_GID_T == 4
assert_cc(sizeof(gid_t) == sizeof(uint32_t));
#define GID_FMT "%" PRIu32
#elif SIZEOF_GID_T == 2
# define GID_FMT "%" PRIu16
#else
# error Unknown gid_t size
#endif
#if SIZEOF_TIME_T == 8
# define PRI_TIME PRIi64

View File

@ -172,7 +172,6 @@ int fork_agent(const char *name, const int except[], size_t n_except, pid_t *pid
int set_oom_score_adjust(int value);
#if SIZEOF_PID_T == 4
/* The highest possibly (theoretic) pid_t value on this architecture. */
#define PID_T_MAX ((pid_t) INT32_MAX)
/* The maximum number of concurrent processes Linux allows on this architecture, as well as the highest valid PID value
@ -182,12 +181,6 @@ int set_oom_score_adjust(int value);
* these values are documented in proc(5) we feel quite confident that they are stable enough for the near future at
* least to define them here too. */
#define TASKS_MAX 4194303U
#elif SIZEOF_PID_T == 2
#define PID_T_MAX ((pid_t) INT16_MAX)
#define TASKS_MAX 32767U
#else
#error "Unknown pid_t size"
#endif
assert_cc(TASKS_MAX <= (unsigned long) PID_T_MAX);

View File

@ -62,6 +62,29 @@ int parse_uid(const char *s, uid_t *ret) {
return 0;
}
int parse_uid_range(const char *s, uid_t *ret_lower, uid_t *ret_upper) {
uint32_t u, l;
int r;
assert(s);
assert(ret_lower);
assert(ret_upper);
r = parse_range(s, &l, &u);
if (r < 0)
return r;
if (l > u)
return -EINVAL;
if (!uid_is_valid(l) || !uid_is_valid(u))
return -ENXIO;
*ret_lower = l;
*ret_upper = u;
return 0;
}
char* getlogname_malloc(void) {
uid_t uid;
struct stat st;

View File

@ -19,6 +19,7 @@ static inline bool gid_is_valid(gid_t gid) {
}
int parse_uid(const char *s, uid_t* ret_uid);
int parse_uid_range(const char *s, uid_t *ret_lower, uid_t *ret_upper);
static inline int parse_gid(const char *s, gid_t *ret_gid) {
return parse_uid(s, (uid_t*) ret_gid);

View File

@ -1893,8 +1893,8 @@ static VOID config_entry_add_linux(
UINTN bufsize = sizeof buf;
EFI_FILE_INFO *f;
CHAR8 *sections[] = {
(UINT8 *)".osrel",
(UINT8 *)".cmdline",
(CHAR8 *)".osrel",
(CHAR8 *)".cmdline",
NULL
};
UINTN offs[ELEMENTSOF(sections)-1] = {};

View File

@ -22,10 +22,10 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
UINTN size;
BOOLEAN secure = FALSE;
CHAR8 *sections[] = {
(UINT8 *)".cmdline",
(UINT8 *)".linux",
(UINT8 *)".initrd",
(UINT8 *)".splash",
(CHAR8 *)".cmdline",
(CHAR8 *)".linux",
(CHAR8 *)".initrd",
(CHAR8 *)".splash",
NULL
};
UINTN addrs[ELEMENTSOF(sections)-1] = {};

View File

@ -189,7 +189,7 @@ static INTN utf8_to_16(CHAR8 *stra, CHAR16 *c) {
UINTN len;
UINTN i;
if (stra[0] < 0x80)
if (!(stra[0] & 0x80))
len = 1;
else if ((stra[0] & 0xe0) == 0xc0)
len = 2;

View File

@ -1158,7 +1158,7 @@ static int introspect(int argc, char **argv, void *userdata) {
}
static int message_dump(sd_bus_message *m, FILE *f) {
return bus_message_dump(m, f, BUS_MESSAGE_DUMP_WITH_HEADER);
return sd_bus_message_dump(m, f, SD_BUS_MESSAGE_DUMP_WITH_HEADER);
}
static int message_pcap(sd_bus_message *m, FILE *f) {
@ -2052,7 +2052,7 @@ static int call(int argc, char **argv, void *userdata) {
} else if (arg_verbose) {
(void) pager_open(arg_pager_flags);
r = bus_message_dump(reply, stdout, 0);
r = sd_bus_message_dump(reply, stdout, 0);
if (r < 0)
return r;
} else {
@ -2158,7 +2158,7 @@ static int get_property(int argc, char **argv, void *userdata) {
} else if (arg_verbose) {
(void) pager_open(arg_pager_flags);
r = bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_SUBTREE_ONLY);
r = sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY);
if (r < 0)
return r;
} else {

View File

@ -1663,7 +1663,7 @@ static int method_lookup_dynamic_user_by_uid(sd_bus_message *message, void *user
assert(message);
assert(m);
assert_cc(sizeof(uid) == sizeof(uint32_t));
assert_cc(sizeof(uid_t) == sizeof(uint32_t));
r = sd_bus_message_read_basic(message, 'u', &uid);
if (r < 0)
return r;

View File

@ -36,7 +36,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (getenv_bool("SYSTEMD_FUZZ_OUTPUT") <= 0)
assert_se(g = open_memstream_unlocked(&out, &out_size));
bus_message_dump(m, g ?: stdout, BUS_MESSAGE_DUMP_WITH_HEADER);
sd_bus_message_dump(m, g ?: stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER);
r = sd_bus_message_rewind(m, true);
assert_se(r >= 0);

View File

@ -675,8 +675,7 @@ static int client_timeout_resend_expire(sd_event_source *s, uint64_t usec, void
}
static usec_t client_timeout_compute_random(usec_t val) {
return val - val / 10 +
(random_u32() % (2 * USEC_PER_SEC)) * val / 10 / USEC_PER_SEC;
return val - (random_u32() % USEC_PER_SEC) * val / 10 / USEC_PER_SEC;
}
static int client_timeout_resend(sd_event_source *s, uint64_t usec, void *userdata) {
@ -686,7 +685,6 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, void *userda
usec_t max_retransmit_duration = 0;
uint8_t max_retransmit_count = 0;
char time_string[FORMAT_TIMESPAN_MAX];
uint32_t expire = 0;
assert(s);
assert(client);
@ -735,8 +733,9 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, void *userda
max_retransmit_time = DHCP6_REB_MAX_RT;
if (event_source_is_enabled(client->timeout_resend_expire) <= 0) {
r = dhcp6_lease_ia_rebind_expire(&client->lease->ia,
&expire);
uint32_t expire = 0;
r = dhcp6_lease_ia_rebind_expire(&client->lease->ia, &expire);
if (r < 0) {
client_stop(client, r);
return 0;
@ -751,7 +750,7 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, void *userda
return 0;
}
if (max_retransmit_count &&
if (max_retransmit_count > 0 &&
client->retransmit_count >= max_retransmit_count) {
client_stop(client, SD_DHCP6_CLIENT_EVENT_RETRANS_MAX);
return 0;
@ -765,7 +764,7 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, void *userda
if (r >= 0)
client->retransmit_count++;
if (!client->retransmit_time) {
if (client->retransmit_time == 0) {
client->retransmit_time =
client_timeout_compute_random(init_retransmit_time);
@ -773,7 +772,7 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, void *userda
client->retransmit_time += init_retransmit_time / 10;
} else {
if (max_retransmit_time &&
if (max_retransmit_time > 0 &&
client->retransmit_time > max_retransmit_time / 2)
client->retransmit_time = client_timeout_compute_random(max_retransmit_time);
else
@ -791,7 +790,7 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, void *userda
if (r < 0)
goto error;
if (max_retransmit_duration && event_source_is_enabled(client->timeout_resend_expire) <= 0) {
if (max_retransmit_duration > 0 && event_source_is_enabled(client->timeout_resend_expire) <= 0) {
log_dhcp6_client(client, "Max retransmission duration %"PRIu64" secs",
max_retransmit_duration / USEC_PER_SEC);

View File

@ -685,6 +685,7 @@ global:
LIBSYSTEMD_245 {
global:
sd_bus_message_dump;
sd_bus_message_sensitive;
sd_event_add_child_pidfd;
sd_event_source_get_child_pidfd;

View File

@ -18,23 +18,23 @@
#include "terminal-util.h"
#include "util.h"
static char *indent(unsigned level, unsigned flags) {
static char *indent(unsigned level, uint64_t flags) {
char *p;
unsigned n, i = 0;
n = 0;
if (flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY && level > 0)
if (flags & SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY && level > 0)
level -= 1;
if (flags & BUS_MESSAGE_DUMP_WITH_HEADER)
if (flags & SD_BUS_MESSAGE_DUMP_WITH_HEADER)
n += 2;
p = new(char, n + level*8 + 1);
if (!p)
return NULL;
if (flags & BUS_MESSAGE_DUMP_WITH_HEADER) {
if (flags & SD_BUS_MESSAGE_DUMP_WITH_HEADER) {
p[i++] = ' ';
p[i++] = ' ';
}
@ -45,7 +45,7 @@ static char *indent(unsigned level, unsigned flags) {
return p;
}
int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
_public_ int sd_bus_message_dump(sd_bus_message *m, FILE *f, uint64_t flags) {
unsigned level = 1;
int r;
@ -54,7 +54,7 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
if (!f)
f = stdout;
if (flags & BUS_MESSAGE_DUMP_WITH_HEADER) {
if (flags & SD_BUS_MESSAGE_DUMP_WITH_HEADER) {
fprintf(f,
"%s%s%s Type=%s%s%s Endian=%c Flags=%u Version=%u Priority=%"PRIi64,
m->header->type == SD_BUS_MESSAGE_METHOD_ERROR ? ansi_highlight_red() :
@ -118,11 +118,11 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
bus_creds_dump(&m->creds, f, true);
}
r = sd_bus_message_rewind(m, !(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY));
r = sd_bus_message_rewind(m, !(flags & SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY));
if (r < 0)
return log_error_errno(r, "Failed to rewind: %m");
if (!(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY)) {
if (!(flags & SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY)) {
_cleanup_free_ char *prefix = NULL;
prefix = indent(0, flags);
@ -259,7 +259,7 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
}
}
if (!(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY)) {
if (!(flags & SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY)) {
_cleanup_free_ char *prefix = NULL;
prefix = indent(0, flags);

View File

@ -6,13 +6,6 @@
#include "sd-bus.h"
enum {
BUS_MESSAGE_DUMP_WITH_HEADER = 1 << 0,
BUS_MESSAGE_DUMP_SUBTREE_ONLY = 1 << 1,
};
int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags);
int bus_creds_dump(sd_bus_creds *c, FILE *f, bool terse);
int bus_pcap_header(size_t snaplen, FILE *f);

View File

@ -145,7 +145,7 @@ static int server(sd_bus *bus) {
strna(sd_bus_message_get_member(m)),
pid,
strna(label));
/* bus_message_dump(m); */
/* sd_bus_message_dump(m); */
/* sd_bus_message_rewind(m, true); */
if (sd_bus_message_is_method_call(m, "org.freedesktop.systemd.test", "LowerCase")) {

View File

@ -175,7 +175,7 @@ static int test_marshal(void) {
}
#endif
assert_se(bus_message_dump(m, NULL, BUS_MESSAGE_DUMP_WITH_HEADER) >= 0);
assert_se(sd_bus_message_dump(m, NULL, SD_BUS_MESSAGE_DUMP_WITH_HEADER) >= 0);
assert_se(bus_message_get_blob(m, &blob, &sz) >= 0);
@ -196,7 +196,7 @@ static int test_marshal(void) {
assert_se(bus_message_from_malloc(bus, blob, sz, NULL, 0, NULL, &n) >= 0);
blob = NULL;
assert_se(bus_message_dump(n, NULL, BUS_MESSAGE_DUMP_WITH_HEADER) >= 0);
assert_se(sd_bus_message_dump(n, NULL, SD_BUS_MESSAGE_DUMP_WITH_HEADER) >= 0);
m = sd_bus_message_unref(m);
@ -205,7 +205,7 @@ static int test_marshal(void) {
assert_se(sd_bus_message_append(m, "as", 0) >= 0);
assert_se(sd_bus_message_seal(m, 4712, 0) >= 0);
assert_se(bus_message_dump(m, NULL, BUS_MESSAGE_DUMP_WITH_HEADER) >= 0);
assert_se(sd_bus_message_dump(m, NULL, SD_BUS_MESSAGE_DUMP_WITH_HEADER) >= 0);
return EXIT_SUCCESS;
}

View File

@ -188,10 +188,10 @@ int main(int argc, char *argv[]) {
r = sd_bus_message_seal(m, 4711, 0);
assert_se(r >= 0);
bus_message_dump(m, stdout, BUS_MESSAGE_DUMP_WITH_HEADER);
sd_bus_message_dump(m, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER);
ms = open_memstream_unlocked(&first, &first_size);
bus_message_dump(m, ms, 0);
sd_bus_message_dump(m, ms, 0);
fflush(ms);
assert_se(!ferror(ms));
@ -244,11 +244,11 @@ int main(int argc, char *argv[]) {
r = bus_message_from_malloc(bus, buffer, sz, NULL, 0, NULL, &m);
assert_se(r >= 0);
bus_message_dump(m, stdout, BUS_MESSAGE_DUMP_WITH_HEADER);
sd_bus_message_dump(m, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER);
fclose(ms);
ms = open_memstream_unlocked(&second, &second_size);
bus_message_dump(m, ms, 0);
sd_bus_message_dump(m, ms, 0);
fflush(ms);
assert_se(!ferror(ms));
assert_se(first_size == second_size);
@ -354,7 +354,7 @@ int main(int argc, char *argv[]) {
fclose(ms);
ms = open_memstream_unlocked(&third, &third_size);
bus_message_dump(copy, ms, 0);
sd_bus_message_dump(copy, ms, 0);
fflush(ms);
assert_se(!ferror(ms));

View File

@ -399,7 +399,7 @@ static int client(struct context *c) {
r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.DBus.Properties", "GetAll", &error, &reply, "s", "");
assert_se(r >= 0);
bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_WITH_HEADER);
sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER);
sd_bus_message_unref(reply);
reply = NULL;
@ -417,7 +417,7 @@ static int client(struct context *c) {
r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/value", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects", &error, &reply, "");
assert_se(r >= 0);
bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_WITH_HEADER);
sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER);
sd_bus_message_unref(reply);
reply = NULL;
@ -429,7 +429,7 @@ static int client(struct context *c) {
assert_se(r > 0);
assert_se(sd_bus_message_is_signal(reply, "org.freedesktop.DBus.Properties", "PropertiesChanged"));
bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_WITH_HEADER);
sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER);
sd_bus_message_unref(reply);
reply = NULL;
@ -441,7 +441,7 @@ static int client(struct context *c) {
assert_se(r > 0);
assert_se(sd_bus_message_is_signal(reply, "org.freedesktop.DBus.Properties", "PropertiesChanged"));
bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_WITH_HEADER);
sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER);
sd_bus_message_unref(reply);
reply = NULL;
@ -453,7 +453,7 @@ static int client(struct context *c) {
assert_se(r > 0);
assert_se(sd_bus_message_is_signal(reply, "org.freedesktop.DBus.ObjectManager", "InterfacesAdded"));
bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_WITH_HEADER);
sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER);
sd_bus_message_unref(reply);
reply = NULL;
@ -465,7 +465,7 @@ static int client(struct context *c) {
assert_se(r > 0);
assert_se(sd_bus_message_is_signal(reply, "org.freedesktop.DBus.ObjectManager", "InterfacesRemoved"));
bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_WITH_HEADER);
sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER);
sd_bus_message_unref(reply);
reply = NULL;
@ -477,7 +477,7 @@ static int client(struct context *c) {
assert_se(r > 0);
assert_se(sd_bus_message_is_signal(reply, "org.freedesktop.DBus.ObjectManager", "InterfacesAdded"));
bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_WITH_HEADER);
sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER);
sd_bus_message_unref(reply);
reply = NULL;
@ -489,7 +489,7 @@ static int client(struct context *c) {
assert_se(r > 0);
assert_se(sd_bus_message_is_signal(reply, "org.freedesktop.DBus.ObjectManager", "InterfacesRemoved"));
bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_WITH_HEADER);
sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER);
sd_bus_message_unref(reply);
reply = NULL;

View File

@ -1138,6 +1138,12 @@ int manager_rtnl_process_rule(sd_netlink *rtnl, sd_netlink_message *message, voi
return 0;
}
r = sd_netlink_message_read(message, FRA_UID_RANGE, sizeof(tmp->uid_range), &tmp->uid_range);
if (r < 0 && r != -ENODATA) {
log_warning_errno(r, "rtnl: could not get FRA_UID_RANGE attribute, ignoring: %m");
return 0;
}
(void) routing_policy_rule_get(m, tmp, &rule);
if (DEBUG_LOGGING) {

View File

@ -130,6 +130,7 @@ RoutingPolicyRule.SourcePort, config_parse_routing_policy_rule_port_ra
RoutingPolicyRule.DestinationPort, config_parse_routing_policy_rule_port_range, 0, 0
RoutingPolicyRule.InvertRule, config_parse_routing_policy_rule_invert, 0, 0
RoutingPolicyRule.Family, config_parse_routing_policy_rule_family, 0, 0
RoutingPolicyRule.User, config_parse_routing_policy_rule_uid_range, 0, 0
Route.Gateway, config_parse_gateway, 0, 0
Route.Destination, config_parse_destination, 0, 0
Route.Source, config_parse_destination, 0, 0

View File

@ -7,6 +7,7 @@
#include "alloc-util.h"
#include "conf-parser.h"
#include "fileio.h"
#include "format-util.h"
#include "ip-protocol-list.h"
#include "networkd-routing-policy-rule.h"
#include "netlink-util.h"
@ -16,6 +17,7 @@
#include "socket-util.h"
#include "string-util.h"
#include "strv.h"
#include "user-util.h"
int routing_policy_rule_new(RoutingPolicyRule **ret) {
RoutingPolicyRule *rule;
@ -26,6 +28,8 @@ int routing_policy_rule_new(RoutingPolicyRule **ret) {
*rule = (RoutingPolicyRule) {
.table = RT_TABLE_MAIN,
.uid_range.start = UID_INVALID,
.uid_range.end = UID_INVALID,
};
*ret = rule;
@ -93,6 +97,7 @@ static int routing_policy_rule_copy(RoutingPolicyRule *dest, RoutingPolicyRule *
dest->protocol = src->protocol;
dest->sport = src->sport;
dest->dport = src->dport;
dest->uid_range = src->uid_range;
return 0;
}
@ -122,6 +127,7 @@ static void routing_policy_rule_hash_func(const RoutingPolicyRule *rule, struct
siphash24_compress(&rule->protocol, sizeof(rule->protocol), state);
siphash24_compress(&rule->sport, sizeof(rule->sport), state);
siphash24_compress(&rule->dport, sizeof(rule->dport), state);
siphash24_compress(&rule->uid_range, sizeof(rule->uid_range), state);
if (rule->iif)
siphash24_compress(rule->iif, strlen(rule->iif), state);
@ -198,6 +204,10 @@ static int routing_policy_rule_compare_func(const RoutingPolicyRule *a, const Ro
if (r != 0)
return r;
r = memcmp(&a->uid_range, &b->uid_range, sizeof(a->uid_range));
if (r != 0)
return r;
r = strcmp_ptr(a->iif, b->iif);
if (r != 0)
return r;
@ -554,6 +564,12 @@ int routing_policy_rule_configure(RoutingPolicyRule *rule, Link *link, link_netl
return log_link_error_errno(link, r, "Could not append FRA_DPORT_RANGE attribute: %m");
}
if (rule->uid_range.start != UID_INVALID && rule->uid_range.end != UID_INVALID) {
r = sd_netlink_message_append_data(m, FRA_UID_RANGE, &rule->uid_range, sizeof(rule->uid_range));
if (r < 0)
return log_link_error_errno(link, r, "Could not append FRA_UID_RANGE attribute: %m");
}
if (rule->invert_rule) {
r = sd_rtnl_message_routing_policy_rule_set_flags(m, FIB_RULE_INVERT);
if (r < 0)
@ -1056,6 +1072,51 @@ int config_parse_routing_policy_rule_family(
return 0;
}
int config_parse_routing_policy_rule_uid_range(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
_cleanup_(routing_policy_rule_free_or_set_invalidp) RoutingPolicyRule *n = NULL;
Network *network = userdata;
uid_t start, end;
int r;
assert(filename);
assert(section);
assert(lvalue);
assert(rvalue);
assert(data);
r = routing_policy_rule_new_static(network, filename, section_line, &n);
if (r < 0)
return r;
r = get_user_creds(&rvalue, &start, NULL, NULL, NULL, 0);
if (r >= 0)
end = start;
else {
r = parse_uid_range(rvalue, &start, &end);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
"Invalid uid or uid range '%s', ignoring: %m", rvalue);
return 0;
}
}
n->uid_range.start = start;
n->uid_range.end = end;
n = NULL;
return 0;
}
static int routing_policy_rule_read_full_file(const char *state_file, char **ret) {
_cleanup_free_ char *s = NULL;
size_t size;
@ -1170,6 +1231,14 @@ int routing_policy_serialize_rules(Set *rules, FILE *f) {
space = true;
}
if (rule->uid_range.start != UID_INVALID && rule->uid_range.end != UID_INVALID) {
assert_cc(sizeof(uid_t) == sizeof(uint32_t));
fprintf(f, "%suidrange="UID_FMT"-"UID_FMT,
space ? " " : "",
rule->uid_range.start, rule->uid_range.end);
space = true;
}
fprintf(f, "%stable=%"PRIu32 "\n",
space ? " " : "",
rule->table);
@ -1311,6 +1380,18 @@ int routing_policy_load_rules(const char *state_file, Set **rules) {
rule->dport.start = low;
rule->dport.end = high;
} else if (streq(a, "uidrange")) {
uid_t lower, upper;
r = parse_uid_range(b, &lower, &upper);
if (r < 0) {
log_error_errno(r, "Invalid routing policy rule uid range, ignoring assignment: '%s'", b);
continue;
}
rule->uid_range.start = lower;
rule->uid_range.end = upper;
}
}

View File

@ -49,6 +49,7 @@ struct RoutingPolicyRule {
struct fib_rule_port_range sport;
struct fib_rule_port_range dport;
struct fib_rule_uid_range uid_range;
LIST_FIELDS(RoutingPolicyRule, rules);
};
@ -79,3 +80,4 @@ CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_port_range);
CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_ip_protocol);
CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_invert);
CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_family);
CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_uid_range);

View File

@ -19,6 +19,7 @@
#include <inttypes.h>
#include <stdarg.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/uio.h>
@ -105,6 +106,11 @@ enum {
SD_BUS_NAME_QUEUE = 1ULL << 2
};
enum {
SD_BUS_MESSAGE_DUMP_WITH_HEADER = 1ULL << 0,
SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY = 1ULL << 1,
};
/* Callbacks */
typedef int (*sd_bus_message_handler_t)(sd_bus_message *m, void *userdata, sd_bus_error *ret_error);
@ -330,6 +336,8 @@ int sd_bus_message_at_end(sd_bus_message *m, int complete);
int sd_bus_message_rewind(sd_bus_message *m, int complete);
int sd_bus_message_sensitive(sd_bus_message *m);
int sd_bus_message_dump(sd_bus_message *m, FILE *f, uint64_t flags);
/* Bus management */
int sd_bus_get_unique_name(sd_bus *bus, const char **unique);

View File

@ -39,6 +39,7 @@ typedef struct Item {
ItemType type;
char *name;
char *group_name;
char *uid_path;
char *gid_path;
char *description;
@ -1085,18 +1086,15 @@ static int gid_is_ok(gid_t gid) {
return 1;
}
static int add_group(Item *i) {
static int get_gid_by_name(const char *name, gid_t *gid) {
void *z;
int r;
assert(i);
assert(gid);
/* Check the database directly */
z = hashmap_get(database_by_groupname, i->name);
z = hashmap_get(database_by_groupname, name);
if (z) {
log_debug("Group %s already exists.", i->name);
i->gid = PTR_TO_GID(z);
i->gid_set = true;
*gid = PTR_TO_GID(z);
return 0;
}
@ -1105,15 +1103,30 @@ static int add_group(Item *i) {
struct group *g;
errno = 0;
g = getgrnam(i->name);
g = getgrnam(name);
if (g) {
log_debug("Group %s already exists.", i->name);
i->gid = g->gr_gid;
i->gid_set = true;
*gid = g->gr_gid;
return 0;
}
if (!IN_SET(errno, 0, ENOENT))
return log_error_errno(errno, "Failed to check if group %s already exists: %m", i->name);
return log_error_errno(errno, "Failed to check if group %s already exists: %m", name);
}
return -ENOENT;
}
static int add_group(Item *i) {
int r;
assert(i);
r = get_gid_by_name(i->name, &i->gid);
if (r != -ENOENT) {
if (r < 0)
return r;
log_debug("Group %s already exists.", i->name);
i->gid_set = true;
return 0;
}
/* Try to use the suggested numeric gid */
@ -1214,14 +1227,22 @@ static int process_item(Item *i) {
case ADD_USER: {
Item *j;
j = ordered_hashmap_get(groups, i->name);
j = ordered_hashmap_get(groups, i->group_name ?: i->name);
if (j && j->todo_group) {
/* When the group with the same name is already in queue,
/* When a group with the target name is already in queue,
* use the information about the group and do not create
* duplicated group entry. */
i->gid_set = j->gid_set;
i->gid = j->gid;
i->id_set_strict = true;
} else if (i->group_name) {
/* When a group name was given instead of a GID and it's
* not in queue, then it must already exist. */
r = get_gid_by_name(i->group_name, &i->gid);
if (r < 0)
return log_error_errno(r, "Group %s not found.", i->group_name);
i->gid_set = true;
i->id_set_strict = true;
} else {
r = add_group(i);
if (r < 0)
@ -1244,6 +1265,7 @@ static Item* item_free(Item *i) {
return NULL;
free(i->name);
free(i->group_name);
free(i->uid_path);
free(i->gid_path);
free(i->description);
@ -1560,10 +1582,15 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
_cleanup_free_ char *uid = NULL, *gid = NULL;
if (split_pair(resolved_id, ":", &uid, &gid) == 0) {
r = parse_gid(gid, &i->gid);
if (r < 0)
if (r < 0) {
if (valid_user_group_name(gid))
i->group_name = TAKE_PTR(gid);
else
return log_error_errno(r, "Failed to parse GID: '%s': %m", id);
} else {
i->gid_set = true;
i->id_set_strict = true;
}
free_and_replace(resolved_id, uid);
}
if (!streq(resolved_id, "-")) {

View File

@ -572,10 +572,8 @@ static void test_pid_to_ptr(void) {
assert_se(PTR_TO_PID(PID_TO_PTR(INT16_MAX)) == INT16_MAX);
assert_se(PTR_TO_PID(PID_TO_PTR(INT16_MIN)) == INT16_MIN);
#if SIZEOF_PID_T >= 4
assert_se(PTR_TO_PID(PID_TO_PTR(INT32_MAX)) == INT32_MAX);
assert_se(PTR_TO_PID(PID_TO_PTR(INT32_MIN)) == INT32_MIN);
#endif
}
static void test_ioprio_class_from_to_string_one(const char *val, int expected) {

View File

@ -0,0 +1,5 @@
hoge:x:300:
baz:x:302:
yyy:x:SYSTEM_GID_MAX:
foo:x:301:
ccc:x:305:

View File

@ -0,0 +1,5 @@
foo:x:301:301::/:NOLOGIN
aaa:x:303:302::/:NOLOGIN
bbb:x:304:302::/:NOLOGIN
ccc:x:305:305::/:NOLOGIN
zzz:x:306:SYSTEM_GID_MAX::/:NOLOGIN

View File

@ -0,0 +1,13 @@
# Ensure that the semantic for the uid:groupname syntax is correct
#
#Type Name ID GECOS HOMEDIR
g hoge 300 - -
u foo 301 - -
g baz 302 - -
u aaa 303:baz - -
u bbb 304:baz - -
u ccc 305 - -
g yyy -
u zzz 306:yyy

View File

@ -0,0 +1 @@
pre:x:987:

View File

@ -0,0 +1 @@
aaa:x:SYSTEM_UID_MAX:987::/:NOLOGIN

View File

@ -0,0 +1 @@
pre:x:987:

View File

@ -0,0 +1,4 @@
# Ensure that a preexisting system group can be used as primary
#
#Type Name ID GECOS HOMEDIR
u aaa -:pre

View File

@ -23,6 +23,7 @@ preprocess() {
# get this value from config.h, however the autopkgtest fails with
# it
SYSTEM_UID_MAX=$(awk 'BEGIN { uid=999 } /^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }' /etc/login.defs)
SYSTEM_GID_MAX=$(awk 'BEGIN { gid=999 } /^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }' /etc/login.defs)
# we can't rely on config.h to get the nologin path, as autopkgtest
# uses pre-compiled binaries, so extract it from the systemd-sysusers
@ -30,6 +31,7 @@ preprocess() {
NOLOGIN=$(strings $(type -p systemd-sysusers) | grep nologin)
sed -e "s/SYSTEM_UID_MAX/${SYSTEM_UID_MAX}/g" \
-e "s/SYSTEM_GID_MAX/${SYSTEM_GID_MAX}/g" \
-e "s#NOLOGIN#${NOLOGIN}#g" "$in"
}

View File

@ -0,0 +1 @@
Group g1 not found.

View File

@ -0,0 +1,4 @@
# Ensure it is not allowed to create groups implicitly in the uid:groupname syntax
#
#Type Name ID GECOS HOMEDIR
u u1 100:g1 -

View File

@ -225,6 +225,7 @@ DestinationPort=
IPProtocol=
InvertRule=
Family=
User=
[IPv6PrefixDelegation]
RouterPreference=
DNSLifetimeSec=

View File

@ -0,0 +1,9 @@
[Match]
Name=test1
[RoutingPolicyRule]
TypeOfService=0x08
Table=7
From= 192.168.100.18
Priority=111
User=100-200

View File

@ -100,6 +100,23 @@ def expectedFailureIfRoutingPolicyIPProtoIsNotAvailable():
return f
def expectedFailureIfRoutingPolicyUIDRangeIsNotAvailable():
def f(func):
support = False
rc = call('ip rule add from 192.168.100.19 table 7 uidrange 200-300', stderr=subprocess.DEVNULL)
if rc == 0:
ret = run('ip rule list from 192.168.100.19 table 7', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if ret.returncode == 0 and 'uidrange 200-300' in ret.stdout.rstrip():
support = True
call('ip rule del from 192.168.100.19 table 7 uidrange 200-300')
if support:
return func
else:
return unittest.expectedFailure(func)
return f
def expectedFailureIfLinkFileFieldIsNotSet():
def f(func):
support = False
@ -1572,6 +1589,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
'25-bond-active-backup-slave.netdev',
'25-fibrule-invert.network',
'25-fibrule-port-range.network',
'25-fibrule-uidrange.network',
'25-gre-tunnel-remote-any.netdev',
'25-ip6gre-tunnel-remote-any.netdev',
'25-ipv6-address-label-section.network',
@ -1776,6 +1794,19 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
self.assertRegex(output, 'tcp')
self.assertRegex(output, 'lookup 7')
@expectedFailureIfRoutingPolicyUIDRangeIsNotAvailable()
def test_routing_policy_rule_uidrange(self):
copy_unit_to_networkd_unit_path('25-fibrule-uidrange.network', '11-dummy.netdev')
start_networkd()
self.wait_online(['test1:degraded'])
output = check_output('ip rule')
print(output)
self.assertRegex(output, '111')
self.assertRegex(output, 'from 192.168.100.18')
self.assertRegex(output, 'lookup 7')
self.assertRegex(output, 'uidrange 100-200')
def test_route_static(self):
copy_unit_to_networkd_unit_path('25-route-static.network', '12-dummy.netdev')
start_networkd()