Bug 61180 - [RFE] nash execve call redirect stdout
[RFE] nash execve call redirect stdout
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: mkinitrd (Show other bugs)
7.3
All Linux
low Severity medium
: ---
: ---
Assigned To: Matt Wilson
David Lawrence
: FutureFeature
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-03-14 16:59 EST by Matt Domsch
Modified: 2007-03-26 23:51 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-03-14 16:59:50 EST
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 Matt Domsch 2002-03-14 16:59:46 EST
Description of Problem:
(ultra low priority enhancement request)

nash can redirect stdout on 'echo' commands, but cannot do so for execve'd 
apps.  Occasionally it's nice to be able to do this, e.g. the kernel starts 
fine, begins running the initrd fine, but hangs while loading a module.  It can 
be handy to stick static apps in the initrd to run before those insmods (like 
say, 'mptable'.

Patch provided against 3.3.4-3 is untested (testing mode keeps getting in the 
way), but I believe it's correct, and would appreciate a review.


Version-Release number of selected component (if applicable):
3.3.4-3


diff -urNp --exclude-from=/home/mdomsch/excludes mkinitrd-3.3.4.orig/nash/nash.c
 mkinitrd-3.3.4/nash/nash.c
--- mkinitrd-3.3.4.orig/nash/nash.c     Wed Jan 16 14:15:39 2002
+++ mkinitrd-3.3.4/nash/nash.c  Thu Mar 14 15:47:35 2002
@@ -212,6 +212,7 @@ int otherCommand(char * bin, char * cmd,
     const static char * sysPath = PATH;
     const char * pathStart;
     const char * pathEnd;
+    FILE *outFile = NULL;

     nextArg = args;

@@ -255,6 +256,13 @@ int otherCommand(char * bin, char * cmd,
     } else {
        if (!doFork || !(pid = fork())) {
            /* child */
+           if ((nextArg - args >= 2) && !strcmp(*(nextArg - 2), ">")) {
+                   outFile = freopen(*(nextArg - 1), "a", stdout);
+                   if (outFile) {
+                           *(nextArg - 2) = NULL;
+                           *(nextArg - 1) = NULL;
+                   }
+           }
            execve(args[0], args, env);
            printf("ERROR: failed in exec of %s\n", args[0]);
            return 1;
Comment 1 Erik Troan 2002-05-20 22:15:45 EDT
anything for you matt ;-)

it's in 3.3.11 (via a slightly different patch)
Comment 2 Matt Domsch 2002-05-20 22:48:50 EDT
Thanks Erik!  I know my patch didn't quite work - hope it wasn't too much 
trouble to make it do the right thing.
Comment 3 Erik Troan 2002-05-20 22:58:50 EDT
nah, it was easy enough

fwiw, you can test nash out by giving it "--force" on the command line, which
overrides test mode. this was broken recently, but it's fixed in CVS (along
with the other change you wanted)

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