]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #15278 from vcaputo/more-trivial-cleanups
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 31 Mar 2020 22:16:56 +0000 (00:16 +0200)
committerGitHub <noreply@github.com>
Tue, 31 Mar 2020 22:16:56 +0000 (00:16 +0200)
Expand use of _cleanup_close_ where trivial

28 files changed:
man/rules/meson.build
man/sd-bus.xml
man/sd-daemon.xml
man/sd_bus_call.xml
man/sd_bus_message_set_destination.xml
man/systemd.network.xml
src/basic/user-util.c
src/home/homectl.c
src/home/homed-home-bus.c
src/home/homed-home.c
src/home/homed-manager-bus.c
src/home/homed-manager.c
src/home/homed-operation.c
src/home/homework-luks.c
src/home/homework-pkcs11.c
src/home/homework.c
src/home/pam_systemd_home.c
src/home/pwquality-util.c
src/libsystemd-network/sd-dhcp-client.c
src/network/networkd-dhcp4.c
src/network/networkd-dhcp4.h
src/network/networkd-network-gperf.gperf
src/network/networkd-network.c
src/network/networkd-network.h
src/systemd/sd-dhcp-client.h
src/userdb/userwork.c
test/fuzz/fuzz-network-parser/directives.network
units/systemd-homed.service.in

index db90073f36f8589361af72d08c9232e04304e2b2..ee8c2367446334246627b1c2ec67aa836a4d908b 100644 (file)
@@ -289,7 +289,9 @@ manpages = [
    'sd_bus_message_get_interface',
    'sd_bus_message_get_member',
    'sd_bus_message_get_path',
+   'sd_bus_message_get_priority',
    'sd_bus_message_get_sender',
+   'sd_bus_message_set_priority',
    'sd_bus_message_set_sender'],
   ''],
  ['sd_bus_message_set_expect_reply',
index 48f4a2a84fce8485b0fd750487f7e0a5508c881c..c649bc46fef447c359f6628b747c25ccac6f10e9 100644 (file)
@@ -67,6 +67,8 @@
 <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_priority</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+<citerefentry><refentrytitle>sd_bus_message_get_sender</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
 <citerefentry><refentrytitle>sd_bus_message_get_signature</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
 <citerefentry><refentrytitle>sd_bus_message_get_type</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
 <citerefentry><refentrytitle>sd_bus_message_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
@@ -79,6 +81,8 @@
 <citerefentry><refentrytitle>sd_bus_message_rewind</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
 <citerefentry><refentrytitle>sd_bus_message_seal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
 <citerefentry><refentrytitle>sd_bus_message_set_destination</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+<citerefentry><refentrytitle>sd_bus_message_set_priority</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+<citerefentry><refentrytitle>sd_bus_message_set_sender</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
 <citerefentry><refentrytitle>sd_bus_message_set_expect_reply</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
 <citerefentry><refentrytitle>sd_bus_message_skip</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
 <citerefentry><refentrytitle>sd_bus_message_verify_type</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
index 84deda188d22fa17d7a738a44e1ab3690693c409..64ed5f3779c73ac71a87d7b4a552b88f13e4b62f 100644 (file)
 #define SD_INFO    "&lt;6&gt;"  /* informational */
 #define SD_DEBUG   "&lt;7&gt;"  /* debug-level messages */</programlisting>
 
-    <para>These prefixes are intended to be used in conjunction with
-    stderr-based logging as implemented by systemd. If a systemd
-    service definition file is configured with
-    <varname>StandardError=journal</varname>,
-    <varname>StandardError=syslog</varname> or
-    <varname>StandardError=kmsg</varname>, these prefixes can be used
-    to encode a log level in lines printed. This is similar to the
-    kernel <function>printk()</function>-style logging. See
-    <citerefentry><refentrytitle>klogctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
-    for more information.</para>
+    <para>These prefixes are intended to be used in conjunction with stderr-based logging (or stdout-based
+    logging) as implemented by systemd. If a systemd service definition file is configured with
+    <varname>StandardError=journal</varname>, <varname>StandardError=syslog</varname> or
+    <varname>StandardError=kmsg</varname> (and similar with <varname>StandardOutput=</varname>), these
+    prefixes can be used to encode a log level in lines printed. This is similar to the kernel
+    <function>printk()</function>-style logging. See
+    <citerefentry><refentrytitle>klogctl</refentrytitle><manvolnum>2</manvolnum></citerefentry> for more
+    information.</para>
 
     <para>The log levels are identical to
     <citerefentry project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>'s
index f2d725a29f0bcd75cc554fd9e88ef97deb4b2ef4..93462f24b594fa42eb15ff3dc39efdddc91769e9 100644 (file)
     <title>Description</title>
 
     <para><function>sd_bus_call()</function> takes a complete bus message object and calls the
-    corresponding D-Bus method. The response is stored in <parameter>reply</parameter>.
+    corresponding D-Bus method. On success, the response is stored in <parameter>reply</parameter>.
     <parameter>usec</parameter> indicates the timeout in microseconds. If
     <parameter>ret_error</parameter> is not <constant>NULL</constant> and
-    <function>sd_bus_call()</function> returns an error, <parameter>ret_error</parameter> is
-    initialized to an instance of <structname>sd_bus_error</structname> describing the error.</para>
+    <function>sd_bus_call()</function> fails (either because of an internal error or because it
+    received a D-Bus error reply), <parameter>ret_error</parameter> is initialized to an instance of
+    <structname>sd_bus_error</structname> describing the error.</para>
 
     <para><function>sd_bus_call_async()</function> is like <function>sd_bus_call()</function> but
-    works asynchronously. The <parameter>callback</parameter> shall reference a function to call
-    when the event source is triggered. The <parameter>userdata</parameter> pointer will be passed
-    to the callback function, and may be chosen freely by the caller. If <parameter>slot</parameter>
-    is not <constant>NULL</constant> and <function>sd_bus_call_async()</function> succeeds,
+    works asynchronously. The <parameter>callback</parameter> indicates the function to call when
+    the response arrives. The <parameter>userdata</parameter> pointer will be passed to the callback
+    function, and may be chosen freely by the caller. If <parameter>slot</parameter> is not
+    <constant>NULL</constant> and <function>sd_bus_call_async()</function> succeeds,
     <parameter>slot</parameter> is set to a slot object which can be used to cancel the method call
     at a later time using
     <citerefentry><refentrytitle>sd_bus_slot_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
     If <parameter>slot</parameter> is <constant>NULL</constant>, the lifetime of the method call is
     bound to the lifetime of the bus object itself, and it cannot be cancelled independently. See
     <citerefentry><refentrytitle>sd_bus_slot_set_floating</refentrytitle><manvolnum>3</manvolnum></citerefentry>
-    for details. The <parameter>callback</parameter> function is called when the response arrives
-    and receives the response, <parameter>userdata</parameter> and a
-    <structname>sd_bus_error</structname> object as its arguments. The
-    <structname>sd_bus_error</structname> object is unused here and should be ignored. If
-    <parameter>callback</parameter> returns a non-negative integer when called, a debug message is
-    logged along with details about the response.</para>
-
-    <para>To determine whether the method call succeeded, use
+    for details. <parameter>callback</parameter> is called when a reply arrives with the reply,
+    <parameter>userdata</parameter> and an <structname>sd_bus_error</structname> output
+    parameter as its arguments. Unlike <function>sd_bus_call()</function>, the
+    <structname>sd_bus_error</structname> output parameter passed to the callback will be empty. To
+    determine whether the method call succeeded, use
     <citerefentry><refentrytitle>sd_bus_message_is_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>
-    on the reply object returned by <function>sd_bus_call()</function> or passed to the callback of
-    <function>sd_bus_call_async()</function>.</para>
+    on the reply message passed to the callback instead. If the callback returns zero and the
+    <structname>sd_bus_error</structname> output parameter is still empty when the callback
+    inishes, other handlers registered with functions such as
+    <citerefentry><refentrytitle>sd_bus_add_filter</refentrytitle><manvolnum>3</manvolnum></citerefentry> or
+    <citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+    are given a chance to process the message. If the callback returns a non-zero value or the
+    <structname>sd_bus_error</structname> output parameter is not empty when the callback finishes,
+    no further processing of the message is done. Generally, you want to return zero from the
+    callback to give other registered handlers a chance to process the reply as well.</para>
 
     <para>If <parameter>usec</parameter> is zero, the default D-Bus method call timeout is used. See
     <citerefentry><refentrytitle>sd_bus_get_method_call_timeout</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
index ca3e466d7a95e3e15cba6b0126fdd77ff695fdc3..126778fc3cec8ef1ef3c822a7bf2dfa96be2cbfb 100644 (file)
@@ -19,6 +19,8 @@
     <refname>sd_bus_message_get_path</refname>
     <refname>sd_bus_message_get_interface</refname>
     <refname>sd_bus_message_get_member</refname>
+    <refname>sd_bus_message_set_priority</refname>
+    <refname>sd_bus_message_get_priority</refname>
     <refname>sd_bus_message_set_sender</refname>
     <refname>sd_bus_message_get_sender</refname>
 
         <paramdef>sd_bus_message *<parameter>message</parameter></paramdef>
       </funcprototype>
 
+      <funcprototype>
+        <funcdef>int <function>sd_bus_message_set_priority</function></funcdef>
+        <paramdef>sd_bus_message *<parameter>message</parameter></paramdef>
+        <paramdef>int64_t <parameter>priority</parameter></paramdef>
+      </funcprototype>
+
+      <funcprototype>
+        <funcdef>int <function>sd_bus_message_get_priority</function></funcdef>
+        <paramdef>sd_bus_message *<parameter>message</parameter></paramdef>
+        <paramdef>int64_t *<parameter>priority</parameter></paramdef>
+      </funcprototype>
+
       <funcprototype>
         <funcdef>int <function>sd_bus_message_set_sender</function></funcdef>
         <paramdef>sd_bus_message *<parameter>message</parameter></paramdef>
     member fields from <parameter>message</parameter> header. The return value will be
     <constant>NULL</constant> is <parameter>message</parameter> is <constant>NULL</constant> or the
     message is of a type that doesn't use those fields or the message doesn't have them set. See
-    <citerefentry><refentrytitle>sd_bus_message_new_method_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>
-    and
+    <citerefentry><refentrytitle>sd_bus_message_new_method_call</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
     <citerefentry><refentrytitle>sd_bus_message_set_destination</refentrytitle><manvolnum>3</manvolnum></citerefentry>
     for more discussion of those values.</para>
 
+    <para><function>sd_bus_message_set_priority()</function> and
+    <function>sd_bus_message_get_priority()</function> modify and query a message's priority
+    respectively. sd-bus currently doesn't make use of a message's priority.</para>
 
     <para><function>sd_bus_message_set_sender()</function> sets the sender service name for the specified bus message
     object. The specified name must be a valid unique or well-known service name. This function is useful only for
         <varlistentry>
           <term><constant>-EPERM</constant></term>
 
-          <listitem><para>For <function>sd_bus_message_set_destination</function> or
-          <function>sd_bus_message_set_sender</function>, the message is already
-          sealed.</para></listitem>
+          <listitem><para>For <function>sd_bus_message_set_destination()</function>,
+          <function>sd_bus_message_set_sender()</function> and
+          <function>sd_bus_message_set_priority()</function>, the message is already sealed.</para>
+          </listitem>
         </varlistentry>
 
         <varlistentry>
index 2ead483519e7810fc9f18e6073fe2fae6b2da7d9..bb6c35f9babf49e4a7a9b3f6f8df59cc8e55e08f 100644 (file)
             sent even if this is set to true.</para>
           </listitem>
         </varlistentry>
+
+        <varlistentry>
+          <term><varname>MUDURL=</varname></term>
+          <listitem>
+            <para>When configured, the Manufacturer Usage Descriptions (MUD) URL will be sent to the
+            DHCPv4 server. Takes an URL of length up to 255 characters. A superficial verification that
+            the string is a valid URL will be performed. DHCPv4 clients are intended to have at most one
+            MUD URL associated with them. See
+            <ulink url="https://tools.ietf.org/html/rfc8520">RFC 8520</ulink>.</para>
+          </listitem>
+        </varlistentry>
+
         <varlistentry>
           <term><varname>UseHostname=</varname></term>
           <listitem>
index e998a46e72aea75e68754abe9c9a39528c0f317b..1510fc96ef955e9c47f274e4845743b653b13287 100644 (file)
@@ -778,10 +778,10 @@ bool valid_user_group_name_or_id_full(const char *u, bool strict) {
         if (isempty(u))
                 return false;
 
-        if (valid_user_group_name_full(u, strict))
+        if (parse_uid(u, NULL) >= 0)
                 return true;
 
-        return parse_uid(u, NULL) >= 0;
+        return valid_user_group_name_full(u, strict);
 }
 
 bool valid_gecos(const char *d) {
index eb72bac7045b8c5a28806f22ebe655955062a420..1ccc053d3feb97699a643b09e563beeeb81ca0b4 100644 (file)
@@ -1207,7 +1207,7 @@ static int add_pkcs11_key_data(JsonVariant **v, const char *uri) {
 
         pkey = X509_get0_pubkey(cert);
         if (!pkey)
-                return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to exract public key from X.509 certificate.");
+                return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to extract public key from X.509 certificate.");
 
         if (EVP_PKEY_base_id(pkey) != EVP_PKEY_RSA)
                 return log_error_errno(SYNTHETIC_ERRNO(EBADMSG), "X.509 certificate does not refer to RSA key.");
@@ -1338,7 +1338,7 @@ static int acquire_new_password(
                 string_erase(e);
 
                 if (unsetenv("NEWPASSWORD") < 0)
-                        return log_error_errno(errno, "Failed to unse $NEWPASSWORD: %m");
+                        return log_error_errno(errno, "Failed to unset $NEWPASSWORD: %m");
 
                 return 0;
         }
@@ -1376,7 +1376,7 @@ static int acquire_new_password(
                         return 0;
                 }
 
-                log_error("Password didn't mach, try again.");
+                log_error("Password didn't match, try again.");
         }
 }
 
@@ -3148,7 +3148,7 @@ static int parse_argv(int argc, char *argv[]) {
 
                                         r = read_line(f, LONG_LINE_MAX, &line);
                                         if (r < 0)
-                                                return log_error_errno(r, "Faile dto read from '%s': %m", optarg+1);
+                                                return log_error_errno(r, "Faileto read from '%s': %m", optarg+1);
                                         if (r == 0)
                                                 break;
 
index 02a87a5ec5eb8afcdac30e9f1a61cb9a3617dce5..6b4fa58a6f62b1862667b39fb6e582703455f122 100644 (file)
@@ -630,7 +630,7 @@ int bus_home_method_acquire(
         /* This operation might not be something we can executed immediately, hence queue it */
         fd = home_create_fifo(h, please_suspend);
         if (fd < 0)
-                return sd_bus_reply_method_errnof(message, fd, "Failed to allocate fifo for %s: %m", h->user_name);
+                return sd_bus_reply_method_errnof(message, fd, "Failed to allocate FIFO for %s: %m", h->user_name);
 
         o = operation_new(OPERATION_ACQUIRE, message);
         if (!o)
@@ -681,7 +681,7 @@ int bus_home_method_ref(
 
         fd = home_create_fifo(h, please_suspend);
         if (fd < 0)
-                return sd_bus_reply_method_errnof(message, fd, "Failed to allocate fifo for %s: %m", h->user_name);
+                return sd_bus_reply_method_errnof(message, fd, "Failed to allocate FIFO for %s: %m", h->user_name);
 
         return sd_bus_reply_method_return(message, "h", fd);
 }
index f553419c4130f349483d53e0f1af03ea883a30b0..09afbc70c3fe0433bdce9909f4aca763632be032 100644 (file)
@@ -422,7 +422,7 @@ static int home_verify_user_record(Home *h, UserRecord *hr, bool *ret_signed_loc
 
         case -ENOKEY:
                 sd_bus_error_setf(ret_error, BUS_ERROR_BAD_SIGNATURE, "User record %s is not signed by any known key, refusing.", hr->user_name);
-                return log_error_errno(is_signed, "Home %s contians user record that is not signed by any known key, refusing.", hr->user_name);
+                return log_error_errno(is_signed, "Home %s contains user record that is not signed by any known key, refusing.", hr->user_name);
 
         default:
                 assert(is_signed < 0);
@@ -436,7 +436,7 @@ static int convert_worker_errno(Home *h, int e, sd_bus_error *error) {
         switch (e) {
 
         case -EMSGSIZE:
-                return sd_bus_error_setf(error, BUS_ERROR_BAD_HOME_SIZE, "File systems of this type cannot shrinked");
+                return sd_bus_error_setf(error, BUS_ERROR_BAD_HOME_SIZE, "File systems of this type cannot be shrinked");
         case -ETXTBSY:
                 return sd_bus_error_setf(error, BUS_ERROR_BAD_HOME_SIZE, "File systems of this type can only be shrinked offline");
         case -ERANGE:
@@ -1470,7 +1470,7 @@ int home_resize(Home *h, uint64_t disk_size, UserRecord *secret, sd_bus_error *e
 
         if (disk_size == UINT64_MAX || disk_size == h->record->disk_size) {
                 if (h->record->disk_size == UINT64_MAX)
-                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Not disk size to resize to specified.");
+                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "No disk size to resize to specified.");
 
                 c = user_record_ref(h->record); /* Shortcut if size is unspecified or matches the record */
         } else {
@@ -1902,7 +1902,7 @@ static int home_get_disk_status_luks(
                 goto finish;
 
         if (statfs(hd, &sfs) < 0) {
-                log_debug_errno(errno, "Failed  to statfs() %s, ignoring: %m", hd);
+                log_debug_errno(errno, "Failed to statfs() %s, ignoring: %m", hd);
                 goto finish;
         }
 
index a6b30d961f8713fbf920374fe4e9dafbe0fc1ad3..fce85452743590d886a575ca33ea08008dc07ee0 100644 (file)
@@ -584,7 +584,7 @@ static int method_lock_all_homes(sd_bus_message *message, void *userdata, sd_bus
                                 return -ENOMEM;
                 }
 
-                log_info("Automatically locking of home of user %s.", h->user_name);
+                log_info("Automatically locking home of user %s.", h->user_name);
 
                 r = home_schedule_operation(h, o, error);
                 if (r < 0)
index 5d77760f215160855fdd086741710459cb0098c6..c9bfb64e7f62a683cc01adca5b08e325bc4e8872 100644 (file)
@@ -631,7 +631,7 @@ static int manager_add_home_by_image(
                 }
 
                 if (!same) {
-                        log_debug("Found a multiple images for a user '%s', ignoring image '%s'.", user_name, image_path);
+                        log_debug("Found multiple images for user '%s', ignoring image '%s'.", user_name, image_path);
                         return 0;
                 }
         } else {
@@ -768,7 +768,7 @@ static int manager_assess_image(
                 r = stat(path, &st);
         if (r < 0)
                 return log_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_WARNING, errno,
-                                      "Failed to stat directory entry '%s', ignoring: %m", dentry_name);
+                                      "Failed to stat() directory entry '%s', ignoring: %m", dentry_name);
 
         if (S_ISREG(st.st_mode)) {
                 _cleanup_free_ char *n = NULL, *user_name = NULL, *realm = NULL;
@@ -833,7 +833,7 @@ static int manager_assess_image(
                                 if (errno == ENODATA)
                                         log_debug_errno(errno, "Determined %s is not fscrypt encrypted.", path);
                                 else if (ERRNO_IS_NOT_SUPPORTED(errno))
-                                        log_debug_errno(errno, "Determined %s is not fscrypt encrypted because kernel or file system don't support it.", path);
+                                        log_debug_errno(errno, "Determined %s is not fscrypt encrypted because kernel or file system doesn't support it.", path);
                                 else
                                         log_debug_errno(errno, "FS_IOC_GET_ENCRYPTION_POLICY failed with unexpected error code on %s, ignoring: %m", path);
 
@@ -1307,7 +1307,7 @@ static int manager_generate_key_pair(Manager *m) {
         /* Write out public key (note that we only do that as a help to the user, we don't make use of this ever */
         r = fopen_temporary("/var/lib/systemd/home/local.public", &fpublic, &temp_public);
         if (r < 0)
-                return log_error_errno(errno, "Failed ot open key file for writing: %m");
+                return log_error_errno(errno, "Failed to open key file for writing: %m");
 
         if (PEM_write_PUBKEY(fpublic, m->private_key) <= 0)
                 return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to write public key.");
@@ -1321,7 +1321,7 @@ static int manager_generate_key_pair(Manager *m) {
         /* Write out the private key (this actually writes out both private and public, OpenSSL is confusing) */
         r = fopen_temporary("/var/lib/systemd/home/local.private", &fprivate, &temp_private);
         if (r < 0)
-                return log_error_errno(errno, "Failed ot open key file for writing: %m");
+                return log_error_errno(errno, "Failed to open key file for writing: %m");
 
         if (PEM_write_PrivateKey(fprivate, m->private_key, NULL, NULL, 0, NULL, 0) <= 0)
                 return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to write private key pair.");
@@ -1660,7 +1660,7 @@ int manager_enqueue_gc(Manager *m, Home *focus) {
 
         r = sd_event_add_defer(m->event, &m->deferred_gc_event_source, on_deferred_gc, m);
         if (r < 0)
-                return log_error_errno(r, "Failed to allocate gc event source: %m");
+                return log_error_errno(r, "Failed to allocate GC event source: %m");
 
         r = sd_event_source_set_priority(m->deferred_gc_event_source, SD_EVENT_PRIORITY_IDLE);
         if (r < 0)
index 80dc555cd0e66f38602a2657df17ed430d9b0450..156a25ec816138908ce57bea6fc7825034eb758e 100644 (file)
@@ -47,7 +47,7 @@ static Operation *operation_free(Operation *o) {
                                 r = sd_bus_reply_method_errnof(o->message, o->ret, "Failed to execute operation: %m");
                 }
                 if (r < 0)
-                        log_warning_errno(r, "Failed ot reply to %s method call, ignoring: %m", sd_bus_message_get_member(o->message));
+                        log_warning_errno(r, "Failed to reply to %s method call, ignoring: %m", sd_bus_message_get_member(o->message));
         }
 
         sd_bus_message_unref(o->message);
index 0cd5902bff6a782e6f430b7b53b56d4536b0ef4d..d731d0d64f0a43acf6517600335f43993c8c86ad 100644 (file)
@@ -616,7 +616,7 @@ static int crypt_device_to_evp_cipher(struct crypt_device *cd, const EVP_CIPHER
         /* Verify that our key length calculations match what OpenSSL thinks */
         r = EVP_CIPHER_key_length(cc);
         if (r < 0 || (uint64_t) r != key_size)
-                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Key size of selected cipher doesn't meet out expectations.");
+                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Key size of selected cipher doesn't meet our expectations.");
 
         *ret = cc;
         return 0;
@@ -787,7 +787,7 @@ static int format_luks_token_text(
 
         r = json_variant_format(hr->json, 0, &text);
         if (r < 0)
-                return log_error_errno(r,"Failed to format user record for LUKS: %m");
+                return log_error_errno(r, "Failed to format user record for LUKS: %m");
 
         text_length = strlen(text);
         encrypted_size = text_length + 2*key_size - 1;
@@ -1263,7 +1263,7 @@ int home_activate_luks(
 
         r = dm_deferred_remove(setup.dm_name);
         if (r < 0)
-                log_warning_errno(r, "Failed to relinquish dm device, ignoring: %m");
+                log_warning_errno(r, "Failed to relinquish DM device, ignoring: %m");
 
         setup.undo_dm = false;
 
@@ -1328,7 +1328,7 @@ static int run_mkfs(
         if (r < 0)
                 return log_error_errno(r, "Failed to check if mkfs for file system %s exists: %m", fstype);
         if (r == 0)
-                return log_error_errno(SYNTHETIC_ERRNO(EPROTONOSUPPORT), "Nt mkfs for file system %s installed.", fstype);
+                return log_error_errno(SYNTHETIC_ERRNO(EPROTONOSUPPORT), "No mkfs for file system %s installed.", fstype);
 
         r = safe_fork("(mkfs)", FORK_RESET_SIGNALS|FORK_RLIMIT_NOFILE_SAFE|FORK_DEATHSIG|FORK_LOG|FORK_WAIT|FORK_STDOUT_TO_STDERR, NULL);
         if (r < 0)
@@ -1584,7 +1584,7 @@ static int make_partition_table(
 
         r = fdisk_create_disklabel(c, "gpt");
         if (r < 0)
-                return log_error_errno(r, "Failed to create gpt disk label: %m");
+                return log_error_errno(r, "Failed to create GPT disk label: %m");
 
         p = fdisk_new_partition();
         if (!p)
@@ -2212,7 +2212,7 @@ static int ext4_offline_resize_fs(HomeSetup *setup, uint64_t new_size, bool disc
                 re_mount = true;
         }
 
-        log_info("Temporarary unmounting of file system completed.");
+        log_info("Temporary unmounting of file system completed.");
 
         /* resize2fs requires that the file system is force checked first, do so. */
         r = safe_fork("(e2fsck)", FORK_RESET_SIGNALS|FORK_RLIMIT_NOFILE_SAFE|FORK_DEATHSIG|FORK_LOG|FORK_STDOUT_TO_STDERR, &fsck_pid);
@@ -2426,7 +2426,7 @@ static int apply_resize_partition(int fd, sd_id128_t disk_uuids, struct fdisk_ta
         if (n < 0)
                 return log_error_errno(errno, "Failed to wipe partition table: %m");
         if (n != 1024)
-                return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short write while whiping partition table.");
+                return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short write while wiping partition table.");
 
         c = fdisk_new_context();
         if (!c)
@@ -2536,7 +2536,7 @@ int home_resize_luks(
         } else {
                 r = stat_verify_regular(&st);
                 if (r < 0)
-                        return log_error_errno(r, "Image file %s is not a block device nor regular: %m", ip);
+                        return log_error_errno(r, "Image %s is not a block device nor regular file: %m", ip);
 
                 old_image_size = st.st_size;
 
index 941ba23b3c30f138e3e3ed465dfd15836d44eef2..915bc0e57ec8880af77e029bfe9d866fffa12b41 100644 (file)
@@ -53,7 +53,7 @@ int pkcs11_callback(
                 if (rv != CKR_OK)
                         return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to log into security token '%s': %s", token_label, p11_kit_strerror(rv));
 
-                log_info("Successully logged into security token '%s' via protected authentication path.", token_label);
+                log_info("Successfully logged into security token '%s' via protected authentication path.", token_label);
                 goto decrypt;
         }
 
index 58fa0870973da2489b3fb5e22b66b97b612fd0aa..3fccab095c588244c862bd7d67a3f123af065ee1 100644 (file)
@@ -378,7 +378,7 @@ int home_load_embedded_identity(
                 return r;
 
         if (!user_record_compatible(h, embedded_home))
-                return log_error_errno(SYNTHETIC_ERRNO(EREMCHG), "Hmbedded home record not compatible with host record, refusing.");
+                return log_error_errno(SYNTHETIC_ERRNO(EREMCHG), "Embedded home record not compatible with host record, refusing.");
 
         /* Insist that credentials the user supplies also unlocks any embedded records. */
         r = user_record_authenticate(embedded_home, h, pkcs11_decrypted_passwords);
@@ -981,7 +981,7 @@ static int home_remove(UserRecord *h) {
 
                 if (stat(ip, &st) < 0) {
                         if (errno != -ENOENT)
-                                return log_error_errno(errno, "Failed to stat %s: %m", ip);
+                                return log_error_errno(errno, "Failed to stat() %s: %m", ip);
 
                 } else {
                         if (S_ISREG(st.st_mode)) {
index 67aff9350fa45ce9ca537723cccf1b1a40b46264..440ed85e2c2e0a9accdbe6e89ca0dd1fdd6ceae2 100644 (file)
@@ -41,7 +41,7 @@ static int parse_argv(
 
                         k = parse_boolean(v);
                         if (k < 0)
-                                pam_syslog(handle, LOG_WARNING, "Failed to parse suspend-please= argument, ignoring: %s", v);
+                                pam_syslog(handle, LOG_WARNING, "Failed to parse suspend= argument, ignoring: %s", v);
                         else if (please_suspend)
                                 *please_suspend = k;
 
@@ -95,7 +95,7 @@ static int acquire_user_record(
         r = pam_get_data(handle, "systemd-user-record-is-homed", &b);
         if (!IN_SET(r, PAM_SUCCESS, PAM_NO_MODULE_DATA)) {
                 /* Failure */
-                pam_syslog(handle, LOG_ERR, "Failed to get PAM user record is homed flag: %s", pam_strerror(handle, r));
+                pam_syslog(handle, LOG_ERR, "Failed to get PAM user-record-is-homed flag: %s", pam_strerror(handle, r));
                 return r;
         } else if (b == NULL)
                 /* Nothing cached yet, need to acquire fresh */
@@ -200,7 +200,7 @@ user_unknown:
         /* Cache this, so that we don't check again */
         r = pam_set_data(handle, "systemd-user-record-is-homed", USER_RECORD_IS_OTHER, NULL);
         if (r != PAM_SUCCESS)
-                pam_syslog(handle, LOG_ERR, "Failed to set PAM user record is homed flag, ignoring: %s", pam_strerror(handle, r));
+                pam_syslog(handle, LOG_ERR, "Failed to set PAM user-record-is-homed flag, ignoring: %s", pam_strerror(handle, r));
 
         return PAM_USER_UNKNOWN;
 }
@@ -214,7 +214,7 @@ static int release_user_record(pam_handle_t *handle) {
 
         k = pam_set_data(handle, "systemd-user-record-is-homed", NULL, NULL);
         if (k != PAM_SUCCESS)
-                pam_syslog(handle, LOG_ERR, "Failed to release PAM user record is homed flag: %s", pam_strerror(handle, k));
+                pam_syslog(handle, LOG_ERR, "Failed to release PAM user-record-is-homed flag: %s", pam_strerror(handle, k));
 
         return IN_SET(r, PAM_SUCCESS, PAM_NO_MODULE_DATA) ? k : r;
 }
index f2342b28f863420942419dd03eecb45661da43da..5863a229b80850a557a5a88be139fb1ab8d2b457 100644 (file)
@@ -73,7 +73,7 @@ int quality_check_password(
 
         r = pwquality_read_config(pwq, NULL, &auxerror);
         if (r < 0)
-                log_warning_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to read libpwquality configuation, ignoring: %s",
+                log_warning_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to read libpwquality configuration, ignoring: %s",
                                   pwquality_strerror(buf, sizeof(buf), r, auxerror));
 
         pwquality_maybe_disable_dictionary(pwq);
@@ -143,7 +143,7 @@ int suggest_passwords(void) {
 
         r = pwquality_read_config(pwq, NULL, &auxerror);
         if (r < 0)
-                log_warning_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to read libpwquality configuation, ignoring: %s",
+                log_warning_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to read libpwquality configuration, ignoring: %s",
                                   pwquality_strerror(buf, sizeof(buf), r, auxerror));
 
         pwquality_maybe_disable_dictionary(pwq);
index 82553e79cadfb8a4ccd678a3d7f6b274e201506c..a59ae4767e2b6acd9256b05c600b7cfa0f4ad94c 100644 (file)
@@ -27,6 +27,7 @@
 #include "random-util.h"
 #include "string-util.h"
 #include "strv.h"
+#include "web-util.h"
 
 #define MAX_CLIENT_ID_LEN (sizeof(uint32_t) + MAX_DUID_LEN)  /* Arbitrary limit */
 #define MAX_MAC_ADDR_LEN CONST_MAX(INFINIBAND_ALEN, ETH_ALEN)
@@ -83,6 +84,7 @@ struct sd_dhcp_client {
         size_t client_id_len;
         char *hostname;
         char *vendor_class_identifier;
+        char *mudurl;
         char **user_class;
         uint32_t mtu;
         uint32_t xid;
@@ -493,6 +495,18 @@ int sd_dhcp_client_set_vendor_class_identifier(
         return free_and_strdup(&client->vendor_class_identifier, vci);
 }
 
+int sd_dhcp_client_set_mud_url(
+                sd_dhcp_client *client,
+                const char *mudurl) {
+
+        assert_return(client, -EINVAL);
+        assert_return(mudurl, -EINVAL);
+        assert_return(strlen(mudurl) <= 255, -EINVAL);
+        assert_return(http_url_is_valid(mudurl), -EINVAL);
+
+        return free_and_strdup(&client->mudurl, mudurl);
+}
+
 int sd_dhcp_client_set_user_class(
                 sd_dhcp_client *client,
                 const char* const* user_class) {
@@ -895,6 +909,15 @@ static int client_send_discover(sd_dhcp_client *client) {
                         return r;
         }
 
+        if (client->mudurl) {
+                r = dhcp_option_append(&discover->dhcp, optlen, &optoffset, 0,
+                                       SD_DHCP_OPTION_MUD_URL,
+                                       strlen(client->mudurl),
+                                       client->mudurl);
+                if (r < 0)
+                        return r;
+        }
+
         if (client->user_class) {
                 r = dhcp_option_append(&discover->dhcp, optlen, &optoffset, 0,
                                        SD_DHCP_OPTION_USER_CLASS,
@@ -1032,6 +1055,16 @@ static int client_send_request(sd_dhcp_client *client) {
                         return r;
         }
 
+        if (client->mudurl) {
+                r = dhcp_option_append(&request->dhcp, optlen, &optoffset, 0,
+                                       SD_DHCP_OPTION_MUD_URL,
+                                       strlen(client->mudurl),
+                                       client->mudurl);
+                if (r < 0)
+                        return r;
+        }
+
+
         r = dhcp_option_append(&request->dhcp, optlen, &optoffset, 0,
                                SD_DHCP_OPTION_END, 0, NULL);
         if (r < 0)
@@ -2101,6 +2134,7 @@ static sd_dhcp_client *dhcp_client_free(sd_dhcp_client *client) {
         free(client->req_opts);
         free(client->hostname);
         free(client->vendor_class_identifier);
+        free(client->mudurl);
         client->user_class = strv_free(client->user_class);
         ordered_hashmap_free(client->extra_options);
         ordered_hashmap_free(client->vendor_options);
index 83fb25264ab5fdbd07b57bd75ec8c21e43bb905e..48e5c15fd09c1aead15d6c51d9a6658bad6559f6 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/if.h>
 #include <linux/if_arp.h>
 
+#include "escape.h"
 #include "alloc-util.h"
 #include "dhcp-client-internal.h"
 #include "hostname-util.h"
@@ -17,6 +18,7 @@
 #include "string-table.h"
 #include "string-util.h"
 #include "sysctl-util.h"
+#include "web-util.h"
 
 static int dhcp_remove_routes(Link *link, sd_dhcp_lease *lease, const struct in_addr *address, bool remove_all);
 static int dhcp_remove_router(Link *link, sd_dhcp_lease *lease, const struct in_addr *address, bool remove_all);
@@ -1456,6 +1458,13 @@ int dhcp4_configure(Link *link) {
                         return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set vendor class identifier: %m");
         }
 
+       if (link->network->dhcp_mudurl) {
+                r = sd_dhcp_client_set_mud_url(link->dhcp_client,
+                                               link->network->dhcp_mudurl);
+                if (r < 0)
+                        return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set MUD URL: %m");
+        }
+
         if (link->network->dhcp_user_class) {
                 r = sd_dhcp_client_set_user_class(link->dhcp_client, (const char **) link->network->dhcp_user_class);
                 if (r < 0)
@@ -1744,6 +1753,48 @@ int config_parse_dhcp_ip_service_type(
         return 0;
 }
 
+int config_parse_dhcp_mud_url(
+                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_free_ char *unescaped = NULL;
+        Network *network = data;
+        int r;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+
+        if (isempty(rvalue)) {
+                network->dhcp_mudurl = mfree(network->dhcp_mudurl);
+                return 0;
+        }
+
+        r = cunescape(rvalue, 0, &unescaped);
+        if (r < 0) {
+                log_syntax(unit, LOG_ERR, filename, line, r,
+                           "Failed to Failed to unescape MUD URL, ignoring: %s", rvalue);
+                return 0;
+        }
+
+        if (!http_url_is_valid(unescaped) || strlen(unescaped) > 255) {
+                log_syntax(unit, LOG_ERR, filename, line, 0,
+                           "Failed to parse MUD URL '%s', ignoring: %m", rvalue);
+
+                return 0;
+        }
+
+        return free_and_strdup_warn(&network->dhcp_mudurl, unescaped);
+}
+
 static const char* const dhcp_client_identifier_table[_DHCP_CLIENT_ID_MAX] = {
         [DHCP_CLIENT_ID_MAC] = "mac",
         [DHCP_CLIENT_ID_DUID] = "duid",
index 95fa5ee4b5bce81c8e42c306658cbc186b6ffee2..b0c30b598ce9ce8cc1962856c289462dbcf3b1e1 100644 (file)
@@ -28,3 +28,4 @@ CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_max_attempts);
 CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_user_class);
 CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_request_options);
 CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_ip_service_type);
+CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_mud_url);
index 04d411c4adbc9e9577256824bb345adea5c1d785..18ba23bfc8bcb6af4497bfe8447c94bd8295396f 100644 (file)
@@ -170,6 +170,7 @@ DHCPv4.SendHostname,                         config_parse_bool,
 DHCPv4.Hostname,                             config_parse_hostname,                                    0,                             offsetof(Network, dhcp_hostname)
 DHCPv4.RequestBroadcast,                     config_parse_bool,                                        0,                             offsetof(Network, dhcp_broadcast)
 DHCPv4.VendorClassIdentifier,                config_parse_string,                                      0,                             offsetof(Network, dhcp_vendor_class_identifier)
+DHCPv4.MUDURL,                               config_parse_dhcp_mud_url,                                0,                             0
 DHCPv4.MaxAttempts,                          config_parse_dhcp_max_attempts,                           0,                             0
 DHCPv4.UserClass,                            config_parse_dhcp_user_class,                             0,                             offsetof(Network, dhcp_user_class)
 DHCPv4.DUIDType,                             config_parse_duid_type,                                   0,                             offsetof(Network, duid)
index a71fac6790be5bc454634e0e7c90e5212f031ca6..6afe29d53bf911c1e41b7cf3b05832480e07b7e9 100644 (file)
@@ -640,6 +640,7 @@ static Network *network_free(Network *network) {
 
         free(network->description);
         free(network->dhcp_vendor_class_identifier);
+        free(network->dhcp_mudurl);
         strv_free(network->dhcp_user_class);
         free(network->dhcp_hostname);
         set_free(network->dhcp_black_listed_ip);
index fe2878978470e5fe6e7b3f5ae0a8dc232d4ee5f1..66ee01d7f3fbaac34461fb0ce5d3628238807956 100644 (file)
@@ -91,6 +91,7 @@ struct Network {
         AddressFamily dhcp;
         DHCPClientIdentifier dhcp_client_identifier;
         char *dhcp_vendor_class_identifier;
+        char *dhcp_mudurl;
         char **dhcp_user_class;
         char *dhcp_hostname;
         uint64_t dhcp_max_attempts;
index dc2fd02afe6cf44132e6e15756c37fa777aae67e..da2aa6c73b75cff403f0f7b494ebe0827fbcd1e9 100644 (file)
@@ -92,6 +92,7 @@ enum {
         SD_DHCP_OPTION_DOMAIN_SEARCH_LIST          = 119,
         SD_DHCP_OPTION_SIP_SERVER                  = 120,
         SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE      = 121,
+        SD_DHCP_OPTION_MUD_URL                     = 161,
         SD_DHCP_OPTION_PRIVATE_BASE                = 224,
        /* Windows 10 option to send when Anonymize=true */
         SD_DHCP_OPTION_PRIVATE_CLASSLESS_STATIC_ROUTE = 249,
@@ -171,6 +172,9 @@ int sd_dhcp_client_set_hostname(
 int sd_dhcp_client_set_vendor_class_identifier(
                 sd_dhcp_client *client,
                 const char *vci);
+int sd_dhcp_client_set_mud_url(
+                sd_dhcp_client *client,
+                const char *mudurl);
 int sd_dhcp_client_set_user_class(
                 sd_dhcp_client *client,
                 const char* const *user_class);
index df11b5b984ec5b1633e9da438a08903223af4db4..3bc5ecc1d0393d47ceffac5e34c8393c181bd617 100644 (file)
@@ -763,7 +763,7 @@ static int run(int argc, char *argv[]) {
                                 if (parent <= 1)
                                         return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Parent already died?");
 
-                                if (kill(parent, SIGUSR1) < 0)
+                                if (kill(parent, SIGUSR2) < 0)
                                         return log_error_errno(errno, "Failed to kill our own parent.");
                         }
                 }
index e1af20694171d73a05d5bdebabb756b7e6f7cef9..01b1b50ff6a26bea7eb25f122613590cf935ea24 100644 (file)
@@ -102,6 +102,7 @@ IPServiceType=
 SendOption=
 SendVendorOption=
 SendDecline=
+MUDURL=
 RouteMTUBytes=
 [DHCPv6]
 UseNTP=
index 7cf98e6fa66ce2c277eb2b9caef4c8702be0d2b0..6490f48a15691575c9a04d2a8d830f80798a37a7 100644 (file)
@@ -10,7 +10,7 @@
 [Unit]
 Description=Home Area Manager
 Documentation=man:systemd-homed.service(8)
-RequiresMountsFor=/home
+After=home.mount
 
 [Service]
 BusName=org.freedesktop.home1