]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: also restrict on which session classes one cange the session type 30884/head
authorLennart Poettering <lennart@poettering.net>
Thu, 11 Jan 2024 16:20:38 +0000 (17:20 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 11 Jan 2024 17:24:44 +0000 (18:24 +0100)
src/login/logind-session-dbus.c
src/login/logind-session.h

index 03a043fe7d82e14f03655263cd076aa930bd388b..7217b8147642c188d959c77d826bff94cf3f22e5 100644 (file)
@@ -393,6 +393,9 @@ static int method_set_type(sd_bus_message *message, void *userdata, sd_bus_error
                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
                                          "Invalid session type '%s'", t);
 
+        if (!SESSION_CLASS_CAN_CHANGE_TYPE(s->class))
+                return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Session class doesn't support changing type.");
+
         if (!session_is_controller(s, sd_bus_message_get_sender(message)))
                 return sd_bus_error_set(error, BUS_ERROR_NOT_IN_CONTROL, "You must be in control of this session to set type");
 
index 5f3961cf61a0cb6ac8c2d9ede470d634f6fc7d7c..6a0fb5430359f4fbb8895c66f7f786a4cf84d3d2 100644 (file)
@@ -60,6 +60,9 @@ typedef enum SessionClass {
 /* Which session classes can take control of devices */
 #define SESSION_CLASS_CAN_TAKE_DEVICE(class) (IN_SET((class), SESSION_USER, SESSION_USER_EARLY, SESSION_GREETER, SESSION_LOCK_SCREEN))
 
+/* Which session classes allow changing session types */
+#define SESSION_CLASS_CAN_CHANGE_TYPE(class) (IN_SET((class), SESSION_USER, SESSION_USER_EARLY, SESSION_GREETER, SESSION_LOCK_SCREEN))
+
 typedef enum SessionType {
         SESSION_UNSPECIFIED,
         SESSION_TTY,