Skip to content

Commit

Permalink
Increase MAX command, and arg., length: 64 -> 256
Browse files Browse the repository at this point in the history
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 <troglobit@gmail.com>
  • Loading branch information
troglobit committed Sep 14, 2023
1 parent 480d291 commit 939ae02
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion plugins/modules-load.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/finit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 8 additions & 7 deletions src/svc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 939ae02

Please sign in to comment.