Commit Graph

875 Commits

Author SHA1 Message Date
Lennart Poettering bed0b7dfc0
pid1: warn if people use User=nobody (#16293) 2020-06-26 22:36:39 +02:00
Yu Watanabe 5202be27ee sd-network: drop unused functions 2020-06-23 19:13:05 +09:00
Lennart Poettering 2a71d57f4e network: clean-up DHCP lease server data configuration
This is an attempt to clean up the POP3/SMTP/LPR/… DHCP lease server
data logic in networkd. This reduces code duplication and fixes a number
of bugs.

This removes any support for collecting POP3/SMPT/LPR servers acquired
via local DHCP client releases since noone uses that, and given how old
these protocols are I doubt this will change. It keeps support for
configuring them for the dhcp server however.

The differences between the DNS/NTP/SIP/POP3/SMTP/LPR configuration
logics are minimized.

This removes the relevant symbols from sd-network.h (which is an
internal API only at this point after all).

This is unfortunately not well test, given the old code for this had
barely any tests. But the new code should not perform worse at least,
and allow us to release, since it corrects some interfaces visible in
the .network configuration format.

Fixes: #15943
2020-06-18 13:08:18 +09:00
Susant Sahani a9deab2eec sd-network: Introduce APIs to get DHCP6 DUID 2020-06-10 19:21:21 +02:00
Susant Sahani 6b7d5b6eaf network: DHCP6 - introduce DHCP6 DUID to string 2020-06-10 19:17:28 +02:00
Susant Sahani 01dd138031 sd-network: Introduce API to get DHCPv6 IAID 2020-06-09 19:58:36 +09:00
Susant Sahani d69d4038ec dhcp6: Provide method to access IAID 2020-06-09 19:57:38 +09:00
Susant Sahani daec96821d sd-network: Introduce API to access DHCP4 client ID 2020-06-08 07:09:24 +02:00
Marc-André Lureau 7be3261222 sd-dhcp-client: add sd_dhcp_client_id_to_string()
Add a human-friendly pretty-printer for client ID.
2020-06-04 11:16:15 +02:00
Marc-André Lureau 36d35f2259 sd-dhcp-server: notify callback on lease changed 2020-06-04 11:16:15 +02:00
Marc-André Lureau 5b03043a75 sd-dhcp-server: add sd_dhcp_server_set_callback() 2020-06-04 11:04:06 +02:00
Yu Watanabe f3e4b1e07c
Merge pull request #15884 from ssahani/dhcpv6-vendor
DHCPv6: Introduce vendor specific
2020-06-01 12:25:54 +09:00
Lennart Poettering ddb82ec2a2 sd-dhcp: clean-up of DHCP lease server code
This is an attempt to clean-up the DHCP lease server type code a bit. We
now strictly use the same enum everywhere, and store server info in an
array. Moreover, we use the same nomenclature everywhere.

This only makes the changes in the sd-dhcp code. The networkd code is
untouched so far (but should be fixed up like this too. But it's more
complicated since this would then touch actual settings in .network
files).

Note that this also changes some field names in serialized lease files.
But given that these field names have not been part of a released
version of systemd yet, such a change should be ok.

This is pure renaming/refactoring, shouldn't actually change any
behaviour.
2020-05-30 14:18:43 +02:00
Susant Sahani 99ccb8ff89 sd-dhcp6: Introduce vendor specific information
RFC: 8415
21.17.  Vendor-specific Information Option

   This option is used by clients and servers to exchange vendor-
   specific information.

   The format of the Vendor-specific Information option is:

       0                   1                   2                   3
       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |      OPTION_VENDOR_OPTS       |           option-len          |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |                       enterprise-number                       |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      .                                                               .
      .                       vendor-option-data                      .
      .                                                               .
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

           Figure 30: Vendor-specific Information Option Format

      option-code          OPTION_VENDOR_OPTS (17).

      option-len           4 + length of vendor-option-data field.

      enterprise-number    The vendor's registered Enterprise Number as
                           maintained by IANA [IANA-PEN].  A 4-octet
                           field containing an unsigned integer.

      vendor-option-data   Vendor options, interpreted by
                           vendor-specific code on the clients and
                           servers.  A variable-length field (4 octets
                           less than the value in the option-len field).

 The definition of the information carried in this option is vendor
   specific.  The vendor is indicated in the enterprise-number field.
   Use of vendor-specific information allows enhanced operation,
   utilizing additional features in a vendor's DHCP implementation.  A
   DHCP client that does not receive requested vendor-specific
   information will still configure the node's IPv6 stack to be
   functional.

   The vendor-option-data field MUST be encoded as a sequence of
   code/length/value fields of format identical to the DHCP options (see
   Section 21.1).  The sub-option codes are defined by the vendor
   identified in the enterprise-number field and are not managed by
   IANA.  Each of the sub-options is formatted as follows:

       0                   1                   2                   3
       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |          sub-opt-code         |         sub-option-len        |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      .                                                               .
      .                        sub-option-data                        .
      .                                                               .
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                 Figure 31: Vendor-specific Options Format

      sub-opt-code         The code for the sub-option.  A 2-octet
                           field.

      sub-option-len       An unsigned integer giving the length of the
                           sub-option-data field in this sub-option in
                           octets.  A 2-octet field.

      sub-option-data      The data area for the sub-option.  The
                           length, in octets, is specified by
                           sub-option-len.

   Multiple instances of the Vendor-specific Information option may
   appear in a DHCP message.  Each instance of the option is interpreted
   according to the option codes defined by the vendor identified by the
   Enterprise Number in that option.  Servers and clients MUST NOT send
   more than one instance of the Vendor-specific Information option with
   the same Enterprise Number.  Each instance of the Vendor-specific
   Information option MAY contain multiple sub-options.

A client that is interested in receiving a Vendor-specific
   Information option:

   -  MUST specify the Vendor-specific Information option in an Option
      Request option.

   -  MAY specify an associated Vendor Class option (see Section 21.16).

   -  MAY specify the Vendor-specific Information option with
      appropriate data.

   Servers only return the Vendor-specific Information options if
   specified in Option Request options from clients and:

   -  MAY use the Enterprise Numbers in the associated Vendor Class
      options to restrict the set of Enterprise Numbers in the
      Vendor-specific Information options returned.

   -  MAY return all configured Vendor-specific Information options.

   -  MAY use other information in the packet or in its configuration to
      determine which set of Enterprise Numbers in the Vendor-specific
      Information options to return.
2020-05-29 13:36:42 +02:00
Yu Watanabe fac729f811
Merge pull request #15911 from poettering/unit-name-tighten
pid1: improve logging when we encounter a path that is too long to be converted into a mount unit name
2020-05-29 15:55:38 +09:00
Lennart Poettering ccdf03b9c7 sd-path: drop "-dir" and "-path" suffixes from path enums
Clean up the naming of the sd-path enums. Previously, the more recently
added fields where named in the form SD_PATH_xyz_DIR and
SD_PATH_xyz_PATH, while the older fields where called just SD_PATH_xyz
and SD_PATH_SEARCH_xyz. Let's clean this up, to come to a more unified
way how we name this stuff.

I opted to stick to the old naming, i.e. dropthe suffixes. It's a bit of
a bike-shedding question of course, but I think there's a good reason to
avoid the additional DIR and PATH suffixes: the enum prefix contains
"PATH" anyway (i.e. "SD_PATH_"), so including PATH twice in each name is
redundant. Moreover, the key difference between the enums with the "dir"
and the "path" in the name is that the latter are *seach* paths, and I
think this is better emphasized by sticking to the "SEARCH" in the name.

Moreover dropping the suffixes makes the identifiers a lot shorter, in
particular in the "systemd-path" list output. And that's always good.

This means the naming pkgconfig file and in sd-path slightly deviate
(though the mapping is very simple), but I think that's OK, given that
this is developer facing and not user facing.
2020-05-28 23:54:35 +02:00
Lennart Poettering cf3317f63a
Merge pull request #15906 from keszybz/busctl-stdout-stderr
Make busctl stdout/stderr split consistent
2020-05-26 15:38:14 +02:00
Zbigniew Jędrzejewski-Szmek 00813316b0 sd-dhcp6: constify output arguments in get_{ntp,nds}_addr
This matches what we do for ipv4 and is in general better.
2020-05-26 09:47:45 +02:00
Lennart Poettering 2c905207db core: improve log messages when we cannot process a mount point
Whenever we pick up a new line in /proc/self/mountinfo and want to
synthesize a new mount unit from it, let's say which one it is.
Moreover, downgrade the log message when we encounter a mount point with
an overly long name to LOG_WARNING, since it's generally fine to ignore
such mount points.

Also, attach a catalog entry to explain the situation further.

Prompted-By: #15221
2020-05-26 09:17:48 +02:00
Zbigniew Jędrzejewski-Szmek d2916409ed sd-bus: make name validation functions public
Those are fairly trivial to reimplement, but any non-trivial user of sd-bus
is likely to need them. So let's expose them to save everyone the trouble.

I'm keeping the internal functions and making the public ones thin wrappers,
because for the internal uses we don't need the additional asserts, and also we
can't expose _pure_ annotation easily, and dropping it would likely make the
compiled code a bit less efficient.
2020-05-25 11:09:21 +02:00
Zbigniew Jędrzejewski-Szmek 929d07ddcb
Merge pull request #15274 from ssahani/network-issue-9610
DHCP4: Allow lease time to be set when missing from offer
2020-05-20 16:39:41 +02:00
Susant Sahani 73c8ced784 sd-network: DHCPv6 - Add support to send vendor class data
```
21.16.  Vendor Class Option

   This option is used by a client to identify the vendor that
   manufactured the hardware on which the client is running.  The
   information contained in the data area of this option is contained in
   one or more opaque fields that identify details of the hardware
   configuration.  The format of the Vendor Class option is:

       0                   1                   2                   3
       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |      OPTION_VENDOR_CLASS      |           option-len          |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |                       enterprise-number                       |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      .                                                               .
      .                       vendor-class-data                       .
      .                             . . .                             .
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                   Figure 28: Vendor Class Option Format

      option-code          OPTION_VENDOR_CLASS (16).

      option-len           4 + length of vendor-class-data field.

      enterprise-number    The vendor's registered Enterprise Number as
                           maintained by IANA [IANA-PEN].  A 4-octet
                           field containing an unsigned integer.

      vendor-class-data    The hardware configuration of the node on
                           which the client is running.  A
                           variable-length field (4 octets less than the
                           value in the option-len field).

   The vendor-class-data field is composed of a series of separate
   items, each of which describes some characteristic of the client's
   hardware configuration.  Examples of vendor-class-data instances
   might include the version of the operating system the client is
   running or the amount of memory installed on the client.

   Each instance of vendor-class-data is formatted as follows:

      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...-+-+-+-+-+-+-+
      |       vendor-class-len        |          opaque-data          |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...-+-+-+-+-+-+-+

               Figure 29: Format of vendor-class-data Field

   The vendor-class-len field is 2 octets long and specifies the length
   of the opaque vendor-class-data in network byte order.

   Servers and clients MUST NOT include more than one instance of
   OPTION_VENDOR_CLASS with the same Enterprise Number.  Each instance
   of OPTION_VENDOR_CLASS can carry multiple vendor-class-data
   instances.
   ```
2020-05-20 07:52:19 +02:00
Susant Sahani 4c0b8d563d sd-dhcpv4: Allow to configure lease lifetime 2020-05-20 06:30:05 +02:00
Susant Sahani 3392392518 sd-network: DHCPv6 - add support to send userclass option
sd-network: DHCPv6 - add support to send userclass option

21.15.  User Class Option

   The User Class option is used by a client to identify the type or
   category of users or applications it represents.

   The format of the User Class option is:

       0                   1                   2                   3
       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |       OPTION_USER_CLASS       |          option-len           |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      .                                                               .
      .                          user-class-data                      .
      .                                                               .
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Figure 26: User Class Option Format

      option-code          OPTION_USER_CLASS (15).

      option-len           Length of user-class-data field.

      user-class-data      The user classes carried by the client.  The
                           length, in octets, is specified by
                           option-len.

The information contained in the data area of this option is
   contained in one or more opaque fields that represent the user class
   or classes of which the client is a member.  A server selects
   configuration information for the client based on the classes
   identified in this option.  For example, the User Class option can be
   used to configure all clients of people in the accounting department
   with a different printer than clients of people in the marketing
   department.  The user class information carried in this option MUST
   be configurable on the client.

   The data area of the User Class option MUST contain one or more
   instances of user-class-data information.  Each instance of
   user-class-data is formatted as follows:

      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...-+-+-+-+-+-+-+
      |        user-class-len         |          opaque-data          |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...-+-+-+-+-+-+-+

                Figure 27: Format of user-class-data Field
2020-05-19 11:44:51 +02:00
Zbigniew Jędrzejewski-Szmek b3d15d90c0
Merge pull request #15804 from poettering/hostnamed-instant-part1
four likely safe commits split out of #15624
2020-05-18 15:26:24 +02:00
Lennart Poettering 90810f7a37 sd-dhcp-server: some function prototype fix-ups
Let's use size_t for numbers of entries in memory.

Let's use const wherever appropriate.

Drop `_server` suffix from function name where we don't have it for
similar other cases.
2020-05-14 17:11:44 +02:00
Lennart Poettering 491ce16103 sd-bus: introduce new SD_BUS_VTABLE_ABSOLUTE_OFFSET vtable flag
When set, the offset specified for the vtable entry is passed to the
handler as-is, and is not added to the userdata pointer. This is useful
in case methods/properties are mixed on the same vtable, that expect to
operate relative to some object in memory and that expect pointers to
absolute memory, or that just want a number passed.
2020-05-13 16:57:44 +02:00
Andrew Doran e7d5fe17db DHCP client: make SendOption work for DHCPv6 too. 2020-05-11 16:31:08 +02:00
Daan De Meyer eff7c2d3c9 sd-bus: Add a nicer way of specifying sd-bus vtable method arguments
SD_BUS_NAMES_WITH_ARGS is a less error-prone way of specifying D-Bus
method arguments.
2020-05-06 10:22:54 +02:00
Kumar Kartikeya Dwivedi 4f07ddfa9b
Introduce sd_notify_barrier
This adds the sd_notify_barrier function, to allow users to synchronize against
the reception of sd_notify(3) status messages. It acts as a synchronization
point, and a successful return gurantees that all previous messages have been
consumed by the manager. This can be used to eliminate race conditions where
the sending process exits too early for systemd to associate its PID to a
cgroup and attribute the status message to a unit correctly.

systemd-notify now uses this function for proper notification delivery and be
useful for NotifyAccess=all units again in user mode, or in cases where it
doesn't have a control process as parent.

Fixes: #2739
2020-05-01 03:22:47 +05:30
Daan De Meyer bac1b83217 sd-bus: Add sd_bus_query_sender_creds/privilege docs 2020-04-28 19:38:04 +02:00
Thomas Haller feb7d7a212 dhcp6: make string argument to sd_dhcp6_client_set_request_mud_url() const 2020-04-24 10:13:33 +02:00
Zbigniew Jędrzejewski-Szmek 73781de41f
Merge pull request #15530 from ssahani/lpr-dhcpv4-option-9
network: add support to DHCPv4 server/client option 9 LPR
2020-04-23 09:10:14 +02:00
Susant Sahani d64cc72e80 sd-network: Add support to retrive LPR servers 2020-04-22 14:49:52 +02:00
Susant Sahani 50018bfa84 sd-network: DHCPv4 Add support to send and receive LPR servers. 2020-04-22 14:48:11 +02:00
Frantisek Sumsal 86b52a3958 tree-wide: fix spelling errors
Based on a report from Fossies.org using Codespell.

Followup to #15436
2020-04-21 23:21:08 +02:00
Lennart Poettering 543d1e7854
Merge pull request #15314 from keszybz/network-server-access-functions
Define network server access functions
2020-04-21 09:24:48 +02:00
Zbigniew Jędrzejewski-Szmek 0500114e2a headers: get rid of pointless /* deprecated */ comment
The _sd_deprecated_ annotation gives it all away, and the comment adds
no additional value.
2020-04-17 16:15:30 +02:00
Zbigniew Jędrzejewski-Szmek 8f8cc84ba4 sd-login: get rid of seat_can_multi_session()
Follow-up for fa2cf64a91.
Backwards-compat is retained. A short note is added in docs, in case
people see sd_seat_can_multi_session() mentioned somewhere and wonder what
happened to it.

Also see https://github.com/systemd/systemd/pull/15337#issuecomment-610369404.
2020-04-17 16:15:30 +02:00
Daan De Meyer 59a77060e0 sd-bus: Use pointer syntax for sd_bus_set_exec argv parameter 2020-04-11 21:57:28 +02:00
Zbigniew Jędrzejewski-Szmek c8407baf30 sd-dhcp-server: add a meta-setter to simplify setting of server lists 2020-04-10 17:52:59 +02:00
Zbigniew Jędrzejewski-Szmek 8541db8f59 sd-dhcp-lease: add a meta-getter to simplify querying of server lists 2020-04-10 17:45:46 +02:00
Lennart Poettering 9b3c65ed36
Merge pull request #15352 from poettering/user-group-name-valdity-rework
user/group name validity rework
2020-04-09 18:49:22 +02:00
Lennart Poettering 7a8867abfa user-util: rework how we validate user names
This reworks the user validation infrastructure. There are now two
modes. In regular mode we are strict and test against a strict set of
valid chars. And in "relaxed" mode we just filter out some really
obvious, dangerous stuff. i.e. strict is whitelisting what is OK, but
"relaxed" is blacklisting what is really not OK.

The idea is that we use strict mode whenver we allocate a new user
(i.e. in sysusers.d or homed), while "relaxed" mode is when we process
users registered elsewhere, (i.e. userdb, logind, …)

The requirements on user name validity vary wildly. SSSD thinks its fine
to embedd "@" for example, while the suggested NAME_REGEX field on
Debian does not even allow uppercase chars…

This effectively liberaralizes a lot what we expect from usernames.

The code that warns about questionnable user names is now optional and
only used at places such as unit file parsing, so that it doesn't show
up on every userdb query, but only when processing configuration files
that know better.

Fixes: #15149 #15090
2020-04-08 17:11:20 +02:00
Susant Sahani f69b4ae885 sd-lldp: Add support to receive MUD 2020-04-07 17:17:29 +02:00
Daan De Meyer 11a177d9de sd-bus: Deprecate priority functions 2020-04-02 21:36:59 +02:00
Vito Caputo 935052a8aa sd-bus: add va_list variants of variadic convenience functions
Consumers of the sd-bus convenience API can't make convenience
helpers of their own without va_list variants.

This commit is a mechanical change splitting out the existing function
bodies into bare va_list variants having a 'v' suffixed to the names.

The original functions now simply create the va_list before forwarding
the call on to the va_list variant, and the va_list variants dispense
with those steps.
2020-04-02 10:26:18 +02:00
Zbigniew Jędrzejewski-Szmek c51c6f2f57
Merge pull request #15252 from ssahani/dhcpv6-mud
DHCPv6: Add support to send MUD URL
2020-04-02 10:23:15 +02:00
Susant Sahani de8d6e5563 sd-dhcpv6: Add support to set request MUD URL 2020-04-01 16:59:29 +02:00
Susant Sahani d11d4a6459 sd-dhcpv4: introduce The Manufacturer Usage Description (MUD) 2020-03-30 19:16:01 +02:00