Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CISOfy/lynis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatarina Durechova <durechova@ynet.sk>2017-10-31 11:05:29 +0300
committerMichael Boelen <michael.boelen@cisofy.com>2017-10-31 11:05:29 +0300
commit09de901d114afc157040e998ee3aacf82357d60d (patch)
tree17cda6ef0bb205d546548cb7b7ac3d3d205dda3b
parent8048b3d682bbb65489c5c6a8740007b61badc211 (diff)
Check zero size of files correctly (#487)
from man test: -s FILE FILE exists and has a size greater than zero -z STRING the length of STRING is zero
-rw-r--r--include/functions4
-rw-r--r--include/tests_time2
2 files changed, 3 insertions, 3 deletions
diff --git a/include/functions b/include/functions
index 87382c58..d81382d6 100644
--- a/include/functions
+++ b/include/functions
@@ -726,7 +726,7 @@
if [ $# -eq 0 ]; then ExitFatal "Missing parameter when calling FileIsEmpty function"; fi
EMPTY=0
LogText "Test: checking if file $1 is empty"
- if [ -z $1 ]; then
+ if [ ! -s "$1" ]; then
LogText "Result: file $1 is empty"
EMPTY=1
return 0
@@ -1489,7 +1489,7 @@
# Amazon EC2
if [ "${SHORT}" = "" ]; then
LogText "Test: checking specific files for Amazon"
- if [ -f /etc/ec2_version -a ! -z /etc/ec2_version ]; then
+ if [ -f /etc/ec2_version -a -s /etc/ec2_version ]; then
SHORT="amazon-ec2"
else
LogText "Result: system not hosted on Amazon"
diff --git a/include/tests_time b/include/tests_time
index 05781c81..4d9dbfe5 100644
--- a/include/tests_time
+++ b/include/tests_time
@@ -428,7 +428,7 @@
FOUND=0
FILE="/etc/ntp/step-tickers"
if [ -f ${FILE} ]; then
- if [ -z ${FILE} ]; then
+ if [ ! -s "${FILE}" ]; then
LogText "Result: ${FILE} is empty. The step-tickers contain no configured NTP servers"
Display --indent 2 --text "- Checking NTP step-tickers file" --result "EMPTY FILE" --color YELLOW
ReportSuggestion ${TEST_NO} "Use step-tickers file for quicker time synchronization"