mirror of
https://github.com/systemd/systemd
synced 2025-11-17 07:44:46 +01:00
Compare commits
No commits in common. "25a507d290823e04795e048eefa5dacbfa358bfc" and "dd15dd1a586ceed5e6b9bc6324227c09d7d4480e" have entirely different histories.
25a507d290
...
dd15dd1a58
2
.github/workflows/issue-labeler.yml
vendored
2
.github/workflows/issue-labeler.yml
vendored
@ -29,7 +29,7 @@ jobs:
|
||||
template-path: .github/ISSUE_TEMPLATE/${{ matrix.template }}
|
||||
|
||||
- name: Set labels based on component field
|
||||
uses: redhat-plumbers-in-action/advanced-issue-labeler@e38e6809c5420d038eed380d49ee9a6ca7c92dbf
|
||||
uses: redhat-plumbers-in-action/advanced-issue-labeler@0db433d412193574252480b4fc22f2e4319a4ea3
|
||||
with:
|
||||
issue-form: ${{ steps.issue-parser.outputs.jsonString }}
|
||||
template: ${{ matrix.template }}
|
||||
|
||||
2
.github/workflows/make-release.yml
vendored
2
.github/workflows/make-release.yml
vendored
@ -18,7 +18,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090
|
||||
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631
|
||||
with:
|
||||
prerelease: ${{ contains(github.ref_name, '-rc') }}
|
||||
draft: ${{ github.repository == 'systemd/systemd' }}
|
||||
|
||||
@ -793,11 +793,12 @@ char* strip_tab_ansi(char **ibuf, size_t *_isz, size_t highlight[2]) {
|
||||
return *ibuf;
|
||||
}
|
||||
|
||||
char* strextendv_with_separator(char **x, const char *separator, va_list ap) {
|
||||
char* strextend_with_separator_internal(char **x, const char *separator, ...) {
|
||||
_cleanup_free_ char *buffer = NULL;
|
||||
size_t f, l, l_separator;
|
||||
bool need_separator;
|
||||
char *nr, *p;
|
||||
va_list ap;
|
||||
|
||||
if (!x)
|
||||
x = &buffer;
|
||||
@ -807,12 +808,11 @@ char* strextendv_with_separator(char **x, const char *separator, va_list ap) {
|
||||
need_separator = !isempty(*x);
|
||||
l_separator = strlen_ptr(separator);
|
||||
|
||||
va_list aq;
|
||||
va_copy(aq, ap);
|
||||
va_start(ap, separator);
|
||||
for (const char *t;;) {
|
||||
size_t n;
|
||||
|
||||
t = va_arg(aq, const char *);
|
||||
t = va_arg(ap, const char *);
|
||||
if (!t)
|
||||
break;
|
||||
if (t == POINTER_MAX)
|
||||
@ -824,14 +824,14 @@ char* strextendv_with_separator(char **x, const char *separator, va_list ap) {
|
||||
n += l_separator;
|
||||
|
||||
if (n >= SIZE_MAX - l) {
|
||||
va_end(aq);
|
||||
va_end(ap);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
l += n;
|
||||
need_separator = true;
|
||||
}
|
||||
va_end(aq);
|
||||
va_end(ap);
|
||||
|
||||
need_separator = !isempty(*x);
|
||||
|
||||
@ -842,6 +842,7 @@ char* strextendv_with_separator(char **x, const char *separator, va_list ap) {
|
||||
*x = nr;
|
||||
p = nr + f;
|
||||
|
||||
va_start(ap, separator);
|
||||
for (;;) {
|
||||
const char *t;
|
||||
|
||||
@ -858,6 +859,7 @@ char* strextendv_with_separator(char **x, const char *separator, va_list ap) {
|
||||
|
||||
need_separator = true;
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
assert(p == nr + l);
|
||||
*p = 0;
|
||||
@ -870,17 +872,6 @@ char* strextendv_with_separator(char **x, const char *separator, va_list ap) {
|
||||
return p;
|
||||
}
|
||||
|
||||
char* strextend_with_separator_internal(char **x, const char *separator, ...) {
|
||||
va_list ap;
|
||||
char *ret;
|
||||
|
||||
va_start(ap, separator);
|
||||
ret = strextendv_with_separator(x, separator, ap);
|
||||
va_end(ap);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int strextendf_with_separator(char **x, const char *separator, const char *format, ...) {
|
||||
size_t m, a, l_separator;
|
||||
va_list ap;
|
||||
|
||||
@ -169,7 +169,6 @@ char* strreplace(const char *text, const char *old_string, const char *new_strin
|
||||
|
||||
char* strip_tab_ansi(char **ibuf, size_t *_isz, size_t highlight[2]);
|
||||
|
||||
char* strextendv_with_separator(char **x, const char *separator, va_list ap);
|
||||
char* strextend_with_separator_internal(char **x, const char *separator, ...) _sentinel_;
|
||||
#define strextend_with_separator(x, separator, ...) strextend_with_separator_internal(x, separator, __VA_ARGS__, NULL)
|
||||
#define strextend(x, ...) strextend_with_separator_internal(x, NULL, __VA_ARGS__, NULL)
|
||||
|
||||
@ -906,7 +906,7 @@ void strv_print_full(char * const *l, const char *prefix) {
|
||||
printf("%s%s\n", strempty(prefix), *s);
|
||||
}
|
||||
|
||||
int strv_extendf_with_size(char ***l, size_t *n, const char *format, ...) {
|
||||
int strv_extendf(char ***l, const char *format, ...) {
|
||||
va_list ap;
|
||||
char *x;
|
||||
int r;
|
||||
@ -918,19 +918,7 @@ int strv_extendf_with_size(char ***l, size_t *n, const char *format, ...) {
|
||||
if (r < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
return strv_consume_with_size(l, n, x);
|
||||
}
|
||||
|
||||
int strv_extend_joined_with_size_sentinel(char ***l, size_t *n, ...) {
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, n);
|
||||
char *x = strextendv_with_separator(/* x= */ NULL, /* separator=*/ NULL, ap);
|
||||
va_end(ap);
|
||||
if (!x)
|
||||
return -ENOMEM;
|
||||
|
||||
return strv_consume_with_size(l, n, x);
|
||||
return strv_consume(l, x);
|
||||
}
|
||||
|
||||
char* startswith_strv(const char *s, char * const *l) {
|
||||
|
||||
@ -56,12 +56,7 @@ static inline int strv_extend(char ***l, const char *value) {
|
||||
int strv_extend_many_internal(char ***l, const char *value, ...);
|
||||
#define strv_extend_many(l, ...) strv_extend_many_internal(l, __VA_ARGS__, POINTER_MAX)
|
||||
|
||||
int strv_extendf_with_size(char ***l, size_t *n, const char *format, ...) _printf_(3,4);
|
||||
#define strv_extendf(l, ...) strv_extendf_with_size(l, NULL, __VA_ARGS__)
|
||||
|
||||
int strv_extend_joined_with_size_sentinel(char ***l, size_t *n, ...) _sentinel_;
|
||||
#define strv_extend_joined_with_size(l, n, ...) strv_extend_joined_with_size_sentinel(l, n, __VA_ARGS__, NULL)
|
||||
#define strv_extend_joined(l, ...) strv_extend_joined_with_size(l, NULL, __VA_ARGS__)
|
||||
int strv_extendf(char ***l, const char *format, ...) _printf_(2,3);
|
||||
|
||||
int strv_push_with_size(char ***l, size_t *n, char *value);
|
||||
static inline int strv_push(char ***l, char *value) {
|
||||
|
||||
@ -1999,8 +1999,9 @@ static int build_environment(
|
||||
bool needs_sandboxing,
|
||||
char ***ret) {
|
||||
|
||||
_cleanup_strv_free_ char **e = NULL;
|
||||
size_t n = 0;
|
||||
_cleanup_strv_free_ char **our_env = NULL;
|
||||
size_t n_env = 0;
|
||||
char *x;
|
||||
int r;
|
||||
|
||||
assert(c);
|
||||
@ -2008,50 +2009,57 @@ static int build_environment(
|
||||
assert(cgroup_context);
|
||||
assert(ret);
|
||||
|
||||
#define N_ENV_VARS 20
|
||||
our_env = new0(char*, N_ENV_VARS + _EXEC_DIRECTORY_TYPE_MAX + 1);
|
||||
if (!our_env)
|
||||
return -ENOMEM;
|
||||
|
||||
if (p->n_socket_fds + p->n_stashed_fds > 0) {
|
||||
_cleanup_free_ char *joined = NULL;
|
||||
|
||||
r = strv_extendf_with_size(&e, &n, "LISTEN_PID="PID_FMT, getpid_cached());
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (asprintf(&x, "LISTEN_PID="PID_FMT, getpid_cached()) < 0)
|
||||
return -ENOMEM;
|
||||
our_env[n_env++] = x;
|
||||
|
||||
uint64_t pidfdid;
|
||||
if (pidfd_get_inode_id_self_cached(&pidfdid) >= 0) {
|
||||
r = strv_extendf_with_size(&e, &n, "LISTEN_PIDFDID=%"PRIu64, pidfdid);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (asprintf(&x, "LISTEN_PIDFDID=%"PRIu64, pidfdid) < 0)
|
||||
return -ENOMEM;
|
||||
our_env[n_env++] = x;
|
||||
}
|
||||
|
||||
r = strv_extendf_with_size(&e, &n, "LISTEN_FDS=%zu", p->n_socket_fds + p->n_stashed_fds);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (asprintf(&x, "LISTEN_FDS=%zu", p->n_socket_fds + p->n_stashed_fds) < 0)
|
||||
return -ENOMEM;
|
||||
our_env[n_env++] = x;
|
||||
|
||||
joined = strv_join(p->fd_names, ":");
|
||||
if (!joined)
|
||||
return -ENOMEM;
|
||||
|
||||
r = strv_extend_joined_with_size(&e, &n, "LISTEN_FDNAMES=", joined);
|
||||
if (r < 0)
|
||||
return r;
|
||||
x = strjoin("LISTEN_FDNAMES=", joined);
|
||||
if (!x)
|
||||
return -ENOMEM;
|
||||
our_env[n_env++] = x;
|
||||
}
|
||||
|
||||
if ((p->flags & EXEC_SET_WATCHDOG) && p->watchdog_usec > 0) {
|
||||
r = strv_extendf_with_size(&e, &n, "WATCHDOG_PID="PID_FMT, getpid_cached());
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (asprintf(&x, "WATCHDOG_PID="PID_FMT, getpid_cached()) < 0)
|
||||
return -ENOMEM;
|
||||
our_env[n_env++] = x;
|
||||
|
||||
r = strv_extendf_with_size(&e, &n, "WATCHDOG_USEC="USEC_FMT, p->watchdog_usec);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (asprintf(&x, "WATCHDOG_USEC="USEC_FMT, p->watchdog_usec) < 0)
|
||||
return -ENOMEM;
|
||||
our_env[n_env++] = x;
|
||||
}
|
||||
|
||||
/* If this is D-Bus, tell the nss-systemd module, since it relies on being able to use blocking
|
||||
* Varlink calls back to us for look up dynamic users in PID 1. Break the deadlock between D-Bus and
|
||||
* PID 1 by disabling use of PID1' NSS interface for looking up dynamic users. */
|
||||
if (p->flags & EXEC_NSS_DYNAMIC_BYPASS) {
|
||||
r = strv_extend_with_size(&e, &n, "SYSTEMD_NSS_DYNAMIC_BYPASS=1");
|
||||
if (r < 0)
|
||||
return r;
|
||||
x = strdup("SYSTEMD_NSS_DYNAMIC_BYPASS=1");
|
||||
if (!x)
|
||||
return -ENOMEM;
|
||||
our_env[n_env++] = x;
|
||||
}
|
||||
|
||||
/* We query "root" if this is a system unit and User= is not specified. $USER is always set. $HOME
|
||||
@ -2069,14 +2077,16 @@ static int build_environment(
|
||||
bool set_user_login_env = exec_context_get_set_login_environment(c);
|
||||
|
||||
if (username) {
|
||||
r = strv_extend_joined_with_size(&e, &n, "USER=", username);
|
||||
if (r < 0)
|
||||
return r;
|
||||
x = strjoin("USER=", username);
|
||||
if (!x)
|
||||
return -ENOMEM;
|
||||
our_env[n_env++] = x;
|
||||
|
||||
if (set_user_login_env) {
|
||||
r = strv_extend_joined_with_size(&e, &n, "LOGNAME=", username);
|
||||
if (r < 0)
|
||||
return r;
|
||||
x = strjoin("LOGNAME=", username);
|
||||
if (!x)
|
||||
return -ENOMEM;
|
||||
our_env[n_env++] = x;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2084,51 +2094,51 @@ static int build_environment(
|
||||
* (i.e. are "/" or "/bin/nologin"). */
|
||||
|
||||
if (home && set_user_login_env && !empty_or_root(home)) {
|
||||
_cleanup_free_ char *x = NULL;
|
||||
x = strjoin("HOME=", home);
|
||||
if (!x)
|
||||
return -ENOMEM;
|
||||
|
||||
r = path_simplify_alloc(home, &x);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = strv_extend_joined_with_size(&e, &n, "HOME=", x);
|
||||
if (r < 0)
|
||||
return r;
|
||||
path_simplify(x + 5);
|
||||
our_env[n_env++] = x;
|
||||
}
|
||||
|
||||
if (shell && set_user_login_env && !shell_is_placeholder(shell)) {
|
||||
_cleanup_free_ char *x = NULL;
|
||||
x = strjoin("SHELL=", shell);
|
||||
if (!x)
|
||||
return -ENOMEM;
|
||||
|
||||
r = path_simplify_alloc(shell, &x);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = strv_extend_joined_with_size(&e, &n, "SHELL=", x);
|
||||
if (r < 0)
|
||||
return r;
|
||||
path_simplify(x + 6);
|
||||
our_env[n_env++] = x;
|
||||
}
|
||||
|
||||
if (!sd_id128_is_null(p->invocation_id)) {
|
||||
assert(p->invocation_id_string);
|
||||
|
||||
r = strv_extend_joined_with_size(&e, &n, "INVOCATION_ID=", p->invocation_id_string);
|
||||
if (r < 0)
|
||||
return r;
|
||||
x = strjoin("INVOCATION_ID=", p->invocation_id_string);
|
||||
if (!x)
|
||||
return -ENOMEM;
|
||||
|
||||
our_env[n_env++] = x;
|
||||
}
|
||||
|
||||
if (journal_stream_dev != 0 && journal_stream_ino != 0) {
|
||||
r = strv_extendf_with_size(&e, &n, "JOURNAL_STREAM=" DEV_FMT ":" INO_FMT, journal_stream_dev, journal_stream_ino);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (asprintf(&x, "JOURNAL_STREAM=" DEV_FMT ":" INO_FMT, journal_stream_dev, journal_stream_ino) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
our_env[n_env++] = x;
|
||||
}
|
||||
|
||||
if (c->log_namespace) {
|
||||
r = strv_extend_joined_with_size(&e, &n, "LOG_NAMESPACE=", c->log_namespace);
|
||||
if (r < 0)
|
||||
return r;
|
||||
x = strjoin("LOG_NAMESPACE=", c->log_namespace);
|
||||
if (!x)
|
||||
return -ENOMEM;
|
||||
|
||||
our_env[n_env++] = x;
|
||||
}
|
||||
|
||||
for (ExecDirectoryType t = 0; t < _EXEC_DIRECTORY_TYPE_MAX; t++) {
|
||||
_cleanup_free_ char *joined = NULL;
|
||||
const char *n;
|
||||
|
||||
if (!p->prefix[t])
|
||||
continue;
|
||||
@ -2136,8 +2146,8 @@ static int build_environment(
|
||||
if (c->directories[t].n_items == 0)
|
||||
continue;
|
||||
|
||||
const char *name = exec_directory_env_name_to_string(t);
|
||||
if (!name)
|
||||
n = exec_directory_env_name_to_string(t);
|
||||
if (!n)
|
||||
continue;
|
||||
|
||||
for (size_t i = 0; i < c->directories[t].n_items; i++) {
|
||||
@ -2151,9 +2161,11 @@ static int build_environment(
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
r = strv_extend_joined_with_size(&e, &n, name, "=", joined);
|
||||
if (r < 0)
|
||||
return r;
|
||||
x = strjoin(n, "=", joined);
|
||||
if (!x)
|
||||
return -ENOMEM;
|
||||
|
||||
our_env[n_env++] = x;
|
||||
}
|
||||
|
||||
_cleanup_free_ char *creds_dir = NULL;
|
||||
@ -2161,22 +2173,27 @@ static int build_environment(
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r > 0) {
|
||||
r = strv_extend_joined_with_size(&e, &n, "CREDENTIALS_DIRECTORY=", creds_dir);
|
||||
if (r < 0)
|
||||
return r;
|
||||
x = strjoin("CREDENTIALS_DIRECTORY=", creds_dir);
|
||||
if (!x)
|
||||
return -ENOMEM;
|
||||
|
||||
our_env[n_env++] = x;
|
||||
}
|
||||
|
||||
r = strv_extendf_with_size(&e, &n, "SYSTEMD_EXEC_PID=" PID_FMT, getpid_cached());
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (asprintf(&x, "SYSTEMD_EXEC_PID=" PID_FMT, getpid_cached()) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
our_env[n_env++] = x;
|
||||
|
||||
if (memory_pressure_path) {
|
||||
r = strv_extend_joined_with_size(&e, &n, "MEMORY_PRESSURE_WATCH=", memory_pressure_path);
|
||||
if (r < 0)
|
||||
return r;
|
||||
x = strjoin("MEMORY_PRESSURE_WATCH=", memory_pressure_path);
|
||||
if (!x)
|
||||
return -ENOMEM;
|
||||
|
||||
our_env[n_env++] = x;
|
||||
|
||||
if (!path_equal(memory_pressure_path, "/dev/null")) {
|
||||
_cleanup_free_ char *b = NULL, *x = NULL;
|
||||
_cleanup_free_ char *b = NULL, *e = NULL;
|
||||
|
||||
if (asprintf(&b, "%s " USEC_FMT " " USEC_FMT,
|
||||
MEMORY_PRESSURE_DEFAULT_TYPE,
|
||||
@ -2185,21 +2202,23 @@ static int build_environment(
|
||||
MEMORY_PRESSURE_DEFAULT_WINDOW_USEC) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
if (base64mem(b, strlen(b) + 1, &x) < 0)
|
||||
if (base64mem(b, strlen(b) + 1, &e) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
r = strv_extend_joined_with_size(&e, &n, "MEMORY_PRESSURE_WRITE=", x);
|
||||
if (r < 0)
|
||||
return r;
|
||||
x = strjoin("MEMORY_PRESSURE_WRITE=", e);
|
||||
if (!x)
|
||||
return -ENOMEM;
|
||||
|
||||
our_env[n_env++] = x;
|
||||
}
|
||||
}
|
||||
|
||||
if (p->notify_socket) {
|
||||
r = strv_extend_joined_with_size(
|
||||
&e, &n, "NOTIFY_SOCKET=",
|
||||
exec_get_private_notify_socket_path(c, p, needs_sandboxing) ?: p->notify_socket);
|
||||
if (r < 0)
|
||||
return r;
|
||||
x = strjoin("NOTIFY_SOCKET=", exec_get_private_notify_socket_path(c, p, needs_sandboxing) ?: p->notify_socket);
|
||||
if (!x)
|
||||
return -ENOMEM;
|
||||
|
||||
our_env[n_env++] = x;
|
||||
}
|
||||
|
||||
assert(c->private_var_tmp >= 0 && c->private_var_tmp < _PRIVATE_TMP_MAX);
|
||||
@ -2210,12 +2229,18 @@ static int build_environment(
|
||||
/* When private tmpfs is enabled only on /tmp/, then explicitly set $TMPDIR to suggest the
|
||||
* service to use /tmp/. */
|
||||
|
||||
r = strv_extend_with_size(&e, &n, "TMPDIR=/tmp");
|
||||
if (r < 0)
|
||||
return r;
|
||||
x = strdup("TMPDIR=/tmp");
|
||||
if (!x)
|
||||
return -ENOMEM;
|
||||
|
||||
our_env[n_env++] = x;
|
||||
}
|
||||
|
||||
*ret = TAKE_PTR(e);
|
||||
assert(n_env <= N_ENV_VARS + _EXEC_DIRECTORY_TYPE_MAX);
|
||||
#undef N_ENV_VARS
|
||||
|
||||
*ret = TAKE_PTR(our_env);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -24,6 +24,20 @@
|
||||
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_type, image_type, ImageType);
|
||||
|
||||
static int property_get_read_only(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Image *image = ASSERT_PTR(userdata);
|
||||
|
||||
return sd_bus_message_append(ASSERT_PTR(reply), "b", image_is_read_only(image));
|
||||
}
|
||||
|
||||
int bus_image_method_remove(
|
||||
sd_bus_message *message,
|
||||
void *userdata,
|
||||
@ -448,7 +462,7 @@ const sd_bus_vtable image_vtable[] = {
|
||||
SD_BUS_PROPERTY("Name", "s", NULL, offsetof(Image, name), 0),
|
||||
SD_BUS_PROPERTY("Path", "s", NULL, offsetof(Image, path), 0),
|
||||
SD_BUS_PROPERTY("Type", "s", property_get_type, offsetof(Image, type), 0),
|
||||
SD_BUS_PROPERTY("ReadOnly", "b", bus_property_get_image_is_read_only, 0, 0),
|
||||
SD_BUS_PROPERTY("ReadOnly", "b", property_get_read_only, 0, 0),
|
||||
SD_BUS_PROPERTY("CreationTimestamp", "t", NULL, offsetof(Image, crtime), 0),
|
||||
SD_BUS_PROPERTY("ModificationTimestamp", "t", NULL, offsetof(Image, mtime), 0),
|
||||
SD_BUS_PROPERTY("Usage", "t", NULL, offsetof(Image, usage), 0),
|
||||
|
||||
@ -30,6 +30,20 @@
|
||||
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_type, image_type, ImageType);
|
||||
|
||||
static int property_get_read_only(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Image *image = ASSERT_PTR(userdata);
|
||||
|
||||
return sd_bus_message_append(ASSERT_PTR(reply), "b", image_is_read_only(image));
|
||||
}
|
||||
|
||||
int bus_image_common_get_os_release(
|
||||
Manager *m,
|
||||
sd_bus_message *message,
|
||||
@ -865,7 +879,7 @@ const sd_bus_vtable image_vtable[] = {
|
||||
SD_BUS_PROPERTY("Name", "s", NULL, offsetof(Image, name), 0),
|
||||
SD_BUS_PROPERTY("Path", "s", NULL, offsetof(Image, path), 0),
|
||||
SD_BUS_PROPERTY("Type", "s", property_get_type, offsetof(Image, type), 0),
|
||||
SD_BUS_PROPERTY("ReadOnly", "b", bus_property_get_image_is_read_only, 0, 0),
|
||||
SD_BUS_PROPERTY("ReadOnly", "b", property_get_read_only, 0, 0),
|
||||
SD_BUS_PROPERTY("CreationTimestamp", "t", NULL, offsetof(Image, crtime), 0),
|
||||
SD_BUS_PROPERTY("ModificationTimestamp", "t", NULL, offsetof(Image, mtime), 0),
|
||||
SD_BUS_PROPERTY("Usage", "t", NULL, offsetof(Image, usage), 0),
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
#include "alloc-util.h"
|
||||
#include "blockdev-util.h"
|
||||
#include "btrfs-util.h"
|
||||
#include "bus-get-properties.h"
|
||||
#include "chase.h"
|
||||
#include "chattr-util.h"
|
||||
#include "copy.h"
|
||||
@ -2221,5 +2220,3 @@ int image_root_pick(
|
||||
*ret = TAKE_PTR(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
BUS_DEFINE_PROPERTY_GET(bus_property_get_image_is_read_only, "b", Image, (int) image_is_read_only);
|
||||
|
||||
@ -91,7 +91,7 @@ static inline bool image_is_hidden(const Image *i) {
|
||||
return i->name && i->name[0] == '.';
|
||||
}
|
||||
|
||||
static inline bool image_is_read_only(const Image *i) {
|
||||
static inline int image_is_read_only(const Image *i) {
|
||||
assert(i);
|
||||
|
||||
/* We enforce the rule that hidden images are always read-only too. If people want to change hidden
|
||||
@ -102,7 +102,6 @@ static inline bool image_is_read_only(const Image *i) {
|
||||
|
||||
return i->read_only;
|
||||
}
|
||||
int bus_property_get_image_is_read_only(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *reterr_error);
|
||||
|
||||
bool image_is_vendor(const Image *i);
|
||||
bool image_is_host(const Image *i);
|
||||
|
||||
@ -819,12 +819,21 @@ static char *format_types(Bitmap *types) {
|
||||
int r;
|
||||
|
||||
BITMAP_FOREACH(type, types) {
|
||||
if (dns_type_to_string(type))
|
||||
if (dns_type_to_string(type)) {
|
||||
r = strv_extend(&strv, dns_type_to_string(type));
|
||||
else
|
||||
r = strv_extendf(&strv, "TYPE%u", type);
|
||||
if (r < 0)
|
||||
return NULL;
|
||||
} else {
|
||||
char *t;
|
||||
|
||||
r = asprintf(&t, "TYPE%u", type);
|
||||
if (r < 0)
|
||||
return NULL;
|
||||
|
||||
r = strv_consume(&strv, t);
|
||||
if (r < 0)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
str = strv_join(strv, " ");
|
||||
|
||||
@ -749,43 +749,6 @@ TEST(strv_extendf) {
|
||||
ASSERT_STREQ(b[0], "test3 bar foo 128");
|
||||
}
|
||||
|
||||
TEST(strv_extendf_with_size) {
|
||||
_cleanup_strv_free_ char **a = NULL;
|
||||
size_t n = 0;
|
||||
|
||||
ASSERT_OK(strv_extendf_with_size(&a, &n, "test2 %s %d %s", "foo", 128, "bar"));
|
||||
ASSERT_OK(strv_extendf_with_size(&a, &n, "test3 %s %s %d", "bar", "foo", 128));
|
||||
|
||||
ASSERT_EQ(n, 2u);
|
||||
ASSERT_EQ(strv_length(a), n);
|
||||
ASSERT_STREQ(a[0], "test2 foo 128 bar");
|
||||
ASSERT_STREQ(a[1], "test3 bar foo 128");
|
||||
}
|
||||
|
||||
TEST(strv_extend_joined) {
|
||||
_cleanup_strv_free_ char **a = NULL;
|
||||
|
||||
ASSERT_OK(strv_extend_joined(&a, "hoge"));
|
||||
ASSERT_OK(strv_extend_joined(&a, "aaa", "bbb", "ccc"));
|
||||
|
||||
ASSERT_EQ(strv_length(a), 2u);
|
||||
ASSERT_STREQ(a[0], "hoge");
|
||||
ASSERT_STREQ(a[1], "aaabbbccc");
|
||||
}
|
||||
|
||||
TEST(strv_extend_joined_with_size) {
|
||||
_cleanup_strv_free_ char **a = NULL;
|
||||
size_t n = 0;
|
||||
|
||||
ASSERT_OK(strv_extend_joined_with_size(&a, &n, "hoge"));
|
||||
ASSERT_OK(strv_extend_joined_with_size(&a, &n, "aaa", "bbb", "ccc"));
|
||||
|
||||
ASSERT_EQ(n, 2u);
|
||||
ASSERT_EQ(strv_length(a), n);
|
||||
ASSERT_STREQ(a[0], "hoge");
|
||||
ASSERT_STREQ(a[1], "aaabbbccc");
|
||||
}
|
||||
|
||||
TEST(strv_foreach) {
|
||||
_cleanup_strv_free_ char **a;
|
||||
unsigned i = 0;
|
||||
|
||||
@ -1154,7 +1154,7 @@ static int cmdline_add_kernel_cmdline(char ***cmdline, const char *kernel, const
|
||||
if (strv_extend(cmdline, "-smbios") < 0)
|
||||
return log_oom();
|
||||
|
||||
if (strv_extend_joined(cmdline, "type=11,path=", p) < 0)
|
||||
if (strv_extendf(cmdline, "type=11,path=%s", p) < 0)
|
||||
return log_oom();
|
||||
}
|
||||
}
|
||||
@ -1191,7 +1191,7 @@ static int cmdline_add_smbios11(char ***cmdline, const char* smbios_dir) {
|
||||
if (strv_extend(cmdline, "-smbios") < 0)
|
||||
return log_oom();
|
||||
|
||||
if (strv_extend_joined(cmdline, "type=11,path=", p) < 0)
|
||||
if (strv_extendf(cmdline, "type=11,path=%s", p) < 0)
|
||||
return log_oom();
|
||||
|
||||
p = mfree(p);
|
||||
@ -1289,7 +1289,7 @@ static int start_tpm(
|
||||
if (!argv)
|
||||
return log_oom();
|
||||
|
||||
r = strv_extend_joined(&argv, "dir=", state_dir);
|
||||
r = strv_extendf(&argv, "dir=%s", state_dir);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
@ -1933,10 +1933,11 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
|
||||
return log_error_errno(r, "Failed to make up randomized vmgenid: %m");
|
||||
}
|
||||
|
||||
if (strv_extend(&cmdline, "-device") < 0)
|
||||
_cleanup_free_ char *vmgenid_device = NULL;
|
||||
if (asprintf(&vmgenid_device, "vmgenid,guid=" SD_ID128_UUID_FORMAT_STR, SD_ID128_FORMAT_VAL(vmgenid)) < 0)
|
||||
return log_oom();
|
||||
|
||||
if (strv_extendf(&cmdline, "vmgenid,guid=" SD_ID128_UUID_FORMAT_STR, SD_ID128_FORMAT_VAL(vmgenid)) < 0)
|
||||
if (strv_extend_many(&cmdline, "-device", vmgenid_device) < 0)
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
@ -2150,7 +2151,8 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
|
||||
"-chardev") < 0)
|
||||
return log_oom();
|
||||
|
||||
if (strv_extend_joined(&cmdline, "serial,id=console,path=", pty_path) < 0)
|
||||
if (strv_extendf(&cmdline,
|
||||
"serial,id=console,path=%s", pty_path) < 0)
|
||||
return log_oom();
|
||||
|
||||
r = strv_extend_many(
|
||||
@ -2280,7 +2282,7 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
|
||||
if (strv_extend(&cmdline, "-device") < 0)
|
||||
return log_oom();
|
||||
|
||||
if (strv_extend_joined(&cmdline, "virtio-blk-pci,drive=vmspawn,bootindex=1,serial=", escaped_image_fn) < 0)
|
||||
if (strv_extendf(&cmdline, "virtio-blk-pci,drive=vmspawn,bootindex=1,serial=%s", escaped_image_fn) < 0)
|
||||
return log_oom();
|
||||
|
||||
r = grow_image(arg_image, arg_grow_image);
|
||||
@ -2550,7 +2552,7 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
|
||||
if (strv_extend(&cmdline, "-chardev") < 0)
|
||||
return log_oom();
|
||||
|
||||
if (strv_extend_joined(&cmdline, "socket,id=chrtpm,path=", tpm_socket_address) < 0)
|
||||
if (strv_extendf(&cmdline, "socket,id=chrtpm,path=%s", tpm_socket_address) < 0)
|
||||
return log_oom();
|
||||
|
||||
if (strv_extend_many(&cmdline, "-tpmdev", "emulator,id=tpm0,chardev=chrtpm") < 0)
|
||||
@ -2685,7 +2687,7 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
r = strv_extend_joined(&cmdline, "type=11,path=", p);
|
||||
r = strv_extendf(&cmdline, "type=11,path=%s", p);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user