Skip to content

Commit

Permalink
fix: issue #24
Browse files Browse the repository at this point in the history
Fixed issue related to /dev/tty device when running UAC via CrowdStrike RTR (Real Time Response) console ([#24](#24)).

Signed-off-by: Thiago Canozzo Lahr <[email protected]>
  • Loading branch information
tclahr committed Sep 4, 2021
1 parent 586b445 commit 29ee536
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 32 deletions.
4 changes: 2 additions & 2 deletions lib/ask_question_yn.lib
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
################################################################################
ask_question_yn() {
while true; do
uprintf "$1 [y/n] "
printf %b "$1 [y/n] " >/dev/tty
read ANSWER
case $ANSWER in
"Y"|"y") return 0 ;;
"N"|"n") return 1 ;;
* ) uprintf "Please answer y or n\n" ;;
* ) printf %b "Please answer y or n\n" >/dev/tty ;;
esac
done
return 1
Expand Down
2 changes: 1 addition & 1 deletion lib/logging.lib
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ logging() {
printf %b "$LOG_TIMESTAMP $1 $2" >> "$UAC_LOG_FILE" 2>> "$UAC_LOG_FILE"
fi
if [ "$1" = "E" ] || [ "$1" = "W" ] || [ "$1" = "I" ]; then
uprintf "$2"
printf %b "$2"
fi
}
2 changes: 1 addition & 1 deletion lib/run_command.lib
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ run_command() {
LOCAL_OUTPUT_DESTINATION="$2"

logging D "run_command: $1\n"
$VERBOSE && uprintf " $ $1\n"
$VERBOSE && printf %b " $ $1\n"
if [ ! "$LOCAL_OUTPUT_DESTINATION" ]; then
eval "($LOCAL_COMMAND)" 2>> "$UAC_LOG_FILE"
else
Expand Down
11 changes: 6 additions & 5 deletions lib/terminate.lib
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2019,2020 IBM Corporation
# Copyright (C) 2020 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the “License”);
# you may not use this file except in compliance with the License.
Expand All @@ -14,19 +14,20 @@

################################################################################
# NAME
# terminate - run when the script is terminated by either SIGINT or SIGTERM
# terminate - run when the script is terminated by SIGINT
# SYNOPSIS
# terminate
################################################################################
terminate() {
logging I "\nCaught signal! Quitting...\n"
logging D "\nCaught signal! Quitting...\n"
printf %b "\nCaught signal! Quitting...\n" >/dev/tty
if [ -d "$DESTINATION_DIR" ] && [ -d "$DESTINATION_DIR/$TMP_DATA_DIR" ]; then
if ask_question_yn "Do you want to remove the temporary directory $DESTINATION_DIR/$TMP_DATA_DIR ?"; then
rm -rf "$DESTINATION_DIR/$TMP_DATA_DIR" > /dev/null
if [ ! -d "$DESTINATION_DIR/$TMP_DATA_DIR" ]; then
uprintf "Temporary directory removed successfully.\n"
printf %b "Temporary directory removed successfully.\n" >/dev/tty
else
uprintf "Cannot remove temporary directory.\n"
printf %b "Cannot remove temporary directory.\n" >/dev/tty
fi
fi
fi
Expand Down
23 changes: 0 additions & 23 deletions lib/uprintf.lib

This file was deleted.

0 comments on commit 29ee536

Please sign in to comment.