1: #ifndef lint
   2: static char sccsid[] = "@(#)getpwinfo.c	5.3 (Berkeley) 6/19/85";
   3: #endif
   4: 
   5: #include "uucp.h"
   6: #include <pwd.h>
   7: 
   8: /*LINTLIBRARY*/
   9: 
  10: /*
  11:  *	get passwd file info for uid
  12:  *
  13:  *	return codes:  SUCCESS  |  FAIL
  14:  *
  15:  */
  16: 
  17: guinfo(uid, name, path)
  18: int uid;
  19: register char *path, *name;
  20: {
  21:     register struct passwd *pwd;
  22:     struct passwd *getpwuid(), *getpwnam();
  23:     char *getlogin(), *getenv(), *l;
  24: 
  25:     if ((l = getlogin()) == NULL) {
  26:         l = getenv("USER");
  27:     }
  28:     if (l != NULL) {
  29:         pwd = getpwnam(l);
  30:         if (pwd != NULL && pwd->pw_uid == uid)
  31:             goto setup;
  32:     }
  33:     if ((pwd = getpwuid(uid)) == NULL) {
  34:         /* can not find uid in passwd file */
  35:         *name = '\0';
  36:         *path = '\0';
  37:         return FAIL;
  38:     }
  39: 
  40:     setup:
  41:     strcpy(path, pwd->pw_dir);
  42:     strcpy(name, pwd->pw_name);
  43:     return SUCCESS;
  44: }
  45: 
  46: 
  47: /*
  48:  *	get passwd file info for name
  49:  *
  50:  *	return codes:  SUCCESS  |  FAIL
  51:  */
  52: 
  53: gninfo(name, uid, path)
  54: char *path, *name;
  55: int *uid;
  56: {
  57:     register struct passwd *pwd;
  58:     struct passwd *getpwnam();
  59: 
  60:     if ((pwd = getpwnam(name)) == NULL) {
  61:         /* can not find name in passwd file */
  62:         *path = '\0';
  63:         return FAIL;
  64:     }
  65: 
  66:     strcpy(path, pwd->pw_dir);
  67:     *uid = pwd->pw_uid;
  68:     return SUCCESS;
  69: }

Defined functions

gninfo defined in line 53; used 1 times

Defined variables

sccsid defined in line 2; never used
Last modified: 1986-01-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1087
Valid CSS Valid XHTML 1.0 Strict