home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / auucp+-1.02 / fuucp_plus_src.lzh / getty / passwd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-21  |  1.8 KB  |  84 lines

  1.  
  2. /*
  3.  *  PASSWD.C
  4.  *
  5.  *  $Header: Beta:src/uucp/src/getty/RCS/passwd.c,v 1.1 90/02/02 12:13:35 dillon Exp Locker: dillon $
  6.  *
  7.  *  (C) Copyright 1989-1990 by Matthew Dillon,  All Rights Reserved.
  8.  *
  9.  */
  10.  
  11. #include <exec/types.h>
  12. #include <libraries/dosextens.h>
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <pwd.h>
  16. #include "protos.h"
  17.  
  18. #include "log.h"
  19.  
  20. #define BTOCP(bp,type)  ((type)((long)bp << 2))
  21.  
  22. extern long NullFH;
  23. extern char LoginBuf[];
  24. extern char PasswdBuf[];
  25. extern char *DeviceName;
  26. extern long DeviceUnit;
  27.  
  28. static struct passwd *Pas;
  29.  
  30. CheckLoginAndPassword()
  31. {
  32.     Pas = getpwnam(LoginBuf);
  33.  
  34.     if (Pas == NULL)
  35.     return(0);
  36.     if (strcmp(Pas->pw_passwd, "*") == 0)
  37.     return(1);
  38.     if (strcmp(PasswdBuf, Pas->pw_passwd) == 0)
  39.     return(1);
  40.     return(0);
  41. }
  42.  
  43. void
  44. RunPasswdEntry()
  45. {
  46.     static char buf[256];
  47.     static char redir[128];
  48.     char *arg0 = Pas->pw_shell_arg0;
  49.     struct Process *proc = (struct Process *)FindTask(NULL);
  50.     APTR oldConsoleTask = proc->pr_ConsoleTask;
  51.     BPTR oldDir;
  52.     BPTR DirLock;
  53.  
  54.     strcpy(redir, " ");
  55.  
  56.     if (*arg0 == '*') {
  57.     ++arg0;
  58.     sprintf(redir, " >UUSER:%s/%d/R300000G1 <UUSER:%s/%d/R300000G1 ", DeviceName, DeviceUnit, DeviceName, DeviceUnit);
  59.     } else {
  60.     if (LogToStdout == 0)
  61.         strcpy(redir, " >null: <null: ");
  62.     }
  63.     if (LogToStdout == 0)
  64.     proc->pr_ConsoleTask = (APTR)BTOCP(NullFH, struct FileHandle *)->fh_Port;
  65.  
  66.     sprintf(buf, "%s%s%s -Getty -DEVICE %s -UNIT %d", arg0, redir, Pas->pw_shell_argn, DeviceName, DeviceUnit);
  67.  
  68.     DirLock = (BPTR)Lock(Pas->pw_dir, SHARED_LOCK);
  69.     if (DirLock)
  70.     oldDir = (BPTR)CurrentDir(DirLock);
  71.  
  72.     ulog(1, "Execute %s\n", buf);
  73.  
  74.     Execute(buf, NullFH, NullFH);
  75.  
  76.     proc->pr_ConsoleTask = oldConsoleTask;
  77.  
  78.     if (DirLock)
  79.     UnLock(CurrentDir(oldDir));
  80.  
  81.     ulog(1, "ran\n");
  82. }
  83.  
  84.