mirror of
https://github.com/systemd/systemd
synced 2026-03-24 07:44:52 +01:00
Compare commits
No commits in common. "23a0ffa59f9cb26c4b016c9fd1a3a70da2607f61" and "463aef23a73d7850e0208cf4e96fd448693a755a" have entirely different histories.
23a0ffa59f
...
463aef23a7
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <linux/oom.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -730,7 +731,7 @@ int parse_oom_score_adjust(const char *s, int *ret) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (!oom_score_adjust_is_valid(v))
|
if (v < OOM_SCORE_ADJ_MIN || v > OOM_SCORE_ADJ_MAX)
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
|
|
||||||
*ret = v;
|
*ret = v;
|
||||||
|
|||||||
@ -1037,10 +1037,6 @@ bool is_main_thread(void) {
|
|||||||
return cached > 0;
|
return cached > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool oom_score_adjust_is_valid(int oa) {
|
|
||||||
return oa >= OOM_SCORE_ADJ_MIN && oa <= OOM_SCORE_ADJ_MAX;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long personality_from_string(const char *p) {
|
unsigned long personality_from_string(const char *p) {
|
||||||
int architecture;
|
int architecture;
|
||||||
|
|
||||||
|
|||||||
@ -82,8 +82,6 @@ int pid_from_same_root_fs(pid_t pid);
|
|||||||
|
|
||||||
bool is_main_thread(void);
|
bool is_main_thread(void);
|
||||||
|
|
||||||
bool oom_score_adjust_is_valid(int oa);
|
|
||||||
|
|
||||||
#ifndef PERSONALITY_INVALID
|
#ifndef PERSONALITY_INVALID
|
||||||
/* personality(7) documents that 0xffffffffUL is used for querying the
|
/* personality(7) documents that 0xffffffffUL is used for querying the
|
||||||
* current personality, hence let's use that here as error
|
* current personality, hence let's use that here as error
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
|
||||||
|
#include <linux/oom.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
|
|
||||||
@ -94,6 +95,10 @@ static int property_get_environment_files(
|
|||||||
return sd_bus_message_close_container(reply);
|
return sd_bus_message_close_container(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool oom_score_adjust_is_valid(int oa) {
|
||||||
|
return oa >= OOM_SCORE_ADJ_MIN && oa <= OOM_SCORE_ADJ_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
static int property_get_oom_score_adjust(
|
static int property_get_oom_score_adjust(
|
||||||
sd_bus *bus,
|
sd_bus *bus,
|
||||||
const char *path,
|
const char *path,
|
||||||
|
|||||||
@ -6,20 +6,33 @@
|
|||||||
#include "systemctl-util.h"
|
#include "systemctl-util.h"
|
||||||
#include "systemctl.h"
|
#include "systemctl.h"
|
||||||
|
|
||||||
static int set_property_one(sd_bus *bus, const char *name, char **properties) {
|
int set_property(int argc, char *argv[], void *userdata) {
|
||||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
|
||||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
|
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
|
||||||
|
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||||
|
_cleanup_free_ char *n = NULL;
|
||||||
|
UnitType t;
|
||||||
|
sd_bus *bus;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
r = acquire_bus(BUS_MANAGER, &bus);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
polkit_agent_open_maybe();
|
||||||
|
|
||||||
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "SetUnitProperties");
|
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "SetUnitProperties");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
UnitType t = unit_name_to_type(name);
|
r = unit_name_mangle(argv[1], arg_quiet ? 0 : UNIT_NAME_MANGLE_WARN, &n);
|
||||||
if (t < 0)
|
if (r < 0)
|
||||||
return log_error_errno(t, "Invalid unit type: %s", name);
|
return log_error_errno(r, "Failed to mangle unit name: %m");
|
||||||
|
|
||||||
r = sd_bus_message_append(m, "sb", name, arg_runtime);
|
t = unit_name_to_type(n);
|
||||||
|
if (t < 0)
|
||||||
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid unit type: %s", n);
|
||||||
|
|
||||||
|
r = sd_bus_message_append(m, "sb", n, arg_runtime);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
@ -27,7 +40,7 @@ static int set_property_one(sd_bus *bus, const char *name, char **properties) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
r = bus_append_unit_property_assignment_many(m, t, properties);
|
r = bus_append_unit_property_assignment_many(m, t, strv_skip(argv, 2));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
@ -37,33 +50,7 @@ static int set_property_one(sd_bus *bus, const char *name, char **properties) {
|
|||||||
|
|
||||||
r = sd_bus_call(bus, m, 0, &error, NULL);
|
r = sd_bus_call(bus, m, 0, &error, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to set unit properties on %s: %s",
|
return log_error_errno(r, "Failed to set unit properties on %s: %s", n, bus_error_message(&error, r));
|
||||||
name, bus_error_message(&error, r));
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int set_property(int argc, char *argv[], void *userdata) {
|
|
||||||
sd_bus *bus;
|
|
||||||
_cleanup_strv_free_ char **names = NULL;
|
|
||||||
char **name;
|
|
||||||
int r, k;
|
|
||||||
|
|
||||||
r = acquire_bus(BUS_MANAGER, &bus);
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
polkit_agent_open_maybe();
|
|
||||||
|
|
||||||
r = expand_unit_names(bus, STRV_MAKE(argv[1]), NULL, &names, NULL);
|
|
||||||
if (r < 0)
|
|
||||||
return log_error_errno(r, "Failed to expand '%s' into names: %m", argv[1]);
|
|
||||||
|
|
||||||
r = 0;
|
|
||||||
STRV_FOREACH(name, names) {
|
|
||||||
k = set_property_one(bus, *name, strv_skip(argv, 2));
|
|
||||||
if (k < 0 && r >= 0)
|
|
||||||
r = k;
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -76,10 +76,7 @@ struct sd_bus_vtable {
|
|||||||
const unsigned *vtable_format_reference;
|
const unsigned *vtable_format_reference;
|
||||||
} start;
|
} start;
|
||||||
struct {
|
struct {
|
||||||
/* This field exists only to make sure we have something to initialize in
|
size_t reserved;
|
||||||
* SD_BUS_VTABLE_END in a way that is both compatible with pedantic versions of C and
|
|
||||||
* C++. It's unused otherwise. */
|
|
||||||
size_t _reserved;
|
|
||||||
} end;
|
} end;
|
||||||
struct {
|
struct {
|
||||||
const char *member;
|
const char *member;
|
||||||
@ -193,7 +190,7 @@ struct sd_bus_vtable {
|
|||||||
.flags = 0, \
|
.flags = 0, \
|
||||||
.x = { \
|
.x = { \
|
||||||
.end = { \
|
.end = { \
|
||||||
._reserved = 0, \
|
.reserved = 0, \
|
||||||
}, \
|
}, \
|
||||||
}, \
|
}, \
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user