mirror of
https://github.com/systemd/systemd
synced 2026-03-12 08:04:46 +01:00
Compare commits
7 Commits
a81c7ac8d4
...
46cfe8f50d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46cfe8f50d | ||
|
|
945317a4b6 | ||
|
|
8a773a30ba | ||
|
|
bc52deda4b | ||
|
|
f1a8a66c35 | ||
|
|
a9899ff358 | ||
|
|
ca79564309 |
@ -857,10 +857,13 @@ conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale)
|
|||||||
|
|
||||||
localegen_path = get_option('localegen-path')
|
localegen_path = get_option('localegen-path')
|
||||||
have = false
|
have = false
|
||||||
|
writable = ''
|
||||||
if localegen_path != ''
|
if localegen_path != ''
|
||||||
conf.set_quoted('LOCALEGEN_PATH', localegen_path)
|
conf.set_quoted('LOCALEGEN_PATH', localegen_path)
|
||||||
have = true
|
have = true
|
||||||
|
writable = ' /usr/lib/locale'
|
||||||
endif
|
endif
|
||||||
|
substs.set('SERVICE_LOCALEGEN_WRITABLE', writable)
|
||||||
conf.set10('HAVE_LOCALEGEN', have)
|
conf.set10('HAVE_LOCALEGEN', have)
|
||||||
|
|
||||||
conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
|
conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
|
||||||
|
|||||||
@ -27,7 +27,8 @@
|
|||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
#include "tmpfile-util.h"
|
#include "tmpfile-util.h"
|
||||||
|
|
||||||
#define READ_FULL_BYTES_MAX (4U*1024U*1024U)
|
/* The maximum size of the file we'll read in one go. */
|
||||||
|
#define READ_FULL_BYTES_MAX (4U*1024U*1024U - 1)
|
||||||
|
|
||||||
int fopen_unlocked(const char *path, const char *options, FILE **ret) {
|
int fopen_unlocked(const char *path, const char *options, FILE **ret) {
|
||||||
assert(ret);
|
assert(ret);
|
||||||
@ -386,8 +387,10 @@ int read_full_virtual_file(const char *filename, char **ret_contents, size_t *re
|
|||||||
|
|
||||||
/* Start size for files in /proc/ which usually report a file size of 0. (Files in /sys/ report a
|
/* Start size for files in /proc/ which usually report a file size of 0. (Files in /sys/ report a
|
||||||
* file size of 4K, which is probably OK for sizing our initial buffer, and sysfs attributes can't be
|
* file size of 4K, which is probably OK for sizing our initial buffer, and sysfs attributes can't be
|
||||||
* larger anyway.) */
|
* larger anyway.)
|
||||||
size = LINE_MAX / 2;
|
*
|
||||||
|
* It's one less than 4k, so that the malloc() below allocates exactly 4k. */
|
||||||
|
size = 4095;
|
||||||
|
|
||||||
/* Limit the number of attempts to read the number of bytes returned by fstat(). */
|
/* Limit the number of attempts to read the number of bytes returned by fstat(). */
|
||||||
n_retries = 3;
|
n_retries = 3;
|
||||||
@ -403,22 +406,27 @@ int read_full_virtual_file(const char *filename, char **ret_contents, size_t *re
|
|||||||
return -EBADF;
|
return -EBADF;
|
||||||
|
|
||||||
/* Be prepared for files from /proc which generally report a file size of 0. */
|
/* Be prepared for files from /proc which generally report a file size of 0. */
|
||||||
|
assert_cc(READ_FULL_BYTES_MAX < SSIZE_MAX);
|
||||||
if (st.st_size > 0) {
|
if (st.st_size > 0) {
|
||||||
if (st.st_size > SSIZE_MAX) /* safety check in case off_t is 64bit and size_t 32bit */
|
if (st.st_size > READ_FULL_BYTES_MAX)
|
||||||
return -E2BIG;
|
return -E2BIG;
|
||||||
|
|
||||||
size = st.st_size;
|
size = st.st_size;
|
||||||
n_retries--;
|
n_retries--;
|
||||||
} else
|
} else {
|
||||||
/* Double the buffer size (saturate in case of overflow) */
|
/* Double the buffer size */
|
||||||
size = size > SSIZE_MAX / 2 ? SSIZE_MAX : size * 2;
|
if (size >= READ_FULL_BYTES_MAX)
|
||||||
|
return -E2BIG;
|
||||||
if (size > READ_FULL_BYTES_MAX)
|
if (size > READ_FULL_BYTES_MAX / 2 - 1)
|
||||||
return -E2BIG;
|
size = READ_FULL_BYTES_MAX; /* clamp to max */
|
||||||
|
else
|
||||||
|
size = size * 2 + 1; /* Stay always one less than page size, so we malloc evenly */
|
||||||
|
}
|
||||||
|
|
||||||
buf = malloc(size + 1);
|
buf = malloc(size + 1);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
size = malloc_usable_size(buf) - 1; /* Use a bigger allocation if we got it anyway */
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ssize_t k;
|
ssize_t k;
|
||||||
@ -462,16 +470,13 @@ int read_full_virtual_file(const char *filename, char **ret_contents, size_t *re
|
|||||||
buf = TAKE_PTR(p);
|
buf = TAKE_PTR(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ret_size) {
|
if (ret_size)
|
||||||
/* Safety check: if the caller doesn't want to know the size of what we
|
|
||||||
* just read it will rely on the trailing NUL byte. But if there's an
|
|
||||||
* embedded NUL byte, then we should refuse operation as otherwise
|
|
||||||
* there'd be ambiguity about what we just read. */
|
|
||||||
|
|
||||||
if (memchr(buf, 0, n))
|
|
||||||
return -EBADMSG;
|
|
||||||
} else
|
|
||||||
*ret_size = n;
|
*ret_size = n;
|
||||||
|
else if (memchr(buf, 0, n))
|
||||||
|
/* Safety check: if the caller doesn't want to know the size of what we just read it will
|
||||||
|
* rely on the trailing NUL byte. But if there's an embedded NUL byte, then we should refuse
|
||||||
|
* operation as otherwise there'd be ambiguity about what we just read. */
|
||||||
|
return -EBADMSG;
|
||||||
|
|
||||||
buf[n] = 0;
|
buf[n] = 0;
|
||||||
*ret_contents = TAKE_PTR(buf);
|
*ret_contents = TAKE_PTR(buf);
|
||||||
|
|||||||
@ -28,11 +28,17 @@ int bus_error_set_errnofv(sd_bus_error *e, int error, const char *format, va_lis
|
|||||||
* the bus error table, and BUS_ERROR_MAP_ELF_USE has to be used at
|
* the bus error table, and BUS_ERROR_MAP_ELF_USE has to be used at
|
||||||
* least once per compilation unit (i.e. per library), to ensure that
|
* least once per compilation unit (i.e. per library), to ensure that
|
||||||
* the error map is really added to the final binary.
|
* the error map is really added to the final binary.
|
||||||
|
*
|
||||||
|
* In addition, set the retain attribute so that the section cannot be
|
||||||
|
* discarded by ld --gc-sections -z start-stop-gc. Older compilers would
|
||||||
|
* warn for the unknown attribute, so just disable -Wattributes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BUS_ERROR_MAP_ELF_REGISTER \
|
#define BUS_ERROR_MAP_ELF_REGISTER \
|
||||||
|
_Pragma("GCC diagnostic ignored \"-Wattributes\"") \
|
||||||
_section_("SYSTEMD_BUS_ERROR_MAP") \
|
_section_("SYSTEMD_BUS_ERROR_MAP") \
|
||||||
_used_ \
|
_used_ \
|
||||||
|
__attribute__((retain)) \
|
||||||
_alignptr_ \
|
_alignptr_ \
|
||||||
_variable_no_sanitize_address_
|
_variable_no_sanitize_address_
|
||||||
|
|
||||||
|
|||||||
@ -30,8 +30,6 @@ int main(int argc, char *argv[]) {
|
|||||||
const char *key, *value;
|
const char *key, *value;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
unsetenv("SYSTEMD_MEMPOOL");
|
|
||||||
|
|
||||||
r = sd_device_new_from_syspath(&loopback, "/sys/class/net/lo");
|
r = sd_device_new_from_syspath(&loopback, "/sys/class/net/lo");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return handle_error_errno(r, "Failed to create loopback device object");
|
return handle_error_errno(r, "Failed to create loopback device object");
|
||||||
|
|||||||
@ -28,8 +28,6 @@ int main(int argc, char *argv[]) {
|
|||||||
pthread_t t;
|
pthread_t t;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
unsetenv("SYSTEMD_MEMPOOL");
|
|
||||||
|
|
||||||
loopback = udev_device_new_from_syspath(NULL, "/sys/class/net/lo");
|
loopback = udev_device_new_from_syspath(NULL, "/sys/class/net/lo");
|
||||||
if (!loopback)
|
if (!loopback)
|
||||||
return handle_error_errno(errno, "Failed to create loopback device object");
|
return handle_error_errno(errno, "Failed to create loopback device object");
|
||||||
|
|||||||
@ -33,7 +33,7 @@ ProtectKernelLogs=yes
|
|||||||
ProtectKernelModules=yes
|
ProtectKernelModules=yes
|
||||||
ProtectKernelTunables=yes
|
ProtectKernelTunables=yes
|
||||||
ProtectSystem=strict
|
ProtectSystem=strict
|
||||||
ReadWritePaths=/etc
|
ReadWritePaths=/etc@SERVICE_LOCALEGEN_WRITABLE@
|
||||||
RestrictAddressFamilies=AF_UNIX
|
RestrictAddressFamilies=AF_UNIX
|
||||||
RestrictNamespaces=yes
|
RestrictNamespaces=yes
|
||||||
RestrictRealtime=yes
|
RestrictRealtime=yes
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user