Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/run_part: Minor cleanups #1077

Merged
merged 6 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/run_part.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@
#include "shadowlog_internal.h"


int run_part (char *script_path, const char *name, const char *action)
static int run_part (char *script_path, const char *name, const char *action)
alejandro-colomar marked this conversation as resolved.
Show resolved Hide resolved
{
int pid;
pid_t pid;
int wait_status;
int pid_status;
pid_t pid_status;
alejandro-colomar marked this conversation as resolved.
Show resolved Hide resolved
char *args[] = { script_path, NULL };

pid=fork();
if (pid==-1) {
perror ("Could not fork");
fprintf (shadow_logfd, "Could not fork: %s\n", strerror(errno));
return 1;
}
if (pid==0) {
setenv ("ACTION",action,1);
setenv ("SUBJECT",name,1);
execv (script_path,args);
perror ("execv");
fprintf (shadow_logfd, "execv: %s\n", strerror(errno));
alejandro-colomar marked this conversation as resolved.
Show resolved Hide resolved
exit(1);
}

Expand All @@ -40,7 +40,7 @@ int run_part (char *script_path, const char *name, const char *action)
return (wait_status);
}

perror ("waitpid");
fprintf (shadow_logfd, "waitpid: %s\n", strerror(errno));
return (1);
}

Expand All @@ -61,7 +61,7 @@ int run_parts (const char *directory, const char *name, const char *action)
struct stat sb;

if (asprintf(&s, "%s/%s", directory, namelist[n]->d_name) == -1) {
fprintf(stderr, "could not allocate memory\n");
fprintf (shadow_logfd, "could not allocate memory\n");
alejandro-colomar marked this conversation as resolved.
Show resolved Hide resolved
for (; n<scanlist; n++) {
free(namelist[n]);
}
Expand All @@ -71,7 +71,7 @@ int run_parts (const char *directory, const char *name, const char *action)

execute_result = 0;
if (stat (s, &sb) == -1) {
perror ("stat");
fprintf (shadow_logfd, "stat: %s\n", strerror(errno));
free(s);
for (; n<scanlist; n++) {
free (namelist[n]);
Expand Down
1 change: 0 additions & 1 deletion lib/run_part.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef _RUN_PART_H
#define _RUN_PART_H

int run_part (char *script_path, const char *name, const char *action);
int run_parts (const char *directory, const char *name, const char *action);

#endif /* _RUN_PART_H */
2 changes: 1 addition & 1 deletion lib/shadowlog_internal.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef _SHADOWLOG_INTERNAL_H
#define _SHADOWLOG_INTERNAL_H

extern const char *shadow_progname; /* Program name showed in error messages */
extern const char *shadow_progname; /* Program name shown in error messages */
extern FILE *shadow_logfd; /* file descriptor to which error messages are printed */

#endif /* _SHADOWLOG_INTERNAL_H */
Loading