]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #4672: packet_capture: use existing util function to check directory...
authorNirmala Venkata Subbaiah -X (nirmvenk - XORIANT CORPORATION at Cisco) <nirmvenk@cisco.com>
Mon, 24 Mar 2025 17:19:11 +0000 (17:19 +0000)
committerSteven Baigal (sbaigal) <sbaigal@cisco.com>
Mon, 24 Mar 2025 17:19:11 +0000 (17:19 +0000)
Merge in SNORT/snort3 from ~NIRMVENK/snort3:fix_error to master

Squashed commit of the following:

commit 47e879770de81b34013c58c66f73713bbb2dcb42
Author: Nirmala Subbaiah <nirmvenk@cisco.com>
Date:   Fri Mar 21 13:24:01 2025 -0400

    packet_capture: use existing util function to check directory path

src/network_inspectors/packet_capture/capture_module.cc
src/utils/util.cc
src/utils/util.h

index 5555ec67642aedbc31c2dfb37903c75c97a7c028..46eb102c115f9a0844beb2fb27cecd66d94e5d1e 100644 (file)
@@ -24,7 +24,6 @@
 
 #include "capture_module.h"
 
-#include <filesystem>
 #include <lua.hpp>
 
 #include "control/control.h"
@@ -254,7 +253,7 @@ PegCount* CaptureModule::get_counts() const
 
 bool is_path_valid(const std::string& path)
 {
-  if ( !std::filesystem::exists(path) )
+  if ( !is_directory_path(path) )
   {
     WarningMessage("Cannot create pcap at %s; directory does not exist\n", path.c_str());
     return false;
index 579efe040a65527e2c4a75851f796b8ba2a8c60b..8568b42b8cdfc21c5a3985be62f24434286f91ee 100644 (file)
@@ -85,6 +85,8 @@ bool get_file_size(const std::string& path, size_t& size)
     return true;
 }
 
+namespace snort
+{
 bool is_directory_path(const std::string& path)
 {
     struct STAT sb;
@@ -95,8 +97,6 @@ bool is_directory_path(const std::string& path)
     return ISDIR(sb.st_mode);
 }
 
-namespace snort
-{
 const char* get_error(int errnum)
 {
     static THREAD_LOCAL char buf[128];
index 99368753057fb327b4ca710b79cf11ece5a6a1b6..f3302b512554249260b919055cbbd2d1161c2038 100644 (file)
@@ -65,7 +65,6 @@
 
 unsigned int get_random_seed();
 bool get_file_size(const std::string&, size_t&);
-bool is_directory_path(const std::string&);
 
 namespace
 {
@@ -119,6 +118,7 @@ SO_PUBLIC std::string int_vector_to_str(const std::vector<uint32_t>& elems, char
 SO_PUBLIC bool rotate_file_for_max_size(const char* file_owner, const char* old_file,
     FILE* old_fh, uint32_t max_file_size);
 SO_PUBLIC bool check_file_size(FILE* fh, uint64_t max_file_size);
+SO_PUBLIC bool is_directory_path(const std::string&);
 }
 
 #endif