User env not set on chrootshell
James Lemke
jim@wasabisystems.com
Mon Mar 20 19:01:00 GMT 2006
> 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
-------------- next part --------------
--- 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 / ?");
-------------- next part --------------
--
For unsubscribe information see http://sourceware.org/lists.html#faq
More information about the crossgcc
mailing list