Bug 49491

Summary: all environment is wiped out prior to executing user command
Product: [Retired] Red Hat Raw Hide Reporter: j. alan eldridge <alane>
Component: atAssignee: Jens Petersen <petersen>
Status: CLOSED CURRENTRELEASE QA Contact: Aaron Brown <abrown>
Severity: high Docs Contact:
Priority: high    
Version: 1.0   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-08-05 04:42:37 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
replacement for patch15 that works and is clearer
none
The RIGHT patch file (I grabbed the wrong one in the wee hours of the AM)
none
OK just shoot me. I had 3 versions lying around. Now I feel like and idiot. none

Description j. alan eldridge 2001-07-20 05:09:28 UTC
Description of Problem:

I marked this as "all" platforms because at's generic, and this is really 
badly broken.

How Reproducible:

submit a job that relies on any variable in the current environment. 
let's take a real obvious one: PATH.

E.g., I use "#!/usr/bin/env bash" on my scripts so they'll still work on 
Slowlaris, where bash is in /usr/local.

Now let's look at the file that at creates to run the job:

PATH=/home/alane/misc/scripts:/home/alane/bin:/home/alane/sbin:/usr/local/sbin:/usr/local/bin:/usr/local/jre1.2.2/bin:/usr/kerberos/bin:/bin:/usr/bin:/usr/X11R6/bin; 
export PATH=
# <horshack>
# OOH! OOH! THERE IT IS!
# </horshack>
cd /system/software/redhat/rh\-installed || {
         echo 'Execution directory inaccessible' >&2
         exit 1
}



AAAUUUUGGGHH!!! WTF!!!???? Patch13 introduces this bug. Remove the second 
hunk of Patch13. 

diff -u -r at-3.1.8/at.c.env at-3.1.8/at.c
--- at-3.1.8/at.c	Fri May 18 13:09:36 2001
+++ at-3.1.8-eqp/at.c	Fri May 18 12:47:08 2001
@@ -360,7 +360,7 @@
 	char *eqp;
 
 	eqp = strchr(*atenv, '=');
-	if (ap == NULL)
+	if (eqp == NULL)
 	    eqp = *atenv;
 	else {
 	    unsigned int i;
@@ -405,7 +405,7 @@
 		}
 	    }
 	    fputs("; export ", fp);
-	    fwrite(*atenv, sizeof(char), eqp - *atenv - 1, fp);
+	    fwrite(*atenv, sizeof(char), eqp - *atenv, fp);
 	    fputc('\n', fp);
 
 	}

How in hell did this get released?

Comment 1 j. alan eldridge 2001-07-20 05:15:36 UTC
Oops. It's Patch15. at-3.1.8-env.patch. The most recent one. The one that was 
applied to make this new release. 

wp's environment patch didn't work out quite right.

Comment 2 j. alan eldridge 2001-07-20 05:56:27 UTC
Ahh. Well. I guess I was a bit harsh there. Sorry.

Here's a different patch. It's a bit clearer. Uses a couple more vars, but 
hey, E Pluribus Optimizum.



Comment 3 j. alan eldridge 2001-07-20 05:58:44 UTC
Created attachment 24269 [details]
replacement for patch15 that works and is clearer

Comment 4 j. alan eldridge 2001-07-20 15:37:54 UTC
Created attachment 24309 [details]
The RIGHT patch file (I grabbed the wrong one in the wee hours of the AM)

Comment 5 j. alan eldridge 2001-07-20 15:46:55 UTC
Created attachment 24311 [details]
OK just shoot me. I had 3 versions lying around. Now I feel like and idiot.

Comment 6 Jens Petersen 2002-08-14 09:47:34 UTC
Seems this has been fixed for some time.  Works in Red Hat 7.3 at least and
limbo. Closing.