summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/afm-user-daemon.c1
-rw-r--r--src/utils-systemd.c44
-rw-r--r--src/utils-systemd.h2
3 files changed, 47 insertions, 0 deletions
diff --git a/src/afm-user-daemon.c b/src/afm-user-daemon.c
index b20fe92..481013f 100644
--- a/src/afm-user-daemon.c
+++ b/src/afm-user-daemon.c
@@ -490,6 +490,7 @@ static void on_signal_changed(struct json_object *obj, void *unused)
{
/* enforce daemon reload */
systemd_daemon_reload(1);
+ systemd_unit_restart_name(1, "sockets.target");
/* update the database */
#ifdef LEGACY_MODE_WITHOUT_SYSTEMD
diff --git a/src/utils-systemd.c b/src/utils-systemd.c
index 830fec6..df9b89f 100644
--- a/src/utils-systemd.c
+++ b/src/utils-systemd.c
@@ -57,8 +57,10 @@ static const char sdbi_unit[] = "org.freedesktop.systemd1.Unit";
static const char sdbi_service[] = "org.freedesktop.systemd1.Service";
static const char sdbm_reload[] = "Reload";
static const char sdbm_start_unit[] = "StartUnit";
+static const char sdbm_restart_unit[] = "RestartUnit";
static const char sdbm_stop_unit[] = "StopUnit";
static const char sdbm_start[] = "Start";
+static const char sdbm_restart[] = "Restart";
static const char sdbm_stop[] = "Stop";
static const char sdbm_get_unit[] = "GetUnit";
static const char sdbm_get_unit_by_pid[] = "GetUnitByPID";
@@ -289,6 +291,17 @@ static int unit_start(struct sd_bus *bus, const char *dpath)
return rc;
}
+static int unit_restart(struct sd_bus *bus, const char *dpath)
+{
+ int rc;
+ struct sd_bus_message *ret = NULL;
+ sd_bus_error err = SD_BUS_ERROR_NULL;
+
+ rc = sd_bus_call_method(bus, sdb_destination, dpath, sdbi_unit, sdbm_restart, &err, &ret, "s", "replace");
+ sd_bus_message_unref(ret);
+ return rc;
+}
+
static int unit_stop(struct sd_bus *bus, const char *dpath)
{
int rc;
@@ -311,6 +324,17 @@ static int unit_start_name(struct sd_bus *bus, const char *name)
return rc;
}
+static int unit_restart_name(struct sd_bus *bus, const char *name)
+{
+ int rc;
+ struct sd_bus_message *ret = NULL;
+ sd_bus_error err = SD_BUS_ERROR_NULL;
+
+ rc = sd_bus_call_method(bus, sdb_destination, sdb_path, sdbi_manager, sdbm_restart_unit, &err, &ret, "ss", name, "replace");
+ sd_bus_message_unref(ret);
+ return rc;
+}
+
static int unit_stop_name(struct sd_bus *bus, const char *name)
{
int rc;
@@ -478,6 +502,15 @@ int systemd_unit_start_dpath(int isuser, const char *dpath)
return rc < 0 ? rc : unit_start(bus, dpath);
}
+int systemd_unit_restart_dpath(int isuser, const char *dpath)
+{
+ int rc;
+ struct sd_bus *bus;
+
+ rc = get_bus(isuser, &bus);
+ return rc < 0 ? rc : unit_restart(bus, dpath);
+}
+
int systemd_unit_stop_dpath(int isuser, const char *dpath)
{
int rc;
@@ -498,6 +531,17 @@ int systemd_unit_start_name(int isuser, const char *name)
return rc;
}
+int systemd_unit_restart_name(int isuser, const char *name)
+{
+ int rc;
+ struct sd_bus *bus;
+
+ rc = get_bus(isuser, &bus);
+ if (rc >= 0)
+ rc = unit_restart_name(bus, name);
+ return rc;
+}
+
int systemd_unit_stop_name(int isuser, const char *name)
{
int rc;
diff --git a/src/utils-systemd.h b/src/utils-systemd.h
index b4c3b8c..7f67e3e 100644
--- a/src/utils-systemd.h
+++ b/src/utils-systemd.h
@@ -35,9 +35,11 @@ extern char *systemd_unit_dpath_by_name(int isuser, const char *name, int load);
extern char *systemd_unit_dpath_by_pid(int isuser, unsigned pid);
extern int systemd_unit_start_dpath(int isuser, const char *dpath);
+extern int systemd_unit_restart_dpath(int isuser, const char *dpath);
extern int systemd_unit_stop_dpath(int isuser, const char *dpath);
extern int systemd_unit_start_name(int isuser, const char *name);
+extern int systemd_unit_restart_name(int isuser, const char *name);
extern int systemd_unit_stop_name(int isuser, const char *name);
extern int systemd_unit_stop_pid(int isuser, unsigned pid);