1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-05-28 13:05:47 +03:00

bus-unit-util: add socket unit related options

Also, split bus_append_unit_property_assignment().
This commit is contained in:
Yu Watanabe 2017-12-23 16:59:56 +09:00
parent 9c0320e7ab
commit 89ada3ba08
6 changed files with 1092 additions and 986 deletions

View File

@ -40,6 +40,7 @@
#include "stat-util.h"
#include "strv.h"
#include "udev-util.h"
#include "unit-def.h"
#include "unit-name.h"
#include "user-util.h"
#include "terminal-util.h"
@ -403,7 +404,7 @@ static int parse_argv(int argc, char *argv[]) {
return 1;
}
static int transient_unit_set_properties(sd_bus_message *m, char **properties) {
static int transient_unit_set_properties(sd_bus_message *m, UnitType t, char **properties) {
int r;
if (!isempty(arg_description)) {
@ -432,7 +433,7 @@ static int transient_unit_set_properties(sd_bus_message *m, char **properties) {
return r;
}
r = bus_append_unit_property_assignment_many(m, properties);
r = bus_append_unit_property_assignment_many(m, t, properties);
if (r < 0)
return r;
@ -445,7 +446,7 @@ static int transient_mount_set_properties(sd_bus_message *m) {
assert(m);
r = transient_unit_set_properties(m, arg_property);
r = transient_unit_set_properties(m, UNIT_MOUNT, arg_property);
if (r < 0)
return r;
@ -503,7 +504,7 @@ static int transient_automount_set_properties(sd_bus_message *m) {
assert(m);
r = transient_unit_set_properties(m, arg_automount_property);
r = transient_unit_set_properties(m, UNIT_AUTOMOUNT, arg_automount_property);
if (r < 0)
return r;

View File

@ -203,7 +203,7 @@ int register_machine(
if (r < 0)
return r;
r = bus_append_unit_property_assignment_many(m, properties);
r = bus_append_unit_property_assignment_many(m, UNIT_SERVICE, properties);
if (r < 0)
return r;
@ -339,7 +339,7 @@ int allocate_scope(
if (r < 0)
return r;
r = bus_append_unit_property_assignment_many(m, properties);
r = bus_append_unit_property_assignment_many(m, UNIT_SCOPE, properties);
if (r < 0)
return r;

View File

@ -40,6 +40,7 @@
#include "spawn-polkit-agent.h"
#include "strv.h"
#include "terminal-util.h"
#include "unit-def.h"
#include "unit-name.h"
#include "user-util.h"
@ -462,7 +463,7 @@ static int parse_argv(int argc, char *argv[]) {
return 1;
}
static int transient_unit_set_properties(sd_bus_message *m, char **properties) {
static int transient_unit_set_properties(sd_bus_message *m, UnitType t, char **properties) {
int r;
r = sd_bus_message_append(m, "(sv)", "Description", "s", arg_description);
@ -475,7 +476,7 @@ static int transient_unit_set_properties(sd_bus_message *m, char **properties) {
return bus_log_create_error(r);
}
r = bus_append_unit_property_assignment_many(m, properties);
r = bus_append_unit_property_assignment_many(m, t, properties);
if (r < 0)
return r;
@ -521,7 +522,7 @@ static int transient_service_set_properties(sd_bus_message *m, char **argv, cons
assert(m);
r = transient_unit_set_properties(m, arg_property);
r = transient_unit_set_properties(m, UNIT_SERVICE, arg_property);
if (r < 0)
return r;
@ -694,7 +695,7 @@ static int transient_scope_set_properties(sd_bus_message *m) {
assert(m);
r = transient_unit_set_properties(m, arg_property);
r = transient_unit_set_properties(m, UNIT_SCOPE, arg_property);
if (r < 0)
return r;
@ -718,7 +719,7 @@ static int transient_timer_set_properties(sd_bus_message *m) {
assert(m);
r = transient_unit_set_properties(m, arg_timer_property);
r = transient_unit_set_properties(m, UNIT_TIMER, arg_timer_property);
if (r < 0)
return r;

File diff suppressed because it is too large Load Diff

View File

@ -20,10 +20,10 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include "sd-bus.h"
#include "output-mode.h"
#include "install.h"
#include "output-mode.h"
#include "sd-bus.h"
#include "unit-def.h"
typedef struct UnitInfo {
const char *machine;
@ -41,8 +41,8 @@ typedef struct UnitInfo {
int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u);
int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignment);
int bus_append_unit_property_assignment_many(sd_bus_message *m, char **l);
int bus_append_unit_property_assignment(sd_bus_message *m, UnitType t, const char *assignment);
int bus_append_unit_property_assignment_many(sd_bus_message *m, UnitType t, char **l);
typedef struct BusWaitForJobs BusWaitForJobs;

View File

@ -84,6 +84,7 @@
#include "stat-util.h"
#include "strv.h"
#include "terminal-util.h"
#include "unit-def.h"
#include "unit-name.h"
#include "user-util.h"
#include "util.h"
@ -5582,6 +5583,7 @@ static int set_property(int argc, char *argv[], void *userdata) {
_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;
@ -5605,6 +5607,12 @@ static int set_property(int argc, char *argv[], void *userdata) {
if (r < 0)
return log_error_errno(r, "Failed to mangle unit name: %m");
t = unit_name_to_type(n);
if (t < 0) {
log_error("Invalid unit type: %s", n);
return -EINVAL;
}
r = sd_bus_message_append(m, "sb", n, arg_runtime);
if (r < 0)
return bus_log_create_error(r);
@ -5613,7 +5621,7 @@ static int set_property(int argc, char *argv[], void *userdata) {
if (r < 0)
return bus_log_create_error(r);
r = bus_append_unit_property_assignment_many(m, strv_skip(argv, 2));
r = bus_append_unit_property_assignment_many(m, t, strv_skip(argv, 2));
if (r < 0)
return r;