prep for point release

This commit is contained in:
phanes
2023-02-17 03:21:24 -05:00
parent 004addd2b4
commit d0fbd30f31
21 changed files with 48 additions and 51 deletions

View File

@@ -36,15 +36,15 @@ std::string prefix_generator(
// it's not a shell command, so we can just execute it directly
prefix = command;
}
std::cout << "prefix: " << prefix << std::endl;
std::cout << "LAUNCHER: " << prefix << std::endl;
return prefix;
}
int lcpex(
std::string command,
std::string stdout_log_file,
std::string stderr_log_file,
FILE * stdout_log_fh,
FILE * stderr_log_fh,
bool context_override,
std::string context_user,
std::string context_group,
@@ -72,11 +72,11 @@ int lcpex(
// if we are forcing a pty, then we will use the vpty library
if( force_pty )
{
return exec_pty( command, stdout_log_file, stderr_log_file, context_override, context_user, context_group, supply_environment );
return exec_pty( command, stdout_log_fh, stderr_log_fh, context_override, context_user, context_group, supply_environment );
}
// otherwise, we will use the execute function
return execute( command, stdout_log_file, stderr_log_file, context_override, context_user, context_group, supply_environment );
return execute( command, stdout_log_fh, stderr_log_fh, context_override, context_user, context_group, supply_environment );
}
/**
@@ -161,8 +161,8 @@ void run_child_process(bool context_override, const char* context_user, const ch
int execute(
std::string command,
std::string stdout_log_file,
std::string stderr_log_file,
FILE * stdout_log_fh,
FILE * stderr_log_fh,
bool context_override,
std::string context_user,
std::string context_group,
@@ -183,10 +183,6 @@ int execute(
clearenv();
}
// open file handles to the two log files we need to create for each execution
FILE * stdout_log_fh = fopen( stdout_log_file.c_str(), "a+" );
FILE * stderr_log_fh = fopen( stderr_log_file.c_str(), "a+" );
// create the pipes for the child process to write and read from using its stdin/stdout/stderr
int fd_child_stdout_pipe[2];
int fd_child_stderr_pipe[2];
@@ -325,9 +321,7 @@ int execute(
// wait for child to exit, capture status
waitpid(pid, &status, 0);
// close the log file handles
fclose(stdout_log_fh);
fclose(stderr_log_fh);
if WIFEXITED(status) {
return WEXITSTATUS(status);
} else {

View File

@@ -39,8 +39,8 @@
*/
int execute(
std::string command,
std::string stdout_log_file,
std::string stderr_log_file,
FILE * stdout_log_fh,
FILE * stderr_log_fh,
bool context_override,
std::string context_user,
std::string context_group,
@@ -76,8 +76,8 @@ int execute(
*/
int lcpex(
std::string command,
std::string stdout_log_file,
std::string stderr_log_file,
FILE * stdout_log_fh,
FILE * stderr_log_fh,
bool context_override,
std::string context_user,
std::string context_group,

View File

@@ -1,5 +1,7 @@
#include "string_expansion.h"
// convert a string to a char** representing our artificial argv to be consumed by execvp
char ** expand_env(const std::string& var, int flags )
{

View File

@@ -83,7 +83,7 @@ void run_child_process( int fd_child_stderr_pipe[2], char * processed_command[],
// execute the dang command, print to stdout, stderr (of parent), and dump to file for each!!!!
// (and capture exit code in parent)
int exit_code = execvp(processed_command[0], processed_command);
int exit_code = execvp( processed_command[0], processed_command );
safe_perror("failed on execvp in child", ttyOrig );
exit(exit_code);
}
@@ -94,8 +94,8 @@ void run_child_process( int fd_child_stderr_pipe[2], char * processed_command[],
// - TEE child stdout/stderr to parent stdout/stderr
int exec_pty(
std::string command,
std::string stdout_log_file,
std::string stderr_log_file,
FILE * stdout_log_fh,
FILE * stderr_log_fh,
bool context_override,
std::string context_user,
std::string context_group,
@@ -112,16 +112,13 @@ int exec_pty(
}
// turn our command string into something execvp can consume
char ** processed_command = expand_env(command );
// open file handles to the two log files we need to create for each execution
FILE * stdout_log_fh = fopen( stdout_log_file.c_str(), "a+" );
FILE * stderr_log_fh = fopen( stderr_log_file.c_str(), "a+" );
char ** processed_command = expand_env( command );
if ( stdout_log_fh == NULL ) {
safe_perror( "Error opening STDOUT log file. Aborting.", &ttyOrig );
exit( 1 );
}
if ( stderr_log_fh == NULL ) {
safe_perror( "Error opening STDERR log file. Aborting.", &ttyOrig );
exit( 1 );
@@ -277,9 +274,6 @@ int exec_pty(
// wait for child to exit, capture status
waitpid(pid, &status, 0);
// close the log file handles
fclose(stdout_log_fh);
fclose(stderr_log_fh);
ttyResetExit( &ttyOrig);
if WIFEXITED(status) {
return WEXITSTATUS(status);

View File

@@ -38,8 +38,8 @@
*/
int exec_pty(
std::string command,
std::string stdout_log_file,
std::string stderr_log_file,
FILE * stdout_log_fh,
FILE * stderr_log_fh,
bool context_override,
std::string context_user,
std::string context_group,