From e2d35ca2674f6b48ea49bb03d2fdf99cbfa3cdde Mon Sep 17 00:00:00 2001 From: Shreya Date: Sat, 13 Jun 2020 19:37:01 +0530 Subject: [PATCH] Simpler bash commands for linux PBA --- .../utils/linux/shell_startup_files_modification.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/monkey/infection_monkey/utils/linux/shell_startup_files_modification.py b/monkey/infection_monkey/utils/linux/shell_startup_files_modification.py index f6f8c3ffd..8c54b9168 100644 --- a/monkey/infection_monkey/utils/linux/shell_startup_files_modification.py +++ b/monkey/infection_monkey/utils/linux/shell_startup_files_modification.py @@ -3,14 +3,11 @@ BASH_STARTUP_FILES = ["~/.bashrc", "~/.profile", "~/.bash_profile"] def get_linux_commands_to_modify_shell_startup_files(): return [ - 'if [ -f {0} ] ;', # does the file exist? - 'then', - 'echo \"# Succesfully modified {0}\" |', - 'tee -a', - '{0}', # add comment to file + 'echo \"# Succesfully modified {0}\"', + '3<{0} 3<&- |', # check for existence of file + 'tee -a', # append to file + '{0}', '&&', - 'sed -i \'$d\' {0} ;', # remove last line of file - 'else', - 'echo \"{0} does not exist\" ; fi' # mention if file does not exist + 'sed -i \'$d\' {0}', # remove last line of file ],\ BASH_STARTUP_FILES