Compare commits
14 Commits
f5d9daaea3
...
c083264115
Author | SHA1 | Date |
---|---|---|
Zbigniew Jędrzejewski-Szmek | c083264115 | |
Lennart Poettering | 9e76a88faf | |
Daan De Meyer | 47203ed085 | |
Daan De Meyer | e3e5a6eebd | |
Zbigniew Jędrzejewski-Szmek | b1b9e829c2 | |
Vito Caputo | 8e06af804b | |
Vito Caputo | b46c3e4913 | |
Vito Caputo | 9f81a592c1 | |
Vito Caputo | f61457b0fe | |
Vito Caputo | 4fa744a35c | |
Vito Caputo | 3ebbb6cb39 | |
Vito Caputo | 3aeea37d88 | |
Susant Sahani | 7b8d23a9bb | |
Susant Sahani | d11d4a6459 |
|
@ -289,7 +289,9 @@ manpages = [
|
||||||
'sd_bus_message_get_interface',
|
'sd_bus_message_get_interface',
|
||||||
'sd_bus_message_get_member',
|
'sd_bus_message_get_member',
|
||||||
'sd_bus_message_get_path',
|
'sd_bus_message_get_path',
|
||||||
|
'sd_bus_message_get_priority',
|
||||||
'sd_bus_message_get_sender',
|
'sd_bus_message_get_sender',
|
||||||
|
'sd_bus_message_set_priority',
|
||||||
'sd_bus_message_set_sender'],
|
'sd_bus_message_set_sender'],
|
||||||
''],
|
''],
|
||||||
['sd_bus_message_set_expect_reply',
|
['sd_bus_message_set_expect_reply',
|
||||||
|
|
|
@ -67,6 +67,8 @@
|
||||||
<citerefentry><refentrytitle>sd_bus_message_dump</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_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_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_signature</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||||
<citerefentry><refentrytitle>sd_bus_message_get_type</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>,
|
<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_rewind</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||||
<citerefentry><refentrytitle>sd_bus_message_seal</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_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_set_expect_reply</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||||
<citerefentry><refentrytitle>sd_bus_message_skip</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>,
|
<citerefentry><refentrytitle>sd_bus_message_verify_type</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||||
|
|
|
@ -68,16 +68,14 @@
|
||||||
#define SD_INFO "<6>" /* informational */
|
#define SD_INFO "<6>" /* informational */
|
||||||
#define SD_DEBUG "<7>" /* debug-level messages */</programlisting>
|
#define SD_DEBUG "<7>" /* debug-level messages */</programlisting>
|
||||||
|
|
||||||
<para>These prefixes are intended to be used in conjunction with
|
<para>These prefixes are intended to be used in conjunction with stderr-based logging (or stdout-based
|
||||||
stderr-based logging as implemented by systemd. If a systemd
|
logging) as implemented by systemd. If a systemd service definition file is configured with
|
||||||
service definition file is configured with
|
<varname>StandardError=journal</varname>, <varname>StandardError=syslog</varname> or
|
||||||
<varname>StandardError=journal</varname>,
|
<varname>StandardError=kmsg</varname> (and similar with <varname>StandardOutput=</varname>), these
|
||||||
<varname>StandardError=syslog</varname> or
|
prefixes can be used to encode a log level in lines printed. This is similar to the kernel
|
||||||
<varname>StandardError=kmsg</varname>, these prefixes can be used
|
<function>printk()</function>-style logging. See
|
||||||
to encode a log level in lines printed. This is similar to the
|
<citerefentry><refentrytitle>klogctl</refentrytitle><manvolnum>2</manvolnum></citerefentry> for more
|
||||||
kernel <function>printk()</function>-style logging. See
|
information.</para>
|
||||||
<citerefentry><refentrytitle>klogctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
|
|
||||||
for more information.</para>
|
|
||||||
|
|
||||||
<para>The log levels are identical to
|
<para>The log levels are identical to
|
||||||
<citerefentry project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>'s
|
<citerefentry project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>'s
|
||||||
|
|
|
@ -52,34 +52,39 @@
|
||||||
<title>Description</title>
|
<title>Description</title>
|
||||||
|
|
||||||
<para><function>sd_bus_call()</function> takes a complete bus message object and calls the
|
<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>usec</parameter> indicates the timeout in microseconds. If
|
||||||
<parameter>ret_error</parameter> is not <constant>NULL</constant> and
|
<parameter>ret_error</parameter> is not <constant>NULL</constant> and
|
||||||
<function>sd_bus_call()</function> returns an error, <parameter>ret_error</parameter> is
|
<function>sd_bus_call()</function> fails (either because of an internal error or because it
|
||||||
initialized to an instance of <structname>sd_bus_error</structname> describing the error.</para>
|
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
|
<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
|
works asynchronously. The <parameter>callback</parameter> indicates the function to call when
|
||||||
when the event source is triggered. The <parameter>userdata</parameter> pointer will be passed
|
the response arrives. The <parameter>userdata</parameter> pointer will be passed to the callback
|
||||||
to the callback function, and may be chosen freely by the caller. If <parameter>slot</parameter>
|
function, and may be chosen freely by the caller. If <parameter>slot</parameter> is not
|
||||||
is not <constant>NULL</constant> and <function>sd_bus_call_async()</function> succeeds,
|
<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
|
<parameter>slot</parameter> is set to a slot object which can be used to cancel the method call
|
||||||
at a later time using
|
at a later time using
|
||||||
<citerefentry><refentrytitle>sd_bus_slot_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
|
<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
|
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
|
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>
|
<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
|
for details. <parameter>callback</parameter> is called when a reply arrives with the reply,
|
||||||
and receives the response, <parameter>userdata</parameter> and a
|
<parameter>userdata</parameter> and an <structname>sd_bus_error</structname> output
|
||||||
<structname>sd_bus_error</structname> object as its arguments. The
|
parameter as its arguments. Unlike <function>sd_bus_call()</function>, the
|
||||||
<structname>sd_bus_error</structname> object is unused here and should be ignored. If
|
<structname>sd_bus_error</structname> output parameter passed to the callback will be empty. To
|
||||||
<parameter>callback</parameter> returns a non-negative integer when called, a debug message is
|
determine whether the method call succeeded, use
|
||||||
logged along with details about the response.</para>
|
|
||||||
|
|
||||||
<para>To determine whether the method call succeeded, use
|
|
||||||
<citerefentry><refentrytitle>sd_bus_message_is_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
<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
|
on the reply message passed to the callback instead. If the callback returns zero and the
|
||||||
<function>sd_bus_call_async()</function>.</para>
|
<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
|
<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>.
|
<citerefentry><refentrytitle>sd_bus_get_method_call_timeout</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
<refname>sd_bus_message_get_path</refname>
|
<refname>sd_bus_message_get_path</refname>
|
||||||
<refname>sd_bus_message_get_interface</refname>
|
<refname>sd_bus_message_get_interface</refname>
|
||||||
<refname>sd_bus_message_get_member</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_set_sender</refname>
|
||||||
<refname>sd_bus_message_get_sender</refname>
|
<refname>sd_bus_message_get_sender</refname>
|
||||||
|
|
||||||
|
@ -55,6 +57,18 @@
|
||||||
<paramdef>sd_bus_message *<parameter>message</parameter></paramdef>
|
<paramdef>sd_bus_message *<parameter>message</parameter></paramdef>
|
||||||
</funcprototype>
|
</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>
|
<funcprototype>
|
||||||
<funcdef>int <function>sd_bus_message_set_sender</function></funcdef>
|
<funcdef>int <function>sd_bus_message_set_sender</function></funcdef>
|
||||||
<paramdef>sd_bus_message *<parameter>message</parameter></paramdef>
|
<paramdef>sd_bus_message *<parameter>message</parameter></paramdef>
|
||||||
|
@ -82,11 +96,13 @@
|
||||||
member fields from <parameter>message</parameter> header. The return value will be
|
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
|
<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
|
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>
|
<citerefentry><refentrytitle>sd_bus_message_new_method_call</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
|
||||||
and
|
|
||||||
<citerefentry><refentrytitle>sd_bus_message_set_destination</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
<citerefentry><refentrytitle>sd_bus_message_set_destination</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||||
for more discussion of those values.</para>
|
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
|
<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
|
object. The specified name must be a valid unique or well-known service name. This function is useful only for
|
||||||
|
@ -123,9 +139,10 @@
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><constant>-EPERM</constant></term>
|
<term><constant>-EPERM</constant></term>
|
||||||
|
|
||||||
<listitem><para>For <function>sd_bus_message_set_destination</function> or
|
<listitem><para>For <function>sd_bus_message_set_destination()</function>,
|
||||||
<function>sd_bus_message_set_sender</function>, the message is already
|
<function>sd_bus_message_set_sender()</function> and
|
||||||
sealed.</para></listitem>
|
<function>sd_bus_message_set_priority()</function>, the message is already sealed.</para>
|
||||||
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
|
|
@ -1430,6 +1430,18 @@
|
||||||
sent even if this is set to true.</para>
|
sent even if this is set to true.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</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>
|
<varlistentry>
|
||||||
<term><varname>UseHostname=</varname></term>
|
<term><varname>UseHostname=</varname></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "copy.h"
|
#include "copy.h"
|
||||||
#include "dirent-util.h"
|
#include "dirent-util.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
|
#include "fileio.h"
|
||||||
#include "fs-util.h"
|
#include "fs-util.h"
|
||||||
#include "io-util.h"
|
#include "io-util.h"
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
|
@ -569,10 +570,9 @@ static int fd_copy_directory(
|
||||||
if (fdf < 0)
|
if (fdf < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
d = fdopendir(fdf);
|
d = take_fdopendir(&fdf);
|
||||||
if (!d)
|
if (!d)
|
||||||
return -errno;
|
return -errno;
|
||||||
fdf = -1;
|
|
||||||
|
|
||||||
exists = false;
|
exists = false;
|
||||||
if (copy_flags & COPY_MERGE_EMPTY) {
|
if (copy_flags & COPY_MERGE_EMPTY) {
|
||||||
|
|
|
@ -54,6 +54,44 @@ int fdopen_unlocked(int fd, const char *options, FILE **ret) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int take_fdopen_unlocked(int *fd, const char *options, FILE **ret) {
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(fd);
|
||||||
|
|
||||||
|
r = fdopen_unlocked(*fd, options, ret);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
*fd = -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE* take_fdopen(int *fd, const char *options) {
|
||||||
|
assert(fd);
|
||||||
|
|
||||||
|
FILE *f = fdopen(*fd, options);
|
||||||
|
if (!f)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
*fd = -1;
|
||||||
|
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
DIR* take_fdopendir(int *dfd) {
|
||||||
|
assert(dfd);
|
||||||
|
|
||||||
|
DIR *d = fdopendir(*dfd);
|
||||||
|
if (!d)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
*dfd = -1;
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
FILE* open_memstream_unlocked(char **ptr, size_t *sizeloc) {
|
FILE* open_memstream_unlocked(char **ptr, size_t *sizeloc) {
|
||||||
FILE *f = open_memstream(ptr, sizeloc);
|
FILE *f = open_memstream(ptr, sizeloc);
|
||||||
if (!f)
|
if (!f)
|
||||||
|
|
|
@ -39,6 +39,9 @@ typedef enum {
|
||||||
|
|
||||||
int fopen_unlocked(const char *path, const char *options, FILE **ret);
|
int fopen_unlocked(const char *path, const char *options, FILE **ret);
|
||||||
int fdopen_unlocked(int fd, const char *options, FILE **ret);
|
int fdopen_unlocked(int fd, const char *options, FILE **ret);
|
||||||
|
int take_fdopen_unlocked(int *fd, const char *options, FILE **ret);
|
||||||
|
FILE* take_fdopen(int *fd, const char *options);
|
||||||
|
DIR* take_fdopendir(int *dfd);
|
||||||
FILE* open_memstream_unlocked(char **ptr, size_t *sizeloc);
|
FILE* open_memstream_unlocked(char **ptr, size_t *sizeloc);
|
||||||
FILE* fmemopen_unlocked(void *buf, size_t size, const char *mode);
|
FILE* fmemopen_unlocked(void *buf, size_t size, const char *mode);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "dirent-util.h"
|
#include "dirent-util.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
|
#include "fileio.h"
|
||||||
#include "fs-util.h"
|
#include "fs-util.h"
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
#include "missing_fs.h"
|
#include "missing_fs.h"
|
||||||
|
@ -77,10 +78,9 @@ int dir_is_empty_at(int dir_fd, const char *path) {
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
d = fdopendir(fd);
|
d = take_fdopendir(&fd);
|
||||||
if (!d)
|
if (!d)
|
||||||
return -errno;
|
return -errno;
|
||||||
fd = -1;
|
|
||||||
|
|
||||||
FOREACH_DIRENT(de, d, return -errno)
|
FOREACH_DIRENT(de, d, return -errno)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -48,14 +48,12 @@ int fopen_temporary(const char *path, FILE **ret_f, char **ret_temp_path) {
|
||||||
/* This assumes that returned FILE object is short-lived and used within the same single-threaded
|
/* This assumes that returned FILE object is short-lived and used within the same single-threaded
|
||||||
* context and never shared externally, hence locking is not necessary. */
|
* context and never shared externally, hence locking is not necessary. */
|
||||||
|
|
||||||
r = fdopen_unlocked(fd, "w", &f);
|
r = take_fdopen_unlocked(&fd, "w", &f);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
(void) unlink(t);
|
(void) unlink(t);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAKE_FD(fd);
|
|
||||||
|
|
||||||
if (ret_f)
|
if (ret_f)
|
||||||
*ret_f = TAKE_PTR(f);
|
*ret_f = TAKE_PTR(f);
|
||||||
|
|
||||||
|
@ -80,18 +78,16 @@ int mkostemp_safe(char *pattern) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int fmkostemp_safe(char *pattern, const char *mode, FILE **ret_f) {
|
int fmkostemp_safe(char *pattern, const char *mode, FILE **ret_f) {
|
||||||
int fd;
|
_cleanup_close_ int fd = -1;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
fd = mkostemp_safe(pattern);
|
fd = mkostemp_safe(pattern);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return fd;
|
return fd;
|
||||||
|
|
||||||
f = fdopen(fd, mode);
|
f = take_fdopen(&fd, mode);
|
||||||
if (!f) {
|
if (!f)
|
||||||
safe_close(fd);
|
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
|
||||||
|
|
||||||
*ret_f = f;
|
*ret_f = f;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -982,8 +982,9 @@ static int install_loader_config(const char *esp_path, sd_id128_t machine_id) {
|
||||||
char machine_string[SD_ID128_STRING_MAX];
|
char machine_string[SD_ID128_STRING_MAX];
|
||||||
_cleanup_(unlink_and_freep) char *t = NULL;
|
_cleanup_(unlink_and_freep) char *t = NULL;
|
||||||
_cleanup_fclose_ FILE *f = NULL;
|
_cleanup_fclose_ FILE *f = NULL;
|
||||||
|
_cleanup_close_ int fd = -1;
|
||||||
const char *p;
|
const char *p;
|
||||||
int r, fd;
|
int r;
|
||||||
|
|
||||||
p = prefix_roota(esp_path, "/loader/loader.conf");
|
p = prefix_roota(esp_path, "/loader/loader.conf");
|
||||||
if (access(p, F_OK) >= 0) /* Silently skip creation if the file already exists (early check) */
|
if (access(p, F_OK) >= 0) /* Silently skip creation if the file already exists (early check) */
|
||||||
|
@ -993,11 +994,9 @@ static int install_loader_config(const char *esp_path, sd_id128_t machine_id) {
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return log_error_errno(fd, "Failed to open \"%s\" for writing: %m", p);
|
return log_error_errno(fd, "Failed to open \"%s\" for writing: %m", p);
|
||||||
|
|
||||||
f = fdopen(fd, "w");
|
f = take_fdopen(&fd, "w");
|
||||||
if (!f) {
|
if (!f)
|
||||||
safe_close(fd);
|
|
||||||
return log_oom();
|
return log_oom();
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(f, "#timeout 3\n"
|
fprintf(f, "#timeout 3\n"
|
||||||
"#console-mode keep\n"
|
"#console-mode keep\n"
|
||||||
|
|
|
@ -3107,7 +3107,7 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int manager_open_serialization(Manager *m, FILE **_f) {
|
int manager_open_serialization(Manager *m, FILE **_f) {
|
||||||
int fd;
|
_cleanup_close_ int fd = -1;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
assert(_f);
|
assert(_f);
|
||||||
|
@ -3116,11 +3116,9 @@ int manager_open_serialization(Manager *m, FILE **_f) {
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return fd;
|
return fd;
|
||||||
|
|
||||||
f = fdopen(fd, "w+");
|
f = take_fdopen(&fd, "w+");
|
||||||
if (!f) {
|
if (!f)
|
||||||
safe_close(fd);
|
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
|
||||||
|
|
||||||
*_f = f;
|
*_f = f;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -560,7 +560,7 @@ static int compose_open_fds(pid_t pid, char **open_fds) {
|
||||||
FOREACH_DIRENT(dent, proc_fd_dir, return -errno) {
|
FOREACH_DIRENT(dent, proc_fd_dir, return -errno) {
|
||||||
_cleanup_fclose_ FILE *fdinfo = NULL;
|
_cleanup_fclose_ FILE *fdinfo = NULL;
|
||||||
_cleanup_free_ char *fdname = NULL;
|
_cleanup_free_ char *fdname = NULL;
|
||||||
int fd;
|
_cleanup_close_ int fd = -1;
|
||||||
|
|
||||||
r = readlinkat_malloc(dirfd(proc_fd_dir), dent->d_name, &fdname);
|
r = readlinkat_malloc(dirfd(proc_fd_dir), dent->d_name, &fdname);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -574,11 +574,9 @@ static int compose_open_fds(pid_t pid, char **open_fds) {
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
fdinfo = fdopen(fd, "r");
|
fdinfo = take_fdopen(&fd, "r");
|
||||||
if (!fdinfo) {
|
if (!fdinfo)
|
||||||
safe_close(fd);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
_cleanup_free_ char *line = NULL;
|
_cleanup_free_ char *line = NULL;
|
||||||
|
|
|
@ -360,12 +360,10 @@ static int home_parse_worker_stdout(int _fd, UserRecord **ret) {
|
||||||
if (lseek(fd, SEEK_SET, 0) == (off_t) -1)
|
if (lseek(fd, SEEK_SET, 0) == (off_t) -1)
|
||||||
return log_error_errno(errno, "Failed to seek to beginning of memfd: %m");
|
return log_error_errno(errno, "Failed to seek to beginning of memfd: %m");
|
||||||
|
|
||||||
f = fdopen(fd, "r");
|
f = take_fdopen(&fd, "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
return log_error_errno(errno, "Failed to reopen memfd: %m");
|
return log_error_errno(errno, "Failed to reopen memfd: %m");
|
||||||
|
|
||||||
TAKE_FD(fd);
|
|
||||||
|
|
||||||
if (DEBUG_LOGGING) {
|
if (DEBUG_LOGGING) {
|
||||||
_cleanup_free_ char *text = NULL;
|
_cleanup_free_ char *text = NULL;
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,8 @@ int home_create_cifs(UserRecord *h, UserRecord **ret_home) {
|
||||||
_cleanup_(home_setup_undo) HomeSetup setup = HOME_SETUP_INIT;
|
_cleanup_(home_setup_undo) HomeSetup setup = HOME_SETUP_INIT;
|
||||||
_cleanup_(user_record_unrefp) UserRecord *new_home = NULL;
|
_cleanup_(user_record_unrefp) UserRecord *new_home = NULL;
|
||||||
_cleanup_(closedirp) DIR *d = NULL;
|
_cleanup_(closedirp) DIR *d = NULL;
|
||||||
int r, copy;
|
_cleanup_close_ int copy = -1;
|
||||||
|
int r;
|
||||||
|
|
||||||
assert(h);
|
assert(h);
|
||||||
assert(user_record_storage(h) == USER_CIFS);
|
assert(user_record_storage(h) == USER_CIFS);
|
||||||
|
@ -166,11 +167,9 @@ int home_create_cifs(UserRecord *h, UserRecord **ret_home) {
|
||||||
if (copy < 0)
|
if (copy < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
d = fdopendir(copy);
|
d = take_fdopendir(©);
|
||||||
if (!d) {
|
if (!d)
|
||||||
safe_close(copy);
|
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (readdir_no_dot(d))
|
if (readdir_no_dot(d))
|
||||||
|
|
|
@ -38,7 +38,6 @@ int user_record_authenticate(
|
||||||
|
|
||||||
bool need_password = false, need_token = false, need_pin = false, need_protected_authentication_path_permitted = false,
|
bool need_password = false, need_token = false, need_pin = false, need_protected_authentication_path_permitted = false,
|
||||||
pin_locked = false, pin_incorrect = false, pin_incorrect_few_tries_left = false, pin_incorrect_one_try_left = false;
|
pin_locked = false, pin_incorrect = false, pin_incorrect_few_tries_left = false, pin_incorrect_one_try_left = false;
|
||||||
size_t n;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(h);
|
assert(h);
|
||||||
|
@ -70,7 +69,7 @@ int user_record_authenticate(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Second, let's see if any of the PKCS#11 security tokens are plugged in and help us */
|
/* Second, let's see if any of the PKCS#11 security tokens are plugged in and help us */
|
||||||
for (n = 0; n < h->n_pkcs11_encrypted_key; n++) {
|
for (size_t n = 0; n < h->n_pkcs11_encrypted_key; n++) {
|
||||||
#if HAVE_P11KIT
|
#if HAVE_P11KIT
|
||||||
_cleanup_(pkcs11_callback_data_release) struct pkcs11_callback_data data = {
|
_cleanup_(pkcs11_callback_data_release) struct pkcs11_callback_data data = {
|
||||||
.user_record = h,
|
.user_record = h,
|
||||||
|
@ -280,12 +279,10 @@ static int read_identity_file(int root_fd, JsonVariant **ret) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Embedded identity file is not a regular file, refusing: %m");
|
return log_error_errno(r, "Embedded identity file is not a regular file, refusing: %m");
|
||||||
|
|
||||||
identity_file = fdopen(identity_fd, "r");
|
identity_file = take_fdopen(&identity_fd, "r");
|
||||||
if (!identity_file)
|
if (!identity_file)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
identity_fd = -1;
|
|
||||||
|
|
||||||
r = json_parse_file(identity_file, ".identity", JSON_PARSE_SENSITIVE, ret, &line, &column);
|
r = json_parse_file(identity_file, ".identity", JSON_PARSE_SENSITIVE, ret, &line, &column);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "[.identity:%u:%u] Failed to parse JSON data: %m", line, column);
|
return log_error_errno(r, "[.identity:%u:%u] Failed to parse JSON data: %m", line, column);
|
||||||
|
@ -319,14 +316,12 @@ static int write_identity_file(int root_fd, JsonVariant *v, uid_t uid) {
|
||||||
if (identity_fd < 0)
|
if (identity_fd < 0)
|
||||||
return log_error_errno(errno, "Failed to create .identity file in home directory: %m");
|
return log_error_errno(errno, "Failed to create .identity file in home directory: %m");
|
||||||
|
|
||||||
identity_file = fdopen(identity_fd, "w");
|
identity_file = take_fdopen(&identity_fd, "w");
|
||||||
if (!identity_file) {
|
if (!identity_file) {
|
||||||
r = log_oom();
|
r = log_oom();
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
identity_fd = -1;
|
|
||||||
|
|
||||||
json_variant_dump(normalized, JSON_FORMAT_PRETTY, identity_file, NULL);
|
json_variant_dump(normalized, JSON_FORMAT_PRETTY, identity_file, NULL);
|
||||||
|
|
||||||
r = fflush_and_check(identity_file);
|
r = fflush_and_check(identity_file);
|
||||||
|
|
|
@ -123,18 +123,16 @@ static int request_meta_ensure_tmp(RequestMeta *m) {
|
||||||
if (m->tmp)
|
if (m->tmp)
|
||||||
rewind(m->tmp);
|
rewind(m->tmp);
|
||||||
else {
|
else {
|
||||||
int fd;
|
_cleanup_close_ int fd = -1;
|
||||||
|
|
||||||
fd = open_tmpfile_unlinkable("/tmp", O_RDWR|O_CLOEXEC);
|
fd = open_tmpfile_unlinkable("/tmp", O_RDWR|O_CLOEXEC);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return fd;
|
return fd;
|
||||||
|
|
||||||
m->tmp = fdopen(fd, "w+");
|
m->tmp = take_fdopen(&fd, "w+");
|
||||||
if (!m->tmp) {
|
if (!m->tmp)
|
||||||
safe_close(fd);
|
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1718,7 +1718,7 @@ static int add_root_directory(sd_journal *j, const char *p, bool missing_ok) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int dfd;
|
_cleanup_close_ int dfd = -1;
|
||||||
|
|
||||||
/* If there's no path specified, then we use the top-level fd itself. We duplicate the fd here, since
|
/* If there's no path specified, then we use the top-level fd itself. We duplicate the fd here, since
|
||||||
* opendir() will take possession of the fd, and close it, which we don't want. */
|
* opendir() will take possession of the fd, and close it, which we don't want. */
|
||||||
|
@ -1731,10 +1731,9 @@ static int add_root_directory(sd_journal *j, const char *p, bool missing_ok) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
d = fdopendir(dfd);
|
d = take_fdopendir(&dfd);
|
||||||
if (!d) {
|
if (!d) {
|
||||||
r = -errno;
|
r = -errno;
|
||||||
safe_close(dfd);
|
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "random-util.h"
|
#include "random-util.h"
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
#include "strv.h"
|
#include "strv.h"
|
||||||
|
#include "web-util.h"
|
||||||
|
|
||||||
#define MAX_CLIENT_ID_LEN (sizeof(uint32_t) + MAX_DUID_LEN) /* Arbitrary limit */
|
#define MAX_CLIENT_ID_LEN (sizeof(uint32_t) + MAX_DUID_LEN) /* Arbitrary limit */
|
||||||
#define MAX_MAC_ADDR_LEN CONST_MAX(INFINIBAND_ALEN, ETH_ALEN)
|
#define MAX_MAC_ADDR_LEN CONST_MAX(INFINIBAND_ALEN, ETH_ALEN)
|
||||||
|
@ -83,6 +84,7 @@ struct sd_dhcp_client {
|
||||||
size_t client_id_len;
|
size_t client_id_len;
|
||||||
char *hostname;
|
char *hostname;
|
||||||
char *vendor_class_identifier;
|
char *vendor_class_identifier;
|
||||||
|
char *mudurl;
|
||||||
char **user_class;
|
char **user_class;
|
||||||
uint32_t mtu;
|
uint32_t mtu;
|
||||||
uint32_t xid;
|
uint32_t xid;
|
||||||
|
@ -493,6 +495,18 @@ int sd_dhcp_client_set_vendor_class_identifier(
|
||||||
return free_and_strdup(&client->vendor_class_identifier, vci);
|
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(
|
int sd_dhcp_client_set_user_class(
|
||||||
sd_dhcp_client *client,
|
sd_dhcp_client *client,
|
||||||
const char* const* user_class) {
|
const char* const* user_class) {
|
||||||
|
@ -895,6 +909,15 @@ static int client_send_discover(sd_dhcp_client *client) {
|
||||||
return r;
|
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) {
|
if (client->user_class) {
|
||||||
r = dhcp_option_append(&discover->dhcp, optlen, &optoffset, 0,
|
r = dhcp_option_append(&discover->dhcp, optlen, &optoffset, 0,
|
||||||
SD_DHCP_OPTION_USER_CLASS,
|
SD_DHCP_OPTION_USER_CLASS,
|
||||||
|
@ -1032,6 +1055,16 @@ static int client_send_request(sd_dhcp_client *client) {
|
||||||
return r;
|
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,
|
r = dhcp_option_append(&request->dhcp, optlen, &optoffset, 0,
|
||||||
SD_DHCP_OPTION_END, 0, NULL);
|
SD_DHCP_OPTION_END, 0, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -2101,6 +2134,7 @@ static sd_dhcp_client *dhcp_client_free(sd_dhcp_client *client) {
|
||||||
free(client->req_opts);
|
free(client->req_opts);
|
||||||
free(client->hostname);
|
free(client->hostname);
|
||||||
free(client->vendor_class_identifier);
|
free(client->vendor_class_identifier);
|
||||||
|
free(client->mudurl);
|
||||||
client->user_class = strv_free(client->user_class);
|
client->user_class = strv_free(client->user_class);
|
||||||
ordered_hashmap_free(client->extra_options);
|
ordered_hashmap_free(client->extra_options);
|
||||||
ordered_hashmap_free(client->vendor_options);
|
ordered_hashmap_free(client->vendor_options);
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "env-file.h"
|
#include "env-file.h"
|
||||||
#include "env-util.h"
|
#include "env-util.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
|
#include "fileio.h"
|
||||||
#include "format-util.h"
|
#include "format-util.h"
|
||||||
#include "fs-util.h"
|
#include "fs-util.h"
|
||||||
#include "in-addr-util.h"
|
#include "in-addr-util.h"
|
||||||
|
@ -399,12 +400,10 @@ int bus_machine_method_get_os_release(sd_bus_message *message, void *userdata, s
|
||||||
|
|
||||||
pair[1] = safe_close(pair[1]);
|
pair[1] = safe_close(pair[1]);
|
||||||
|
|
||||||
f = fdopen(pair[0], "r");
|
f = take_fdopen(&pair[0], "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
pair[0] = -1;
|
|
||||||
|
|
||||||
r = load_env_file_pairs(f, "/etc/os-release", &l);
|
r = load_env_file_pairs(f, "/etc/os-release", &l);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -620,12 +620,10 @@ static int clean_pool_done(Operation *operation, int ret, sd_bus_error *error) {
|
||||||
if (lseek(operation->extra_fd, 0, SEEK_SET) == (off_t) -1)
|
if (lseek(operation->extra_fd, 0, SEEK_SET) == (off_t) -1)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
f = fdopen(operation->extra_fd, "r");
|
f = take_fdopen(&operation->extra_fd, "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
operation->extra_fd = -1;
|
|
||||||
|
|
||||||
/* The resulting temporary file starts with a boolean value that indicates success or not. */
|
/* The resulting temporary file starts with a boolean value that indicates success or not. */
|
||||||
errno = 0;
|
errno = 0;
|
||||||
n = fread(&success, 1, sizeof(success), f);
|
n = fread(&success, 1, sizeof(success), f);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <linux/if.h>
|
#include <linux/if.h>
|
||||||
#include <linux/if_arp.h>
|
#include <linux/if_arp.h>
|
||||||
|
|
||||||
|
#include "escape.h"
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "dhcp-client-internal.h"
|
#include "dhcp-client-internal.h"
|
||||||
#include "hostname-util.h"
|
#include "hostname-util.h"
|
||||||
|
@ -17,6 +18,7 @@
|
||||||
#include "string-table.h"
|
#include "string-table.h"
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
#include "sysctl-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_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);
|
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");
|
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) {
|
if (link->network->dhcp_user_class) {
|
||||||
r = sd_dhcp_client_set_user_class(link->dhcp_client, (const char **) 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)
|
if (r < 0)
|
||||||
|
@ -1744,6 +1753,48 @@ int config_parse_dhcp_ip_service_type(
|
||||||
return 0;
|
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] = {
|
static const char* const dhcp_client_identifier_table[_DHCP_CLIENT_ID_MAX] = {
|
||||||
[DHCP_CLIENT_ID_MAC] = "mac",
|
[DHCP_CLIENT_ID_MAC] = "mac",
|
||||||
[DHCP_CLIENT_ID_DUID] = "duid",
|
[DHCP_CLIENT_ID_DUID] = "duid",
|
||||||
|
|
|
@ -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_user_class);
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_request_options);
|
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_request_options);
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_ip_service_type);
|
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_ip_service_type);
|
||||||
|
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_mud_url);
|
||||||
|
|
|
@ -170,6 +170,7 @@ DHCPv4.SendHostname, config_parse_bool,
|
||||||
DHCPv4.Hostname, config_parse_hostname, 0, offsetof(Network, dhcp_hostname)
|
DHCPv4.Hostname, config_parse_hostname, 0, offsetof(Network, dhcp_hostname)
|
||||||
DHCPv4.RequestBroadcast, config_parse_bool, 0, offsetof(Network, dhcp_broadcast)
|
DHCPv4.RequestBroadcast, config_parse_bool, 0, offsetof(Network, dhcp_broadcast)
|
||||||
DHCPv4.VendorClassIdentifier, config_parse_string, 0, offsetof(Network, dhcp_vendor_class_identifier)
|
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.MaxAttempts, config_parse_dhcp_max_attempts, 0, 0
|
||||||
DHCPv4.UserClass, config_parse_dhcp_user_class, 0, offsetof(Network, dhcp_user_class)
|
DHCPv4.UserClass, config_parse_dhcp_user_class, 0, offsetof(Network, dhcp_user_class)
|
||||||
DHCPv4.DUIDType, config_parse_duid_type, 0, offsetof(Network, duid)
|
DHCPv4.DUIDType, config_parse_duid_type, 0, offsetof(Network, duid)
|
||||||
|
|
|
@ -640,6 +640,7 @@ static Network *network_free(Network *network) {
|
||||||
|
|
||||||
free(network->description);
|
free(network->description);
|
||||||
free(network->dhcp_vendor_class_identifier);
|
free(network->dhcp_vendor_class_identifier);
|
||||||
|
free(network->dhcp_mudurl);
|
||||||
strv_free(network->dhcp_user_class);
|
strv_free(network->dhcp_user_class);
|
||||||
free(network->dhcp_hostname);
|
free(network->dhcp_hostname);
|
||||||
set_free(network->dhcp_black_listed_ip);
|
set_free(network->dhcp_black_listed_ip);
|
||||||
|
|
|
@ -91,6 +91,7 @@ struct Network {
|
||||||
AddressFamily dhcp;
|
AddressFamily dhcp;
|
||||||
DHCPClientIdentifier dhcp_client_identifier;
|
DHCPClientIdentifier dhcp_client_identifier;
|
||||||
char *dhcp_vendor_class_identifier;
|
char *dhcp_vendor_class_identifier;
|
||||||
|
char *dhcp_mudurl;
|
||||||
char **dhcp_user_class;
|
char **dhcp_user_class;
|
||||||
char *dhcp_hostname;
|
char *dhcp_hostname;
|
||||||
uint64_t dhcp_max_attempts;
|
uint64_t dhcp_max_attempts;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "acl-util.h"
|
#include "acl-util.h"
|
||||||
#include "dirent-util.h"
|
#include "dirent-util.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
|
#include "fileio.h"
|
||||||
#include "fs-util.h"
|
#include "fs-util.h"
|
||||||
#include "missing_magic.h"
|
#include "missing_magic.h"
|
||||||
#include "nspawn-def.h"
|
#include "nspawn-def.h"
|
||||||
|
@ -335,12 +336,11 @@ static int recurse_fd(int fd, bool donate_fd, const struct stat *st, uid_t shift
|
||||||
donate_fd = true;
|
donate_fd = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
d = fdopendir(fd);
|
d = take_fdopendir(&fd);
|
||||||
if (!d) {
|
if (!d) {
|
||||||
r = -errno;
|
r = -errno;
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
fd = -1;
|
|
||||||
|
|
||||||
FOREACH_DIRENT_ALL(de, d, r = -errno; goto finish) {
|
FOREACH_DIRENT_ALL(de, d, r = -errno; goto finish) {
|
||||||
struct stat fst;
|
struct stat fst;
|
||||||
|
|
|
@ -118,10 +118,9 @@ int change_uid_gid(const char *user, char **_home) {
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return fd;
|
return fd;
|
||||||
|
|
||||||
f = fdopen(fd, "r");
|
f = take_fdopen(&fd, "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
fd = -1;
|
|
||||||
|
|
||||||
r = read_line(f, LONG_LINE_MAX, &line);
|
r = read_line(f, LONG_LINE_MAX, &line);
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
|
@ -191,10 +190,9 @@ int change_uid_gid(const char *user, char **_home) {
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return fd;
|
return fd;
|
||||||
|
|
||||||
f = fdopen(fd, "r");
|
f = take_fdopen(&fd, "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
fd = -1;
|
|
||||||
|
|
||||||
r = read_line(f, LONG_LINE_MAX, &line);
|
r = read_line(f, LONG_LINE_MAX, &line);
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
|
|
|
@ -1092,10 +1092,9 @@ static int test_chroot_dropin(
|
||||||
return log_debug_errno(errno, "Failed to open %s/%s: %m", where, p);
|
return log_debug_errno(errno, "Failed to open %s/%s: %m", where, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = fdopen_unlocked(fd, "r", &f);
|
r = take_fdopen_unlocked(&fd, "r", &f);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_debug_errno(r, "Failed to convert file handle: %m");
|
return log_debug_errno(r, "Failed to convert file handle: %m");
|
||||||
TAKE_FD(fd);
|
|
||||||
|
|
||||||
r = read_line(f, LONG_LINE_MAX, &line);
|
r = read_line(f, LONG_LINE_MAX, &line);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
|
|
@ -79,12 +79,10 @@ static int append_fd(sd_bus_message *m, PortableMetadata *d) {
|
||||||
assert(d);
|
assert(d);
|
||||||
assert(d->fd >= 0);
|
assert(d->fd >= 0);
|
||||||
|
|
||||||
f = fdopen(d->fd, "r");
|
f = take_fdopen(&d->fd, "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
d->fd = -1;
|
|
||||||
|
|
||||||
r = read_full_stream(f, &buf, &n);
|
r = read_full_stream(f, &buf, &n);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -791,14 +791,12 @@ int ask_password_agent(
|
||||||
|
|
||||||
(void) fchmod(fd, 0644);
|
(void) fchmod(fd, 0644);
|
||||||
|
|
||||||
f = fdopen(fd, "w");
|
f = take_fdopen(&fd, "w");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
r = -errno;
|
r = -errno;
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = -1;
|
|
||||||
|
|
||||||
signal_fd = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC);
|
signal_fd = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC);
|
||||||
if (signal_fd < 0) {
|
if (signal_fd < 0) {
|
||||||
r = -errno;
|
r = -errno;
|
||||||
|
|
|
@ -1541,14 +1541,12 @@ int dissected_image_acquire_metadata(DissectedImage *m) {
|
||||||
|
|
||||||
fds[2*k+1] = safe_close(fds[2*k+1]);
|
fds[2*k+1] = safe_close(fds[2*k+1]);
|
||||||
|
|
||||||
f = fdopen(fds[2*k], "r");
|
f = take_fdopen(&fds[2*k], "r");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
r = -errno;
|
r = -errno;
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
fds[2*k] = -1;
|
|
||||||
|
|
||||||
switch (k) {
|
switch (k) {
|
||||||
|
|
||||||
case META_HOSTNAME:
|
case META_HOSTNAME:
|
||||||
|
|
|
@ -1280,10 +1280,9 @@ static int unit_file_load(
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
f = fdopen(fd, "r");
|
f = take_fdopen(&fd, "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
return -errno;
|
return -errno;
|
||||||
fd = -1;
|
|
||||||
|
|
||||||
/* c is only needed if we actually load the file (it's referenced from items[] btw, in case you wonder.) */
|
/* c is only needed if we actually load the file (it's referenced from items[] btw, in case you wonder.) */
|
||||||
assert(c);
|
assert(c);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "env-file.h"
|
#include "env-file.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
|
#include "fileio.h"
|
||||||
#include "fs-util.h"
|
#include "fs-util.h"
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
#include "os-util.h"
|
#include "os-util.h"
|
||||||
|
@ -76,10 +77,9 @@ int fopen_os_release(const char *root, char **ret_path, FILE **ret_file) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
f = fdopen(fd, "r");
|
f = take_fdopen(&fd, "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
return -errno;
|
return -errno;
|
||||||
fd = -1;
|
|
||||||
|
|
||||||
*ret_file = f;
|
*ret_file = f;
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,7 @@ enum {
|
||||||
SD_DHCP_OPTION_DOMAIN_SEARCH_LIST = 119,
|
SD_DHCP_OPTION_DOMAIN_SEARCH_LIST = 119,
|
||||||
SD_DHCP_OPTION_SIP_SERVER = 120,
|
SD_DHCP_OPTION_SIP_SERVER = 120,
|
||||||
SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE = 121,
|
SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE = 121,
|
||||||
|
SD_DHCP_OPTION_MUD_URL = 161,
|
||||||
SD_DHCP_OPTION_PRIVATE_BASE = 224,
|
SD_DHCP_OPTION_PRIVATE_BASE = 224,
|
||||||
/* Windows 10 option to send when Anonymize=true */
|
/* Windows 10 option to send when Anonymize=true */
|
||||||
SD_DHCP_OPTION_PRIVATE_CLASSLESS_STATIC_ROUTE = 249,
|
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(
|
int sd_dhcp_client_set_vendor_class_identifier(
|
||||||
sd_dhcp_client *client,
|
sd_dhcp_client *client,
|
||||||
const char *vci);
|
const char *vci);
|
||||||
|
int sd_dhcp_client_set_mud_url(
|
||||||
|
sd_dhcp_client *client,
|
||||||
|
const char *mudurl);
|
||||||
int sd_dhcp_client_set_user_class(
|
int sd_dhcp_client_set_user_class(
|
||||||
sd_dhcp_client *client,
|
sd_dhcp_client *client,
|
||||||
const char* const *user_class);
|
const char* const *user_class);
|
||||||
|
|
|
@ -102,6 +102,7 @@ IPServiceType=
|
||||||
SendOption=
|
SendOption=
|
||||||
SendVendorOption=
|
SendVendorOption=
|
||||||
SendDecline=
|
SendDecline=
|
||||||
|
MUDURL=
|
||||||
RouteMTUBytes=
|
RouteMTUBytes=
|
||||||
[DHCPv6]
|
[DHCPv6]
|
||||||
UseNTP=
|
UseNTP=
|
||||||
|
|
Loading…
Reference in New Issue