This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: User env not set on chrootshell


> EJS wrote:
> > http://www.scit.wlv.ac.uk/cgi-bin/mansec?1+login
> > says that USER isn't in the initial environment.
> > Maybe chrootshell should set it using
> > getpwuid(getuid())
> >
> > getpwuid(getuid()) did the trick! Thanks Dan.
>
> Can you submit a patch?
> - Dan

I ran into this problem recently also.  Here is a modification to EJS's
patch which works for me.

Jim.

-- 
Jim Lemke   jim@wasabisystems.com   Orillia, Ontario
--- chrootshell.c-orig	2006-03-10 19:07:22.000000000 -0500
+++ chrootshell.c	2006-03-20 13:27:31.000000000 -0500
@@ -126,16 +126,11 @@ int main(int argc, char **argv)
 #ifdef DEBUG_PRINTS
 	fp = fopen("/var/log/chrootshell.log", "a");
 #endif
-	user = getenv("USER");
-	if (!user)
-		die("USER not set?!");
-	logname = getenv("LOGNAME");
-	if (logname && *logname && strcmp(user, logname))
-		die("USER does not match LOGNAME\n");
 	/* Look up user in outer /etc/passwd */
-	pw = getpwnam(user);
+	pw = getpwuid(getuid());
 	if (!pw)
-		die2("no such user %s\n", user);
+		die("could not get /etc/passwd info for user\n");
+	user = logname = pw->pw_name;
 	shell = strrchr(pw->pw_shell, '/');
 	if (!shell)
 		die("shell contains no / ?");

--
For unsubscribe information see http://sourceware.org/lists.html#faq

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]