[test suite] additional code coverage
This commit is contained in:
@@ -119,7 +119,7 @@ main(int argc, char **argv)
|
||||
|
||||
/* Initialize the firewall rules handler based on the fwknopd.conf
|
||||
* file, but (for iptables firewalls) don't flush any rules or create
|
||||
* any chains yet. This allows us to dump the current firewall rules
|
||||
* any chains yet. This allows us to dump the current firewall rules
|
||||
* via fw_rules_dump() in --fw-list mode before changing around any rules
|
||||
* of an existing fwknopd process.
|
||||
*/
|
||||
@@ -236,7 +236,7 @@ main(int argc, char **argv)
|
||||
kill(opts.tcp_server_pid, SIGTERM);
|
||||
|
||||
/* --DSS XXX: This seems to be necessary if the tcp server
|
||||
* was restarted by this program. We need to
|
||||
* was restarted by this program. We need to
|
||||
* investigate and fix this. For now, this works
|
||||
* (it is kludgy, but does no harm afaik).
|
||||
*/
|
||||
@@ -312,7 +312,7 @@ static void setup_pid(fko_srv_options_t *opts)
|
||||
pid_t old_pid;
|
||||
|
||||
/* If we are a new process (just being started), proceed with normal
|
||||
* start-up. Otherwise, we are here as a result of a signal sent to an
|
||||
* start-up. Otherwise, we are here as a result of a signal sent to an
|
||||
* existing process and we want to restart.
|
||||
*/
|
||||
if(get_running_pid(opts) != getpid())
|
||||
@@ -506,7 +506,7 @@ static int stop_fwknopd(fko_srv_options_t * const opts)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Ensure the specified directory exists. If not, create it or die.
|
||||
/* Ensure the specified directory exists. If not, create it or die.
|
||||
*/
|
||||
static int
|
||||
check_dir_path(const char * const filepath, const char * const fp_desc, const unsigned char use_basename)
|
||||
@@ -538,7 +538,7 @@ check_dir_path(const char * const filepath, const char * const fp_desc, const un
|
||||
strlcpy(tmp_path, filepath, sizeof(tmp_path));
|
||||
|
||||
/* At this point, we should make the path is more than just the
|
||||
* PATH_SEP. If it is not, silently return.
|
||||
* PATH_SEP. If it is not, silently return.
|
||||
*/
|
||||
if(strlen(tmp_path) < 2)
|
||||
return 1;
|
||||
@@ -551,7 +551,7 @@ check_dir_path(const char * const filepath, const char * const fp_desc, const un
|
||||
if(errno == ENOENT)
|
||||
{
|
||||
log_msg(LOG_WARNING,
|
||||
"%s directory: %s does not exist. Attempting to create it.",
|
||||
"%s directory: %s does not exist. Attempting to create it.",
|
||||
fp_desc, tmp_path
|
||||
);
|
||||
|
||||
@@ -619,7 +619,7 @@ make_dir_path(const char * const run_dir)
|
||||
|
||||
/* Stat this part of the path to see if it is a valid directory.
|
||||
* If it does not exist, attempt to create it. If it does, and
|
||||
* it is a directory, go on. Otherwise, any other error cause it
|
||||
* it is a directory, go on. Otherwise, any other error cause it
|
||||
* to bail.
|
||||
*/
|
||||
if(stat(tmp_path, &st) != 0)
|
||||
@@ -750,7 +750,7 @@ write_pid_file(fko_srv_options_t *opts)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Attempt to lock the PID file. If we get an EWOULDBLOCK
|
||||
/* Attempt to lock the PID file. If we get an EWOULDBLOCK
|
||||
* error, another instance already has the lock. So we grab
|
||||
* the pid from the existing lock file, complain and bail.
|
||||
*/
|
||||
|
||||
@@ -100,8 +100,6 @@ is_valid_dir(const char *path)
|
||||
int
|
||||
verify_file_perms_ownership(const char *file)
|
||||
{
|
||||
int res = 1;
|
||||
|
||||
#if HAVE_STAT
|
||||
struct stat st;
|
||||
|
||||
@@ -118,10 +116,7 @@ verify_file_perms_ownership(const char *file)
|
||||
"[-] file: %s is not a regular file or symbolic link.",
|
||||
file
|
||||
);
|
||||
/* when we start in enforcing this instead of just warning
|
||||
* the user
|
||||
res = 0;
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
if((st.st_mode & (S_IRWXU|S_IRWXG|S_IRWXO)) != (S_IRUSR|S_IWUSR))
|
||||
@@ -155,13 +150,13 @@ verify_file_perms_ownership(const char *file)
|
||||
{
|
||||
log_msg(LOG_ERR, "[-] stat() against file: %s returned: %s",
|
||||
file, strerror(errno));
|
||||
res = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return res;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -2146,6 +2146,22 @@
|
||||
],
|
||||
'positive_output_matches' => [qr/to\screate/],
|
||||
},
|
||||
{
|
||||
'category' => 'basic operations',
|
||||
'subcategory' => 'server',
|
||||
'detail' => 'run dir non-directory',
|
||||
'function' => \&server_conf_files,
|
||||
'fwknopd_cmdline' => "$server_rewrite_conf_files --fw-list",
|
||||
'exec_err' => $YES,
|
||||
'server_access_file' => [
|
||||
'SOURCE any',
|
||||
'KEY testtest'
|
||||
],
|
||||
'server_conf_file' => [
|
||||
'FWKNOP_RUN_DIR ' . cwd() . "/$cf{'def'}"
|
||||
],
|
||||
'positive_output_matches' => [qr/NOT a directory/],
|
||||
},
|
||||
|
||||
{
|
||||
'category' => 'basic operations',
|
||||
@@ -2169,6 +2185,16 @@
|
||||
'cmdline' => "$fwknopdCmd $default_server_conf_args -f -P proto invalid",
|
||||
'exec_err' => $YES,
|
||||
},
|
||||
{
|
||||
'category' => 'basic operations',
|
||||
'subcategory' => 'server',
|
||||
'detail' => 'invalid config path /dev/null',
|
||||
'function' => \&generic_exec,
|
||||
'cmdline' => "$fwknopdCmd -c /dev/null -a $cf{'def_access'} " .
|
||||
"-p $default_pid_file $intf_str --exit-parse-config ",
|
||||
'exec_err' => $YES,
|
||||
},
|
||||
|
||||
{
|
||||
'category' => 'basic operations',
|
||||
'subcategory' => 'server',
|
||||
|
||||
Reference in New Issue
Block a user