Bash

TEMPLATE bash_instantiate_variables

Pass strings that correspond to XCCDF value names as arguments to this macro: bash_instantiate_variables(“varname1”, “varname2”)

Then, assume that variables of that names are defined and contain the correct value, e.g. echo “Setting=$varname1” >> config_file

bash_instantiate_variables()

TEMPLATE bash_package_install

Install a package

Uses the right command based on pkg_manager property defined in product.yml.

param package

name of the package

type package

str

bash_package_install(package)

TEMPLATE bash_package_remove

Remove a package

Uses the right command based on pkg_manager property defined in product.yml.

param package

name of the package

type package

str

bash_package_remove(package)

TEMPLATE bash_dconf_settings

# Macro to configure DConf settings for RHEL and Fedora systems. bash_dconf_settings(path, key, value, db, setting_file)

TEMPLATE bash_dconf_lock

# Macro to configure DConf locks for RHEL and Fedora systems. bash_dconf_lock(key, setting, db, lock_file)

TEMPLATE bash_service_command

# Macro to enable or disable a particular service. # # Examples: # # bash_service_command(“enable”, “bluetooth”) # bash_service_command(“disable”, “bluetooth.service”) # bash_service_command(“disable”, “rsh.socket”, xinetd=”rsh”) bash_service_command(service_state, service, xinetd=””)

TEMPLATE bash_firefox_js_setting

# bash_firefox_js_setting expects three arguments: # # config_file: Configuration file that will be modified # key: Configuration option to change # value: Value of the configuration option to change # # Example Calls: # # With a fixed integer value: # bash_firefox_js_setting(“local-settings.js”, “general.config.obscure_value”, “0”) # # With a fixed string value: # bash_firefox_js_setting(“local-settings.js”, “general.config.filename”, quoted_value=”mozilla.cfg”) # # With a string variable: # bash_firefox_js_setting(“local-settings.js”, “general.config.filename”, quoted_value=”$var_config_file_name”) bash_firefox_js_setting(config_file, key, value=””, quoted_value=””, sed_separator=”/”)

TEMPLATE bash_firefox_cfg_setting

# Function to replace configuration setting(s) in the Firefox preferences configuration (.cfg) file or add the # preference if it does not exist. # # Expects three arguments: # # config_file: Configuration file that will be modified # key: Configuration option to change # value: Value of the configuration option to change # # # Example Call(s): # # Without string or variable: # bash_firefox_cfg_setting(“mozilla.cfg” “extensions.update.enabled” value=”false”) # # With string: # bash_firefox_cfg_setting(“mozilla.cfg” “security.default_personal_cert” quoted_value=”Ask Every Time”) # # With a string variable: # bash_firefox_cfg_setting(“mozilla.cfg” “browser.startup.homepage” quoted_value=”${var_default_home_page}”) bash_firefox_cfg_setting(config_file, key, value=””, quoted_value=””, sed_separator=”/”)

TEMPLATE bash_ensure_there_are_servers_in_ntp_compatible_config_file

# Macro to ensure that the ntp/chrony config file contains valid server entries. # config_file: Path to the ntp/chrony config file # servers_list: Comma-separated list of servers bash_ensure_there_are_servers_in_ntp_compatible_config_file(config_file, servers_list)

TEMPLATE bash_set_faillock_option

# Sets PAM faillock module options and values. # Also it adds pam_faillock.so as required module for account. # option: faillock option eg. deny, unlock_time # value: value of option bash_set_faillock_option(option, value)

TEMPLATE die

# Print a message to stderr and exit the shell # message: The message to print. # rc: The error code (optional, default is 1) # action: What to do (optional, default is ‘exit’, can be also ‘return’ or anything else) die(message, rc=1, action=”exit”)

TEMPLATE set_config_file

# Add an entry to a text configuration file # path: path of the configuration file # parameter: the paramenter to be set in the configuration file # value: the value of the parameter to be set in the configuration file # create: whether create the file specified by path if the file does not exits # insert_after: inserts the entry right after first line that matches regular expression specified by this argument, set to EOF to insert at the end of the file # insert_before: inserts the entry right before first line that matches regular expression specified by this argument, set to BOF to insert at the beginning of the file # insensitive: ignore case # separator: separates parameter from the value (literal) # separator_regex: regular expression that describes the separator and surrounding whitespace # prefix_regex: regular expression describing allowed leading characters at each line set_config_file(path, parameter, value, create, insert_after, insert_before, insensitive=true, separator=” “, separator_regex=”s+”, prefix_regex=”^s*”)

TEMPLATE bash_file_contents

Generates bash script code that puts ‘contents’ into a file at ‘filepath’ Parameters:

  • filepath - filepath of the file to check

  • contents - contents that should be in the file

bash_file_contents(filepath=’’, contents=’’)

TEMPLATE bash_deregexify_banner_anchors

Strips anchors regex around the banner text

bash_deregexify_banner_anchors(banner_var_name)

TEMPLATE bash_deregexify_multiple_banners

Strips multibanner regex and keeps only the first banner

bash_deregexify_multiple_banners(banner_var_name)

TEMPLATE bash_deregexify_banner_space

Strips whitespace or newline regex

bash_deregexify_banner_space(banner_var_name)

TEMPLATE bash_deregexify_banner_newline

Strips newline or newline escape sequence regex

bash_deregexify_banner_newline(banner_var_name, newline)

TEMPLATE bash_deregexify_banner_newline_token

Strips newline token for a newline escape sequence regex

bash_deregexify_banner_newline_token(banner_var_name)

TEMPLATE bash_deregexify_banner_backslash

Strips backslash regex

bash_deregexify_banner_backslash(banner_var_name)