X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fuserspec.c;h=bf51778d74e05d5cf75dc06a36c8682814340ac0;hb=a19e601b42a86b59b4af13aa9f960397f5306c38;hp=c6a49fae2745c113d3fc29205259889d092fb6b4;hpb=a70069a6c8c79d622312ad0f4b38d6d2efadc1d4;p=gnulib.git diff --git a/lib/userspec.c b/lib/userspec.c index c6a49fae2..bf51778d7 100644 --- a/lib/userspec.c +++ b/lib/userspec.c @@ -1,5 +1,5 @@ /* userspec.c -- Parse a user and group string. - Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. + Copyright (C) 1989, 1990, 1991, 1992, 1997 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,13 +12,13 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Written by David MacKenzie . */ - -#ifdef HAVE_CONFIG_H -#include + +#if HAVE_CONFIG_H +# include #endif #ifdef __GNUC__ @@ -28,7 +28,7 @@ # include # else # ifdef _AIX - #pragma alloca + # pragma alloca # else char *alloca (); # endif @@ -40,7 +40,7 @@ char *alloca (); #include #include -#ifdef HAVE_STRING_H +#if HAVE_STRING_H # include #else # include @@ -49,11 +49,11 @@ char *alloca (); # endif #endif -#ifdef STDC_HEADERS +#if STDC_HEADERS # include #endif -#ifdef HAVE_UNISTD_H +#if HAVE_UNISTD_H # include #endif @@ -153,6 +153,15 @@ parse_user_spec (spec_arg, uid, gid, username_arg, groupname_arg) if (u == NULL && g == NULL) return "can not omit both user and group"; +#ifdef __DJGPP__ + /* Pretend that we are the user U whose group is G. This makes + pwd and grp functions ``know'' about the UID and GID of these. */ + if (u && !is_number (u)) + setenv ("USER", u, 1); + if (g && !is_number (g)) + setenv ("GROUP", g, 1); +#endif + if (u != NULL) { pwd = getpwnam (u); @@ -247,7 +256,7 @@ parse_user_spec (spec_arg, uid, gid, username_arg, groupname_arg) #ifdef TEST -#define NULL_CHECK(s) ((s) == NULL ? "(null)" : (s)) +# define NULL_CHECK(s) ((s) == NULL ? "(null)" : (s)) int main (int argc, char **argv)