summaryrefslogtreecommitdiff
path: root/src/login/logind-dbus.c
diff options
context:
space:
mode:
authorLudwig Nussel <ludwig.nussel@suse.de>2022-02-07 11:50:12 +0100
committerLudwig Nussel <ludwig.nussel@suse.de>2022-02-14 09:35:12 +0100
commit1831759a705b85c3486a79fb98a20474bbe6bae4 (patch)
tree7fe297d7f55a052ba3ea2f15ca819679f61e24fb /src/login/logind-dbus.c
parentd2fc0ecf9a217aad46fe4b792640fb8911599d93 (diff)
downloadsystemd-1831759a705b85c3486a79fb98a20474bbe6bae4.tar.gz
logind: increase max wall message length to 4096
Diffstat (limited to 'src/login/logind-dbus.c')
-rw-r--r--src/login/logind-dbus.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index ef31ec654e..8fcdf6e936 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -54,6 +54,15 @@
#include "utmp-wtmp.h"
#include "virt.h"
+/* As a random fun fact sysvinit had a 252 (256-(strlen(" \r\n")+1))
+ * character limit for the wall message.
+ * https://git.savannah.nongnu.org/cgit/sysvinit.git/tree/src/shutdown.c#n72
+ * There is no real technical need for that but doesn't make sense
+ * to store arbitrary amounts either. As we are not stingy here, we
+ * allow 4k.
+ */
+#define WALL_MESSAGE_MAX 4096
+
static void reset_scheduled_shutdown(Manager *m);
static int get_sender_session(
@@ -3116,14 +3125,10 @@ static int method_set_wall_message(
if (r < 0)
return r;
- /* sysvinit has a 252 (256-(strlen(" \r\n")+1)) character
- * limit for the wall message. There is no real technical
- * need for that but doesn't make sense to store arbitrary
- * amounts either.
- * https://git.savannah.nongnu.org/cgit/sysvinit.git/tree/src/shutdown.c#n72)
- */
- if (strlen(wall_message) > 252)
- return -EMSGSIZE;
+ if (strlen(wall_message) > WALL_MESSAGE_MAX)
+ return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
+ "Wall message too long, maximum permitted length is %u characters.",
+ WALL_MESSAGE_MAX);
/* Short-circuit the operation if the desired state is already in place, to
* avoid an unnecessary polkit permission check. */