------- Comment #9 from burnus at gcc dot gnu dot org  2007-03-22 09:36 -------
Bob Proulx wrote at bugs-coreutils@
> Regardless of that I think it would be better if the program calling
> getlogin() avoided using it since using the utmp file for this
> accounting is often a source of troublesome errors.  The login user is
> rarely the right answer.  Usually the current effective id provided by
> getpwuid(geteuid()) would be better.  I expect that use of getlogin()
> in the original case that motivated this example is actually a bug by
> itself.

Thus: We should consider using getpwuid(geteuid()) which is also what g95 does,
maybe guarded by "#ifdef" (or maybe not, both are part of IEEE
1003.1-2001/POSIX):
       #include <pwd.h>
       struct passwd *getpwuid(uid_t uid);
and
       #include <unistd.h>
       uid_t geteuid(void);

(I somehow missed initially the clause "getlogin() function shall return a
pointer to a string containing the user name associated by the login activity
with the *controlling terminal* of the current process.")

One should probably also update the manual together with this change?!?


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|WONTFIX                     |
            Summary|getlog returns blanks when  |Use getpwuid(geteuid())
                   |not run from the command    |instead of getlogin() for
                   |prompt                      |GETLOG()


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31299

Reply via email to