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:
authorMichael Boelen <michael.boelen@cisofy.com>2017-04-23 21:19:18 +0300
committerMichael Boelen <michael.boelen@cisofy.com>2017-04-23 21:19:18 +0300
commit2340e7bbbc6b3e955c7df0069686c016e40d0a6d (patch)
tree4f149960c2a01ce9422e0280592ec33c4ee7ee9a
parenta04b2da85113c23394be23726b94889d1e12f3f5 (diff)
Added HasData and IsEmpty function
-rw-r--r--include/functions35
1 files changed, 35 insertions, 0 deletions
diff --git a/include/functions b/include/functions
index ba8149de..c03022bc 100644
--- a/include/functions
+++ b/include/functions
@@ -50,12 +50,14 @@
# FileIsEmpty Check if a file is empty
# FileIsReadable Check if a file is readable or directory accessible
# GetHostID Retrieve an unique ID for this host
+# HasData Checks for data in variable
# InsertSection Insert a section block
# InsertPluginSection Insert a section block for plugins
# IsContainer Determine if program runs in a container
# IsDebug Check if --debug is used
# IsDeveloperMode Check if --developer is used
# IsDeveloperVersion Check if program is a developer release
+# IsEmpty Check for empty result or variable
# IsNotebook System detection
# IsOwnedByRoot Determine if file or directory is owned by root
# IsRunning Check if a process is running
@@ -1090,6 +1092,22 @@
fi
}
+ ################################################################################
+ # Name : HasData()
+ # Description : Check for a filled variable
+ #
+ # Returns : 0 = True, 1 = False
+ # Usage : if HasData "${FIND}"; then
+ ################################################################################
+
+ HasData() {
+ if [ $# -eq 1 ]; then
+ if [ ! -z "$1" ]; then return 0; else return 1; fi
+ else
+ ExitFatal "Function HasData called without parameters - look in log to determine where this happened, or use sh -x lynis to see all details."
+ fi
+ }
+
################################################################################
# Name : InsertSection()
@@ -1190,6 +1208,23 @@
################################################################################
+ # Name : IsEmpty()
+ # Description : Check for variable that has no data in it
+ #
+ # Returns : 0 = True, 1 = False
+ # Usage : if IsEmpty "${FIND}"; then
+ ################################################################################
+
+ IsEmpty() {
+ if [ $# -eq 1 ]; then
+ if [ -z "$1" ]; then return 0; else return 1; fi
+ else
+ ExitFatal "Function IsEmpty called without parameters - look in log to determine where this happened, or use sh -x lynis to see all details."
+ fi
+ }
+
+
+ ################################################################################
# Name : IsRunning()
# Description : Check if a process is running
# Returns : 0 (process is running), 1 (process not running)