[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: windows-NT/pwd.c - struct passwd - Home Directory

From: Derek Price
Subject: Re: windows-NT/pwd.c - struct passwd - Home Directory
Date: Tue, 31 May 2005 12:21:29 -0400
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

Hash: SHA1

Conrad T. Pino wrote:

>What I don't understand is why "." is a reasonable home directory according
>to the "getpwuid" implementation:
> static char *home_dir = "."; /* we feel (no|every)where at home */

I don't agree that it is.  I think it was a poor, arbitrary
implementation decision at some point in the past before Windows had the
concept of a home dir, which did not show up until NT, I believe.

>My thought was along the lines of:
> struct passwd *
> getpwuid (int uid)
> {
> pw.pw_name = getlogin ();
>- pw.pw_dir = home_dir;
>+ pw.pw_dir = get_homedir ();
> pw.pw_shell = login_shell;
> pw.pw_uid = 0;
> return &pw;
> }

If the getpwuid function in windows-NT/pwd.c worked, then the
get_homedir in src/filesubr.c might be moved into src/subr.c and shared
with the Windows implementation, or so I was thinking.

Regardless, I do think this basic idea is correct.  My reconsideration
is that perhaps all user-settable environment variable references,
should be in get_homedir, and getpwuid would need to return the "secure"
home directory, as it is defined to on UNIX, where it is often read from
the /etc/passwd file, for instance.  The closest thing might be the
value from the registry on Windows.  Windows must read this from
somewhere in order to set USERPROFILE, HOMEDRIVE, and HOMEPATH on boot. 
You need to read the Windows specifications and determine where these
values are coming from to implement this correctly.  Is there no
equivalent to this function on Windows, where the home dir value may
have come from a domain server or whatever?

The UNIX specification for getpwuid is here:

>Another thought can take use one step closer to using "src/filesubr.c"
>of "windows-NT/filesubr.c" by defining "wnt_homedir" in "woe32.c":

This would be fine if we decide the proper place for all env var lookups
is in get_homedir.

>A grep of "get_homedir" usage (below) leads me to believe that whichever way
>we choose, functions "getpwuid" and "get_homedir" should present a
>view of where the home directory is on a given platform.

Once again, to summarize, if getpwuid is to be implemented,
functionality should be divided as follows:

getpwuid: to POSIX spec as much as possible, secure source if possible,
output not user settable
get_homedir: to CVS requirements, uses env vars, possibly set by user

You should be able to get POSIX specs for the other functions in
windows-NT/pwd.c from opengroup.org as well.  Try changing the
"getpwuid" in the URL above to other function names as needed.



Version: GnuPG v1.4.0 (Cygwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org


reply via email to

[Prev in Thread] Current Thread [Next in Thread]