Changeset dcf42bb2 in rtems


Ignore:
Timestamp:
Oct 5, 2018, 12:39:46 PM (7 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
51da629
Parents:
e761fb4
Message:

ftpd: Remove FTPD_SessionInfo_t::pass member

There is no need to keep the password throughout the session.

Update #3530.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ftpd/ftpd.c

    re761fb4 rdcf42bb2  
    266266  rtems_id            tid;         /* Task id */
    267267  char                *user;       /* user name (0 if not supplied) */
    268   char                *pass;       /* password (0 if not supplied) */
    269268  bool                auth;        /* true if user/pass was valid, false if not or not supplied */
    270269} FTPD_SessionInfo_t;
     
    17401739    sscanf(args, "%254s", fname);
    17411740    free(info->user);
    1742     free(info->pass);
    1743     info->pass = NULL;
    17441741    info->user = strdup(fname);
    17451742    if (ftpd_config->login &&
     
    17541751  else if (!strcmp("PASS", cmd))
    17551752  {
    1756     sscanf(args, "%254s", fname);
    1757     free(info->pass);
    1758     info->pass = strdup(fname);
    17591753    if (!info->user) {
    17601754      send_reply(info, 332, "Need account to log in");
    17611755    } else {
    17621756      if (ftpd_config->login &&
    1763         !ftpd_config->login(info->user, info->pass)) {
     1757        !ftpd_config->login(info->user, args)) {
    17641758        info->auth = false;
    17651759        send_reply(info, 530, "Not logged in.");
     
    19521946    close_stream(info);
    19531947    free(info->user);
    1954     free(info->pass);
    19551948    task_pool_release(info);
    19561949  }
     
    20392032            info->idle = ftpd_timeout;
    20402033            info->user = NULL;
    2041             info->pass = NULL;
    20422034            if (ftpd_config->login)
    20432035              info->auth = false;
  • testsuites/libtests/ftp01/ftp01.scn

    re761fb4 rdcf42bb2  
    1 *** TEST FTP 1 ***
     1*** BEGIN OF TEST FTP 1 ***
     2*** TEST VERSION: 5.0.0.b38887ad22e2e28c15b4e248dac72f6eaff8cb13
     3*** TEST STATE: EXPECTED-PASS
     4*** TEST BUILD: RTEMS_NETWORKING
     5*** TEST TOOLS: 7.3.0 20180125 (RTEMS 5, RSB 9670d7541e0621915e521fe76e7bb33de8cee661, Newlib d13c84eb07e35984bf7a974cd786a6cdac29e6b9)
    26syslog: ftpd: FTP daemon started (2 sessions max)
    37220 RTEMS FTP server (Version 1.1-JWJ) ready.
     8login check (1): user "anonymous"
    49USER anonymous
    510230 User logged in.
    611TYPE I
    712200 Type set to I.
     13SIZE a.txt
     14550 Could not get file size.
    815PASV
    916227 Entering passive mode (127,0,0,1,4,1).
     
    1421221 Goodbye.
    1522220 RTEMS FTP server (Version 1.1-JWJ) ready.
     23login check (1): user "anonymous"
    1624USER anonymous
    1725230 User logged in.
     
    2533150 Opening BINARY mode data connection.
    2634220 RTEMS FTP server (Version 1.1-JWJ) ready.
    27 USER anonymous
     35login check (1): user "user"
     36USER user
     37331 User name okay, need password.
     38login check (2): user "user", pass "pass"
     39PASS pass
    2840230 User logged in.
    2941TYPE I
    3042200 Type set to I.
     43SIZE b.txt
     44550 Could not get file size.
    3145PASV
    3246227 Entering passive mode (127,0,0,1,4,7).
     
    4054221 Goodbye.
    4155220 RTEMS FTP server (Version 1.1-JWJ) ready.
    42 USER anonymous
     56login check (1): user "user"
     57USER user
     58331 User name okay, need password.
     59login check (2): user "user", pass "pass"
     60PASS pass
    4361230 User logged in.
    4462TYPE I
     
    5472221 Goodbye.
    5573220 RTEMS FTP server (Version 1.1-JWJ) ready.
     74login check (1): user "anonymous"
    5675USER anonymous
    5776230 User logged in.
     
    6382221 Goodbye.
    6483220 RTEMS FTP server (Version 1.1-JWJ) ready.
    65 USER anonymous
     84login check (1): user "user"
     85USER user
     86331 User name okay, need password.
     87login check (2): user "user", pass "pass"
     88PASS pass
    6689230 User logged in.
    6790TYPE I
     
    7194QUIT
    7295221 Goodbye.
     96
    7397*** END OF TEST FTP 1 ***
  • testsuites/libtests/ftp01/init.c

    re761fb4 rdcf42bb2  
    11/*
    2  * Copyright (c) 2011 embedded brains GmbH.  All rights reserved.
     2 * Copyright (c) 2011, 2018 embedded brains GmbH.  All rights reserved.
    33 *
    44 *  embedded brains GmbH
    5  *  Obere Lagerstr. 30
     5 *  Dornierstr. 4
    66 *  82178 Puchheim
    77 *  Germany
     
    3939#define FTP_WORKER_TASK_EXTRA_STACK (FTP_WORKER_TASK_COUNT * FTPD_STACKSIZE)
    4040
     41static bool login_check(const char *user, const char *pass)
     42{
     43  rtems_test_assert(
     44    strcmp(user, "anonymous") == 0 || strcmp(user, "user") == 0
     45  );
     46
     47  if (pass != NULL) {
     48    rtems_test_assert(
     49      strcmp(pass, "anonymous") == 0 || strcmp(pass, "pass") == 0
     50    );
     51    printf("login check (2): user \"%s\", pass \"%s\"\n", user, pass);
     52    return true;
     53  } else {
     54    printf("login check (1): user \"%s\"\n", user);
     55    return strcmp(user, "anonymous") == 0;
     56  }
     57}
     58
    4159struct rtems_ftpd_configuration rtems_ftpd_configuration = {
    4260  .priority = 90,
     
    4765  .tasks_count = FTP_WORKER_TASK_COUNT,
    4866  .idle = 0,
     67  .login = login_check,
    4968  .access = 0
    5069};
     
    200219  int rv = 0;
    201220  const char file_a [] = "/FTP/127.0.0.1/a.txt";
    202   const char file_b [] = "/FTP/127.0.0.1/b.txt";
     221  const char file_b [] = "/FTP/user:pass@127.0.0.1/b.txt";
    203222
    204223  rv = rtems_bsdnet_initialize_network();
Note: See TracChangeset for help on using the changeset viewer.