expect
I've attached a bug report I filed against expect. This causes annoying avc messages about fd use if you have expect running a process in a different security context where it can't write to the controlling terminal.
Signature · 4 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page
Subject: expect: leaves file handle 3 open when running programs
Package: expect
Version: 5.38.0-2
Severity: normal
When expect opens the new stdin/out/err handles from the pseudo tty it creates it will first dup2 the stderr file handle to file handle 3 so it can report errors directly to the controlling terminal.
However it does not set this file handle to close on exec (NB setting file handle 3 to close on exec after doing dup2(2, 3) has no affect on file handle 2). This means that the child process will have file handle 3 unexpectedly open. Among other things the child process could use this file handle to detect the presence of expect and to send back data to the terminal directly without expect controlling it.
Here is a patch to fix this.
exp_clib.c +1 -0
@@ -2500,6 +2500,7 @@/* save error fd while we're setting up new one */ errorfd =fcntl (2 ,F_DUPFD ,3 ); +fcntl (3 ,F_SETFD ,FD_CLOEXEC );/* and here is the macro to restore it */ #define restore_error_fd {close(2);fcntl(errorfd,F_DUPFD,2);}
exp_command.c +1 -0
@@ -1036,6 +1036,7 @@/* save error fd while we're setting up new one */ errorfd =fcntl (2 ,F_DUPFD ,3 ); +fcntl (3 ,F_SETFD ,FD_CLOEXEC );/* and here is the macro to restore it */ #define restore_error_fd {close(2);fcntl(errorfd,F_DUPFD,2);}
-- System Information
Debian Release: testing/unstable
Kernel Version: Linux lyta 2.4.19lsm #1 Wed Sep 25 15:49:15 CEST 2002 i686 Pentium III (Coppermine) GenuineIntel GNU/Linux
Versions of the packages expect depends on:
ii libc6 2.3.1-3 GNU C Library: Shared libraries and Timezone ii tcl8.3 8.3.3-8 The Tool Command Language (TCL) v8.3 - Run-T