diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-07-30 02:51:12 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-07-30 02:54:56 +0200 |
commit | 743e89454093361653b85ff394d0434c0714a92d (patch) | |
tree | 54916ca00903e28b91c8b3feef964cb56195fc5d | |
parent | 07beec1244817a0e6e9d79798f7c65bd89b23549 (diff) |
logind: make sure login sessions are terminated with SIGHUP
bash ignores SIGTERM, and can only be terminated cleanly via SIGHUP.
Hence make sure that we the scope unit for the session is created with
SendSIGHUP enabled.
-rw-r--r-- | src/login/logind-dbus.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 7b9bd201b2..ed5d8d888c 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -2526,11 +2526,11 @@ int manager_start_scope( DBusError *error, char **job) { + const char *timeout_stop_property = "TimeoutStopUSec", *send_sighup_property = "SendSIGHUP", *pids_property = "PIDs"; _cleanup_dbus_message_unref_ DBusMessage *m = NULL, *reply = NULL; DBusMessageIter iter, sub, sub2, sub3, sub4; - const char *timeout_stop_property = "TimeoutStopUSec"; - const char *pids_property = "PIDs"; uint64_t timeout = 500 * USEC_PER_MSEC; + dbus_bool_t send_sighup = true; const char *fail = "fail"; uint32_t u; @@ -2607,6 +2607,16 @@ int manager_start_scope( !dbus_message_iter_close_container(&sub, &sub2)) return log_oom(); + /* Make sure that the session shells are terminated with + * SIGHUP since bash and friends tend to ignore SIGTERM */ + if (!dbus_message_iter_open_container(&sub, DBUS_TYPE_STRUCT, NULL, &sub2) || + !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &send_sighup_property) || + !dbus_message_iter_open_container(&sub2, DBUS_TYPE_VARIANT, "b", &sub3) || + !dbus_message_iter_append_basic(&sub3, DBUS_TYPE_BOOLEAN, &send_sighup) || + !dbus_message_iter_close_container(&sub2, &sub3) || + !dbus_message_iter_close_container(&sub, &sub2)) + return log_oom(); + u = pid; if (!dbus_message_iter_open_container(&sub, DBUS_TYPE_STRUCT, NULL, &sub2) || !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &pids_property) || @@ -2615,8 +2625,10 @@ int manager_start_scope( !dbus_message_iter_append_basic(&sub4, DBUS_TYPE_UINT32, &u) || !dbus_message_iter_close_container(&sub3, &sub4) || !dbus_message_iter_close_container(&sub2, &sub3) || - !dbus_message_iter_close_container(&sub, &sub2) || - !dbus_message_iter_close_container(&iter, &sub)) + !dbus_message_iter_close_container(&sub, &sub2)) + return log_oom(); + + if (!dbus_message_iter_close_container(&iter, &sub)) return log_oom(); reply = dbus_connection_send_with_reply_and_block(manager->bus, m, -1, error); |