1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
From 70ece2e36b39c84096cec7de0c9bd7bce0bd426e Mon Sep 17 00:00:00 2001
From: Peter Haag <peter@people.ops-trust.net>
Date: Tue, 15 Apr 2025 14:47:07 +0200
Subject: [PATCH] Add Subdir -S to dynamic FlowSource -M. Replaces pull request
#615
---
src/libnffile/flist.c | 6 +++++-
src/libnffile/flist.h | 4 +++-
src/nfcapd/nfcapd.c | 1 +
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/libnffile/flist.c b/src/libnffile/flist.c
index ebb85b7b..b69b242c 100755
--- a/src/libnffile/flist.c
+++ b/src/libnffile/flist.c
@@ -192,7 +192,8 @@ static const char *subdir_def[] = {"", // default index 0 - no subdir hierarchy
#define AcceptedFormatChar "YymdjHMsUWwuF"
static mode_t mode, dir_mode;
-static const char *subdir_format;
+static const char *subdir_format = NULL;
+static int subdir_index = 0;
static struct entry_filter_s {
char *first_entry;
@@ -1030,6 +1031,7 @@ int InitHierPath(int num) {
}
subdir_format = subdir_def[i];
+ subdir_index = i;
/*
* The default file mode is a=rwx (0777) with selected permissions
@@ -1115,6 +1117,8 @@ char *GetSubDir(struct tm *now) {
} // End of GetSubDir
+int GetSubDirIndex(void) { return subdir_index; }
+
int SetupSubDir(char *dir, char *subdir, char *error, size_t errlen) {
char *p, path[MAXPATHLEN];
struct stat stat_buf;
diff --git a/src/libnffile/flist.h b/src/libnffile/flist.h
index bd550f2e..3ff9e39b 100755
--- a/src/libnffile/flist.h
+++ b/src/libnffile/flist.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009-2024, Peter Haag
+ * Copyright (c) 2009-2025, Peter Haag
* Copyright (c) 2004-2008, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
* All rights reserved.
*
@@ -48,6 +48,8 @@ int InitHierPath(int num);
char *GetSubDir(struct tm *now);
+int GetSubDirIndex(void);
+
int SetupSubDir(char *dir, char *subdir, char *error, size_t errlen);
queue_t *SetupInputFileSequence(flist_t *flist);
diff --git a/src/nfcapd/nfcapd.c b/src/nfcapd/nfcapd.c
index 6f64592a..fb8326db 100644
--- a/src/nfcapd/nfcapd.c
+++ b/src/nfcapd/nfcapd.c
@@ -412,6 +412,7 @@ static void run(packet_function_t receive_packet, int socket, int pfd, int rfd,
// fatal error
return;
}
+ fs->subdir = GetSubDirIndex();
fs->nffile = OpenNewFile(fs->current, NULL, CREATOR_NFCAPD, compress, NOT_ENCRYPTED);
if (!fs->nffile) {
LogError("Failed to open new collector file");
|