Changeset 1fae7b43 in rtems


Ignore:
Timestamp:
Oct 15, 2008, 5:37:16 PM (11 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
b4288f0
Parents:
f3b9811
Message:

2008-10-15 Joel Sherrill <joel.sherrill@…>

PR 1331/networking

  • libmisc/shell/shell.c, telnetd/check_passwd.c, telnetd/telnetd.c, telnetd/telnetd.h: Improve comments and explanation of options to rtems_telnetd_initialize. Add extra newline to login sequence from shell.
Location:
cpukit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    rf3b9811 r1fae7b43  
     12008-10-15      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        PR 1331/networking
     4        * libmisc/shell/shell.c, telnetd/check_passwd.c, telnetd/telnetd.c,
     5        telnetd/telnetd.h: Improve comments and explanation of options to
     6        rtems_telnetd_initialize. Add extra newline to login sequence from
     7        shell.
     8
    192008-10-14      Tim Cussins <timcussins@eml.cc>
    210
  • cpukit/libmisc/shell/shell.c

    rf3b9811 r1fae7b43  
    461461  if (stat("/etc/issue",&buf)) {
    462462    rtems_shell_write_file("/etc/issue",
     463                           "\n"
    463464                           "Welcome to @V\\n"
    464465                           "Login into @S\\n");
     
    467468  if (stat("/etc/issue.net",&buf)) {
    468469     rtems_shell_write_file("/etc/issue.net",
     470                           "\n"
    469471                            "Welcome to %v\n"
    470472                            "running on %m\n");
  • cpukit/telnetd/check_passwd.c

    rf3b9811 r1fae7b43  
    7979int check_passwd(char *peername)
    8080{
    81 char                    *pw;
    82 int                             rval = -1, tmp, retries;
    83 struct termios  t,told;
    84 int                             restore_flags = 0;
    85 char                    buf[30], cryptbuf[21];
    86 char                    salt[3];
     81  char                  *pw;
     82  int                   rval = -1, tmp, retries;
     83  struct termios        t,told;
     84  int                   restore_flags = 0;
     85  char                  buf[30], cryptbuf[21];
     86  char                  salt[3];
    8787
    8888  if ( !(pw=getenv("TELNETD_PASSWD")) || 0 == strlen(pw) )
  • cpukit/telnetd/telnetd.c

    rf3b9811 r1fae7b43  
    8686
    8787/***********************************************************/
    88 rtems_id            telnetd_task_id      =0;
    89 uint32_t            telnetd_stack_size   =32000;
    90 rtems_task_priority telnetd_task_priority=0;
    91 int                 telnetd_dont_spawn   =0;
    92 void                (*telnetd_shell)(char *, void*)=0;
    93 void                *telnetd_shell_arg         =0;
     88rtems_id            telnetd_task_id                 = 0;
     89uint32_t            telnetd_stack_size              = 32000;
     90rtems_task_priority telnetd_task_priority           = 0;
     91bool                telnetd_remain_on_caller_stdio  = false;
     92void                (*telnetd_shell)(char *, void*) = 0;
     93void                *telnetd_shell_arg              = NULL;
    9494void *              (*telnetd_spawn_task)(
    95         const char *, unsigned, unsigned, void (*)(void*), void *) = telnetd_dflt_spawn;
    96 
    97 static char *grab_a_Connection(int des_socket, uni_sa *srv, char *peername, int sz)
     95  const char *,
     96  unsigned,
     97  unsigned,
     98  void (*)(void*),
     99  void *) = telnetd_dflt_spawn;
     100
     101static char *grab_a_Connection(
     102  int des_socket,
     103  uni_sa *srv,
     104  char *peername,
     105  int sz
     106)
    98107{
    99108  char *rval = 0;
     
    191200  int                i=1;
    192201  int                size_adr;
    193   struct shell_args *arg;
     202  struct shell_args *arg = NULL;
    194203
    195204  if ((des_socket=socket(PF_INET,SOCK_STREAM,0))<0) {
     
    206215  if ((bind(des_socket,&srv.sa,size_adr))<0) {
    207216    perror("telnetd:bind");
    208           close(des_socket);
     217    close(des_socket);
    209218    telnetd_task_id=0;
    210219    rtems_task_delete(RTEMS_SELF);
     
    221230   */
    222231  do {
    223     devname = grab_a_Connection(des_socket, &srv, peername, sizeof(peername));
    224 
    225     if ( !devname ) {
    226       /* if something went wrong, sleep for some time */
    227       sleep(10);
    228       continue;
    229     }
    230     if ( telnetd_dont_spawn ) {
    231       if ( !telnetd_askForPassword || (0 == check_passwd(peername)) )
    232         telnetd_shell(devname, telnetd_shell_arg);
     232    if ( telnetd_remain_on_caller_stdio ) {
     233      char device_name[32];
     234      ttyname_r( 1, device_name, sizeof(device_name) );
     235      if ( !telnetd_askForPassword || (0 == check_passwd(arg->peername)) )
     236        telnetd_shell(device_name, telnetd_shell_arg);
    233237    } else {
     238      devname = grab_a_Connection(des_socket, &srv, peername, sizeof(peername));
     239
     240      if ( !devname ) {
     241        /* if something went wrong, sleep for some time */
     242        sleep(10);
     243        continue;
     244      }
     245
    234246      arg = malloc( sizeof(*arg) );
    235247
     
    289301  void               (*cmd)(char *, void *),
    290302  void                *arg,
    291   int                  dontSpawn,
     303  bool                 remainOnCallerSTDIO,
    292304  size_t               stack,
    293305  rtems_task_priority  priority,
    294   int                  askForPassword
     306  bool                 askForPassword
    295307)
    296308{
     
    329341  if ( priority < 2 )
    330342    priority = 100;
    331   telnetd_task_priority = priority;
    332   telnetd_dont_spawn    = dontSpawn;
     343  telnetd_task_priority          = priority;
     344  telnetd_remain_on_caller_stdio = remainOnCallerSTDIO;
    333345
    334346  sc = initialize_telnetd();
    335347  if (sc != RTEMS_SUCCESSFUL) return sc;
    336348
    337   printf("rtems_telnetd() started with stacksize=%u,priority=%d\n",
    338     (unsigned)telnetd_stack_size,(int)telnetd_task_priority);
     349  if ( !telnetd_remain_on_caller_stdio )
     350    fprintf(stderr, "rtems_telnetd() started with stacksize=%u,priority=%d\n",
     351      (unsigned)telnetd_stack_size,(int)telnetd_task_priority);
    339352  return 0;
    340353}
  • cpukit/telnetd/telnetd.h

    rf3b9811 r1fae7b43  
    1818#endif 
    1919
    20 /*
    21  *  Initialize the telnetd subsystem.
     20/**
     21 *  This method initializes the telnetd subsystem.
    2222 *
    23  *  cmd              - function which is the "shell" telnetd invokes
    24  *  arg              - context pointer to cmd
    25  *  dontSpawn        - TRUE if telnetd takes over this task.
    26  *                     FALSE to create another task for the shell.
    27  *  stack            - stack size of spawned task
    28  *  priority         - initial priority of spawned task
    29  *  askForPassword   - TRUE if telnetd asks for password
    30  *                     FALSE to invoke "cmd" with no password check.
    31  *                        This may be OK if "cmd" includes its own check.
     23 *  @param[in] cmd is the function which is the "shell" telnetd invokes
     24 *  @param[in] arg is the context pointer to cmd
     25 *  @param[in] remainOnCallerSTDIO is set to TRUE if telnetd takes over the
     26 *    standard in, out and error associated with task.  In this case,
     27 *    it will be NOT be listening on any sockets.  When this parameters
     28 *    is FALSE the telnetd will create other tasks for the shell
     29 *    which listen on sockets.
     30 *  @param[in] stack is stack size of spawned task.
     31 *  @param[in] priority is the initial priority of spawned task(s).  If
     32 *    this parameter is less than 2, then the default priority of 100 is used.
     33 *  @param[in] askForPassword is set to TRUE if telnetd is to ask for a
     34 *    password. This is set to FALSE to invoke "cmd" with no password check.
     35 *    This may be OK if "cmd" includes its own check and indeed the RTEMS Shell
     36 *    uses a login with a user name and password so this is the usual case.
    3237 */
    3338int rtems_telnetd_initialize(
    3439  void               (*cmd)(char *, void *),
    3540  void                *arg,
    36   int                  dontSpawn,
     41  bool                 remainOnCallerSTDIO,
    3742  size_t               stack,
    3843  rtems_task_priority  priority,
    39   int                  askForPassword
     44  bool                 askForPassword
    4045);
    4146
Note: See TracChangeset for help on using the changeset viewer.