Skip to content

Commit

Permalink
ensure missing paths get assigned correct ownership if install.py is …
Browse files Browse the repository at this point in the history
…run by root
  • Loading branch information
mmguero committed Dec 1, 2022
1 parent 44fdcc3 commit 782e9ed
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion malcolm-iso/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ if [ -d "$WORKDIR" ]; then
mkdir -p "$MALCOLM_DEST_DIR/suricata/rules/"
mkdir -p "$MALCOLM_DEST_DIR/yara/rules/"
mkdir -p "$MALCOLM_DEST_DIR/zeek-logs/current/"
mkdir -p "$MALCOLM_DEST_DIR/zeek-logs/extract_files/"
mkdir -p "$MALCOLM_DEST_DIR/zeek-logs/extract_files/preserved"
mkdir -p "$MALCOLM_DEST_DIR/zeek-logs/extract_files/quarantine"
mkdir -p "$MALCOLM_DEST_DIR/zeek-logs/live/"
mkdir -p "$MALCOLM_DEST_DIR/zeek-logs/processed/"
mkdir -p "$MALCOLM_DEST_DIR/zeek-logs/upload/"
Expand Down
7 changes: 7 additions & 0 deletions scripts/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,13 @@ def tweak_malcolm_runtime(
os.path.join(zeekLogDirFull, os.path.join('extract_files', 'quarantine')),
):
pathlib.Path(pathToCreate).mkdir(parents=True, exist_ok=True)
if (
((self.platform == PLATFORM_LINUX) or (self.platform == PLATFORM_MAC))
and (self.scriptUser == "root")
and (getpwuid(os.stat(pathToCreate).st_uid).pw_name == self.scriptUser)
):
# change ownership of newly-created directory to match puid/pgid
os.chown(pathToCreate, int(puid), int(pgid))

indexSnapshotCompressed = InstallerYesOrNo('Compress OpenSearch index snapshots?', default=False)

Expand Down
3 changes: 2 additions & 1 deletion scripts/malcolm_appliance_packager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ if mkdir "$DESTDIR"; then
mkdir $VERBOSE -p "$DESTDIR/suricata/rules/"
mkdir $VERBOSE -p "$DESTDIR/yara/rules/"
mkdir $VERBOSE -p "$DESTDIR/zeek-logs/current/"
mkdir $VERBOSE -p "$DESTDIR/zeek-logs/extract_files/"
mkdir $VERBOSE -p "$DESTDIR/zeek-logs/extract_files/preserved"
mkdir $VERBOSE -p "$DESTDIR/zeek-logs/extract_files/quarantine"
mkdir $VERBOSE -p "$DESTDIR/zeek-logs/live/"
mkdir $VERBOSE -p "$DESTDIR/zeek-logs/processed/"
mkdir $VERBOSE -p "$DESTDIR/zeek-logs/upload/"
Expand Down

0 comments on commit 782e9ed

Please sign in to comment.