Changeset 90873cc in rtems-libbsd for rtemsbsd/ftpd
- Timestamp:
- 06/28/16 03:32:01 (7 years ago)
- Branches:
- 5, 5-freebsd-12, 6-freebsd-12, freebsd-9.3, master
- Children:
- 4a2b844
- Parents:
- c2ec5f1
- Location:
- rtemsbsd/ftpd
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
rtemsbsd/ftpd/ftpd.c
rc2ec5f1 r90873cc 14 14 * Arnout Vandecappelle <arnout@mind.be> (AV) 15 15 * Sebastien Bourdeauducq <sebastien@milkymist.org> (MM) 16 * 16 * 17 17 * 18 18 * Changes: … … 21 21 * 22 22 * * Support spaces in filenames 23 * 23 * 24 24 * 2010-04-29 Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> 25 * 25 * 26 26 * * Added USER/PASS authentication. 27 * 27 * 28 28 * 2001-01-31 Sergei Organov <osv@javad.ru> 29 29 * … … 245 245 246 246 /* Configuration table */ 247 extern struct rtems_ftpd_configuration rtems_ftpd_configuration;247 static struct rtems_ftpd_configuration* ftpd_config; 248 248 249 249 /* this is not prototyped in strict ansi mode */ … … 954 954 } 955 955 956 if (!null && rtems_ftpd_configuration.hooks != NULL)956 if (!null && ftpd_config->hooks != NULL) 957 957 { 958 958 … … 962 962 963 963 i = 0; 964 hook = & rtems_ftpd_configuration.hooks[i++];964 hook = &ftpd_config->hooks[i++]; 965 965 while (hook->filename != NULL) 966 966 { … … 970 970 break; 971 971 } 972 hook = & rtems_ftpd_configuration.hooks[i++];972 hook = &ftpd_config->hooks[i++]; 973 973 } 974 974 } … … 983 983 */ 984 984 985 char 986 size_t filesize = rtems_ftpd_configuration.max_hook_filesize + 1;985 char *bigBufr; 986 size_t filesize = ftpd_config->max_hook_filesize + 1; 987 987 988 988 /* … … 1767 1767 info->pass = NULL; 1768 1768 info->user = strdup(fname); 1769 if ( rtems_ftpd_configuration.login &&1770 ! rtems_ftpd_configuration.login(info->user, NULL)) {1769 if (ftpd_config->login && 1770 !ftpd_config->login(info->user, NULL)) { 1771 1771 info->auth = false; 1772 1772 send_reply(info, 331, "User name okay, need password."); … … 1785 1785 send_reply(info, 332, "Need account to log in"); 1786 1786 } else { 1787 if ( rtems_ftpd_configuration.login &&1788 ! rtems_ftpd_configuration.login(info->user, info->pass)) {1787 if (ftpd_config->login && 1788 !ftpd_config->login(info->user, info->pass)) { 1789 1789 info->auth = false; 1790 1790 send_reply(info, 530, "Not logged in."); … … 1827 1827 char *c; 1828 1828 c = strchr(args, ' '); 1829 if((c != NULL) && (sscanf(args, "%o", &mask) == 1) && strncpy(fname, c+1, 254) 1829 if((c != NULL) && (sscanf(args, "%o", &mask) == 1) && strncpy(fname, c+1, 254) 1830 1830 && (chmod(fname, (mode_t)mask) == 0)) 1831 1831 send_reply(info, 257, "CHMOD successful."); … … 2010 2010 2011 2011 addr.sin_family = AF_INET; 2012 addr.sin_port = htons( rtems_ftpd_configuration.port);2012 addr.sin_port = htons(ftpd_config->port); 2013 2013 addr.sin_addr.s_addr = htonl(INADDR_ANY); 2014 2014 memset(addr.sin_zero, 0, sizeof(addr.sin_zero)); … … 2065 2065 info->user = NULL; 2066 2066 info->pass = NULL; 2067 if ( rtems_ftpd_configuration.login)2067 if (ftpd_config->login) 2068 2068 info->auth = false; 2069 2069 else … … 2089 2089 * 2090 2090 * Input parameters: 2091 * 2091 * config: constant initial setup. 2092 2092 * Output parameters: 2093 2093 * returns RTEMS_SUCCESSFUL on successful start of the daemon. 2094 2094 */ 2095 2095 int 2096 rtems_ initialize_ftpd(void)2096 rtems_ftpd_start(const struct rtems_ftpd_configuration* config) 2097 2097 { 2098 2098 rtems_status_code sc; … … 2101 2101 int count; 2102 2102 2103 if (rtems_ftpd_configuration.port == 0) 2104 { 2105 rtems_ftpd_configuration.port = FTPD_CONTROL_PORT; 2106 } 2107 2108 if (rtems_ftpd_configuration.priority == 0) 2109 { 2110 rtems_ftpd_configuration.priority = 40; 2111 } 2112 priority = rtems_ftpd_configuration.priority; 2113 2114 ftpd_timeout = rtems_ftpd_configuration.idle; 2103 if (ftpd_config != NULL) 2104 return RTEMS_RESOURCE_IN_USE; 2105 2106 ftpd_config = malloc(sizeof(*ftpd_config)); 2107 if (ftpd_config == NULL) 2108 return RTEMS_NO_MEMORY; 2109 2110 *ftpd_config = *config; 2111 2112 if (ftpd_config->port == 0) 2113 { 2114 ftpd_config->port = FTPD_CONTROL_PORT; 2115 } 2116 2117 if (ftpd_config->priority == 0) 2118 { 2119 ftpd_config->priority = 40; 2120 } 2121 priority = ftpd_config->priority; 2122 2123 ftpd_timeout = ftpd_config->idle; 2115 2124 if (ftpd_timeout < 0) 2116 2125 ftpd_timeout = 0; 2117 rtems_ftpd_configuration.idle = ftpd_timeout;2118 2119 ftpd_access = rtems_ftpd_configuration.access;2126 ftpd_config->idle = ftpd_timeout; 2127 2128 ftpd_access = ftpd_config->access; 2120 2129 2121 2130 ftpd_root = "/"; 2122 if ( rtems_ftpd_configuration.root && 2123 rtems_ftpd_configuration.root[0] == '/' ) 2124 ftpd_root = rtems_ftpd_configuration.root; 2125 2126 rtems_ftpd_configuration.root = ftpd_root; 2127 2128 if (rtems_ftpd_configuration.tasks_count <= 0) 2129 rtems_ftpd_configuration.tasks_count = 1; 2130 count = rtems_ftpd_configuration.tasks_count; 2131 if (ftpd_config->root && ftpd_config->root[0] == '/' ) 2132 ftpd_root = ftpd_config->root; 2133 2134 ftpd_config->root = ftpd_root; 2135 2136 if (ftpd_config->tasks_count <= 0) 2137 ftpd_config->tasks_count = 1; 2138 count = ftpd_config->tasks_count; 2131 2139 2132 2140 if (!task_pool_init(count, priority)) … … 2158 2166 } 2159 2167 2160 syslog(LOG_INFO, "ftpd: FTP daemon started (%d session%s max)", 2161 count, ((count > 1) ? "s" : "")); 2168 if (ftpd_config->verbose) 2169 syslog(LOG_INFO, "ftpd: FTP daemon started (%d session%s max)", 2170 count, ((count > 1) ? "s" : "")); 2162 2171 2163 2172 return RTEMS_SUCCESSFUL;
Note: See TracChangeset
for help on using the changeset viewer.