]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
convert-snort: Use set_ownership() from ids-functions.pl
authorStefan Schantl <stefan.schantl@ipfire.org>
Tue, 29 Jan 2019 08:05:29 +0000 (09:05 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Tue, 29 Jan 2019 08:05:29 +0000 (09:05 +0100)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
config/suricata/convert-snort

index dfd83a530c149a8c2d0073879bfdd09b5d7c4ec2..68d6d337949170dbf1ca666187b0d199cadd53d2 100644 (file)
@@ -51,14 +51,6 @@ if (-z "$snort_settings_file") {
 ##         needs to be full access-able by the WUI user and group (nobody:nobody).
 #
 
-# User and group of the WUI.
-my $uname = "nobody";
-my $grname = "nobody";
-
-# The chown function implemented in perl requies the user and group as nummeric id's.
-my $uid = getpwnam($uname);
-my $gid = getgrnam($grname);
-
 # Check if the settings directory exists.
 unless (-d $IDS::settingsdir) {
        # Create the directory.
@@ -71,26 +63,12 @@ unless (-d $IDS::rulespath) {
        mkdir($IDS::rulespath);
 }
 
-# Set correct ownership for the settings and rules folder.
-chown($uid, $gid, $IDS::settingsdir);
-chown($uid, $gid, $IDS::rulespath);
-
 # Create file layout, if not exists yet.
 &IDS::check_and_create_filelayout();
 
-# Set correct ownership for the files - Open settings directory and do a directory listing.
-opendir(DIR, $IDS::settingsdir) or die $!;
-        # Loop through the direcory.
-        while (my $file = readdir(DIR)) {
-
-                # We only want files.
-                next unless (-f "$IDS::settingsdir/$file");
-
-               # Set correct ownership for the files.
-               chown($uid, $gid, "$IDS::settingsdir/$file");
-       }
-
-closedir(DIR);
+# Set correct ownership for settingsdir and rulespath.
+&IDS::set_ownership("$IDS::settingsdir");
+&IDS::set_ownership("$IDS::rulespath");
 
 #
 ## Step 2: Import snort settings and convert to the required format for the new IDS