/[inetutils]/inetutils/telnetd/pty.c
ViewVC logotype

Diff of /inetutils/telnetd/pty.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by gray, Fri Apr 5 00:03:12 2002 UTC revision 1.3 by gray, Sun Apr 7 14:31:37 2002 UTC
# Line 24  Line 24 
24  # include <libtelnet/auth.h>  # include <libtelnet/auth.h>
25  #endif  #endif
26    
 char *path_login = PATH_LOGIN;  
 char line[256];  
   
 void  
 do_auth ()  
 {  
 #ifdef AUTHENTICATION  
   if (!autoname || !autoname[0])  
     autologin = 0;  
   
   if (autologin < auth_level)  
     {  
       fatal (net, "Authorization failed");  
       exit (1);  
     }  
 #endif  
 }  
27    
28  void  void
29  setup_utmp (char *line)  setup_utmp (char *line)
# Line 56  startslave (char *host, int autologin, c Line 39  startslave (char *host, int autologin, c
39    pid_t pid;    pid_t pid;
40    int master;    int master;
41        
42    do_auth ();  #ifdef AUTHENTICATION
43      if (!autoname || !autoname[0])
44        autologin = 0;
45    
46      if (autologin < auth_level)
47        {
48          fatal (net, "Authorization failed");
49          exit (1);
50        }
51    #endif
52    pid = forkpty (&master, line, NULL, NULL);    pid = forkpty (&master, line, NULL, NULL);
53    if (pid < 0)    if (pid < 0)
54      {      {
# Line 78  startslave (char *host, int autologin, c Line 70  startslave (char *host, int autologin, c
70          if (net > 2)          if (net > 2)
71            close (net);            close (net);
72    
73    #ifdef UTMPX
74          setup_utmp (line);          setup_utmp (line);
75    #endif
76          start_login (host, autologin, line);          start_login (host, autologin, line);
77        }        }
78    
# Line 112  scrub_env () Line 106  scrub_env ()
106  }  }
107    
108  void  void
 argv_add (struct obstack *sp, char *value)  
 {  
   char *p = value ? xstrdup (value) : NULL;  
   obstack_grow (sp, &p, sizeof(char*));  
 }  
     
 void  
109  start_login (char *host, int autologin, char *name)  start_login (char *host, int autologin, char *name)
110  {  {
111    struct obstack stk;    char *cmd;
112      int argc;
113    char **argv;    char **argv;
114        
115    scrub_env ();    scrub_env ();
   obstack_init (&stk);  
   
   argv_add (&stk, path_login);  
   argv_add (&stk, "-h");  
   argv_add (&stk, host);  
     
 #ifdef  SOLARIS  
   {  
     char *term = getenv ("TERM");  
     if (term == NULL || term[0] == 0)  
       argv_add (&stk, "-");  
     else  
       {  
         char *tbuf = xmalloc (sizeof ("TERM=") + strlen (term));  
         strcat (strcpy (tbuf, "TERM="), term);  
         argv_add (&stk, tbuf);  
       }  
   }  
 #endif  
   
 #ifndef NO_LOGIN_P  
   argv_add (&stk, "-p");  
 #endif  
116    
117    /* Set the environment variable "LINEMODE" to indicate our linemode */    /* Set the environment variable "LINEMODE" to indicate our linemode */
118    if (lmodetype == REAL_LINEMODE)    if (lmodetype == REAL_LINEMODE)
# Line 155  start_login (char *host, int autologin, Line 120  start_login (char *host, int autologin,
120    else if (lmodetype == KLUDGE_LINEMODE || lmodetype == KLUDGE_OK)    else if (lmodetype == KLUDGE_LINEMODE || lmodetype == KLUDGE_OK)
121      setenv ("LINEMODE", "kludge", 1);      setenv ("LINEMODE", "kludge", 1);
122    
123  #ifdef AUTHENTICATION    cmd = expand_line (login_invocation);
124    if (auth_level >= 0 && autologin == AUTH_VALID)    if (!cmd)
125      {      fatal (net, "can't expand login command line");
126        argv_add (&stk, "-f");    argcv_get (cmd, "", &argc, &argv);
127        argv_add (&stk, name);    execv (argv[0], argv);
128      }    syslog (LOG_ERR, "%s: %m\n", cmd);
129  #endif    fatalperror (net, cmd);
     
 /*  if (getenv ("USER"))  
     {  
       argv_add (&stk, "--");  
       argv_add (&stk, getenv ("USER"));  
       unsetenv ("USER");  
       }*/  
   argv_add (&stk, NULL);  
   
   argv = (char**) obstack_finish (&stk);  
   execv (path_login, argv);  
   syslog (LOG_ERR, "%s: %m\n", path_login);  
   fatalperror (net, path_login);  
130  }  }
131    
132  void  void
# Line 197  cleanup (int sig) Line 149  cleanup (int sig)
149    shutdown (net, 2);    shutdown (net, 2);
150    exit (1);    exit (1);
151  }  }
152    
153      

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26