# XKB_FIXED_VARIANT=""
# Examples of such devices: the Yubikey or other key-code generating
# devices.
-#
+
+# A device where the scan code to key code mapping is insufficient and
+# requires a special key code to symbol configuration may specify that with:
+# XKB_FIXED_MODEL="xkbmodel"
+# Examples of such devices: Chromebooks where the top row is used for both
+# media and F1-F10 keys.
+
# To update this file, create a new file
# /etc/udev/hwdb.d/70-keyboard.hwdb
# and add your rules there. To load the new rules execute (as root):
KEYBOARD_KEY_d8=!f23 # touchpad off
KEYBOARD_KEY_d9=!f22 # touchpad on
-# Chromebook 14
-# Top row keys (between ESC and power button)
-evdev:atkbd:dmi:bvn*:bvr*:bd*:svnHewlett-Packard*:pnFalco:pvr*
- KEYBOARD_KEY_3b=back
- KEYBOARD_KEY_3c=forward
- KEYBOARD_KEY_3d=refresh
- KEYBOARD_KEY_3f=switchvideomode
- KEYBOARD_KEY_40=brightnessdown
- KEYBOARD_KEY_41=brightnessup
- KEYBOARD_KEY_42=mute
- KEYBOARD_KEY_43=volumedown
- KEYBOARD_KEY_44=volumeup
- KEYBOARD_KEY_db=search # Same position as caps lock key on most keyboards
- # KEYBOARD_KEY_3e=fullscreen, no defined key sym
-
# HP EliteBook 725 G2
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnHewlett-Packard*:pnHPLicrice:pvr*
# HP ProBook 440 G2
# Lenovo ThinkPad X1 Carbon 3rd Gen
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnLENOVO:pn*:pvrThinkPadX1Carbon3rd
KEYBOARD_LED_CAPSLOCK=0
+
+######################### FIXED MODEL DEVICES #############################
+# This section lists devices which require special handling in their key
+# code to keysym mapping by setting the xkb model.
+# The model must be an xkb compatible model (defined with XKB_FIXED_MODEL).
+
+# Chromebooks
+evdev:atkbd:dmi:bvn*:bvr*:bd*:svnHewlett-Packard*:pnFalco:pvr*
+evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pnPeppy:pvr*
+ XKB_FIXED_MODEL="chromebook"
('ID_INPUT_TOUCHPAD_INTEGRATION', Or(('internal', 'external'))),
('XKB_FIXED_LAYOUT', STRING),
('XKB_FIXED_VARIANT', STRING),
+ ('XKB_FIXED_MODEL', STRING),
('KEYBOARD_LED_NUMLOCK', Literal('0')),
('KEYBOARD_LED_CAPSLOCK', Literal('0')),
('ACCEL_MOUNT_MATRIX', mount_matrix),
<citerefentry><refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
Available naming schemes are described below.</para>
- <para>After the udev proprties have been generated, appropriate udev rules may be used to actually rename
+ <para>After the udev properties have been generated, appropriate udev rules may be used to actually rename
devices based on those properties. See the description of <varname>NamePolicy=</varname> and
<varname>MACAddressPolicy=</varname> in
<citerefentry><refentrytitle>systemd.link</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
#include <getopt.h>
#include <sys/epoll.h>
#include <sys/prctl.h>
-#include <sys/socket.h>
#include <sys/wait.h>
#include <unistd.h>
#include <getopt.h>
#include <inttypes.h>
-#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <sys/stat.h>
-#include <sys/statfs.h>
#include <unistd.h>
#include "alloc-util.h"
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <sys/statfs.h>
#include <sys/sysmacros.h>
#include <unistd.h>
#include <stddef.h>
#include <stdlib.h>
-#include <string.h>
#include "string-util.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <grp.h>
#include <stdio.h>
#include <stdlib.h>
-#include <sys/capability.h>
#include <sys/prctl.h>
#include <unistd.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <dirent.h>
#include <errno.h>
#include <ftw.h>
#include <limits.h>
#include <signal.h>
#include <stddef.h>
#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/statfs.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <sys/xattr.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <dirent.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include "conf-files.h"
#include "def.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/sendfile.h>
-#include <sys/stat.h>
#include <sys/xattr.h>
-#include <time.h>
#include <unistd.h>
#include "alloc-util.h"
#include <fcntl.h>
#include <limits.h>
#include <linux/fs.h>
-#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <limits.h>
#include <stdarg.h>
#include <stdlib.h>
-#include <string.h>
#include <unistd.h>
#include "alloc-util.h"
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
-#include <string.h>
#include <syslog.h>
#include "alloc-util.h"
#include <errno.h>
#include <fcntl.h>
#include <sys/resource.h>
-#include <sys/socket.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdint.h>
#include <stdio_ext.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <stdio.h>
-
#include "format-util.h"
#include "memory-util.h"
#include "stdio-util.h"
#include <errno.h>
#include <stddef.h>
-#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
#include <linux/falloc.h>
#include <linux/magic.h>
-#include <time.h>
#include <unistd.h>
#include "alloc-util.h"
}
int inotify_add_watch_and_warn(int fd, const char *pathname, uint32_t mask) {
- if (inotify_add_watch(fd, pathname, mask) < 0) {
- const char *reason;
+ if (inotify_add_watch(fd, pathname, mask) < 0) {
if (errno == ENOSPC)
- reason = "inotify watch limit reached";
- else
- reason = strerror_safe(errno);
+ return log_error_errno(errno, "Failed to add a watch for %s: inotify watch limit reached", pathname);
- return log_error_errno(errno, "Failed to add a watch for %s: %s", pathname, reason);
+ return log_error_errno(errno, "Failed to add a watch for %s: %m", pathname);
}
return 0;
/* SPDX-License-Identifier: LGPL-2.1+ */
#if HAVE_GCRYPT
-#include <gcrypt.h>
#include "gcrypt-util.h"
#include "hexdecoct.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <dirent.h>
#include <errno.h>
-#include <glob.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <glob.h>
#include <stdbool.h>
-#include <string.h>
#include "macro.h"
#include "string-util.h"
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
-#include <string.h>
#include "alloc-util.h"
#include "fileio.h"
#include <errno.h>
#include <limits.h>
#include <stdio.h>
-#include <string.h>
#include <sys/utsname.h>
#include <unistd.h>
#include <limits.h>
#include <poll.h>
#include <stdio.h>
-#include <time.h>
#include <unistd.h>
#include "io-util.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <ftw.h>
#include <langinfo.h>
#include <libintl.h>
-#include <locale.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <limits.h>
#include <stdarg.h>
#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
#include <sys/signalfd.h>
-#include <sys/socket.h>
#include <sys/time.h>
#include <sys/uio.h>
#include <sys/un.h>
-#include <time.h>
#include <unistd.h>
#include "sd-messages.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <string.h>
-
#include "login-util.h"
#include "string-util.h"
#include <errno.h>
#include <stdbool.h>
#include <string.h>
-#include <sys/stat.h>
#include "alloc-util.h"
#include "format-util.h"
#include <errno.h>
#include <inttypes.h>
#include <linux/oom.h>
-#include <locale.h>
#include <net/if.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/socket.h>
#include "alloc-util.h"
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
#include <unistd.h>
/* When we include libgen.h because we need dirname() we immediately
#include <stdbool.h>
#include <stddef.h>
-#include <string.h>
#include "alloc-util.h"
#include "efivars.h"
#include <errno.h>
#include <limits.h>
#include <linux/oom.h>
-#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/personality.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
-#include <alloca.h>
#include <errno.h>
#include <sched.h>
#include <signal.h>
#include <errno.h>
#include <stddef.h>
#include <stdlib.h>
-#include <string.h>
#include "alloc-util.h"
#include "macro.h"
#include <fcntl.h>
#include <stdbool.h>
#include <stddef.h>
-#include <sys/stat.h>
-#include <sys/statfs.h>
#include <unistd.h>
#include "alloc-util.h"
#include <errno.h>
#include <stdarg.h>
-#include <stdio.h>
#include "macro.h"
#include "parse-util.h"
#include <errno.h>
#include <fcntl.h>
-#include <string.h>
#include <sys/stat.h>
#include <sys/xattr.h>
#include <unistd.h>
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
-#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
-#include <linux/magic.h>
#include <sched.h>
-#include <sys/stat.h>
#include <sys/statvfs.h>
#include <sys/types.h>
#include <unistd.h>
extern const struct StaticDestructor _weak_ __start_SYSTEMD_STATIC_DESTRUCT[];
extern const struct StaticDestructor _weak_ __stop_SYSTEMD_STATIC_DESTRUCT[];
-/* The function to destroy everything. (Note that this must be static inline, as it's key that it remains in the same
- * linking unit as the variables we want to destroy. */
+/* The function to destroy everything. (Note that this must be static inline, as it's key that it remains in
+ * the same linking unit as the variables we want to destroy.) */
static inline void static_destruct(void) {
const StaticDestructor *d;
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
-#include <string.h>
#include <sys/types.h>
#include "macro.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include "alloc-util.h"
#include "escape.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
-#include <alloca.h>
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include "alloc-util.h"
#include "escape.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <string.h>
#include <syslog.h>
#include "hexdecoct.h"
#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/inotify.h>
#include <sys/ioctl.h>
-#include <sys/socket.h>
#include <sys/sysmacros.h>
#include <sys/time.h>
#include <sys/types.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/mman.h>
-#include <sys/stat.h>
#include <sys/time.h>
#include <sys/timerfd.h>
#include <sys/timex.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <stdio.h>
#include <sys/mman.h>
#include "alloc-util.h"
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
-#include <string.h>
#include "alloc-util.h"
#include "glob-util.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <alloca.h>
#include <errno.h>
#include <fcntl.h>
-#include <grp.h>
-#include <pwd.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <utmp.h>
}
int in_gid(gid_t gid) {
- gid_t *gids;
- int ngroups, r, i;
+ _cleanup_free_ gid_t *allocated = NULL;
+ gid_t local[16], *p = local;
+ int ngroups = ELEMENTSOF(local);
+ unsigned attempt = 0;
if (getgid() == gid)
return 1;
if (!gid_is_valid(gid))
return -EINVAL;
- ngroups = getgroups(0, NULL);
- if (ngroups < 0)
- return -errno;
- if (ngroups == 0)
- return 0;
-
- gids = newa(gid_t, ngroups);
+ for (;;) {
+ ngroups = getgroups(ngroups, p);
+ if (ngroups >= 0)
+ break;
+ if (errno != EINVAL)
+ return -errno;
+
+ /* Give up eventually */
+ if (attempt++ > 10)
+ return -EINVAL;
+
+ /* Get actual size needed, and size the array explicitly. Note that this is potentially racy
+ * to use (in multi-threaded programs), hence let's call this in a loop. */
+ ngroups = getgroups(0, NULL);
+ if (ngroups < 0)
+ return -errno;
+ if (ngroups == 0)
+ return false;
+
+ free(allocated);
+
+ allocated = new(gid_t, ngroups);
+ if (!allocated)
+ return -ENOMEM;
- r = getgroups(ngroups, gids);
- if (r < 0)
- return -errno;
+ p = allocated;
+ }
- for (i = 0; i < r; i++)
- if (gids[i] == gid)
- return 1;
+ for (int i = 0; i < ngroups; i++)
+ if (p[i] == gid)
+ return true;
- return 0;
+ return false;
}
int in_group(const char *name) {
#include <errno.h>
#include <stdbool.h>
#include <stdlib.h>
-#include <string.h>
#include "alloc-util.h"
#include "gunicode.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <alloca.h>
#include <errno.h>
#include <fcntl.h>
-#include <sched.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <sys/mman.h>
-#include <sys/prctl.h>
-#include <sys/statfs.h>
-#include <sys/sysmacros.h>
-#include <sys/types.h>
-#include <unistd.h>
#include "alloc-util.h"
-#include "btrfs-util.h"
#include "build.h"
-#include "def.h"
-#include "device-nodes.h"
#include "dirent-util.h"
#include "env-file.h"
#include "env-util.h"
#include "fd-util.h"
#include "fileio.h"
-#include "format-util.h"
-#include "hashmap.h"
#include "hostname-util.h"
#include "log.h"
#include "macro.h"
#include "parse-util.h"
-#include "path-util.h"
-#include "process-util.h"
-#include "procfs-util.h"
-#include "set.h"
-#include "signal-util.h"
#include "stat-util.h"
-#include "static-destruct.h"
#include "string-util.h"
-#include "strv.h"
-#include "time-util.h"
-#include "umask-util.h"
-#include "user-util.h"
#include "util.h"
#include "virt.h"
int saved_argc = 0;
char **saved_argv = NULL;
-char **saved_env = NULL;
static int saved_in_initrd = -1;
-STATIC_DESTRUCTOR_REGISTER(saved_env, strv_freep);
-
bool kexec_loaded(void) {
_cleanup_free_ char *s = NULL;
if (r < 0)
log_debug_errno(r, "Failed to turn off coredumps, ignoring: %m");
}
-
-void save_env(void) {
- saved_env = strv_copy(environ);
-}
saved_argv = argv;
}
-extern char **saved_env;
-void save_env(void);
-
bool kexec_loaded(void);
int prot_from_flags(int flags) _const_;
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
-#include <string.h>
#include <unistd.h>
#include "alloc-util.h"
#include <fcntl.h>
#include <stdint.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/time.h>
#include <sys/xattr.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <blkid.h>
#include <ctype.h>
-#include <dirent.h>
#include <errno.h>
#include <ftw.h>
#include <getopt.h>
#include <limits.h>
#include <linux/magic.h>
#include <stdbool.h>
-#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/statfs.h>
#include <unistd.h>
#include "sd-id128.h"
#include "fs-util.h"
#include "locale-util.h"
#include "main-func.h"
+#include "mkdir.h"
#include "pager.h"
#include "parse-util.h"
#include "pretty-print.h"
if (r < 0)
return log_error_errno(r, "Failed to acquire random seed: %m");
+ /* Normally create_subdirs() should already have created everything we need, but in case "bootctl
+ * random-seed" is called we want to just create the minimum we need for it, and not the full
+ * list. */
+ r = mkdir_parents(path, 0755);
+ if (r < 0)
+ return log_error_errno(r, "Failed to create parent directory for %s: %m", path);
+
r = tempfn_random(path, "bootctl", &tmp);
if (r < 0)
return log_oom();
static VOID config_entry_add_from_file(
Config *config,
EFI_HANDLE *device,
+ EFI_FILE *root_dir,
CHAR16 *path,
CHAR16 *file,
CHAR8 *content,
UINTN pos = 0;
CHAR8 *key, *value;
UINTN len;
+ EFI_STATUS err;
+ EFI_FILE_HANDLE handle;
_cleanup_freepool_ CHAR16 *initrd = NULL;
entry = AllocatePool(sizeof(ConfigEntry));
return;
}
+ /* check existence */
+ err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &handle, entry->loader, EFI_FILE_MODE_READ, 0ULL);
+ if (EFI_ERROR(err)) {
+ config_entry_free(entry);
+ return;
+ }
+ uefi_call_wrapper(handle->Close, 1, handle);
+
/* add initrd= to options */
if (entry->type == LOADER_LINUX && initrd) {
if (entry->options) {
err = file_read(entries_dir, f->FileName, 0, 0, &content, NULL);
if (!EFI_ERROR(err))
- config_entry_add_from_file(config, device, L"\\loader\\entries", f->FileName, content, loaded_image_path);
+ config_entry_add_from_file(config, device, root_dir, L"\\loader\\entries", f->FileName, content, loaded_image_path);
}
uefi_call_wrapper(entries_dir->Close, 1, entries_dir);
}
if (r < 0)
return log_error_errno(r, "Failed to show table: %m");
-
-
return 0;
}
#include <errno.h>
#include <getopt.h>
#include <stdio.h>
-#include <string.h>
#include <unistd.h>
#include "sd-bus.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <stdlib.h>
-#include <sys/socket.h>
#include "fd-util.h"
#include "log.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <alloca.h>
#include <errno.h>
#include <getopt.h>
#include <signal.h>
#include <stdint.h>
#include <stdlib.h>
-#include <string.h>
#include <unistd.h>
#include "sd-bus.h"
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <unistd.h>
#include "alloc-util.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <grp.h>
-#include <pwd.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
-#include <glob.h>
-#include <grp.h>
#include <poll.h>
-#include <signal.h>
-#include <string.h>
-#include <sys/capability.h>
#include <sys/eventfd.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/personality.h>
#include <sys/prctl.h>
#include <sys/shm.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
case JOB_TRY_RESTART:
s = unit_active_state(u);
- if (UNIT_IS_INACTIVE_OR_DEACTIVATING(s))
+ if (!UNIT_IS_ACTIVE_OR_RELOADING(s))
return JOB_NOP;
return JOB_RESTART;
case JOB_TRY_RELOAD:
s = unit_active_state(u);
- if (UNIT_IS_INACTIVE_OR_DEACTIVATING(s))
+ if (!UNIT_IS_ACTIVE_OR_RELOADING(s))
return JOB_NOP;
return JOB_RELOAD;
case JOB_RELOAD_OR_START:
s = unit_active_state(u);
- if (UNIT_IS_INACTIVE_OR_DEACTIVATING(s))
+ if (!UNIT_IS_ACTIVE_OR_RELOADING(s))
return JOB_START;
return JOB_RELOAD;
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <ftw.h>
-#include <string.h>
#include <unistd.h>
#include "alloc-util.h"
#include "string-util.h"
#if HAVE_KMOD
-#include <libkmod.h>
#include "module-util.h"
static void systemd_kmod_log(
#include <seccomp.h>
#endif
#include <sched.h>
-#include <string.h>
#include <sys/resource.h>
-#include <sys/stat.h>
#include "af-list.h"
#include "alloc-util.h"
#include <errno.h>
#include <stdlib.h>
-#include <string.h>
#include "env-file.h"
#include "env-util.h"
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
-#include <signal.h>
-#include <stdio.h>
-#include <string.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/reboot.h>
-#include <sys/stat.h>
#include <unistd.h>
#if HAVE_SECCOMP
#include <seccomp.h>
static CPUSet arg_cpu_affinity;
static NUMAPolicy arg_numa_policy;
+/* A copy of the original environment block */
+static char **saved_env = NULL;
+
static int parse_configuration(const struct rlimit *saved_rlimit_nofile,
const struct rlimit *saved_rlimit_memlock);
return found_deserialize; /* When we are deserializing, then we are reexecuting, hence avoid the extensive setup */
}
+static int save_env(void) {
+ char **l;
+
+ l = strv_copy(environ);
+ if (!l)
+ return -ENOMEM;
+
+ strv_free_and_replace(saved_env, l);
+ return 0;
+}
+
int main(int argc, char *argv[]) {
dual_timestamp initrd_timestamp = DUAL_TIMESTAMP_NULL, userspace_timestamp = DUAL_TIMESTAMP_NULL, kernel_timestamp = DUAL_TIMESTAMP_NULL,
/* Save the original command line */
save_argc_argv(argc, argv);
- /* Save the original environment as we might need to restore it if we're requested to
- * execute another system manager later. */
- save_env();
+ /* Save the original environment as we might need to restore it if we're requested to execute another
+ * system manager later. */
+ r = save_env();
+ if (r < 0) {
+ error_message = "Failed to copy environment block";
+ goto finish;
+ }
/* Make sure that if the user says "syslog" we actually log to the journal. */
log_set_upgrade_syslog_to_journal(true);
arg_serialization = safe_fclose(arg_serialization);
fds = fdset_free(fds);
+ saved_env = strv_free(saved_env);
+
#if HAVE_VALGRIND_VALGRIND_H
/* If we are PID 1 and running under valgrind, then let's exit
* here explicitly. valgrind will only generate nice output on
#include <errno.h>
#include <fcntl.h>
#include <linux/kd.h>
-#include <signal.h>
-#include <string.h>
#include <sys/epoll.h>
#include <sys/inotify.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <sched.h>
#include <stdio.h>
-#include <string.h>
#include <sys/mount.h>
-#include <sys/stat.h>
#include <unistd.h>
#include <linux/fs.h>
#include <errno.h>
#include <selinux/avc.h>
#include <selinux/selinux.h>
-#include <stdio.h>
#if HAVE_AUDIT
#include <libaudit.h>
#endif
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <signal.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
Nathaniel Chen <nathaniel.chen@intel.com>
***/
-#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <unistd.h>
#include "alloc-util.h"
#include <fcntl.h>
#include <mqueue.h>
#include <netinet/tcp.h>
-#include <signal.h>
#include <sys/epoll.h>
#include <sys/stat.h>
#include <unistd.h>
if (s->result == SWAP_SUCCESS)
s->result = f;
-
r = unit_kill_context(UNIT(s),
&s->kill_context,
state_to_kill_operation(s, state),
swap_enter_signal(s, SWAP_DEACTIVATING_SIGKILL, SWAP_SUCCESS);
return 0;
-
default:
assert_not_reached("Unexpected state.");
}
#include <errno.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/prctl.h>
-#include <sys/stat.h>
#include <unistd.h>
#include "sd-id128.h"
#include <getopt.h>
#include <locale.h>
#include <stdio.h>
-#include <string.h>
#include <unistd.h>
#include "sd-bus.h"
#include <errno.h>
#include <mntent.h>
-#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <getopt.h>
-#include <string.h>
#include <sys/prctl.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
-#include <stdio.h>
#include <sys/file.h>
#include <sys/prctl.h>
#include <sys/stat.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <mntent.h>
#include <stdio.h>
-#include <string.h>
#include <unistd.h>
#include "alloc-util.h"
#include <errno.h>
#include <fcntl.h>
-#include <string.h>
#include <unistd.h>
#include "alloc-util.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <blkid.h>
#include <stdlib.h>
-#include <sys/statfs.h>
#include <unistd.h>
#include "sd-device.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <string.h>
#include <sys/utsname.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
-#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/prctl.h>
-#include <sys/socket.h>
#include <stdint.h>
#include "sd-daemon.h"
#include <stddef.h>
#include <stdio.h>
-#include <string.h>
#if HAVE_GNUTLS
#include <gnutls/gnutls.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
-#include <alloca.h>
#include <stdio.h>
#include "alloc-util.h"
#include <fcntl.h>
#include <locale.h>
#include <stdio.h>
-#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <inttypes.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
* http://eprint.iacr.org/2013/397
*/
-#include <gcrypt.h>
#include <string.h>
#include "fsprg.h"
#include <fcntl.h>
#include <printf.h>
#include <stddef.h>
-#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <fnmatch.h>
#include <getopt.h>
#include <linux/fs.h>
-#include <locale.h>
#include <poll.h>
#include <signal.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/inotify.h>
#include <sys/stat.h>
#include <unistd.h>
HASHMAP_FOREACH(d, j->directories_by_path, i) {
int q;
- if (d->is_root)
- continue;
-
q = journal_directory_vacuum(d->path, arg_vacuum_size, arg_vacuum_n_files, arg_vacuum_time, NULL, !arg_quiet);
if (q < 0) {
log_error_errno(q, "Failed to vacuum %s: %m", d->path);
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <string.h>
#include "alloc-util.h"
#include "hashmap.h"
}
static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents, void *userdata) {
+ uint8_t buf[CMSG_SPACE(sizeof(struct ucred))];
StdoutStream *s = userdata;
+ struct ucred *ucred = NULL;
+ struct cmsghdr *cmsg;
+ struct iovec iovec;
size_t limit;
ssize_t l;
int r;
+ struct msghdr msghdr = {
+ .msg_iov = &iovec,
+ .msg_iovlen = 1,
+ .msg_control = buf,
+ .msg_controllen = sizeof(buf),
+ };
+
assert(s);
if ((revents|EPOLLIN|EPOLLHUP) != (EPOLLIN|EPOLLHUP)) {
* always leave room for a terminating NUL we might need to add. */
limit = MIN(s->allocated - 1, s->server->line_max);
- l = read(s->fd, s->buffer + s->length, limit - s->length);
+ iovec = IOVEC_MAKE(s->buffer + s->length, limit - s->length);
+
+ l = recvmsg(s->fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
if (l < 0) {
- if (errno == EAGAIN)
+ if (IN_SET(errno, EINTR, EAGAIN))
return 0;
log_warning_errno(errno, "Failed to read from stream: %m");
goto terminate;
}
+ cmsg_close_all(&msghdr);
if (l == 0) {
stdout_stream_scan(s, true);
goto terminate;
}
+ CMSG_FOREACH(cmsg, &msghdr)
+ if (cmsg->cmsg_level == SOL_SOCKET &&
+ cmsg->cmsg_type == SCM_CREDENTIALS &&
+ cmsg->cmsg_len == CMSG_LEN(sizeof(struct ucred))) {
+ ucred = (struct ucred *)CMSG_DATA(cmsg);
+ break;
+ }
+
+ /* Invalidate the context if the pid of the sender changed.
+ * This happens when a forked process inherits stdout / stderr
+ * from a parent. In this case getpeercred returns the ucred
+ * of the parent, which can be invalid if the parent has exited
+ * in the meantime.
+ */
+ if (ucred && ucred->pid != s->ucred.pid) {
+ /* force out any previously half-written lines from a
+ * different process, before we switch to the new ucred
+ * structure for everything we just added */
+ r = stdout_stream_scan(s, true);
+ if (r < 0)
+ goto terminate;
+
+ s->ucred = *ucred;
+ client_context_release(s->server, s->context);
+ s->context = NULL;
+ }
+
s->length += l;
r = stdout_stream_scan(s, false);
if (r < 0)
if (r < 0)
return log_error_errno(r, "Failed to determine peer credentials: %m");
+ r = setsockopt_int(fd, SOL_SOCKET, SO_PASSCRED, true);
+ if (r < 0)
+ return log_error_errno(r, "SO_PASSCRED failed: %m");
+
if (mac_selinux_use()) {
r = getpeersec(fd, &stream->label);
if (r < 0 && r != -EOPNOTSUPP)
#include <net/if_arp.h>
#include <stdio.h>
#include <string.h>
-#include <sys/socket.h>
#include <linux/filter.h>
#include <linux/if_infiniband.h>
#include <linux/if_packet.h>
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
-#include <string.h>
#include "alloc-util.h"
#include "dhcp-internal.h"
#include <netinet/ip6.h>
#include <stdio.h>
#include <string.h>
-#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/if_packet.h>
#include <errno.h>
#include <netinet/in.h>
-#include <string.h>
#include "sd-dhcp6-client.h"
#include <netinet/ip6.h>
#include <stdio.h>
#include <string.h>
-#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/ioctl.h>
#include <linux/if_infiniband.h>
#include <arpa/inet.h>
#include <errno.h>
-#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
***/
#include <errno.h>
-#include <string.h>
#include <sys/ioctl.h>
#include <linux/if_arp.h>
#include <linux/if_infiniband.h>
#include <netinet/if_ether.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include "sd-ipv4acd.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include "sd-id128.h"
#include "sd-ipv4acd.h"
sd_radv_prefix_unref(p);
}
+ while (ra->route_prefixes) {
+ sd_radv_route_prefix *p = ra->route_prefixes;
+
+ LIST_REMOVE(prefix, ra->route_prefixes, p);
+ sd_radv_route_prefix_unref(p);
+ }
+
free(ra->rdnss);
free(ra->dnssl);
#include <net/if_arp.h>
#include <stdbool.h>
#include <stdio.h>
-#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <netinet/if_ether.h>
#include <stdio.h>
#include <stdlib.h>
-#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <net/ethernet.h>
#include <stdio.h>
-#include <string.h>
#include <unistd.h>
#include "sd-event.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include "sd-bus.h"
#pragma once
#include <pthread.h>
-#include <sys/socket.h>
#include "sd-bus.h"
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/un.h>
#include <unistd.h>
initialized = sd_device_get_is_initialized(device);
if (initialized < 0) {
- r = initialized;
+ if (initialized != -ENOENT)
+ /* this is necessarily racey, so ignore missing devices */
+ r = initialized;
+
continue;
}
k = sd_device_get_subsystem(device, &subsystem);
if (k < 0) {
- r = k;
+ if (k != -ENOENT)
+ /* this is necessarily racy, so ignore missing devices */
+ r = k;
continue;
}
#include <errno.h>
#include <linux/filter.h>
#include <linux/netlink.h>
-#include <sys/socket.h>
#include <unistd.h>
#include "sd-device.h"
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <errno.h>
#include <poll.h>
-#include <string.h>
#include <sys/inotify.h>
#include <unistd.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <poll.h>
-#include <string.h>
#include "sd-login.h"
return 0;
}
-
r = sd_genl_message_new(nl, SD_GENL_ID_CTRL, CTRL_CMD_GETFAMILY, &req);
if (r < 0)
return r;
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <poll.h>
-#include <sys/socket.h>
#include "sd-netlink.h"
#include <errno.h>
#include <poll.h>
-#include <string.h>
#include <sys/inotify.h>
#include "sd-network.h"
#include <netinet/in.h>
#include <resolv.h>
#include <stdio.h>
-#include <string.h>
-#include <sys/socket.h>
#include "sd-resolve.h"
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include "libudev.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <ftw.h>
#include <getopt.h>
-#include <locale.h>
#include <stdbool.h>
#include <stdlib.h>
-#include <string.h>
#include "sd-bus.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <getopt.h>
#include <locale.h>
-#include <string.h>
#include <unistd.h>
#include "sd-bus.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <string.h>
#include "sd-device.h"
#include <errno.h>
#include <fcntl.h>
-#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>
-#include <linux/input.h>
#include "sd-messages.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <fcntl.h>
-#include <pwd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <linux/vt.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <pwd.h>
-#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
-#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <string.h>
#include "alloc-util.h"
#include "bus-common-errors.h"
#include <errno.h>
#include <fcntl.h>
-#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <string.h>
#include "alloc-util.h"
#include "bus-common-errors.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <fcntl.h>
-#include <linux/input.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <linux/kd.h>
#include <linux/vt.h>
#include <signal.h>
-#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <unistd.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <string.h>
#include "alloc-util.h"
#include "bus-util.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <string.h>
#include <unistd.h>
#include "alloc-util.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <pwd.h>
-#include <string.h>
#include <unistd.h>
#include "sd-messages.h"
#include <errno.h>
#include <fcntl.h>
-#include <string.h>
#include <unistd.h>
#include "sd-daemon.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <string.h>
#include "sd-device.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <string.h>
#include <sys/mount.h>
#include <sys/wait.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
-#include <locale.h>
#include <math.h>
#include <net/if.h>
#include <netinet/in.h>
-#include <string.h>
#include <sys/mount.h>
#include <sys/socket.h>
#include <unistd.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <string.h>
#include <unistd.h>
#include "sd-id128.h"
#include <errno.h>
#include <getopt.h>
-#include <libkmod.h>
#include <limits.h>
-#include <string.h>
#include <sys/stat.h>
#include "conf-files.h"
return k;
}
-
static int verb_reload(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
struct rtnl_link_stats64 stats_old, stats_new;
bool stats_updated;
-
/* All kinds of DNS configuration */
struct in_addr_data *dns;
unsigned n_dns;
#include <inttypes.h>
#include <net/if.h>
#include <net/if_arp.h>
-#include <string.h>
#include "alloc-util.h"
#include "env-file.h"
}
int network_verify(Network *network) {
+ RoutePrefix *route_prefix, *route_prefix_next;
RoutingPolicyRule *rule, *rule_next;
Neighbor *neighbor, *neighbor_next;
AddressLabel *label, *label_next;
if (section_is_invalid(prefix->section))
prefix_free(prefix);
- LIST_FOREACH_SAFE(prefixes, prefix, prefix_next, network->static_route_prefixes)
- if (section_is_invalid(prefix->section))
- prefix_free(prefix);
+ LIST_FOREACH_SAFE(route_prefixes, route_prefix, route_prefix_next, network->static_route_prefixes)
+ if (section_is_invalid(route_prefix->section))
+ route_prefix_free(route_prefix);
LIST_FOREACH_SAFE(rules, rule, rule_next, network->rules)
if (routing_policy_rule_section_verify(rule) < 0)
static Network *network_free(Network *network) {
IPv6ProxyNDPAddress *ipv6_proxy_ndp_address;
+ RoutePrefix *route_prefix;
RoutingPolicyRule *rule;
+ AddressLabel *label;
FdbEntry *fdb_entry;
Neighbor *neighbor;
- AddressLabel *label;
Address *address;
NextHop *nexthop;
Prefix *prefix;
while ((prefix = network->static_prefixes))
prefix_free(prefix);
+ while ((route_prefix = network->static_route_prefixes))
+ route_prefix_free(route_prefix);
+
while ((rule = network->rules))
routing_policy_rule_free(rule);
hashmap_free(network->neighbors_by_section);
hashmap_free(network->address_labels_by_section);
hashmap_free(network->prefixes_by_section);
+ hashmap_free(network->route_prefixes_by_section);
hashmap_free(network->rules_by_section);
ordered_hashmap_free_with_destructor(network->qdiscs_by_section, qdisc_free);
LIST_HEAD(Neighbor, neighbors);
LIST_HEAD(AddressLabel, address_labels);
LIST_HEAD(Prefix, static_prefixes);
- LIST_HEAD(Prefix, static_route_prefixes);
+ LIST_HEAD(RoutePrefix, static_route_prefixes);
LIST_HEAD(RoutingPolicyRule, rules);
unsigned n_static_addresses;
}
network_config_section_free(prefix->section);
- prefix->radv_prefix = sd_radv_prefix_unref(prefix->radv_prefix);
+ sd_radv_prefix_unref(prefix->radv_prefix);
free(prefix);
}
-int prefix_new(Prefix **ret) {
+static int prefix_new(Prefix **ret) {
_cleanup_(prefix_freep) Prefix *prefix = NULL;
prefix = new0(Prefix, 1);
return 0;
}
-int route_prefix_new(Prefix **ret) {
- _cleanup_(prefix_freep) Prefix *prefix = NULL;
+static int route_prefix_new(RoutePrefix **ret) {
+ _cleanup_(route_prefix_freep) RoutePrefix *prefix = NULL;
- prefix = new0(Prefix, 1);
+ prefix = new0(RoutePrefix, 1);
if (!prefix)
return -ENOMEM;
return 0;
}
-void route_prefix_free(Prefix *prefix) {
+void route_prefix_free(RoutePrefix *prefix) {
if (!prefix)
return;
if (prefix->network) {
- LIST_REMOVE(prefixes, prefix->network->static_route_prefixes, prefix);
+ LIST_REMOVE(route_prefixes, prefix->network->static_route_prefixes, prefix);
assert(prefix->network->n_static_route_prefixes > 0);
prefix->network->n_static_route_prefixes--;
}
network_config_section_free(prefix->section);
+ sd_radv_route_prefix_unref(prefix->radv_route_prefix);
free(prefix);
}
static int route_prefix_new_static(Network *network, const char *filename,
- unsigned section_line, Prefix **ret) {
+ unsigned section_line, RoutePrefix **ret) {
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
- _cleanup_(prefix_freep) Prefix *prefix = NULL;
+ _cleanup_(route_prefix_freep) RoutePrefix *prefix = NULL;
int r;
assert(network);
return r;
prefix->network = network;
- LIST_APPEND(prefixes, network->static_route_prefixes, prefix);
+ LIST_APPEND(route_prefixes, network->static_route_prefixes, prefix);
network->n_static_route_prefixes++;
if (filename) {
void *userdata) {
Network *network = userdata;
- _cleanup_(prefix_free_or_set_invalidp) Prefix *p = NULL;
+ _cleanup_(route_prefix_free_or_set_invalidp) RoutePrefix *p = NULL;
uint8_t prefixlen = 64;
union in_addr_union in6addr;
int r;
void *data,
void *userdata) {
Network *network = userdata;
- _cleanup_(prefix_free_or_set_invalidp) Prefix *p = NULL;
+ _cleanup_(route_prefix_free_or_set_invalidp) RoutePrefix *p = NULL;
usec_t usec;
int r;
r = parse_sec(rvalue, &usec);
if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, r, "Roure lifetime is invalid, ignoring assignment: %s", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, r,
+ "Route lifetime is invalid, ignoring assignment: %s", rvalue);
return 0;
}
}
int radv_configure(Link *link) {
- int r;
+ RoutePrefix *q;
Prefix *p;
+ int r;
assert(link);
assert(link->network);
return r;
}
- LIST_FOREACH(prefixes, p, link->network->static_route_prefixes) {
- r = sd_radv_add_route_prefix(link->radv, p->radv_route_prefix, false);
+ LIST_FOREACH(route_prefixes, q, link->network->static_route_prefixes) {
+ r = sd_radv_add_route_prefix(link->radv, q->radv_route_prefix, false);
if (r == -EEXIST)
continue;
if (r < 0)
#include "networkd-util.h"
typedef struct Prefix Prefix;
+typedef struct RoutePrefix RoutePrefix;
typedef enum RADVPrefixDelegation {
RADV_PREFIX_DELEGATION_NONE,
NetworkConfigSection *section;
sd_radv_prefix *radv_prefix;
- sd_radv_route_prefix *radv_route_prefix;
LIST_FIELDS(Prefix, prefixes);
- LIST_FIELDS(Prefix, route_prefixes);
};
-int prefix_new(Prefix **ret);
+struct RoutePrefix {
+ Network *network;
+ NetworkConfigSection *section;
+
+ sd_radv_route_prefix *radv_route_prefix;
+
+ LIST_FIELDS(RoutePrefix, route_prefixes);
+};
+
void prefix_free(Prefix *prefix);
DEFINE_NETWORK_SECTION_FUNCTIONS(Prefix, prefix_free);
-int route_prefix_new(Prefix **ret);
-void route_prefix_free(Prefix *prefix);
+void route_prefix_free(RoutePrefix *prefix);
-DEFINE_NETWORK_SECTION_FUNCTIONS(Prefix, route_prefix_free);
+DEFINE_NETWORK_SECTION_FUNCTIONS(RoutePrefix, route_prefix_free);
int radv_emit_dns(Link *link);
int radv_configure(Link *link);
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <fcntl.h>
-#include <linux/magic.h>
-#if HAVE_ACL
-#include <sys/acl.h>
-#endif
-#include <sys/stat.h>
#include <sys/statvfs.h>
#include <sys/vfs.h>
#include <unistd.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <fcntl.h>
-#include <grp.h>
#include <sys/types.h>
#include <unistd.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
#if HAVE_BLKID
-#include <blkid.h>
#endif
#include <errno.h>
#include <getopt.h>
-#include <grp.h>
#include <linux/fs.h>
#include <linux/loop.h>
-#include <pwd.h>
-#include <sched.h>
#if HAVE_SELINUX
#include <selinux/selinux.h>
#endif
-#include <signal.h>
-#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/file.h>
#include <sys/personality.h>
#include <sys/prctl.h>
#include "terminal-util.h"
#include "tmpfile-util.h"
#include "umask-util.h"
+#include "unit-name.h"
#include "user-util.h"
#include "util.h"
arg_settings_mask |= SETTING_MACHINE_ID;
break;
- case 'S':
- r = free_and_strdup(&arg_slice, optarg);
+ case 'S': {
+ _cleanup_free_ char *mangled = NULL;
+
+ r = unit_name_mangle_with_suffix(optarg, NULL, UNIT_NAME_MANGLE_WARN, ".slice", &mangled);
if (r < 0)
return log_oom();
+ free_and_replace(arg_slice, mangled);
arg_settings_mask |= SETTING_SLICE;
break;
+ }
case 'M':
if (isempty(optarg))
/* If we're not using OCI, proceed with mangled capabilities (so we don't error out)
* in order to maintain the same behavior as systemd < 242. */
if (capability_quintet_mangle(&q))
- log_warning("Some capabilities will not be set because they are not in the current bounding set.");
+ log_full(arg_quiet ? LOG_DEBUG : LOG_WARNING,
+ "Some capabilities will not be set because they are not in the current bounding set.");
}
#include <netdb.h>
#include <nss.h>
#include <stdlib.h>
-#include <string.h>
#include "alloc-util.h"
#include "errno-util.h"
#include <netdb.h>
#include <nss.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/magic.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
-#include <sys/stat.h>
#include <sys/types.h>
#include <sys/vfs.h>
***/
#include <fcntl.h>
-#include <signal.h>
#include <sys/prctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
#include <linux/random.h>
-#include <string.h>
#include <sys/ioctl.h>
#if USE_SYS_RANDOM_H
# include <sys/random.h>
#include <errno.h>
#include <mntent.h>
-#include <string.h>
#include <sys/prctl.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <errno.h>
#include <stddef.h>
-#include <string.h>
-#include <sys/socket.h>
#include <sys/un.h>
#include "alloc-util.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
-#if HAVE_GCRYPT
-# include <gcrypt.h>
-#endif
-
#include "alloc-util.h"
#include "dns-domain.h"
#include "fd-util.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <net/if.h>
-#include <glob.h>
#include "sd-id128.h"
#include <inttypes.h>
#include <limits.h>
#include <poll.h>
-#include <signal.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/inotify.h>
#include <sys/signalfd.h>
-#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/uio.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
-#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#include <sys/socket.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <alloca.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/mman.h>
-#include <time.h>
#include "alloc-util.h"
#include "calendarspec.h"
return 0;
}
-
static int trim_cb(const char *path, const struct stat *sb, int typeflag, struct FTW *ftwbuf) {
assert(path);
assert(sb);
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include "alloc-util.h"
#include "bus-error.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <mqueue.h>
#include <stdbool.h>
#include <stdio.h>
-#include <string.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <sys/sem.h>
#include <fnmatch.h>
#include <limits.h>
#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <time.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/types.h>
#include "alloc-util.h"
#include <fcntl.h>
#include <linux/dm-ioctl.h>
-#include <string.h>
#include <sys/ioctl.h>
#include "dm-util.h"
#include <endian.h>
#include <netinet/in.h>
#include <stdio.h>
-#include <string.h>
#include <sys/socket.h>
#include "alloc-util.h"
return 0;
}
-
static ssize_t utf16_size(const uint16_t *s, size_t buf_len_bytes) {
size_t l = 0;
return 0;
}
-
static int get_stringset(int fd, struct ifreq *ifr, int stringset_id, struct ethtool_gstrings **gstrings) {
_cleanup_free_ struct ethtool_gstrings *strings = NULL;
struct {
bool tx_pending_set;
} netdev_ring_param;
-
int ethtool_get_driver(int *fd, const char *ifname, char **ret);
int ethtool_get_link_info(int *fd, const char *ifname,
int *ret_autonegotiation, size_t *ret_speed,
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <alloca.h>
#include <errno.h>
#include <fcntl.h>
#include <stddef.h>
*/
#define _NET_IF_H 1
-#include <alloca.h>
#include <arpa/inet.h>
#include <endian.h>
#include <errno.h>
#include <stddef.h>
#include <string.h>
-#include <sys/socket.h>
#include <net/if.h>
#ifndef IFNAMSIZ
#define IFNAMSIZ 16
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <mntent.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include "alloc-util.h"
#include "device-nodes.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <string.h>
#include "alloc-util.h"
#include "btrfs-util.h"
#include <errno.h>
#include <stdio.h>
-#include <string.h>
#include <unistd.h>
#include "format-util.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <fnmatch.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
#include <unistd.h>
#include "alloc-util.h"
if (r < 0)
return r;
+ if (isempty(printed)) {
+ i->default_instance = mfree(i->default_instance);
+ return 0;
+ }
+
if (!unit_instance_is_valid(printed))
return -EINVAL;
#include <math.h>
#include <stdarg.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/types.h>
#include "sd-messages.h"
#include <signal.h>
#include <stdint.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/socket.h>
#include <syslog.h>
-#include <time.h>
#include <unistd.h>
#include "sd-id128.h"
#include <fcntl.h>
#include <linux/loop.h>
#include <sys/ioctl.h>
-#include <sys/stat.h>
#include "alloc-util.h"
#include "fd-util.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <sys/statfs.h>
#include "btrfs-util.h"
#include "label.h"
#include <errno.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <signal.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/prctl.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include "alloc-util.h"
#include "fs-util.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <fcntl.h>
-#include <sys/mman.h>
#include "alloc-util.h"
#include "env-util.h"
#include <linux/fs.h>
#include <stdbool.h>
#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/utsname.h>
#include "sd-id128.h"
#include <fcntl.h>
#include <limits.h>
#include <stdbool.h>
-#include <stdio.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
-#include <string.h>
#include <unistd.h>
#include "fd-util.h"
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/time.h>
#include <sys/utsname.h>
#include <unistd.h>
#include <getopt.h>
#include <stdbool.h>
#include <stddef.h>
-#include <string.h>
#include "env-util.h"
#include "log.h"
#include <errno.h>
#include <stddef.h>
-#include <string.h>
#include "macro.h"
#include "string-util.h"
#include <errno.h>
#include <getopt.h>
#include <linux/reboot.h>
-#include <signal.h>
#include <stdbool.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <linux/dm-ioctl.h>
#include <linux/loop.h>
-#include <string.h>
#include <sys/mount.h>
#include <sys/swap.h>
#include <sys/stat.h>
#include <getopt.h>
#include <linux/fiemap.h>
#include <poll.h>
-#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/timerfd.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
-#include <locale.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
-#include <string.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/reboot.h>
-#include <sys/socket.h>
#include <unistd.h>
#include "sd-bus.h"
return 0;
}
-
static int list_units(int argc, char *argv[], void *userdata) {
_cleanup_free_ UnitInfo *unit_infos = NULL;
_cleanup_(message_set_freep) Set *replies = NULL;
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <string.h>
#include <sys/socket.h>
#include "macro.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <string.h>
-
#include "alloc-util.h"
#include "calendarspec.h"
#include "errno-util.h"
#include <netinet/in.h>
#include <pwd.h>
-#include <sys/capability.h>
#include <sys/prctl.h>
#include <sys/socket.h>
#include <sys/wait.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <string.h>
#include <unistd.h>
#include "cgroup-setup.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <string.h>
-
#include "alloc-util.h"
#include "string-util.h"
#include "tests.h"
#include <errno.h>
#include <stdio.h>
-#include <string.h>
#include "bus-util.h"
#include "manager.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <string.h>
-
#include "env-util.h"
#include "fd-util.h"
#include "fileio.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <string.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <grp.h>
-#include <pwd.h>
#include <stdio.h>
#include <sys/prctl.h>
#include <sys/types.h>
#include <errno.h>
#include <stdlib.h>
-#include <string.h>
#include "extract-word.h"
#include "log.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <fcntl.h>
-#include <glob.h>
#include <sys/stat.h>
#include <unistd.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <fcntl.h>
-#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <getopt.h>
-#include <stdio.h>
#include <sys/epoll.h>
#include <unistd.h>
#include <fcntl.h>
#include <stddef.h>
#include <stdio.h>
-#include <string.h>
-#include <sys/capability.h>
#include <unistd.h>
#include "all-units.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <arpa/inet.h>
-#include <libkmod.h>
#include <linux/if_tunnel.h>
#include <linux/ip.h>
#include <sys/types.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <fcntl.h>
-#include <sched.h>
#include <sys/mount.h>
#include <sys/personality.h>
#include <sys/prctl.h>
#include <fcntl.h>
#include <poll.h>
-#include <sched.h>
#include <stdlib.h>
#include <sys/eventfd.h>
#include <sys/mman.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <signal.h>
#include <unistd.h>
#include "log.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <stdlib.h>
-#include <string.h>
#include "strbuf.h"
#include "string-util.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <string.h>
-
#include "alloc-util.h"
#include "escape.h"
#include "nulstr-util.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <stdio.h>
-#include <string.h>
#include "string-util.h"
#include "strxcpyx.h"
if (r == 0)
log_debug("Cache rebuild skipped based on mtime.");
-
char **id;
STRV_FOREACH(id, ids) {
const char *fragment, *name;
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include "alloc-util.h"
#include "all-units.h"
assert(!streq(s, t));
}
+static void test_in_gid(void) {
+
+ assert(in_gid(getgid()) >= 0);
+ assert(in_gid(getegid()) >= 0);
+
+ assert(in_gid(GID_INVALID) < 0);
+ assert(in_gid(TTY_GID) == 0); /* The TTY gid is for owning ttys, it would be really really weird if we were in it. */
+}
+
int main(int argc, char *argv[]) {
test_uid_to_name_one(0, "root");
test_uid_to_name_one(UID_NOBODY, NOBODY_USER_NAME);
test_make_salt();
+ test_in_gid();
+
return 0;
}
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
*/
#include <errno.h>
-#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <netinet/ip.h>
#include <resolv.h>
#include <stdlib.h>
-#include <sys/socket.h>
#include <sys/timerfd.h>
#include <sys/timex.h>
#include <sys/types.h>
-#include <time.h>
#include "sd-daemon.h"
#include <fcntl.h>
#include <fnmatch.h>
#include <getopt.h>
-#include <glob.h>
#include <limits.h>
#include <linux/fs.h>
#include <stdbool.h>
#include <stddef.h>
-#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/file.h>
-#include <sys/stat.h>
#include <sys/xattr.h>
#include <sysexits.h>
#include <time.h>
#include <fcntl.h>
#include <getopt.h>
#include <poll.h>
-#include <signal.h>
#include <stdbool.h>
#include <stddef.h>
-#include <string.h>
#include <sys/prctl.h>
#include <sys/signalfd.h>
-#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <scsi/sg.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
* Copyright © 2011 Karel Zak <kzak@redhat.com>
*/
-#include <blkid.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/stat.h>
#include "sd-id128.h"
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
-#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <unistd.h>
#include <linux/limits.h>
-#include <linux/input.h>
#include "device-util.h"
#include "fd-util.h"
#include <errno.h>
#include <fcntl.h>
-#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/ioctl.h>
#include <linux/input.h>
*/
#include <errno.h>
-#include <libkmod.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <stdarg.h>
-#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <unistd.h>
#include <linux/pci_regs.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <unistd.h>
#include "alloc-util.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <unistd.h>
#include "alloc-util.h"
#include <getopt.h>
#include <stdio.h>
-#include <string.h>
#include "device-private.h"
#include "device-util.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <fcntl.h>
#include <net/if.h>
#include <stddef.h>
-#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <getopt.h>
#include <stddef.h>
#include <stdio.h>
-#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <getopt.h>
-#include <signal.h>
#include "sd-device.h"
#include "sd-event.h"
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <unistd.h>
#include "sd-bus.h"
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
-#include <signal.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/epoll.h>
#include <sys/file.h>
#include <sys/inotify.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/signalfd.h>
-#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/wait.h>
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
-#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/tiocl.h>
#include <linux/vt.h>
#include <stdbool.h>
-#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sysexits.h>
{ journalctl -ball -b -m 2>&1 || :; } | head -1 > /output
cmp /expected /output
+# https://github.com/systemd/systemd/issues/13708
+ID=$(systemd-id128 new)
+systemd-cat -t "$ID" bash -c 'echo parent; (echo child) & wait' &
+PID=$!
+wait %%
+journalctl --sync
+# We can drop this grep when https://github.com/systemd/systemd/issues/13937
+# has a fix.
+journalctl -b -o export -t "$ID" --output-fields=_PID | grep '^_PID=' >/output
+[[ `grep -c . /output` -eq 2 ]]
+grep -q "^_PID=$PID" /output
+grep -vq "^_PID=$PID" /output
+
+# Add new tests before here, the journald restarts below
+# may make tests flappy.
+
# Don't lose streams on restart
systemctl start forever-print-hola
sleep 3
dnsmasq_pid_file='/run/networkd-ci/test-test-dnsmasq.pid'
dnsmasq_log_file='/run/networkd-ci/test-dnsmasq-log-file'
-networkd_bin='/usr/lib/systemd/systemd-networkd'
-resolved_bin='/usr/lib/systemd/systemd-resolved'
-wait_online_bin='/usr/lib/systemd/systemd-networkd-wait-online'
-networkctl_bin='/usr/bin/networkctl'
-resolvectl_bin='/usr/bin/resolvectl'
-timedatectl_bin='/usr/bin/timedatectl'
+systemd_lib_paths=['/usr/lib/systemd', '/lib/systemd']
+which_paths=':'.join(systemd_lib_paths + os.getenv('PATH', os.defpath).lstrip(':').split(':'))
+
+networkd_bin=shutil.which('systemd-networkd', path=which_paths)
+resolved_bin=shutil.which('systemd-resolved', path=which_paths)
+wait_online_bin=shutil.which('systemd-networkd-wait-online', path=which_paths)
+networkctl_bin=shutil.which('networkctl', path=which_paths)
+resolvectl_bin=shutil.which('resolvectl', path=which_paths)
+timedatectl_bin=shutil.which('timedatectl', path=which_paths)
+
use_valgrind=False
enable_debug=True
env = {}
def is_module_available(module_name):
lsmod_output = check_output('lsmod')
module_re = re.compile(rf'^{re.escape(module_name)}\b', re.MULTILINE)
- return module_re.search(lsmod_output) or not call('modprobe', module_name)
+ return module_re.search(lsmod_output) or not call('modprobe', module_name, stderr=subprocess.DEVNULL)
def expectedFailureIfModuleIsNotAvailable(module_name):
def f(func):
def expectedFailureIfERSPANModuleIsNotAvailable():
def f(func):
- rc = call('ip link add dev erspan99 type erspan seq key 30 local 192.168.1.4 remote 192.168.1.1 erspan_ver 1 erspan 123')
+ rc = call('ip link add dev erspan99 type erspan seq key 30 local 192.168.1.4 remote 192.168.1.1 erspan_ver 1 erspan 123', stderr=subprocess.DEVNULL)
if rc == 0:
call('ip link del erspan99')
return func
def expectedFailureIfRoutingPolicyPortRangeIsNotAvailable():
def f(func):
- rc = call('ip rule add from 192.168.100.19 sport 1123-1150 dport 3224-3290 table 7')
+ rc = call('ip rule add from 192.168.100.19 sport 1123-1150 dport 3224-3290 table 7', stderr=subprocess.DEVNULL)
if rc == 0:
call('ip rule del from 192.168.100.19 sport 1123-1150 dport 3224-3290 table 7')
return func
def expectedFailureIfRoutingPolicyIPProtoIsNotAvailable():
def f(func):
- rc = call('ip rule add not from 192.168.100.19 ipproto tcp table 7')
+ rc = call('ip rule add not from 192.168.100.19 ipproto tcp table 7', stderr=subprocess.DEVNULL)
if rc == 0:
call('ip rule del not from 192.168.100.19 ipproto tcp table 7')
return func
def expectedFailureIfLinkFileFieldIsNotSet():
def f(func):
support = False
- rc = call('ip link add name dummy99 type dummy')
+ rc = call('ip link add name dummy99 type dummy', stderr=subprocess.DEVNULL)
if rc == 0:
ret = run('udevadm info -w10s /sys/class/net/dummy99', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if ret.returncode == 0 and 'E: ID_NET_LINK_FILE=' in ret.stdout.rstrip():
def expectedFailureIfNexthopIsNotAvailable():
def f(func):
- rc = call('ip nexthop list')
+ rc = call('ip nexthop list', stderr=subprocess.DEVNULL)
if rc == 0:
return func
else:
output = check_output(*networkctl_cmd, 'status', 'test1')
print(output)
- self.assertRegex(output, r'Link File: (?:/usr)/lib/systemd/network/99-default.link')
+ self.assertRegex(output, r'Link File: (/usr)?/lib/systemd/network/99-default.link')
self.assertRegex(output, r'Network File: /run/systemd/network/11-dummy.network')
output = check_output(*networkctl_cmd, 'status', 'lo')
print(output)
- self.assertRegex(output, r'Link File: (?:/usr)/lib/systemd/network/99-default.link')
+ self.assertRegex(output, r'Link File: (/usr)?/lib/systemd/network/99-default.link')
self.assertRegex(output, r'Network File: n/a')
def test_delete_links(self):
self.wait_online(['bridge99', 'test1:degraded'], bool_any=True)
- self.check_operstate('bridge99', '(?:off|no-carrier)', setup_state='configuring')
+ self.check_operstate('bridge99', '(off|no-carrier)', setup_state='configuring')
self.check_operstate('test1', 'degraded')
def test_bridge(self):
output = check_output('ip -d link show tun99')
print(output)
# Old ip command does not support IFF_ flags
- self.assertRegex(output, 'tun (?:type tun pi on vnet_hdr on multi_queue|addrgenmode) ')
+ self.assertRegex(output, 'tun (type tun pi on vnet_hdr on multi_queue|addrgenmode) ')
def test_tap(self):
copy_unit_to_networkd_unit_path('25-tap.netdev')
output = check_output('ip -d link show tap99')
print(output)
# Old ip command does not support IFF_ flags
- self.assertRegex(output, 'tun (?:type tap pi on vnet_hdr on multi_queue|addrgenmode) ')
+ self.assertRegex(output, 'tun (type tap pi on vnet_hdr on multi_queue|addrgenmode) ')
@expectedFailureIfModuleIsNotAvailable('vrf')
def test_vrf(self):
output = check_output('ip -d link show ipiptun99')
print(output)
- self.assertRegex(output, 'ipip (?:ipip |)remote 192.169.224.239 local 192.168.223.238 dev dummy98')
+ self.assertRegex(output, 'ipip (ipip )?remote 192.169.224.239 local 192.168.223.238 dev dummy98')
output = check_output('ip -d link show ipiptun98')
print(output)
- self.assertRegex(output, 'ipip (?:ipip |)remote 192.169.224.239 local any dev dummy98')
+ self.assertRegex(output, 'ipip (ipip )?remote 192.169.224.239 local any dev dummy98')
output = check_output('ip -d link show ipiptun97')
print(output)
- self.assertRegex(output, 'ipip (?:ipip |)remote any local 192.168.223.238 dev dummy98')
+ self.assertRegex(output, 'ipip (ipip )?remote any local 192.168.223.238 dev dummy98')
output = check_output('ip -d link show ipiptun96')
print(output)
- self.assertRegex(output, 'ipip (?:ipip |)remote any local any dev dummy98')
+ self.assertRegex(output, 'ipip (ipip )?remote any local any dev dummy98')
def test_gre_tunnel(self):
copy_unit_to_networkd_unit_path('12-dummy.netdev', 'gretun.network',
self.assertRegex(output, 'vti6 remote 2001:473:fece:cafe::5179 local 2a00:ffde:4567:edde::4987 dev dummy98')
output = check_output('ip -d link show vti6tun98')
print(output)
- self.assertRegex(output, 'vti6 remote 2001:473:fece:cafe::5179 local (?:any|::) dev dummy98')
+ self.assertRegex(output, 'vti6 remote 2001:473:fece:cafe::5179 local (any|::) dev dummy98')
output = check_output('ip -d link show vti6tun97')
print(output)
- self.assertRegex(output, 'vti6 remote (?:any|::) local 2a00:ffde:4567:edde::4987 dev dummy98')
+ self.assertRegex(output, 'vti6 remote (any|::) local 2a00:ffde:4567:edde::4987 dev dummy98')
def test_ip6tnl_tunnel(self):
copy_unit_to_networkd_unit_path('12-dummy.netdev', 'ip6tnl.network',
self.assertRegex(output, 'ip6tnl ip6ip6 remote 2001:473:fece:cafe::5179 local 2a00:ffde:4567:edde::4987 dev dummy98')
output = check_output('ip -d link show ip6tnl98')
print(output)
- self.assertRegex(output, 'ip6tnl ip6ip6 remote 2001:473:fece:cafe::5179 local (?:any|::) dev dummy98')
+ self.assertRegex(output, 'ip6tnl ip6ip6 remote 2001:473:fece:cafe::5179 local (any|::) dev dummy98')
output = check_output('ip -d link show ip6tnl97')
print(output)
- self.assertRegex(output, 'ip6tnl ip6ip6 remote (?:any|::) local 2a00:ffde:4567:edde::4987 dev dummy98')
+ self.assertRegex(output, 'ip6tnl ip6ip6 remote (any|::) local 2a00:ffde:4567:edde::4987 dev dummy98')
def test_sit_tunnel(self):
copy_unit_to_networkd_unit_path('12-dummy.netdev', 'sit.network',
output = check_output('ip -d link show sittun99')
print(output)
- self.assertRegex(output, "sit (?:ip6ip |)remote 10.65.223.239 local 10.65.223.238 dev dummy98")
+ self.assertRegex(output, "sit (ip6ip )?remote 10.65.223.239 local 10.65.223.238 dev dummy98")
output = check_output('ip -d link show sittun98')
print(output)
- self.assertRegex(output, "sit (?:ip6ip |)remote 10.65.223.239 local any dev dummy98")
+ self.assertRegex(output, "sit (ip6ip )?remote 10.65.223.239 local any dev dummy98")
output = check_output('ip -d link show sittun97')
print(output)
- self.assertRegex(output, "sit (?:ip6ip |)remote any local 10.65.223.238 dev dummy98")
+ self.assertRegex(output, "sit (ip6ip )?remote any local 10.65.223.238 dev dummy98")
output = check_output('ip -d link show sittun96')
print(output)
- self.assertRegex(output, "sit (?:ip6ip |)remote any local any dev dummy98")
+ self.assertRegex(output, "sit (ip6ip )?remote any local any dev dummy98")
def test_isatap_tunnel(self):
copy_unit_to_networkd_unit_path('12-dummy.netdev', 'isatap.network',
print(output)
self.assertRegex(output, '111:')
self.assertRegex(output, 'from 192.168.100.18')
- self.assertRegex(output, r'tos (?:0x08|throughput)\s')
+ self.assertRegex(output, r'tos (0x08|throughput)\s')
self.assertRegex(output, 'iif test1')
self.assertRegex(output, 'oif test1')
self.assertRegex(output, 'lookup 7')
output = check_output('ip rule list table 7')
print(output)
- self.assertRegex(output, '111: from 192.168.100.18 tos (?:0x08|throughput) iif test1 oif test1 lookup 7')
+ self.assertRegex(output, '111: from 192.168.100.18 tos (0x08|throughput) iif test1 oif test1 lookup 7')
output = check_output('ip rule list table 8')
print(output)
- self.assertRegex(output, '112: from 192.168.101.18 tos (?:0x08|throughput) iif dummy98 oif dummy98 lookup 8')
+ self.assertRegex(output, '112: from 192.168.101.18 tos (0x08|throughput) iif dummy98 oif dummy98 lookup 8')
stop_networkd(remove_state_files=False)
self.assertRegex(data, r'LLMNR=no')
self.assertRegex(data, r'MDNS=yes')
self.assertRegex(data, r'DNSSEC=no')
- self.assertRegex(data, r'ADDRESSES=192.168.(?:10.10|12.12)/24 192.168.(?:12.12|10.10)/24')
+ self.assertRegex(data, r'ADDRESSES=192.168.(10.10|12.12)/24 192.168.(12.12|10.10)/24')
check_output(*resolvectl_cmd, 'dns', 'dummy98', '10.10.10.12', '10.10.10.13', env=env)
check_output(*resolvectl_cmd, 'domain', 'dummy98', 'hogehogehoge', '~foofoofoo', env=env)
print('### ip -6 route list table all dev bridge99')
output = check_output('ip -6 route list table all dev bridge99')
print(output)
- self.assertRegex(output, 'ff00::/8 table local metric 256 (?:linkdown |)pref medium')
+ self.assertRegex(output, 'ff00::/8 table local metric 256 (linkdown )?pref medium')
def test_bridge_ignore_carrier_loss(self):
copy_unit_to_networkd_unit_path('11-dummy.netdev', '12-dummy.netdev', '26-bridge.netdev',
# link become 'routable' when at least one protocol provide an valid address.
self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4')
- self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
+ self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
output = check_output(*networkctl_cmd, 'status', 'veth99', env=env)
print(output)
output = check_output('ip address show dev veth99 scope global')
print(output)
- self.assertRegex(output, r'inet6 2600::[0-9a-f]*/128 scope global (?:noprefixroute dynamic|dynamic noprefixroute)')
+ self.assertRegex(output, r'inet6 2600::[0-9a-f]*/128 scope global (noprefixroute dynamic|dynamic noprefixroute)')
output = check_output('ip -6 route show dev veth99')
print(output)
# link become 'routable' when at least one protocol provide an valid address.
self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4')
- self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
+ self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
output = check_output('ip address show dev veth99 scope global')
print(output)
# link become 'routable' when at least one protocol provide an valid address.
self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4')
- self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
+ self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
print('## ip -d link show dev vrf99')
output = check_output('ip -d link show dev vrf99')
print(output)
self.assertRegex(output, 'inet 169.254.[0-9]*.[0-9]*/16 brd 169.254.255.255 scope link veth99')
self.assertRegex(output, 'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic veth99')
- self.assertRegex(output, 'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)')
+ self.assertRegex(output, 'inet6 2600::[0-9a-f]*/128 scope global (dynamic noprefixroute|noprefixroute dynamic)')
self.assertRegex(output, 'inet6 .* scope link')
print('## ip address show dev veth99')
print(output)
self.assertRegex(output, 'inet 169.254.[0-9]*.[0-9]*/16 brd 169.254.255.255 scope link veth99')
self.assertRegex(output, 'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic veth99')
- self.assertRegex(output, 'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)')
+ self.assertRegex(output, 'inet6 2600::[0-9a-f]*/128 scope global (dynamic noprefixroute|noprefixroute dynamic)')
self.assertRegex(output, 'inet6 .* scope link')
print('## ip route show vrf vrf99')
# link become 'routable' when at least one protocol provide an valid address.
self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4')
- self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
+ self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
time.sleep(3)
output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env)
# link become 'routable' when at least one protocol provide an valid address.
self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4')
- self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
+ self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
time.sleep(3)
output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env)
# link become 'routable' when at least one protocol provide an valid address.
self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4')
- self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
+ self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
time.sleep(3)
output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env)
# link become 'routable' when at least one protocol provide an valid address.
self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4')
- self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
+ self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
time.sleep(3)
output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env)