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

Diff of /inetutils/telnetd/telnetd.c

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

revision 1.26 by gray, Fri Apr 5 00:02:43 2002 UTC revision 1.27 by gray, Sun Apr 7 14:31:08 2002 UTC
# Line 44  static struct option long_options[] = Line 44  static struct option long_options[] =
44    {NULL, 0, NULL, 0}    {NULL, 0, NULL, 0}
45  };  };
46    
47  static void telnetd_version ();  static void telnetd_version P((void));
48  static void telnetd_license ();  static void telnetd_license P((void));
49  static void telnetd_help ();  static void telnetd_help P((void));
50  static void parse_authmode (char *str);  static void parse_authmode P((char *str));
51  static void parse_linemode (char *str);  static void parse_linemode P((char *str));
52  static void parse_debug_level (char *str);  static void parse_debug_level P((char *str));
53  static void telnetd_setup (int fd);  static void telnetd_setup P((int fd));
54  static int telnetd_run ();  static int telnetd_run P((void));
55    static void print_hostinfo P((void));
56    
57    /* Template command line for invoking login program */
58    
59    char *login_invocation =
60    #ifdef SOLARIS
61    "/bin/login -h %h %?T{TERM=%T}{-} %?u{%?a{-f }-- %u}"
62    #else
63    "/bin/login -p -h %h %?u{-f %u}"
64    #endif
65    ;
66    
 char *login_invocation; /* Template command line for invoking login program */  
67  int keepalive = 1;      /* Should the TCP keepalive bit be set */  int keepalive = 1;      /* Should the TCP keepalive bit be set */
68  int reverse_lookup = 0; /* Reject connects from hosts which IP numbers  int reverse_lookup = 0; /* Reject connects from hosts which IP numbers
69                             cannot be reverse mapped to their hostnames */                             cannot be reverse mapped to their hostnames */
# Line 72  int net;      /* Network connection sock Line 81  int net;      /* Network connection sock
81  int pty;      /* PTY master descriptor */  int pty;      /* PTY master descriptor */
82  char *remote_hostname;  char *remote_hostname;
83  char *local_hostname;  char *local_hostname;
84    char *user_name;
85    char line[256];
86    
87  char    options[256];  char    options[256];
88  char    do_dont_resp[256];  char    do_dont_resp[256];
# Line 266  telnetd_setup (int fd) Line 277  telnetd_setup (int fd)
277    int true = 1;    int true = 1;
278    int len;    int len;
279    struct hostent *hp;    struct hostent *hp;
280    char user_name[256]; /*FIXME*/    char uname[256]; /*FIXME*/
281    int level;    int level;
282    
283    len = sizeof (saddr);    len = sizeof (saddr);
# Line 276  telnetd_setup (int fd) Line 287  telnetd_setup (int fd)
287        exit (1);        exit (1);
288      }      }
289    
290    syslog (LOG_INFO, "Connect from %s", inet_ntoa (saddr.sin_addr.s_addr));    syslog (LOG_INFO, "Connect from %s", inet_ntoa (saddr.sin_addr));
291        
292    hp = gethostbyaddr ((char*)&saddr.sin_addr.s_addr,    hp = gethostbyaddr ((char*)&saddr.sin_addr.s_addr,
293                        sizeof (saddr.sin_addr.s_addr), AF_INET);                        sizeof (saddr.sin_addr.s_addr), AF_INET);
# Line 288  telnetd_setup (int fd) Line 299  telnetd_setup (int fd)
299          {          {
300            syslog (LOG_AUTH|LOG_NOTICE,            syslog (LOG_AUTH|LOG_NOTICE,
301                    "Can't resolve %s: %s",                    "Can't resolve %s: %s",
302                    inet_ntoa (saddr.sin_addr.s_addr),                    inet_ntoa (saddr.sin_addr),
303                    hstrerror (h_errno));                    hstrerror (h_errno));
304            fatal (fd, "Cannot resolve address.");            fatal (fd, "Cannot resolve address.");
305          }          }
# Line 313  telnetd_setup (int fd) Line 324  telnetd_setup (int fd)
324            syslog (LOG_AUTH|LOG_NOTICE,            syslog (LOG_AUTH|LOG_NOTICE,
325                    "None of addresses of %s matched %s",                    "None of addresses of %s matched %s",
326                    remote_hostname,                    remote_hostname,
327                    inet_ntoa (saddr.sin_addr.s_addr));                    inet_ntoa (saddr.sin_addr));
328            exit (0);            exit (0);
329          }          }
330      }      }
# Line 322  telnetd_setup (int fd) Line 333  telnetd_setup (int fd)
333        if (hp)        if (hp)
334          remote_hostname = xstrdup (hp->h_name);          remote_hostname = xstrdup (hp->h_name);
335        else        else
336          remote_hostname = xstrdup (inet_ntoa (saddr.sin_addr.s_addr));          remote_hostname = xstrdup (inet_ntoa (saddr.sin_addr));
337      }      }
338        
339    /* Set socket options */    /* Set socket options */
# Line 353  telnetd_setup (int fd) Line 364  telnetd_setup (int fd)
364    /**/    /**/
365                                                                        
366    /* get terminal type. */    /* get terminal type. */
367    *user_name = 0;    uname[0] = 0;
368    level = getterminaltype (&user_name);    level = getterminaltype (uname);
369    setenv ("TERM", terminaltype ? terminaltype : "network", 1);    setenv ("TERM", terminaltype ? terminaltype : "network", 1);
370      if (uname[0])
371        user_name = xstrdup (uname);
372    pty = startslave (remote_hostname, level, user_name);    pty = startslave (remote_hostname, level, user_name);
373    
374  #ifndef HAVE_STREAMSPTY  #ifndef HAVE_STREAMSPTY
# Line 450  telnetd_run () Line 462  telnetd_run ()
462    /* Pick up anything received during the negotiations */    /* Pick up anything received during the negotiations */
463    telrcv ();    telrcv ();
464    
465    /*  if (hostinfo && !getenv("USER"))    if (hostinfo)
466      print_hostinfo ();      print_hostinfo ();
     */  
467            
468    init_termbuf ();    init_termbuf ();
469    localstat ();    localstat ();
# Line 580  void Line 591  void
591  print_hostinfo ()  print_hostinfo ()
592  {  {
593    char *im = NULL;    char *im = NULL;
594      char *str;
595  #ifdef HAVE_UNAME  #ifdef HAVE_UNAME
596    struct utsname u;    struct utsname u;
597        
# Line 597  print_hostinfo () Line 609  print_hostinfo ()
609      }      }
610  #endif /* HAVE_UNAME */  #endif /* HAVE_UNAME */
611    if (!im)    if (!im)
612      im = "\r\n\nUNIX (%h) (%t)\r\n\n";      im = xstrdup ("\r\n\nUNIX (%h) (%t)\r\n\n");
613    
614    /*FIXME*/    str = expand_line (im);
615    DEBUG(debug_pty_data, 1, debug_output_data ("sending %s", im));    free (im);
616    pty_output_datalen (im, strlen (im));    
617      DEBUG(debug_pty_data, 1, debug_output_data ("sending %s", str));
618      pty_input_putback (str, strlen (str));
619      free (str);
620  }  }
621    
622  void  void
# Line 645  Usage: telnetd [OPTION]\n\ Line 660  Usage: telnetd [OPTION]\n\
660  Options are:\n\  Options are:\n\
661      -a, --authmode AUTHMODE  specify what mode to use for authentication\n\      -a, --authmode AUTHMODE  specify what mode to use for authentication\n\
662      -D, --debug[=LEVEL]      set debugging level\n\      -D, --debug[=LEVEL]      set debugging level\n\
663  *   -E, --exec-login STRING  set program to be executed instead of /bin/login\n\      -E, --exec-login STRING  set program to be executed instead of /bin/login\n\
664      -h, --no-hostinfo        do not print host information before login has\n\      -h, --no-hostinfo        do not print host information before login has\n\
665                               been completed\n\                               been completed\n\
666      -l, --linemode[=MODE]    set line mode\n\      -l, --linemode[=MODE]    set line mode\n\
# Line 657  Options are:\n\ Line 672  Options are:\n\
672  Informational options:\n\  Informational options:\n\
673      -V, --version         display this help and exit\n\      -V, --version         display this help and exit\n\
674      -L, --license         display license and exit\n\      -L, --license         display license and exit\n\
675      -H. --help            output version information and exit\n\      -H. --help            output version information and exit\n");
 \n\  
 Options, marked with an * are not yet implemented\n");  
676  }  }
677    
678  int  int

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.27

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