Always log execs

This commit is contained in:
Philip Prindeville 2023-08-24 12:10:58 -06:00 committed by Olof Hagsand
parent 55f3e396e9
commit 4a3fef4946
2 changed files with 31 additions and 12 deletions

View file

@ -190,13 +190,26 @@ clixon_proc_socket(char **argv,
sigfn_t oldhandler = NULL; sigfn_t oldhandler = NULL;
sigset_t oset; sigset_t oset;
int sig = 0; int sig = 0;
unsigned argc;
char *flattened;
if (argv == NULL){ if (argv == NULL){
clicon_err(OE_UNIX, EINVAL, "argv is NULL"); clicon_err(OE_UNIX, EINVAL, "argv is NULL");
goto done; goto done;
} }
if (argv[0] == NULL){
clicon_err(OE_UNIX, EINVAL, "argv[0] is NULL");
goto done;
}
clicon_debug(1, "%s %s", __FUNCTION__, argv[0]); for (argc = 0; argv[argc] != NULL; ++argc)
;
if ((flattened = clicon_strjoin(argc, argv, "', '")) == NULL){
clicon_err(OE_UNIX, ENOMEM, "clicon_strjoin");
goto done;
}
clicon_log(LOG_INFO, "%s '%s'", __FUNCTION__, flattened);
free(flattened);
if (socketpair(AF_UNIX, sock_flags, 0, sp) < 0){ if (socketpair(AF_UNIX, sock_flags, 0, sp) < 0){
clicon_err(OE_UNIX, errno, "socketpair"); clicon_err(OE_UNIX, errno, "socketpair");
@ -297,19 +310,28 @@ clixon_proc_background(char **argv,
sigset_t oset; sigset_t oset;
struct rlimit rlim = {0, }; struct rlimit rlim = {0, };
struct stat fstat; struct stat fstat;
char *flattened;
unsigned argc;
clicon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__); clicon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
if (argv == NULL){ if (argv == NULL){
clicon_err(OE_UNIX, EINVAL, "argv is NULL"); clicon_err(OE_UNIX, EINVAL, "argv is NULL");
goto quit; goto quit;
} }
if (clicon_debug_get()){ if (argv[0] == NULL){
i = 0; clicon_err(OE_UNIX, EINVAL, "argv[0] is NULL");
while (argv[i]){ goto quit;
clicon_debug(1, "%s argv[%d]:%s", __FUNCTION__, i, argv[i]);
i++;
} }
for (argc = 0; argv[argc] != NULL; ++argc)
;
if ((flattened = clicon_strjoin(argc, argv, "', '")) == NULL){
clicon_err(OE_UNIX, ENOMEM, "clicon_strjoin");
goto quit;
} }
clicon_log(LOG_INFO, "%s '%s'", __FUNCTION__, flattened);
free(flattened);
/* Sanity check: program exists */ /* Sanity check: program exists */
if (stat(argv[0], &fstat) < 0) { if (stat(argv[0], &fstat) < 0) {
clicon_err(OE_FATAL, errno, "%s", argv[0]); clicon_err(OE_FATAL, errno, "%s", argv[0]);

View file

@ -178,12 +178,9 @@ clixon_string_del_join(char *str1,
clicon_err(OE_UNIX, errno, "malloc"); clicon_err(OE_UNIX, errno, "malloc");
return NULL; return NULL;
} }
if (str1){ snprintf(str, len, "%s%s%s", (str1 ? str1 : ""), del, str2);
snprintf(str, len, "%s%s%s", str1, del, str2); if (str1)
free(str1); free(str1);
}
else
snprintf(str, len, "%s%s", del, str2);
return str; return str;
} }