From: Ludwig Nussel Date: Mon, 7 Feb 2022 10:50:12 +0000 (+0100) Subject: logind: increase max wall message length to 4096 X-Git-Tag: v251-rc1~298^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1831759a705b85c3486a79fb98a20474bbe6bae4;p=thirdparty%2Fsystemd.git logind: increase max wall message length to 4096 --- diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index ef31ec654ec..8fcdf6e936b 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. */