1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-02-02 09:47:03 +03:00

Merge pull request #12000 from poettering/split-more-util

split more files in src/basic/
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-03-14 15:00:04 +01:00 committed by GitHub
commit 9e9213cd08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
77 changed files with 344 additions and 267 deletions

View File

@ -10,6 +10,7 @@
#include "sd-daemon.h"
#include "alloc-util.h"
#include "errno-util.h"
#include "escape.h"
#include "fd-util.h"
#include "log.h"

View File

@ -13,6 +13,7 @@
#include "locale-util.h"
#include "macro.h"
#include "missing.h"
#include "nulstr-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "pretty-print.h"

View File

@ -29,6 +29,7 @@
#include "locale-util.h"
#include "log.h"
#include "main-func.h"
#include "nulstr-util.h"
#include "pager.h"
#include "parse-util.h"
#include "path-util.h"

View File

@ -6,6 +6,7 @@
#include <unistd.h>
#include "async.h"
#include "errno-util.h"
#include "fd-util.h"
#include "log.h"
#include "macro.h"

View File

@ -1,8 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
#include "util.h"
#define DEFAULT_TIMEOUT_USEC (90*USEC_PER_SEC)
#define DEFAULT_RESTART_USEC (100*USEC_PER_MSEC)
#define DEFAULT_CONFIRM_USEC (30*USEC_PER_SEC)
@ -21,29 +19,6 @@
#define SIGNALS_CRASH_HANDLER SIGSEGV,SIGILL,SIGFPE,SIGBUS,SIGQUIT,SIGABRT
#define SIGNALS_IGNORE SIGPIPE
#if HAVE_SPLIT_USR
#define KBD_KEYMAP_DIRS \
"/usr/share/keymaps/\0" \
"/usr/share/kbd/keymaps/\0" \
"/usr/lib/kbd/keymaps/\0" \
"/lib/kbd/keymaps/\0"
#else
#define KBD_KEYMAP_DIRS \
"/usr/share/keymaps/\0" \
"/usr/share/kbd/keymaps/\0" \
"/usr/lib/kbd/keymaps/\0"
#endif
/* Note that we use the new /run prefix here (instead of /var/run) since we require them to be aliases and that way we
* become independent of /var being mounted */
#define DEFAULT_SYSTEM_BUS_ADDRESS "unix:path=/run/dbus/system_bus_socket"
#define DEFAULT_USER_BUS_ADDRESS_FMT "unix:path=%s/bus"
#define PLYMOUTH_SOCKET { \
.un.sun_family = AF_UNIX, \
.un.sun_path = "\0/org/freedesktop/plymouthd", \
}
#define NOTIFY_FD_MAX 768
#define NOTIFY_BUFFER_MAX PIPE_BUF

29
src/basic/errno-util.h Normal file
View File

@ -0,0 +1,29 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
#include "macro.h"
static inline void _reset_errno_(int *saved_errno) {
if (*saved_errno < 0) /* Invalidated by UNPROTECT_ERRNO? */
return;
errno = *saved_errno;
}
#define PROTECT_ERRNO \
_cleanup_(_reset_errno_) _unused_ int _saved_errno_ = errno
#define UNPROTECT_ERRNO \
do { \
errno = _saved_errno_; \
_saved_errno_ = -1; \
} while (false)
static inline int negative_errno(void) {
/* This helper should be used to shut up gcc if you know 'errno' is
* negative. Instead of "return -errno;", use "return negative_errno();"
* It will suppress bogus gcc warnings in case it assumes 'errno' might
* be 0 and thus the caller's error-handling might not be triggered. */
assert_return(errno > 0, -EINVAL);
return -errno;
}

View File

@ -10,8 +10,8 @@
#include <sys/types.h>
#include <unistd.h>
#include "errno-util.h"
#include "time-util.h"
#include "util.h"
int unlink_noerrno(const char *path);

109
src/basic/kbd-util.c Normal file
View File

@ -0,0 +1,109 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <ftw.h>
#include "kbd-util.h"
#include "log.h"
#include "nulstr-util.h"
#include "path-util.h"
#include "set.h"
#include "string-util.h"
#include "strv.h"
#include "utf8.h"
static thread_local Set *keymaps = NULL;
static int nftw_cb(
const char *fpath,
const struct stat *sb,
int tflag,
struct FTW *ftwbuf) {
_cleanup_free_ char *p = NULL;
char *e;
int r;
if (tflag != FTW_F)
return 0;
if (!endswith(fpath, ".map") &&
!endswith(fpath, ".map.gz"))
return 0;
p = strdup(basename(fpath));
if (!p)
return FTW_STOP;
e = endswith(p, ".map");
if (e)
*e = 0;
e = endswith(p, ".map.gz");
if (e)
*e = 0;
if (!keymap_is_valid(p))
return 0;
r = set_consume(keymaps, TAKE_PTR(p));
if (r < 0 && r != -EEXIST)
return r;
return 0;
}
int get_keymaps(char ***ret) {
_cleanup_strv_free_ char **l = NULL;
const char *dir;
int r;
keymaps = set_new(&string_hash_ops);
if (!keymaps)
return -ENOMEM;
NULSTR_FOREACH(dir, KBD_KEYMAP_DIRS) {
r = nftw(dir, nftw_cb, 20, FTW_PHYS|FTW_ACTIONRETVAL);
if (r == FTW_STOP)
log_debug("Directory not found %s", dir);
else if (r < 0)
log_debug_errno(r, "Can't add keymap: %m");
}
l = set_get_strv(keymaps);
if (!l) {
set_free_free(keymaps);
return -ENOMEM;
}
set_free(keymaps);
if (strv_isempty(l))
return -ENOENT;
strv_sort(l);
*ret = TAKE_PTR(l);
return 0;
}
bool keymap_is_valid(const char *name) {
if (isempty(name))
return false;
if (strlen(name) >= 128)
return false;
if (!utf8_is_valid(name))
return false;
if (!filename_is_valid(name))
return false;
if (!string_is_safe(name))
return false;
return true;
}

20
src/basic/kbd-util.h Normal file
View File

@ -0,0 +1,20 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
#include <stdbool.h>
#if HAVE_SPLIT_USR
#define KBD_KEYMAP_DIRS \
"/usr/share/keymaps/\0" \
"/usr/share/kbd/keymaps/\0" \
"/usr/lib/kbd/keymaps/\0" \
"/lib/kbd/keymaps/\0"
#else
#define KBD_KEYMAP_DIRS \
"/usr/share/keymaps/\0" \
"/usr/share/kbd/keymaps/\0" \
"/usr/lib/kbd/keymaps/\0"
#endif
int get_keymaps(char ***l);
bool keymap_is_valid(const char *name);

View File

@ -255,99 +255,6 @@ out:
return (bool) cached_answer;
}
static thread_local Set *keymaps = NULL;
static int nftw_cb(
const char *fpath,
const struct stat *sb,
int tflag,
struct FTW *ftwbuf) {
char *p, *e;
int r;
if (tflag != FTW_F)
return 0;
if (!endswith(fpath, ".map") &&
!endswith(fpath, ".map.gz"))
return 0;
p = strdup(basename(fpath));
if (!p)
return FTW_STOP;
e = endswith(p, ".map");
if (e)
*e = 0;
e = endswith(p, ".map.gz");
if (e)
*e = 0;
r = set_consume(keymaps, p);
if (r < 0 && r != -EEXIST)
return r;
return 0;
}
int get_keymaps(char ***ret) {
_cleanup_strv_free_ char **l = NULL;
const char *dir;
int r;
keymaps = set_new(&string_hash_ops);
if (!keymaps)
return -ENOMEM;
NULSTR_FOREACH(dir, KBD_KEYMAP_DIRS) {
r = nftw(dir, nftw_cb, 20, FTW_PHYS|FTW_ACTIONRETVAL);
if (r == FTW_STOP)
log_debug("Directory not found %s", dir);
else if (r < 0)
log_debug_errno(r, "Can't add keymap: %m");
}
l = set_get_strv(keymaps);
if (!l) {
set_free_free(keymaps);
return -ENOMEM;
}
set_free(keymaps);
if (strv_isempty(l))
return -ENOENT;
strv_sort(l);
*ret = TAKE_PTR(l);
return 0;
}
bool keymap_is_valid(const char *name) {
if (isempty(name))
return false;
if (strlen(name) >= 128)
return false;
if (!utf8_is_valid(name))
return false;
if (!filename_is_valid(name))
return false;
if (!string_is_safe(name))
return false;
return true;
}
static bool emoji_enabled(void) {
static int cached_emoji_enabled = -1;

View File

@ -68,9 +68,6 @@ const char *special_glyph(SpecialGlyph code) _const_;
const char* locale_variable_to_string(LocaleVariable i) _const_;
LocaleVariable locale_variable_from_string(const char *s) _pure_;
int get_keymaps(char ***l);
bool keymap_is_valid(const char *name);
static inline void freelocalep(locale_t *p) {
if (*p == (locale_t) 0)
return;

View File

@ -19,6 +19,7 @@
#include "sd-messages.h"
#include "alloc-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "format-util.h"
#include "io-util.h"
@ -37,7 +38,6 @@
#include "terminal-util.h"
#include "time-util.h"
#include "utf8.h"
#include "util.h"
#define SNDBUF_SIZE (8*1024*1024)

View File

@ -37,3 +37,21 @@ bool memeqzero(const void *data, size_t length) {
/* Now we know first 16 bytes are NUL, memcmp with self. */
return memcmp(data, p + i, length) == 0;
}
#if !HAVE_EXPLICIT_BZERO
/*
* The pointer to memset() is volatile so that compiler must de-reference the pointer and can't assume that
* it points to any function in particular (such as memset(), which it then might further "optimize"). This
* approach is inspired by openssl's crypto/mem_clr.c.
*/
typedef void *(*memset_t)(void *,int,size_t);
static volatile memset_t memset_func = memset;
void* explicit_bzero_safe(void *p, size_t l) {
if (l > 0)
memset_func(p, '\0', l);
return p;
}
#endif

View File

@ -51,3 +51,29 @@ static inline void *mempset(void *s, int c, size_t n) {
memset(s, c, n);
return (uint8_t*)s + n;
}
/* Normal memmem() requires haystack to be nonnull, which is annoying for zero-length buffers */
static inline void *memmem_safe(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen) {
if (needlelen <= 0)
return (void*) haystack;
if (haystacklen < needlelen)
return NULL;
assert(haystack);
assert(needle);
return memmem(haystack, haystacklen, needle, needlelen);
}
#if HAVE_EXPLICIT_BZERO
static inline void* explicit_bzero_safe(void *p, size_t l) {
if (l > 0)
explicit_bzero(p, l);
return p;
}
#else
void *explicit_bzero_safe(void *p, size_t l);
#endif

View File

@ -45,6 +45,7 @@ basic_sources = files('''
env-util.h
errno-list.c
errno-list.h
errno-util.h
escape.c
escape.h
ether-addr-util.c
@ -75,6 +76,8 @@ basic_sources = files('''
io-util.c
io-util.h
ioprio.h
kbd-util.c
kbd-util.h
khash.c
khash.h
label.c
@ -134,12 +137,16 @@ basic_sources = files('''
namespace-util.c
namespace-util.h
nss-util.h
nulstr-util.c
nulstr-util.h
ordered-set.c
ordered-set.h
parse-util.c
parse-util.h
path-util.c
path-util.h
plymouth-util.c
plymouth-util.h
prioq.c
prioq.h
proc-cmdline.c

17
src/basic/nulstr-util.c Normal file
View File

@ -0,0 +1,17 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#include "nulstr-util.h"
#include "string-util.h"
bool nulstr_contains(const char *nulstr, const char *needle) {
const char *i;
if (!nulstr)
return false;
NULSTR_FOREACH(i, nulstr)
if (streq(i, needle))
return true;
return false;
}

13
src/basic/nulstr-util.h Normal file
View File

@ -0,0 +1,13 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
#include <stdbool.h>
#include <string.h>
#define NULSTR_FOREACH(i, l) \
for ((i) = (l); (i) && *(i); (i) = strchr((i), 0)+1)
#define NULSTR_FOREACH_PAIR(i, j, l) \
for ((i) = (l), (j) = strchr((i), 0)+1; (i) && *(i); (i) = strchr((j), 0)+1, (j) = *(i) ? strchr((i), 0)+1 : (i))
bool nulstr_contains(const char *nulstr, const char *needle);

View File

@ -21,6 +21,7 @@
#include "log.h"
#include "macro.h"
#include "missing.h"
#include "nulstr-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "stat-util.h"

View File

@ -0,0 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <unistd.h>
#include "plymouth-util.h"
bool plymouth_running(void) {
return access("/run/plymouth/pid", F_OK) >= 0;
}

11
src/basic/plymouth-util.h Normal file
View File

@ -0,0 +1,11 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
#include <stdbool.h>
#define PLYMOUTH_SOCKET { \
.un.sun_family = AF_UNIX, \
.un.sun_path = "\0/org/freedesktop/plymouthd", \
}
bool plymouth_running(void);

View File

@ -3,7 +3,7 @@
#include <sys/stat.h>
#include "util.h"
#include "errno-util.h"
typedef enum RemoveFlags {
REMOVE_ONLY_DIRECTORIES = 1 << 0,

View File

@ -16,6 +16,7 @@
#endif
#include "alloc-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "log.h"
#include "macro.h"
@ -23,7 +24,6 @@
#include "selinux-util.h"
#include "stdio-util.h"
#include "time-util.h"
#include "util.h"
#if HAVE_SELINUX
DEFINE_TRIVIAL_CLEANUP_FUNC(char*, freecon);

View File

@ -10,14 +10,15 @@
#include "alloc-util.h"
#include "escape.h"
#include "fileio.h"
#include "gunicode.h"
#include "locale-util.h"
#include "macro.h"
#include "memory-util.h"
#include "string-util.h"
#include "terminal-util.h"
#include "utf8.h"
#include "util.h"
#include "fileio.h"
int strcmp_ptr(const char *a, const char *b) {
@ -675,19 +676,6 @@ char *cellescape(char *buf, size_t len, const char *s) {
return buf;
}
bool nulstr_contains(const char *nulstr, const char *needle) {
const char *i;
if (!nulstr)
return false;
NULSTR_FOREACH(i, nulstr)
if (streq(i, needle))
return true;
return false;
}
char* strshorten(char *s, size_t l) {
assert(s);
@ -1048,25 +1036,6 @@ int free_and_strndup(char **p, const char *s, size_t l) {
return 1;
}
#if !HAVE_EXPLICIT_BZERO
/*
* Pointer to memset is volatile so that compiler must de-reference
* the pointer and can't assume that it points to any function in
* particular (such as memset, which it then might further "optimize")
* This approach is inspired by openssl's crypto/mem_clr.c.
*/
typedef void *(*memset_t)(void *,int,size_t);
static volatile memset_t memset_func = memset;
void* explicit_bzero_safe(void *p, size_t l) {
if (l > 0)
memset_func(p, '\0', l);
return p;
}
#endif
char* string_erase(char *x) {
if (!x)
return NULL;

View File

@ -165,8 +165,6 @@ char *cellescape(char *buf, size_t len, const char *s);
/* This limit is arbitrary, enough to give some idea what the string contains */
#define CELLESCAPE_DEFAULT_LENGTH 64
bool nulstr_contains(const char *nulstr, const char *needle);
char* strshorten(char *s, size_t l);
char *strreplace(const char *text, const char *old_string, const char *new_string);
@ -184,32 +182,6 @@ int split_pair(const char *s, const char *sep, char **l, char **r);
int free_and_strdup(char **p, const char *s);
int free_and_strndup(char **p, const char *s, size_t l);
/* Normal memmem() requires haystack to be nonnull, which is annoying for zero-length buffers */
static inline void *memmem_safe(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen) {
if (needlelen <= 0)
return (void*) haystack;
if (haystacklen < needlelen)
return NULL;
assert(haystack);
assert(needle);
return memmem(haystack, haystacklen, needle, needlelen);
}
#if HAVE_EXPLICIT_BZERO
static inline void* explicit_bzero_safe(void *p, size_t l) {
if (l > 0)
explicit_bzero(p, l);
return p;
}
#else
void *explicit_bzero_safe(void *p, size_t l);
#endif
char *string_erase(char *x);
char *string_free_erase(char *s);

View File

@ -11,6 +11,7 @@
#include "escape.h"
#include "extract-word.h"
#include "fileio.h"
#include "nulstr-util.h"
#include "sort-util.h"
#include "string-util.h"
#include "strv.h"

View File

@ -51,19 +51,6 @@ int saved_argc = 0;
char **saved_argv = NULL;
static int saved_in_initrd = -1;
bool plymouth_running(void) {
return access("/run/plymouth/pid", F_OK) >= 0;
}
bool display_is_local(const char *display) {
assert(display);
return
display[0] == ':' &&
display[1] >= '0' &&
display[1] <= '9';
}
bool kexec_loaded(void) {
_cleanup_free_ char *s = NULL;

View File

@ -43,16 +43,6 @@ static inline const char* enable_disable(bool b) {
return b ? "enable" : "disable";
}
bool plymouth_running(void);
bool display_is_local(const char *display) _pure_;
#define NULSTR_FOREACH(i, l) \
for ((i) = (l); (i) && *(i); (i) = strchr((i), 0)+1)
#define NULSTR_FOREACH_PAIR(i, j, l) \
for ((i) = (l), (j) = strchr((i), 0)+1; (i) && *(i); (i) = strchr((j), 0)+1, (j) = *(i) ? strchr((i), 0)+1 : (i))
extern int saved_argc;
extern char **saved_argv;
@ -65,31 +55,6 @@ void in_initrd_force(bool value);
int on_ac_power(void);
static inline void _reset_errno_(int *saved_errno) {
if (*saved_errno < 0) /* Invalidated by UNPROTECT_ERRNO? */
return;
errno = *saved_errno;
}
#define PROTECT_ERRNO \
_cleanup_(_reset_errno_) _unused_ int _saved_errno_ = errno
#define UNPROTECT_ERRNO \
do { \
errno = _saved_errno_; \
_saved_errno_ = -1; \
} while (false)
static inline int negative_errno(void) {
/* This helper should be used to shut up gcc if you know 'errno' is
* negative. Instead of "return -errno;", use "return negative_errno();"
* It will suppress bogus gcc warnings in case it assumes 'errno' might
* be 0 and thus the caller's error-handling might not be triggered. */
assert_return(errno > 0, -EINVAL);
return -errno;
}
static inline unsigned u64log2(uint64_t n) {
#if __SIZEOF_LONG_LONG__ == 8
return (n > 1) ? (unsigned) __builtin_clzll(n) ^ 63U : 0;

View File

@ -5,15 +5,16 @@
#include "alloc-util.h"
#include "blockdev-util.h"
#include "bpf-devices.h"
#include "bpf-firewall.h"
#include "btrfs-util.h"
#include "bpf-devices.h"
#include "bus-error.h"
#include "cgroup-util.h"
#include "cgroup.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
#include "nulstr-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "process-util.h"

View File

@ -41,6 +41,7 @@
#include "log.h"
#include "missing.h"
#include "mountpoint-util.h"
#include "nulstr-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "process-util.h"

View File

@ -138,11 +138,11 @@ static EmergencyAction arg_cad_burst_action = EMERGENCY_ACTION_REBOOT_FORCE;
_noreturn_ static void freeze_or_exit_or_reboot(void) {
/* If we are running in a contianer, let's prefer exiting, after all we can propagate an exit code to the
* container manager, and thus inform it that something went wrong. */
/* If we are running in a container, let's prefer exiting, after all we can propagate an exit code to
* the container manager, and thus inform it that something went wrong. */
if (detect_container() > 0) {
log_emergency("Exiting PID 1...");
exit(EXIT_EXCEPTION);
_exit(EXIT_EXCEPTION);
}
if (arg_crash_reboot) {

View File

@ -58,6 +58,7 @@
#include "parse-util.h"
#include "path-lookup.h"
#include "path-util.h"
#include "plymouth-util.h"
#include "process-util.h"
#include "ratelimit.h"
#include "rlimit-util.h"

View File

@ -23,12 +23,12 @@
#include "mkdir.h"
#include "mount-setup.h"
#include "mountpoint-util.h"
#include "nulstr-util.h"
#include "path-util.h"
#include "set.h"
#include "smack-util.h"
#include "strv.h"
#include "user-util.h"
#include "util.h"
#include "virt.h"
typedef enum MountMode {

View File

@ -23,6 +23,7 @@
#include "mountpoint-util.h"
#include "namespace-util.h"
#include "namespace.h"
#include "nulstr-util.h"
#include "path-util.h"
#include "selinux-util.h"
#include "socket-util.h"

View File

@ -16,12 +16,12 @@
#include "log.h"
#include "main-func.h"
#include "mount-util.h"
#include "nulstr-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "pretty-print.h"
#include "string-util.h"
#include "strv.h"
#include "pretty-print.h"
#include "util.h"
/* internal helper */
#define ANY_LUKS "LUKS"

View File

@ -14,6 +14,7 @@
#include "locale-util.h"
#include "log.h"
#include "main-func.h"
#include "nulstr-util.h"
#include "pager.h"
#include "parse-util.h"
#include "path-util.h"
@ -24,7 +25,6 @@
#include "string-util.h"
#include "strv.h"
#include "terminal-util.h"
#include "util.h"
static const char prefixes[] =
"/etc\0"

View File

@ -27,6 +27,7 @@
#include "fileio.h"
#include "fs-util.h"
#include "hostname-util.h"
#include "kbd-util.h"
#include "locale-util.h"
#include "main-func.h"
#include "mkdir.h"

View File

@ -19,6 +19,7 @@
#include "main-func.h"
#include "missing_capability.h"
#include "nscd-flush.h"
#include "nulstr-util.h"
#include "os-util.h"
#include "parse-util.h"
#include "path-util.h"

View File

@ -13,6 +13,7 @@
#include "sd-journal.h"
#include "alloc-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "io-util.h"
#include "memfd-util.h"
@ -20,7 +21,6 @@
#include "stdio-util.h"
#include "string-util.h"
#include "tmpfile-util.h"
#include "util.h"
#define SNDBUF_SIZE (8*1024*1024)

View File

@ -52,6 +52,7 @@
#include "logs-show.h"
#include "memory-util.h"
#include "mkdir.h"
#include "nulstr-util.h"
#include "pager.h"
#include "parse-util.h"
#include "path-util.h"

View File

@ -5,6 +5,7 @@
#include <sys/mman.h>
#include "alloc-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "hashmap.h"
#include "list.h"

View File

@ -32,6 +32,7 @@
#include "list.h"
#include "lookup3.h"
#include "missing.h"
#include "nulstr-util.h"
#include "path-util.h"
#include "process-util.h"
#include "replace-var.h"

View File

@ -5,12 +5,12 @@
#include "env-util.h"
#include "macro.h"
#include "memory-util.h"
#include "nulstr-util.h"
#include "parse-util.h"
#include "process-util.h"
#include "random-util.h"
#include "string-util.h"
#include "tests.h"
#include "util.h"
typedef int (compress_t)(const void *src, uint64_t src_size, void *dst,
size_t dst_alloc_size, size_t *dst_size);

View File

@ -12,6 +12,7 @@
#include "alloc-util.h"
#include "bus-error.h"
#include "errno-list.h"
#include "errno-util.h"
#include "string-util.h"
#include "util.h"

View File

@ -16,6 +16,11 @@
#include "socket-util.h"
#include "util.h"
/* Note that we use the new /run prefix here (instead of /var/run) since we require them to be aliases and
* that way we become independent of /var being mounted */
#define DEFAULT_SYSTEM_BUS_ADDRESS "unix:path=/run/dbus/system_bus_socket"
#define DEFAULT_USER_BUS_ADDRESS_FMT "unix:path=%s/bus"
struct reply_callback {
sd_bus_message_handler_t callback;
usec_t timeout_usec; /* this is a relative timeout until we reach the BUS_HELLO state, and an absolute one right after */

View File

@ -16,6 +16,7 @@
#include "hashmap.h"
#include "macro.h"
#include "mkdir.h"
#include "nulstr-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "set.h"
@ -25,7 +26,6 @@
#include "strxcpyx.h"
#include "tmpfile-util.h"
#include "user-util.h"
#include "util.h"
int device_add_property(sd_device *device, const char *key, const char *value) {
int r;

View File

@ -18,8 +18,8 @@
#include "hashmap.h"
#include "hwdb-internal.h"
#include "hwdb-util.h"
#include "nulstr-util.h"
#include "string-util.h"
#include "util.h"
struct sd_hwdb {
unsigned n_ref;

View File

@ -16,6 +16,7 @@
#include "alloc-util.h"
#include "dns-domain.h"
#include "errno-util.h"
#include "fd-util.h"
#include "io-util.h"
#include "list.h"

View File

@ -6,17 +6,18 @@
#include <unistd.h>
#include "bus-util.h"
#include "def.h"
#include "env-file.h"
#include "env-file-label.h"
#include "env-file.h"
#include "env-util.h"
#include "fd-util.h"
#include "fileio-label.h"
#include "fileio.h"
#include "kbd-util.h"
#include "keymap-util.h"
#include "locale-util.h"
#include "macro.h"
#include "mkdir.h"
#include "nulstr-util.h"
#include "string-util.h"
#include "strv.h"
#include "tmpfile-util.h"

View File

@ -11,9 +11,9 @@
#include "bus-error.h"
#include "bus-util.h"
#include "def.h"
#include "fd-util.h"
#include "fileio.h"
#include "kbd-util.h"
#include "locale-util.h"
#include "main-func.h"
#include "memory-util.h"

View File

@ -15,9 +15,9 @@
#include "audit-util.h"
#include "bus-common-errors.h"
#include "bus-error.h"
#include "bus-internal.h"
#include "bus-util.h"
#include "cgroup-util.h"
#include "def.h"
#include "fd-util.h"
#include "fileio.h"
#include "format-util.h"
@ -115,6 +115,15 @@ static int get_user_data(
return PAM_SUCCESS;
}
static bool display_is_local(const char *display) {
assert(display);
return
display[0] == ':' &&
display[1] >= '0' &&
display[1] <= '9';
}
static int socket_from_display(const char *display, char **path) {
size_t k;
char *f, *c;

View File

@ -37,6 +37,7 @@
#include "macro.h"
#include "main-func.h"
#include "mkdir.h"
#include "nulstr-util.h"
#include "pager.h"
#include "parse-util.h"
#include "path-util.h"

View File

@ -74,6 +74,7 @@
#include "nspawn-settings.h"
#include "nspawn-setuid.h"
#include "nspawn-stub-pid1.h"
#include "nulstr-util.h"
#include "os-util.h"
#include "pager.h"
#include "parse-util.h"

View File

@ -8,13 +8,13 @@
#include <string.h>
#include "alloc-util.h"
#include "errno-util.h"
#include "hostname-util.h"
#include "local-addresses.h"
#include "macro.h"
#include "nss-util.h"
#include "signal-util.h"
#include "string-util.h"
#include "util.h"
/* We use 127.0.0.2 as IPv4 address. This has the advantage over
* 127.0.0.1 that it can be translated back to the local hostname. For

View File

@ -9,6 +9,7 @@
#include "alloc-util.h"
#include "bus-common-errors.h"
#include "env-util.h"
#include "errno-util.h"
#include "hostname-util.h"
#include "in-addr-util.h"
#include "macro.h"

View File

@ -9,13 +9,13 @@
#include "sd-bus.h"
#include "bus-common-errors.h"
#include "errno-util.h"
#include "in-addr-util.h"
#include "macro.h"
#include "nss-util.h"
#include "resolved-def.h"
#include "string-util.h"
#include "util.h"
#include "signal-util.h"
#include "string-util.h"
NSS_GETHOSTBYNAME_PROTOTYPES(resolve);
NSS_GETHOSTBYADDR_PROTOTYPES(resolve);

View File

@ -17,6 +17,7 @@
#include "loop-util.h"
#include "machine-image.h"
#include "mkdir.h"
#include "nulstr-util.h"
#include "os-util.h"
#include "path-lookup.h"
#include "portable.h"

View File

@ -11,6 +11,7 @@
#include "fileio.h"
#include "log.h"
#include "macro.h"
#include "memory-util.h"
#include "socket-util.h"
#include "string-util.h"
#include "util.h"

View File

@ -9,6 +9,7 @@
#include "fd-util.h"
#include "fileio.h"
#include "hexdecoct.h"
#include "nulstr-util.h"
#include "parse-util.h"
#include "resolved-dns-dnssec.h"
#include "resolved-dns-trust-anchor.h"

View File

@ -13,10 +13,10 @@
#include "fd-util.h"
#include "log.h"
#include "macro.h"
#include "nulstr-util.h"
#include "string-util.h"
#include "umask-util.h"
#include "user-util.h"
#include "util.h"
typedef struct BaseFilesystem {
const char *dir;

View File

@ -14,6 +14,7 @@
#include "alloc-util.h"
#include "calendarspec.h"
#include "errno-util.h"
#include "fileio.h"
#include "macro.h"
#include "parse-util.h"

View File

@ -12,11 +12,11 @@
#include "alloc-util.h"
#include "clock-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "macro.h"
#include "string-util.h"
#include "util.h"
int clock_get_hwclock(struct tm *tm) {
_cleanup_close_ int fd = -1;

View File

@ -19,6 +19,7 @@
#include "log.h"
#include "macro.h"
#include "missing.h"
#include "nulstr-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "process-util.h"

View File

@ -8,10 +8,10 @@
#include "dev-setup.h"
#include "label.h"
#include "log.h"
#include "nulstr-util.h"
#include "path-util.h"
#include "umask-util.h"
#include "user-util.h"
#include "util.h"
int dev_setup(const char *prefix, uid_t uid, gid_t gid) {
static const char symlinks[] =

View File

@ -29,6 +29,7 @@
#include "missing.h"
#include "mount-util.h"
#include "mountpoint-util.h"
#include "nulstr-util.h"
#include "os-util.h"
#include "path-util.h"
#include "process-util.h"

View File

@ -11,11 +11,11 @@
#include "fstab-util.h"
#include "macro.h"
#include "mount-util.h"
#include "nulstr-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
int fstab_has_fstype(const char *fstype) {
_cleanup_endmntent_ FILE *f = NULL;

View File

@ -8,10 +8,10 @@
#include "import-util.h"
#include "log.h"
#include "macro.h"
#include "nulstr-util.h"
#include "path-util.h"
#include "string-table.h"
#include "string-util.h"
#include "util.h"
int import_url_last_component(const char *url, char **ret) {
const char *e, *p;

View File

@ -11,6 +11,7 @@
#include "sd-messages.h"
#include "alloc-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "float.h"

View File

@ -31,6 +31,7 @@
#include "machine-image.h"
#include "macro.h"
#include "mkdir.h"
#include "nulstr-util.h"
#include "os-util.h"
#include "path-util.h"
#include "rm-rf.h"
@ -39,7 +40,6 @@
#include "strv.h"
#include "time-util.h"
#include "utf8.h"
#include "util.h"
#include "xattr-util.h"
static const char* const image_search_path[_IMAGE_CLASS_MAX] = {

View File

@ -10,15 +10,15 @@
#include "af-list.h"
#include "alloc-util.h"
#include "errno-list.h"
#include "macro.h"
#include "nsflags.h"
#include "nulstr-util.h"
#include "process-util.h"
#include "seccomp-util.h"
#include "set.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
#include "errno-list.h"
const uint32_t seccomp_local_archs[] = {

View File

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <sys/xattr.h>
#include <unistd.h>
#include "alloc-util.h"
#include "chown-recursive.h"

View File

@ -19,15 +19,15 @@
#include "ima-util.h"
#include "log.h"
#include "macro.h"
#include "nulstr-util.h"
#include "selinux-util.h"
#include "set.h"
#include "smack-util.h"
#include "string-util.h"
#include "strv.h"
#include "tests.h"
#include "tomoyo-util.h"
#include "user-util.h"
#include "tests.h"
#include "util.h"
#include "virt.h"
static void test_condition_test_path(void) {

View File

@ -3,11 +3,11 @@
#include "alloc-util.h"
#include "hashmap.h"
#include "log.h"
#include "nulstr-util.h"
#include "stdio-util.h"
#include "string-util.h"
#include "strv.h"
#include "tests.h"
#include "util.h"
void test_hashmap_funcs(void);

View File

@ -1,5 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#include "kbd-util.h"
#include "locale-util.h"
#include "macro.h"
#include "strv.h"

View File

@ -16,6 +16,7 @@
#include "memory-util.h"
#include "missing.h"
#include "nsflags.h"
#include "nulstr-util.h"
#include "process-util.h"
#include "raw-clone.h"
#include "seccomp-util.h"

View File

@ -4,10 +4,10 @@
#include "alloc-util.h"
#include "escape.h"
#include "nulstr-util.h"
#include "specifier.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
static void test_specifier_printf(void) {
static const Specifier table[] = {

View File

@ -5,10 +5,10 @@
#include <sys/wait.h>
#include <unistd.h>
#include "def.h"
#include "fileio.h"
#include "fs-util.h"
#include "limits-util.h"
#include "memory-util.h"
#include "missing_syscall.h"
#include "parse-util.h"
#include "process-util.h"
@ -16,7 +16,7 @@
#include "rm-rf.h"
#include "string-util.h"
#include "tests.h"
#include "memory-util.h"
#include "util.h"
static void test_align_power2(void) {
unsigned long i, p2;

View File

@ -34,6 +34,7 @@
#include "memory-util.h"
#include "mkdir.h"
#include "path-util.h"
#include "plymouth-util.h"
#include "pretty-print.h"
#include "process-util.h"
#include "signal-util.h"