Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  2. #include <pwd.h>
  3. #include <unistd.h>
  4. #include <stdlib.h>
  5.  
  6. static char slash[] = "/";
  7. static char shell[] = "sh";
  8.  
  9. struct passwd *
  10. getpwuid(uid_t uid)
  11. {
  12.   static struct passwd rv;
  13.   rv.pw_uid = getuid();
  14.   if (uid != rv.pw_uid)
  15.     return 0;
  16.   rv.pw_name = getlogin();
  17.   rv.pw_gid = getgid();
  18.   rv.pw_dir = getenv("HOME");
  19.   if (rv.pw_dir == 0)
  20.     rv.pw_dir = slash;
  21.   rv.pw_shell = getenv("SHELL");
  22.   if (rv.pw_shell == 0)
  23.     rv.pw_shell = getenv("COMSPEC");
  24.   if (rv.pw_shell == 0)
  25.     rv.pw_shell = shell;
  26.   return &rv;
  27. }
  28.