All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: expect
@ 2002-11-29 20:02 Stephen D. Smalley
  2002-12-01 12:08 ` expect Russell Coker
  0 siblings, 1 reply; 15+ messages in thread
From: Stephen D. Smalley @ 2002-11-29 20:02 UTC (permalink / raw)
  To: selinux, russell


> Due to what I believe to be bugs in expect, the new open_init_pty program will 
> not work correctly with old versions of expect.  Version 5.38.0 works fine, 
> version 5.32.2 is broken.  I don't know when the bug was fixed exactly.

I've backed out the open_init_pty changes to our internal copy of
run_init.   I'd rather not have the base run_init functionality dependent
on a particular version of expect, and I'm not even sure that it is
wise to depend on having expect installed at all.  

--
Stephen Smalley, NSA
sds@epoch.ncsc.mil


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 15+ messages in thread
* expect
@ 2002-11-29 15:43 Russell Coker
  0 siblings, 0 replies; 15+ messages in thread
From: Russell Coker @ 2002-11-29 15:43 UTC (permalink / raw)
  To: selinux

Due to what I believe to be bugs in expect, the new open_init_pty program will 
not work correctly with old versions of expect.  Version 5.38.0 works fine, 
version 5.32.2 is broken.  I don't know when the bug was fixed exactly.

-- 
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


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 15+ messages in thread
* expect
@ 2002-10-27 19:44 Russell Coker
  0 siblings, 0 replies; 15+ messages in thread
From: Russell Coker @ 2002-10-27 19:44 UTC (permalink / raw)
  To: selinux

[-- Attachment #1: Type: text/plain, Size: 474 bytes --]

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.

-- 
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

[-- Attachment #2: bug --]
[-- Type: text/x-diff, Size: 2026 bytes --]

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.

diff -ru expect-orig/exp_clib.c expect-5.38.0/exp_clib.c
--- expect-orig/exp_clib.c	2002-03-23 05:55:04.000000000 +0100
+++ expect-5.38.0/exp_clib.c	2002-10-27 20:23:15.000000000 +0100
@@ -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);}
 
diff -ru expect-orig/exp_command.c expect-5.38.0/exp_command.c
--- expect-orig/exp_command.c	2002-10-27 19:52:06.000000000 +0100
+++ expect-5.38.0/exp_command.c	2002-10-27 20:36:55.000000000 +0100
@@ -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

^ permalink raw reply	[flat|nested] 15+ messages in thread
* expect
@ 2002-10-26 20:52 Russell Coker
  2002-10-26 21:32 ` expect Chris Albert
  0 siblings, 1 reply; 15+ messages in thread
From: Russell Coker @ 2002-10-26 20:52 UTC (permalink / raw)
  To: selinux

I want to run an expect script as:
script program param1 param2 ...

Then have the script spawn "program param1 param2" (sort of like "$@" in a 
bash script).  How do I do this?  Expect wants to combine all the parameters 
into a single parameter that contains spaces. How can I solve this?

Also I want to do it for a varying number of parameters (so having an entry 
for each parameter isn't going to work).

The aim of this is to provide the open_init_pty functionality.  The version I 
posted to the list before will work for the basic SE functionality (IE 
Slackware type support).  But for Debian support (and for full RPM support 
when someone implements it) we need to have open_init_pty run dpkg to install 
packages (and we can install multiple packages at the same time).

-- 
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


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 15+ messages in thread
* Expect
@ 1999-03-12 12:15 Dean Takemori
  0 siblings, 0 replies; 15+ messages in thread
From: Dean Takemori @ 1999-03-12 12:15 UTC (permalink / raw)
  To: linuxppc-dev


I've been having problems with the expect package, which is part
of the tcltk distribution.  The problem is essentially the TIOCSCTTY
error as reported below from the Expect FAQ.  [Note, not all expect
scripts have this problem, just the ones that allocate ptys.
Unfortunately, this means most (all?) dejanew tests fail.]

I am working with a R4 system, upgraded to egcs-1.1.1-1c,
binutils-2.9.1-19b and glibc-0.961212-1o.

The rest of the tcltk package (tcl-8.0.3-20b, tk-8.0.3-20b,
tix-4.1.0.6-20b and tclx-8.0.3-20b) all compile and install
and test ok.  Expect 5.25, 5.26 and 5.28 all fail.

The FAQ entries quoted below suggest that maybe this is the old
glibc 1.99 != 2 problem in another form

Anyone have any ideas?

>From the Expect 5.28 FAQ:
>#52. Why does Expect fail on RedHat 5.0?
>
>Lots of people have reported the following error from Expect on
>RedHat 5.0:
>
>failed to get controlling terminal using TIOCSCTTY
>parent sync byte write: broken pipe
> 
>Martin Bly <ussc@star.rl.ac.uk> reports that:
> 
>The fault is/was in the GNU libc (aka glibc) provided by Red Hat
>Software.  Our sysadmin updated the version of the C libraries we have
>installed and both problems have vanished - in the case of the expect
>test, without a rebuild.
>======================================================================
> 
>#53. Why does Expect fail on RedHat 5.1?
> 
>People have reported the following error from Expect on RedHat
>5.1:
> 
>failed to get controlling terminal using TIOCSCTTY
>parent sync byte write: broken pipe
> 
>If there are any people
>who have some debugging experience and can reproduce that error on
>RedHat 5.1, read on:
> 
>First look in the man page (or perhaps diff the 5.1 and pre-5.1 man
>pages) governing TIOCSTTY and let me know what you find.
>Alternatively look at the source to xterm (or some other program that
>must allocate a pty) and see how it is allocating a pty.


[[ This message was sent via the linuxppc-dev mailing list.  Replies are ]]
[[ not  forced  back  to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. Please check http://lists.linuxppc.org/ ]]
[[ and http://www.linuxppc.org/ for useful information before posting.   ]]

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2002-12-03 11:47 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-29 20:02 expect Stephen D. Smalley
2002-12-01 12:08 ` expect Russell Coker
2002-12-02 14:09   ` expect Jesse Pollard
2002-12-02 14:58     ` expect Russell Coker
2002-12-02 17:34       ` expect Tom
2002-12-02 19:40         ` expect Russell Coker
2002-12-02 22:00           ` expect Tom
2002-12-03 11:46             ` expect Russell Coker
  -- strict thread matches above, loose matches on Subject: below --
2002-11-29 15:43 expect Russell Coker
2002-10-27 19:44 expect Russell Coker
2002-10-26 20:52 expect Russell Coker
2002-10-26 21:32 ` expect Chris Albert
2002-10-26 22:07   ` expect Russell Coker
     [not found]     ` <3DBB2043.2010709@sympatico.ca>
2002-10-26 23:26       ` expect Russell Coker
1999-03-12 12:15 Expect Dean Takemori

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.