diff mbox

fixfiles: make sure $LOGFILE starts with a slash

Message ID 20160412205141.GA15479@saarenmaa.fi (mailing list archive)
State Not Applicable
Headers show

Commit Message

Oskari Saarenmaa April 12, 2016, 8:51 p.m. UTC
`tty` may output a (localized) "not a tty" message to stdout and exit with a
zero status in case ttyname(3) returns NULL but isatty(3) returns success. 
This happens at least when stdin is connected to a tty but we're inside a
chroot with no access to the tty file.

This results in an error:

    /usr/sbin/fixfiles: line 257: $LOGFILE: ambiguous redirect

Handle `tty` results that don't start with a slash the same way as no tty
errors: point $LOGFILE to /dev/null.

Signed-off-by: Oskari Saarenmaa <os@aiven.io>
---
 policycoreutils/scripts/fixfiles | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/policycoreutils/scripts/fixfiles b/policycoreutils/scripts/fixfiles
index 5c29eb9..1c64191 100755
--- a/policycoreutils/scripts/fixfiles
+++ b/policycoreutils/scripts/fixfiles
@@ -120,7 +120,7 @@  FORCEFLAG=""
 DIRS=""
 RPMILES=""
 LOGFILE=`tty`
-if [ $? != 0 ]; then
+if [ $? != 0 -o ${LOGFILE:0:1} != "/" ]; then
     LOGFILE="/dev/null"
 fi
 LOGGER=/usr/sbin/logger