Bug 11706 - STDOUT applications fail to work with consolehelper
STDOUT applications fail to work with consolehelper
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: usermode (Show other bugs)
6.2
All Linux
medium Severity medium
: ---
: ---
Assigned To: Nalin Dahyabhai
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-05-27 10:47 EDT by redhat-bugs
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-05-27 11:17:39 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description redhat-bugs 2000-05-27 10:47:52 EDT
Hello.

I have found a problem with the consolehelper/userhelper interaction with
applications that use STDOUT.  If you don't have your DISPLAY env. var. set
all works fine -- you see the stdout of the application that is being
"helped" after entering the root password.  However, if you have DISPLAY
set, you get the GUI popup box to enter a password.  The application starts
fine but craps out shortly after starting.  The reason is that the mucking
that consolehelper does with stdin/stdout to get the password to userhelper
(on stdin) does not get cleaned up when the authentication is done.

I am going to take a look into fixing this but your thoughts would be
appreciated.

Thanx,
b.
Comment 1 redhat-bugs 2000-05-27 11:17:59 EDT
OK, I just did a very rude hack to test my theory and it is correct.  Find the
patch below.  I expect that you will come up with something a lot more graceful
to handle this situation.  :-)

diff -ur /tmp/usermode-1.22/userhelper-wrap.c ./userhelper-wrap.c
--- /tmp/usermode-1.22/userhelper-wrap.c	Wed Mar  8 13:11:24 2000
+++ ./userhelper-wrap.c	Sat May 27 08:15:35 2000
@@ -69,6 +69,17 @@
       close(childout[0]);
       close(childin[1]);

+      /* save stdin and stdout so userhelper can restore them for the app */
+      if(dup2(STDIN_FILENO, 20) != 20)
+	{
+	  fprintf(stderr, "dup2() error.\n");
+	  exit(2);
+	}
+      if(dup2(STDOUT_FILENO, 21) != 21)
+	{
+	  fprintf(stderr, "dup2() error.\n");
+	  exit(2);
+	}
       if(childout[1] != STDOUT_FILENO)
 	{
 	  if(dup2(childout[1], STDOUT_FILENO) != STDOUT_FILENO)
diff -ur /tmp/usermode-1.22/userhelper.c ./userhelper.c
--- /tmp/usermode-1.22/userhelper.c	Thu Mar  9 14:25:29 2000
+++ ./userhelper.c	Sat May 27 08:11:35 2000
@@ -631,6 +632,18 @@
 	    if (!(child = fork())) {
 		struct passwd *pw;

+		/* restore stdout */
+		if(dup2(21, STDOUT_FILENO) != STDOUT_FILENO) {
+		    fprintf(stderr, "dup2() error.\n");
+		    exit(ERR_UNK_ERROR);
+		}
+		close(21);
+		/* restore stdin */
+		if(dup2(20, STDIN_FILENO) != STDIN_FILENO) {
+		    fprintf(stderr, "dup2() error.\n");
+		    exit(ERR_UNK_ERROR);
+		}
+		close(20);
 		setuid(0);
 		pw = getpwuid(getuid());
 		if (pw) setenv("HOME", pw->pw_dir, 1);
Comment 2 Nalin Dahyabhai 2000-08-23 19:31:41 EDT
This should be fixed in our next release (as of usermode 1.33 and later).

Note You need to log in before you can comment on or make changes to this bug.