From 939ae02a6aae571450f537e3311f60c6106f40a6 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 14 Sep 2023 09:15:55 +0200 Subject: [PATCH] Increase MAX command, and arg., length: 64 -> 256 With non-standard paths, e.g., when running `make distcheck`, the absolute path to some commands become ridiculously long. However, this has been a recurring issue for some users in the past, so it is time to increase the capabilibieies of Finit to cover this. Yes, a better way is probably to allocate all these strings when they are used, but that would require a redesign of the initctl API and likely cause a lot of regressions before everything has stabilized. Signed-off-by: Joachim Wiberg --- plugins/modules-load.c | 2 +- src/finit.h | 2 +- src/svc.h | 15 ++++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/plugins/modules-load.c b/plugins/modules-load.c index 2a4a461c..83465b02 100644 --- a/plugins/modules-load.c +++ b/plugins/modules-load.c @@ -101,7 +101,7 @@ static int modules_load(const char *file, int index) } while ((line = fparseln(fp, NULL, NULL, NULL, 0))) { - char cmd[CMD_SIZE * 2], *mod, *args, *set; + char cmd[CMD_SIZE], *mod, *args, *set; /* * fparseln() skips regular UNIX comments only. diff --git a/src/finit.h b/src/finit.h index b03c01a6..02f29be1 100644 --- a/src/finit.h +++ b/src/finit.h @@ -60,7 +60,7 @@ #define _PATH_SULOGIN FINIT_EXECPATH_ "/sulogin" #define _PATH_GETTY FINIT_EXECPATH_ "/getty" -#define CMD_SIZE 256 +#define CMD_SIZE 1024 #define LINE_SIZE 1024 #define BUF_SIZE 4096 diff --git a/src/svc.h b/src/svc.h index c5cddca5..40611cfb 100644 --- a/src/svc.h +++ b/src/svc.h @@ -85,6 +85,7 @@ typedef enum { #define MAX_ID_LEN 16 #define MAX_ARG_LEN 64 +#define MAX_CMD_LEN 256 #define MAX_IDENT_LEN (MAX_ARG_LEN + MAX_ID_LEN + 1) #define MAX_STR_LEN 64 #define MAX_COND_LEN (MAX_ARG_LEN * 3) @@ -118,7 +119,7 @@ typedef struct svc { int sighalt; /* Signal to stop process, default: SIGTERM */ int killdelay; /* Delay in msec before sending SIGKILL */ pid_t oldpid, pid; - char pidfile[256]; + char pidfile[MAX_CMD_LEN]; long start_time; /* Start time, as seconds since boot, from sysinfo() */ int started; /* Set for run/task/sysv to track if started */ int status; /* From waitpid() when process is collected */ @@ -181,15 +182,15 @@ typedef struct svc { char group[MAX_USER_LEN]; /* Command, arguments and service description */ - char cmd[MAX_ARG_LEN]; - char args[MAX_NUM_SVC_ARGS][MAX_ARG_LEN]; + char cmd[MAX_CMD_LEN]; + char args[MAX_NUM_SVC_ARGS][MAX_CMD_LEN]; int args_dirty; char conflict[MAX_ARG_LEN]; char desc[MAX_STR_LEN]; - char env[MAX_ARG_LEN]; - char pre_script[MAX_ARG_LEN]; - char post_script[MAX_ARG_LEN]; - char ready_script[MAX_ARG_LEN]; + char env[MAX_CMD_LEN]; + char pre_script[MAX_CMD_LEN]; + char post_script[MAX_CMD_LEN]; + char ready_script[MAX_CMD_LEN]; /* * Used to forcefully kill services that won't shutdown on