Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cert-tool logfile added. Modified common_logger function to write on files without root permission. #2911

Merged
merged 4 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions unattended_installer/cert_tool/certMain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ function main() {
esac
done

common_logger "Verbose logging redirected to ${logfile}"

if [[ -d "${base_path}"/wazuh-certificates ]]; then
if [ -n "$(ls -A "${base_path}"/wazuh-certificates)" ]; then
common_logger -e "Directory wazuh-certificates already exists in the same path as the script. Please, remove the certs directory to create new certificates."
Expand Down
8 changes: 4 additions & 4 deletions unattended_installer/cert_tool/certVariables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# License (version 2) as published by the FSF - Free Software
# Foundation.

base_path="$(dirname "$(readlink -f "$0")")"
readonly base_path
readonly base_path="$(dirname "$(readlink -f "$0")")"
readonly config_file="${base_path}/config.yml"
readonly logfile=""
readonly logfile="${base_path}/wazuh-certificates-tool.log"
cert_tmp_path="/tmp/wazuh-certificates"
debug=">> /dev/null 2>&1"
debug=">> ${logfile} 2>&1"
readonly cert_tool_script_name=".*certs.*\.sh"
2 changes: 1 addition & 1 deletion unattended_installer/common_functions/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function common_logger() {
fi

if [ -z "${debugLogger}" ] || { [ -n "${debugLogger}" ] && [ -n "${debugEnabled}" ]; }; then
if [ "$EUID" -eq 0 ] && [ -z "${nolog}" ]; then
if [ -z "${nolog}" ] && { [ "$EUID" -eq 0 ] || [[ "$(basename "$0")" =~ $cert_tool_script_name ]]; }; then
printf "%s\n" "${now} ${mtype} ${message}" | tee -a ${logfile}
else
printf "%b\n" "${now} ${mtype} ${message}"
Expand Down
Loading