Look for support for fileno() in the system
This should help fwknop remain as portable as before. The fallback code still suffers from the TOCTOU condition though.
This commit is contained in:
parent
2def3bb0e8
commit
40664566e6
@ -899,7 +899,11 @@ show_last_command(const char * const args_save_file)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAVE_FILENO
|
||||||
if(verify_file_perms_ownership(args_save_file, fileno(args_file_ptr)) != 1)
|
if(verify_file_perms_ownership(args_save_file, fileno(args_file_ptr)) != 1)
|
||||||
|
#else
|
||||||
|
if(verify_file_perms_ownership(args_save_file, -1) != 1)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
fclose(args_file_ptr);
|
fclose(args_file_ptr);
|
||||||
return 0;
|
return 0;
|
||||||
@ -937,7 +941,11 @@ run_last_args(fko_cli_options_t *options, const char * const args_save_file)
|
|||||||
args_save_file);
|
args_save_file);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#if HAVE_FILENO
|
||||||
if(verify_file_perms_ownership(args_save_file, fileno(args_file_ptr)) != 1)
|
if(verify_file_perms_ownership(args_save_file, fileno(args_file_ptr)) != 1)
|
||||||
|
#else
|
||||||
|
if(verify_file_perms_ownership(args_save_file, -1) != 1)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
fclose(args_file_ptr);
|
fclose(args_file_ptr);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -1508,7 +1508,11 @@ parse_access_file(fko_srv_options_t *opts, char *access_filename, int *depth)
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAVE_FILENO
|
||||||
if(verify_file_perms_ownership(access_filename, fileno(file_ptr)) != 1)
|
if(verify_file_perms_ownership(access_filename, fileno(file_ptr)) != 1)
|
||||||
|
#else
|
||||||
|
if(verify_file_perms_ownership(access_filename, -1) != 1)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
fclose(file_ptr);
|
fclose(file_ptr);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|||||||
@ -303,7 +303,11 @@ parse_config_file(fko_srv_options_t *opts, const char *config_file)
|
|||||||
clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
|
clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAVE_FILENO
|
||||||
if(verify_file_perms_ownership(config_file, fileno(cfile_ptr)) != 1)
|
if(verify_file_perms_ownership(config_file, fileno(cfile_ptr)) != 1)
|
||||||
|
#else
|
||||||
|
if(verify_file_perms_ownership(config_file, -1) != 1)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
fclose(cfile_ptr);
|
fclose(cfile_ptr);
|
||||||
clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
|
clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
|
||||||
|
|||||||
@ -274,7 +274,11 @@ replay_file_cache_init(fko_srv_options_t *opts)
|
|||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAVE_FILENO
|
||||||
if(verify_file_perms_ownership(opts->config[CONF_DIGEST_FILE], fileno(digest_file_ptr)) != 1)
|
if(verify_file_perms_ownership(opts->config[CONF_DIGEST_FILE], fileno(digest_file_ptr)) != 1)
|
||||||
|
#else
|
||||||
|
if(verify_file_perms_ownership(opts->config[CONF_DIGEST_FILE], -1) != 1)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
fclose(digest_file_ptr);
|
fclose(digest_file_ptr);
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user