1
0
mirror of https://github.com/systemd/systemd synced 2026-04-01 04:34:51 +02:00

Compare commits

..

No commits in common. "3b3113b87c9e721ec386329b9dc6484561377f85" and "a2366debce0e0366dc3c4443b471083b634ab70f" have entirely different histories.

10 changed files with 29 additions and 65 deletions

View File

@ -1,5 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/prctl.h>
#include <stdatomic.h>
#include <stdio.h>
#include <sys/prctl.h>

View File

@ -5,7 +5,6 @@
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include "dirent-util.h"
#include "env-util.h"
@ -55,7 +54,6 @@ static char* normalize_locale(const char *name) {
return strdup(name);
}
#ifdef __GLIBC__
static int add_locales_from_archive(Set *locales) {
/* Stolen from glibc... */
@ -184,34 +182,6 @@ static int add_locales_from_libdir(Set *locales) {
return 0;
}
#else
static int add_locales_for_musl(Set *locales) {
int r;
assert(locales);
_cleanup_closedir_ DIR *dir = opendir("/usr/share/i18n/locales/musl/");
if (!dir)
return errno == ENOENT ? 0 : -errno;
FOREACH_DIRENT(de, dir, return -errno) {
if (de->d_type != DT_REG)
continue;
char *z = normalize_locale(de->d_name);
if (!z)
return -ENOMEM;
r = set_consume(locales, z);
if (r < 0)
return r;
}
return 0;
}
#endif
int get_locales(char ***ret) {
_cleanup_set_free_ Set *locales = NULL;
int r;
@ -220,7 +190,6 @@ int get_locales(char ***ret) {
if (!locales)
return -ENOMEM;
#ifdef __GLIBC__
r = add_locales_from_archive(locales);
if (r < 0 && r != -ENOENT)
return r;
@ -228,11 +197,6 @@ int get_locales(char ***ret) {
r = add_locales_from_libdir(locales);
if (r < 0)
return r;
#else
r = add_locales_for_musl(locales);
if (r < 0)
return r;
#endif
char *locale;
SET_FOREACH(locale, locales) {
@ -300,25 +264,11 @@ int locale_is_installed(const char *name) {
if (STR_IN_SET(name, "C", "POSIX")) /* These ones are always OK */
return true;
#ifdef __GLIBC__
_cleanup_(freelocalep) locale_t loc = newlocale(LC_ALL_MASK, name, (locale_t) 0);
if (loc == (locale_t) 0)
return errno == ENOMEM ? -ENOMEM : false;
return true;
#else
/* musl also has C.UTF-8 as builtin */
if (streq(name, "C.UTF-8"))
return true;
/* musl's newlocale() always succeeds and provides a fake locale object even when the locale does
* not exist. Hence, we need to explicitly check if the locale file exists. */
_cleanup_free_ char *p = path_join("/usr/share/i18n/locales/musl/", name);
if (!p)
return -ENOMEM;
return access(p, F_OK) >= 0;
#endif
}
static bool is_locale_utf8_impl(void) {

View File

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <grp.h>
#include <linux/prctl.h>
#include <linux/sched.h>
#include <linux/securebits.h>
#include <poll.h>

View File

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <fcntl.h>
#include <linux/prctl.h>
#include <poll.h>
#include <sys/mman.h>
#include <sys/mount.h>

View File

@ -1,9 +1,10 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <features.h>
#include <linux/if.h> /* IWYU pragma: export */
#define IF_NAMESIZE 16
extern unsigned int if_nametoindex(const char *__ifname);
extern char *if_indextoname(unsigned int __ifindex, char __ifname[IF_NAMESIZE]);
extern unsigned int if_nametoindex(const char *__ifname) __THROW;
extern char *if_indextoname(unsigned int __ifindex, char __ifname[IF_NAMESIZE]) __THROW;

View File

@ -2,6 +2,7 @@
#pragma once
#include <fcntl.h>
#include <features.h>
#include <linux/fs.h>
#include <linux/mount.h> /* IWYU pragma: export */
#include <stddef.h>
@ -28,20 +29,20 @@ enum
};
/* Mount a filesystem. */
extern int mount(const char *__special_file, const char *__dir, const char *__fstype, unsigned long int __rwflag, const void *__data);
extern int mount(const char *__special_file, const char *__dir, const char *__fstype, unsigned long int __rwflag, const void *__data) __THROW;
/* Unmount a filesystem. */
extern int umount(const char *__special_file);
extern int umount(const char *__special_file) __THROW;
/* Unmount a filesystem. Force unmounting if FLAGS is set to MNT_FORCE. */
extern int umount2(const char *__special_file, int __flags);
extern int umount2(const char *__special_file, int __flags) __THROW;
/* Open the filesystem referenced by FS_NAME so it can be configured for
mouting. */
/* Defined since glibc-2.36.
* Supported since kernel v5.2 (24dcb3d90a1f67fe08c68a004af37df059d74005). */
#if HAVE_FSOPEN
extern int fsopen(const char *__fs_name, unsigned int __flags);
extern int fsopen(const char *__fs_name, unsigned int __flags) __THROW;
#else
int missing_fsopen(const char *fsname, unsigned flags);
# define fsopen missing_fsopen
@ -52,7 +53,7 @@ int missing_fsopen(const char *fsname, unsigned flags);
/* Defined since glibc-2.36.
* Supported since kernel v5.2 (93766fbd2696c2c4453dd8e1070977e9cd4e6b6d). */
#if HAVE_FSMOUNT
extern int fsmount(int __fd, unsigned int __flags, unsigned int __ms_flags);
extern int fsmount(int __fd, unsigned int __flags, unsigned int __ms_flags) __THROW;
#else
int missing_fsmount(int fd, unsigned flags, unsigned ms_flags);
# define fsmount missing_fsmount
@ -64,7 +65,7 @@ int missing_fsmount(int fd, unsigned flags, unsigned ms_flags);
/* Defined since glibc-2.36.
* Supported since kernel v5.2 (2db154b3ea8e14b04fee23e3fdfd5e9d17fbc6ae). */
#if HAVE_MOVE_MOUNT
extern int move_mount(int __from_dfd, const char *__from_pathname, int __to_dfd, const char *__to_pathname, unsigned int flags);
extern int move_mount(int __from_dfd, const char *__from_pathname, int __to_dfd, const char *__to_pathname, unsigned int flags) __THROW;
#else
int missing_move_mount(int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, unsigned flags);
# define move_mount missing_move_mount
@ -75,7 +76,7 @@ int missing_move_mount(int from_dfd, const char *from_pathname, int to_dfd, cons
/* Defined since glibc-2.36.
* Supported since kernel v5.2 (ecdab150fddb42fe6a739335257949220033b782). */
#if HAVE_FSCONFIG
extern int fsconfig(int __fd, unsigned int __cmd, const char *__key, const void *__value, int __aux);
extern int fsconfig(int __fd, unsigned int __cmd, const char *__key, const void *__value, int __aux) __THROW;
#else
int missing_fsconfig(int fd, unsigned cmd, const char *key, const void *value, int aux);
# define fsconfig missing_fsconfig
@ -85,7 +86,7 @@ int missing_fsconfig(int fd, unsigned cmd, const char *key, const void *value, i
/* Defined since glibc-2.36.
* Supported since kernel v5.2 (a07b20004793d8926f78d63eb5980559f7813404). */
#if HAVE_OPEN_TREE
extern int open_tree(int __dfd, const char *__filename, unsigned int __flags);
extern int open_tree(int __dfd, const char *__filename, unsigned int __flags) __THROW;
#else
int missing_open_tree(int dfd, const char *filename, unsigned flags);
# define open_tree missing_open_tree
@ -99,7 +100,7 @@ int missing_open_tree(int dfd, const char *filename, unsigned flags);
/* Defined since glibc-2.36.
* Supported since kernel v5.12 (2a1867219c7b27f928e2545782b86daaf9ad50bd). */
#if HAVE_MOUNT_SETATTR
extern int mount_setattr(int __dfd, const char *__path, unsigned int __flags, struct mount_attr *__uattr, size_t __usize);
extern int mount_setattr(int __dfd, const char *__path, unsigned int __flags, struct mount_attr *__uattr, size_t __usize) __THROW;
#else
int missing_mount_setattr(int dfd, const char *path, unsigned flags, struct mount_attr *attr, size_t size);
# define mount_setattr missing_mount_setattr
@ -108,7 +109,7 @@ int missing_mount_setattr(int dfd, const char *path, unsigned flags, struct moun
/* Not defined in glibc yet as of glibc-2.41.
* Supported since kernel v6.15 (c4a16820d90199409c9bf01c4f794e1e9e8d8fd8). */
#if HAVE_OPEN_TREE_ATTR
extern int open_tree_attr(int __dfd, const char *__filename, unsigned int __flags, struct mount_attr *__uattr, size_t __usize);
extern int open_tree_attr(int __dfd, const char *__filename, unsigned int __flags, struct mount_attr *__uattr, size_t __usize) __THROW;
#else
int missing_open_tree_attr(int dfd, const char *filename, unsigned int flags, struct mount_attr *attr, size_t size);
# define open_tree_attr missing_open_tree_attr

View File

@ -229,7 +229,9 @@ TEST(sd_bus_error_set_errnof) {
assert_se(sd_bus_error_set_errnof(&error, EACCES, NULL) == -EACCES);
assert_se(sd_bus_error_has_name(&error, SD_BUS_ERROR_ACCESS_DENIED));
ASSERT_STREQ(error.message, STRERROR(EACCES));
errno = EACCES;
assert_se(asprintf(&str, "%m") >= 0);
assert_se(streq(error.message, str));
assert_se(error._need_free == 0);
str = mfree(str);
@ -237,7 +239,9 @@ TEST(sd_bus_error_set_errnof) {
assert_se(sd_bus_error_set_errnof(&error, ENOANO, NULL) == -ENOANO);
assert_se(sd_bus_error_has_name(&error, "System.Error.ENOANO"));
ASSERT_STREQ(error.message, STRERROR(ENOANO));
errno = ENOANO;
assert_se(asprintf(&str, "%m") >= 0);
assert_se(streq(error.message, str));
assert_se(error._need_free == 1);
str = mfree(str);
@ -245,7 +249,9 @@ TEST(sd_bus_error_set_errnof) {
assert_se(sd_bus_error_set_errnof(&error, 100000, NULL) == -100000);
assert_se(sd_bus_error_has_name(&error, SD_BUS_ERROR_FAILED));
ASSERT_STREQ(error.message, STRERROR(100000));
errno = 100000;
assert_se(asprintf(&str, "%m") >= 0);
assert_se(streq(error.message, str));
assert_se(error._need_free == 1);
str = mfree(str);

View File

@ -1,5 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/prctl.h>
#include <netinet/in.h>
#include <pwd.h>
#include <stdlib.h>

View File

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <fnmatch.h>
#include <linux/prctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mount.h>

View File

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <fcntl.h>
#include <linux/prctl.h>
#include <sched.h>
#include <stdlib.h>
#include <sys/prctl.h>