From 77c3156e61ec8573c8f79dafce3683fea116512d Mon Sep 17 00:00:00 2001 From: Roger Luethi Date: Sun, 10 Aug 2014 18:24:23 +0200 Subject: [PATCH] labs: fix snapshot taking for ssh installs autostart_from_config reads the config/scripts.* files from stdin. That works as long as nothing messes with the standard file descriptors. When we use ssh to execute scripts within the autostart_from_config reading loop, stdin is no longer safe. The result is that config files are only read until the first boot command is encountered and executed, which for the current configuration files means that the final snapshot command is skipped. To fix this bug, the patch opens the config file on file descriptor 3 where it is safe from ssh. Change-Id: I2880a8b301c6032b1e077bd458b2b25a89552b89 --- labs/lib/osbash/functions.host | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/labs/lib/osbash/functions.host b/labs/lib/osbash/functions.host index 5a90880c..fc896083 100644 --- a/labs/lib/osbash/functions.host +++ b/labs/lib/osbash/functions.host @@ -263,7 +263,11 @@ function autostart_from_config { fi log_autostart_source "$config_file" - while read -r field_1 field_2; do + + # Open file on file descriptor 3 so programs we call in this loop (ssh) + # are free to mess with the standard file descriptors. + exec 3< "$config_path" + while read -r field_1 field_2 <&3; do if [[ $field_1 =~ ^# ]]; then # Skip lines that are commented out continue @@ -282,7 +286,7 @@ function autostart_from_config { echo >&2 _autostart_queue "$field_1/$field_2" _autostart_queue "$field_1/$field_2" fi - done < "$config_path" + done } #-------------------------------------------------------------------------------