Skip to content

Commit

Permalink
Always log execs
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Prindeville authored and olofhagsand committed Oct 21, 2023
1 parent 55f3e39 commit 4a3fef4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
36 changes: 29 additions & 7 deletions lib/src/clixon_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,26 @@ clixon_proc_socket(char **argv,
sigfn_t oldhandler = NULL;
sigset_t oset;
int sig = 0;
unsigned argc;
char *flattened;

if (argv == NULL){
clicon_err(OE_UNIX, EINVAL, "argv is NULL");
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){
clicon_err(OE_UNIX, errno, "socketpair");
Expand Down Expand Up @@ -297,19 +310,28 @@ clixon_proc_background(char **argv,
sigset_t oset;
struct rlimit rlim = {0, };
struct stat fstat;
char *flattened;
unsigned argc;

clicon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
if (argv == NULL){
clicon_err(OE_UNIX, EINVAL, "argv is NULL");
goto quit;
}
if (clicon_debug_get()){
i = 0;
while (argv[i]){
clicon_debug(1, "%s argv[%d]:%s", __FUNCTION__, i, argv[i]);
i++;
}
if (argv[0] == NULL){
clicon_err(OE_UNIX, EINVAL, "argv[0] is NULL");
goto quit;
}

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 */
if (stat(argv[0], &fstat) < 0) {
clicon_err(OE_FATAL, errno, "%s", argv[0]);
Expand Down
7 changes: 2 additions & 5 deletions lib/src/clixon_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,9 @@ clixon_string_del_join(char *str1,
clicon_err(OE_UNIX, errno, "malloc");
return NULL;
}
if (str1){
snprintf(str, len, "%s%s%s", str1, del, str2);
snprintf(str, len, "%s%s%s", (str1 ? str1 : ""), del, str2);
if (str1)
free(str1);
}
else
snprintf(str, len, "%s%s", del, str2);
return str;
}

Expand Down

0 comments on commit 4a3fef4

Please sign in to comment.