Compare commits
No commits in common. "c08326411575a17738e3f8928a194bd4de06b0d1" and "f5d9daaea3dd3f8eaef8b7f5b5a712c6476b05d7" have entirely different histories.
c083264115
...
f5d9daaea3
|
@ -289,9 +289,7 @@ 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',
|
||||
|
|
|
@ -67,8 +67,6 @@
|
|||
<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>,
|
||||
|
@ -81,8 +79,6 @@
|
|||
<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>,
|
||||
|
|
|
@ -68,14 +68,16 @@
|
|||
#define SD_INFO "<6>" /* informational */
|
||||
#define SD_DEBUG "<7>" /* debug-level messages */</programlisting>
|
||||
|
||||
<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>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>The log levels are identical to
|
||||
<citerefentry project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>'s
|
||||
|
|
|
@ -52,39 +52,34 @@
|
|||
<title>Description</title>
|
||||
|
||||
<para><function>sd_bus_call()</function> takes a complete bus message object and calls the
|
||||
corresponding D-Bus method. On success, the response is stored in <parameter>reply</parameter>.
|
||||
corresponding D-Bus method. 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> 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>
|
||||
<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>
|
||||
|
||||
<para><function>sd_bus_call_async()</function> is like <function>sd_bus_call()</function> but
|
||||
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,
|
||||
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,
|
||||
<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. <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
|
||||
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
|
||||
<citerefentry><refentrytitle>sd_bus_message_is_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
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>
|
||||
on the reply object returned by <function>sd_bus_call()</function> or passed to the callback of
|
||||
<function>sd_bus_call_async()</function>.</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>.
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
<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>
|
||||
|
||||
|
@ -57,18 +55,6 @@
|
|||
<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>
|
||||
|
@ -96,13 +82,11 @@
|
|||
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
|
||||
|
@ -139,10 +123,9 @@
|
|||
<varlistentry>
|
||||
<term><constant>-EPERM</constant></term>
|
||||
|
||||
<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>
|
||||
<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>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
|
|
|
@ -1430,18 +1430,6 @@
|
|||
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>
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "copy.h"
|
||||
#include "dirent-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fs-util.h"
|
||||
#include "io-util.h"
|
||||
#include "macro.h"
|
||||
|
@ -570,9 +569,10 @@ static int fd_copy_directory(
|
|||
if (fdf < 0)
|
||||
return -errno;
|
||||
|
||||
d = take_fdopendir(&fdf);
|
||||
d = fdopendir(fdf);
|
||||
if (!d)
|
||||
return -errno;
|
||||
fdf = -1;
|
||||
|
||||
exists = false;
|
||||
if (copy_flags & COPY_MERGE_EMPTY) {
|
||||
|
|
|
@ -54,44 +54,6 @@ int fdopen_unlocked(int fd, const char *options, FILE **ret) {
|
|||
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 *f = open_memstream(ptr, sizeloc);
|
||||
if (!f)
|
||||
|
|
|
@ -39,9 +39,6 @@ typedef enum {
|
|||
|
||||
int fopen_unlocked(const char *path, 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* fmemopen_unlocked(void *buf, size_t size, const char *mode);
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "alloc-util.h"
|
||||
#include "dirent-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fs-util.h"
|
||||
#include "macro.h"
|
||||
#include "missing_fs.h"
|
||||
|
@ -78,9 +77,10 @@ int dir_is_empty_at(int dir_fd, const char *path) {
|
|||
if (fd < 0)
|
||||
return -errno;
|
||||
|
||||
d = take_fdopendir(&fd);
|
||||
d = fdopendir(fd);
|
||||
if (!d)
|
||||
return -errno;
|
||||
fd = -1;
|
||||
|
||||
FOREACH_DIRENT(de, d, return -errno)
|
||||
return 0;
|
||||
|
|
|
@ -48,12 +48,14 @@ 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
|
||||
* context and never shared externally, hence locking is not necessary. */
|
||||
|
||||
r = take_fdopen_unlocked(&fd, "w", &f);
|
||||
r = fdopen_unlocked(fd, "w", &f);
|
||||
if (r < 0) {
|
||||
(void) unlink(t);
|
||||
return r;
|
||||
}
|
||||
|
||||
TAKE_FD(fd);
|
||||
|
||||
if (ret_f)
|
||||
*ret_f = TAKE_PTR(f);
|
||||
|
||||
|
@ -78,16 +80,18 @@ int mkostemp_safe(char *pattern) {
|
|||
}
|
||||
|
||||
int fmkostemp_safe(char *pattern, const char *mode, FILE **ret_f) {
|
||||
_cleanup_close_ int fd = -1;
|
||||
int fd;
|
||||
FILE *f;
|
||||
|
||||
fd = mkostemp_safe(pattern);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
f = take_fdopen(&fd, mode);
|
||||
if (!f)
|
||||
f = fdopen(fd, mode);
|
||||
if (!f) {
|
||||
safe_close(fd);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
*ret_f = f;
|
||||
return 0;
|
||||
|
|
|
@ -982,9 +982,8 @@ static int install_loader_config(const char *esp_path, sd_id128_t machine_id) {
|
|||
char machine_string[SD_ID128_STRING_MAX];
|
||||
_cleanup_(unlink_and_freep) char *t = NULL;
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
_cleanup_close_ int fd = -1;
|
||||
const char *p;
|
||||
int r;
|
||||
int r, fd;
|
||||
|
||||
p = prefix_roota(esp_path, "/loader/loader.conf");
|
||||
if (access(p, F_OK) >= 0) /* Silently skip creation if the file already exists (early check) */
|
||||
|
@ -994,9 +993,11 @@ static int install_loader_config(const char *esp_path, sd_id128_t machine_id) {
|
|||
if (fd < 0)
|
||||
return log_error_errno(fd, "Failed to open \"%s\" for writing: %m", p);
|
||||
|
||||
f = take_fdopen(&fd, "w");
|
||||
if (!f)
|
||||
f = fdopen(fd, "w");
|
||||
if (!f) {
|
||||
safe_close(fd);
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
fprintf(f, "#timeout 3\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) {
|
||||
_cleanup_close_ int fd = -1;
|
||||
int fd;
|
||||
FILE *f;
|
||||
|
||||
assert(_f);
|
||||
|
@ -3116,9 +3116,11 @@ int manager_open_serialization(Manager *m, FILE **_f) {
|
|||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
f = take_fdopen(&fd, "w+");
|
||||
if (!f)
|
||||
f = fdopen(fd, "w+");
|
||||
if (!f) {
|
||||
safe_close(fd);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
*_f = f;
|
||||
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) {
|
||||
_cleanup_fclose_ FILE *fdinfo = NULL;
|
||||
_cleanup_free_ char *fdname = NULL;
|
||||
_cleanup_close_ int fd = -1;
|
||||
int fd;
|
||||
|
||||
r = readlinkat_malloc(dirfd(proc_fd_dir), dent->d_name, &fdname);
|
||||
if (r < 0)
|
||||
|
@ -574,9 +574,11 @@ static int compose_open_fds(pid_t pid, char **open_fds) {
|
|||
if (fd < 0)
|
||||
continue;
|
||||
|
||||
fdinfo = take_fdopen(&fd, "r");
|
||||
if (!fdinfo)
|
||||
fdinfo = fdopen(fd, "r");
|
||||
if (!fdinfo) {
|
||||
safe_close(fd);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
_cleanup_free_ char *line = NULL;
|
||||
|
|
|
@ -360,10 +360,12 @@ static int home_parse_worker_stdout(int _fd, UserRecord **ret) {
|
|||
if (lseek(fd, SEEK_SET, 0) == (off_t) -1)
|
||||
return log_error_errno(errno, "Failed to seek to beginning of memfd: %m");
|
||||
|
||||
f = take_fdopen(&fd, "r");
|
||||
f = fdopen(fd, "r");
|
||||
if (!f)
|
||||
return log_error_errno(errno, "Failed to reopen memfd: %m");
|
||||
|
||||
TAKE_FD(fd);
|
||||
|
||||
if (DEBUG_LOGGING) {
|
||||
_cleanup_free_ char *text = NULL;
|
||||
|
||||
|
|
|
@ -142,8 +142,7 @@ int home_create_cifs(UserRecord *h, UserRecord **ret_home) {
|
|||
_cleanup_(home_setup_undo) HomeSetup setup = HOME_SETUP_INIT;
|
||||
_cleanup_(user_record_unrefp) UserRecord *new_home = NULL;
|
||||
_cleanup_(closedirp) DIR *d = NULL;
|
||||
_cleanup_close_ int copy = -1;
|
||||
int r;
|
||||
int r, copy;
|
||||
|
||||
assert(h);
|
||||
assert(user_record_storage(h) == USER_CIFS);
|
||||
|
@ -167,9 +166,11 @@ int home_create_cifs(UserRecord *h, UserRecord **ret_home) {
|
|||
if (copy < 0)
|
||||
return -errno;
|
||||
|
||||
d = take_fdopendir(©);
|
||||
if (!d)
|
||||
d = fdopendir(copy);
|
||||
if (!d) {
|
||||
safe_close(copy);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
if (readdir_no_dot(d))
|
||||
|
|
|
@ -38,6 +38,7 @@ int user_record_authenticate(
|
|||
|
||||
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;
|
||||
size_t n;
|
||||
int r;
|
||||
|
||||
assert(h);
|
||||
|
@ -69,7 +70,7 @@ int user_record_authenticate(
|
|||
}
|
||||
|
||||
/* Second, let's see if any of the PKCS#11 security tokens are plugged in and help us */
|
||||
for (size_t n = 0; n < h->n_pkcs11_encrypted_key; n++) {
|
||||
for (n = 0; n < h->n_pkcs11_encrypted_key; n++) {
|
||||
#if HAVE_P11KIT
|
||||
_cleanup_(pkcs11_callback_data_release) struct pkcs11_callback_data data = {
|
||||
.user_record = h,
|
||||
|
@ -279,10 +280,12 @@ static int read_identity_file(int root_fd, JsonVariant **ret) {
|
|||
if (r < 0)
|
||||
return log_error_errno(r, "Embedded identity file is not a regular file, refusing: %m");
|
||||
|
||||
identity_file = take_fdopen(&identity_fd, "r");
|
||||
identity_file = fdopen(identity_fd, "r");
|
||||
if (!identity_file)
|
||||
return log_oom();
|
||||
|
||||
identity_fd = -1;
|
||||
|
||||
r = json_parse_file(identity_file, ".identity", JSON_PARSE_SENSITIVE, ret, &line, &column);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "[.identity:%u:%u] Failed to parse JSON data: %m", line, column);
|
||||
|
@ -316,12 +319,14 @@ static int write_identity_file(int root_fd, JsonVariant *v, uid_t uid) {
|
|||
if (identity_fd < 0)
|
||||
return log_error_errno(errno, "Failed to create .identity file in home directory: %m");
|
||||
|
||||
identity_file = take_fdopen(&identity_fd, "w");
|
||||
identity_file = fdopen(identity_fd, "w");
|
||||
if (!identity_file) {
|
||||
r = log_oom();
|
||||
goto fail;
|
||||
}
|
||||
|
||||
identity_fd = -1;
|
||||
|
||||
json_variant_dump(normalized, JSON_FORMAT_PRETTY, identity_file, NULL);
|
||||
|
||||
r = fflush_and_check(identity_file);
|
||||
|
|
|
@ -123,15 +123,17 @@ static int request_meta_ensure_tmp(RequestMeta *m) {
|
|||
if (m->tmp)
|
||||
rewind(m->tmp);
|
||||
else {
|
||||
_cleanup_close_ int fd = -1;
|
||||
int fd;
|
||||
|
||||
fd = open_tmpfile_unlinkable("/tmp", O_RDWR|O_CLOEXEC);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
m->tmp = take_fdopen(&fd, "w+");
|
||||
if (!m->tmp)
|
||||
m->tmp = fdopen(fd, "w+");
|
||||
if (!m->tmp) {
|
||||
safe_close(fd);
|
||||
return -errno;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -1718,7 +1718,7 @@ static int add_root_directory(sd_journal *j, const char *p, bool missing_ok) {
|
|||
goto fail;
|
||||
}
|
||||
} else {
|
||||
_cleanup_close_ int dfd = -1;
|
||||
int dfd;
|
||||
|
||||
/* 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. */
|
||||
|
@ -1731,9 +1731,10 @@ static int add_root_directory(sd_journal *j, const char *p, bool missing_ok) {
|
|||
goto fail;
|
||||
}
|
||||
|
||||
d = take_fdopendir(&dfd);
|
||||
d = fdopendir(dfd);
|
||||
if (!d) {
|
||||
r = -errno;
|
||||
safe_close(dfd);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#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)
|
||||
|
@ -84,7 +83,6 @@ 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;
|
||||
|
@ -495,18 +493,6 @@ 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) {
|
||||
|
@ -909,15 +895,6 @@ 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,
|
||||
|
@ -1055,16 +1032,6 @@ 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)
|
||||
|
@ -2134,7 +2101,6 @@ 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);
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "env-file.h"
|
||||
#include "env-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "format-util.h"
|
||||
#include "fs-util.h"
|
||||
#include "in-addr-util.h"
|
||||
|
@ -400,10 +399,12 @@ int bus_machine_method_get_os_release(sd_bus_message *message, void *userdata, s
|
|||
|
||||
pair[1] = safe_close(pair[1]);
|
||||
|
||||
f = take_fdopen(&pair[0], "r");
|
||||
f = fdopen(pair[0], "r");
|
||||
if (!f)
|
||||
return -errno;
|
||||
|
||||
pair[0] = -1;
|
||||
|
||||
r = load_env_file_pairs(f, "/etc/os-release", &l);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
|
|
@ -620,10 +620,12 @@ static int clean_pool_done(Operation *operation, int ret, sd_bus_error *error) {
|
|||
if (lseek(operation->extra_fd, 0, SEEK_SET) == (off_t) -1)
|
||||
return -errno;
|
||||
|
||||
f = take_fdopen(&operation->extra_fd, "r");
|
||||
f = fdopen(operation->extra_fd, "r");
|
||||
if (!f)
|
||||
return -errno;
|
||||
|
||||
operation->extra_fd = -1;
|
||||
|
||||
/* The resulting temporary file starts with a boolean value that indicates success or not. */
|
||||
errno = 0;
|
||||
n = fread(&success, 1, sizeof(success), f);
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#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"
|
||||
|
@ -18,7 +17,6 @@
|
|||
#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);
|
||||
|
@ -1458,13 +1456,6 @@ 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)
|
||||
|
@ -1753,48 +1744,6 @@ 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",
|
||||
|
|
|
@ -28,4 +28,3 @@ 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);
|
||||
|
|
|
@ -170,7 +170,6 @@ 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)
|
||||
|
|
|
@ -640,7 +640,6 @@ 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);
|
||||
|
|
|
@ -91,7 +91,6 @@ 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;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "acl-util.h"
|
||||
#include "dirent-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fs-util.h"
|
||||
#include "missing_magic.h"
|
||||
#include "nspawn-def.h"
|
||||
|
@ -336,11 +335,12 @@ static int recurse_fd(int fd, bool donate_fd, const struct stat *st, uid_t shift
|
|||
donate_fd = true;
|
||||
}
|
||||
|
||||
d = take_fdopendir(&fd);
|
||||
d = fdopendir(fd);
|
||||
if (!d) {
|
||||
r = -errno;
|
||||
goto finish;
|
||||
}
|
||||
fd = -1;
|
||||
|
||||
FOREACH_DIRENT_ALL(de, d, r = -errno; goto finish) {
|
||||
struct stat fst;
|
||||
|
|
|
@ -118,9 +118,10 @@ int change_uid_gid(const char *user, char **_home) {
|
|||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
f = take_fdopen(&fd, "r");
|
||||
f = fdopen(fd, "r");
|
||||
if (!f)
|
||||
return log_oom();
|
||||
fd = -1;
|
||||
|
||||
r = read_line(f, LONG_LINE_MAX, &line);
|
||||
if (r == 0)
|
||||
|
@ -190,9 +191,10 @@ int change_uid_gid(const char *user, char **_home) {
|
|||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
f = take_fdopen(&fd, "r");
|
||||
f = fdopen(fd, "r");
|
||||
if (!f)
|
||||
return log_oom();
|
||||
fd = -1;
|
||||
|
||||
r = read_line(f, LONG_LINE_MAX, &line);
|
||||
if (r == 0)
|
||||
|
|
|
@ -1092,9 +1092,10 @@ static int test_chroot_dropin(
|
|||
return log_debug_errno(errno, "Failed to open %s/%s: %m", where, p);
|
||||
}
|
||||
|
||||
r = take_fdopen_unlocked(&fd, "r", &f);
|
||||
r = fdopen_unlocked(fd, "r", &f);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to convert file handle: %m");
|
||||
TAKE_FD(fd);
|
||||
|
||||
r = read_line(f, LONG_LINE_MAX, &line);
|
||||
if (r < 0)
|
||||
|
|
|
@ -79,10 +79,12 @@ static int append_fd(sd_bus_message *m, PortableMetadata *d) {
|
|||
assert(d);
|
||||
assert(d->fd >= 0);
|
||||
|
||||
f = take_fdopen(&d->fd, "r");
|
||||
f = fdopen(d->fd, "r");
|
||||
if (!f)
|
||||
return -errno;
|
||||
|
||||
d->fd = -1;
|
||||
|
||||
r = read_full_stream(f, &buf, &n);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
|
|
@ -791,12 +791,14 @@ int ask_password_agent(
|
|||
|
||||
(void) fchmod(fd, 0644);
|
||||
|
||||
f = take_fdopen(&fd, "w");
|
||||
f = fdopen(fd, "w");
|
||||
if (!f) {
|
||||
r = -errno;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
fd = -1;
|
||||
|
||||
signal_fd = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC);
|
||||
if (signal_fd < 0) {
|
||||
r = -errno;
|
||||
|
|
|
@ -1541,12 +1541,14 @@ int dissected_image_acquire_metadata(DissectedImage *m) {
|
|||
|
||||
fds[2*k+1] = safe_close(fds[2*k+1]);
|
||||
|
||||
f = take_fdopen(&fds[2*k], "r");
|
||||
f = fdopen(fds[2*k], "r");
|
||||
if (!f) {
|
||||
r = -errno;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
fds[2*k] = -1;
|
||||
|
||||
switch (k) {
|
||||
|
||||
case META_HOSTNAME:
|
||||
|
|
|
@ -1280,9 +1280,10 @@ static int unit_file_load(
|
|||
if (r < 0)
|
||||
return r;
|
||||
|
||||
f = take_fdopen(&fd, "r");
|
||||
f = fdopen(fd, "r");
|
||||
if (!f)
|
||||
return -errno;
|
||||
fd = -1;
|
||||
|
||||
/* c is only needed if we actually load the file (it's referenced from items[] btw, in case you wonder.) */
|
||||
assert(c);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include "alloc-util.h"
|
||||
#include "env-file.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fs-util.h"
|
||||
#include "macro.h"
|
||||
#include "os-util.h"
|
||||
|
@ -77,9 +76,10 @@ int fopen_os_release(const char *root, char **ret_path, FILE **ret_file) {
|
|||
if (r < 0)
|
||||
return r;
|
||||
|
||||
f = take_fdopen(&fd, "r");
|
||||
f = fdopen(fd, "r");
|
||||
if (!f)
|
||||
return -errno;
|
||||
fd = -1;
|
||||
|
||||
*ret_file = f;
|
||||
|
||||
|
|
|
@ -92,7 +92,6 @@ 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,
|
||||
|
@ -172,9 +171,6 @@ 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);
|
||||
|
|
|
@ -102,7 +102,6 @@ IPServiceType=
|
|||
SendOption=
|
||||
SendVendorOption=
|
||||
SendDecline=
|
||||
MUDURL=
|
||||
RouteMTUBytes=
|
||||
[DHCPv6]
|
||||
UseNTP=
|
||||
|
|
Loading…
Reference in New Issue