-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zeek-archiver: Respect umask setting
Rather than hard-coding 0700 and 0644, use 0775 and 0664 and assume and rely on open() and mkdir() to pick up the environment's umask value. This may break someone relying on the strict permissions, but I'd argue it's not worth a configuration option. And pointing them at umask may be pragmatic enough. Closes #57.
- Loading branch information
Showing
2 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# @TEST-DOC: Check file permissions with different umask settings. | ||
# @TEST-EXEC: bash %INPUT | ||
|
||
. "$SCRIPTS/zeek-archiver-common.sh" | ||
|
||
umask 0002 | ||
|
||
log_in=test__2020-07-16-09-43-10__2020-07-16-09-43-10__.log | ||
log_out=test.09:43:10-09:43:10.log | ||
|
||
echo hello > "$(queue_dir)/${log_in}" | ||
zeek-archiver -1 -v "$(queue_dir)" "$(archive_dir)" | ||
|
||
dir_perms=$(ls -ld $(archive_date_dir) | cut -d ' ' -f 1) | ||
file_perms=$(ls -l $(archive_date_dir)/${log_out}.gz | cut -d ' ' -f 1) | ||
|
||
test "${dir_perms}" == "drwxrwxr-x" || exit 1 | ||
test "${file_perms}" == "-rw-rw-r--" || exit 1 | ||
|
||
# @TEST-START-NEXT | ||
|
||
. "$SCRIPTS/zeek-archiver-common.sh" | ||
|
||
umask 0077 | ||
|
||
log_in=test__2020-07-16-09-43-10__2020-07-16-09-43-10__.log | ||
log_out=test.09:43:10-09:43:10.log | ||
|
||
echo hello > "$(queue_dir)/${log_in}" | ||
zeek-archiver -1 -v "$(queue_dir)" "$(archive_dir)" | ||
|
||
dir_perms=$(ls -ld $(archive_date_dir) | cut -d ' ' -f 1) | ||
file_perms=$(ls -l $(archive_date_dir)/${log_out}.gz | cut -d ' ' -f 1) | ||
|
||
test "${dir_perms}" == "drwx------" || exit 1 | ||
test "${file_perms}" == "-rw-------" || exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters