<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>change log for rtems (2011-06-24)</title>
</head>
<body text='#000000' bgcolor='#ffffff'>
<a name='cs1'></a>
<table border='0' cellspacing='0' cellpadding='5' width='100%' bgcolor='#eeeeee'>
<tr><td colspan='3' bgcolor='#dddddd'>
<font color='#bb2222'><strong>sh</strong></font>
</td></tr>
<tr><td colspan='3' bgcolor='#dddddd'><pre>2011-06-24 Arnout Vandecappelle <arnout@mind.be>
Sebastien Bourdeauducq <sebastien@milkymist.org>
PR 1724/cpukit
* ftpd/ftpd.h, ftpd/ftpd.c: Added USER/PASS authentication.
</pre></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/ChangeLog.diff?r1=text&tr1=1.2858&r2=text&tr2=1.2859&diff_format=h">M</a></td><td width='1%'>1.2859</td><td width='100%'>cpukit/ChangeLog</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/ftpd/ftpd.h.diff?r1=text&tr1=1.10&r2=text&tr2=1.11&diff_format=h">M</a></td><td width='1%'>1.11</td><td width='100%'>cpukit/ftpd/ftpd.h</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/ftpd/ftpd.c.diff?r1=text&tr1=1.25&r2=text&tr2=1.26&diff_format=h">M</a></td><td width='1%'>1.26</td><td width='100%'>cpukit/ftpd/ftpd.c</td></tr>
</table>
<pre>
<font color='#006600'>diff -u rtems/cpukit/ChangeLog:1.2858 rtems/cpukit/ChangeLog:1.2859
--- rtems/cpukit/ChangeLog:1.2858 Fri Jun 17 10:54:58 2011
+++ rtems/cpukit/ChangeLog Fri Jun 24 05:00:36 2011
</font><font color='#997700'>@@ -1,3 +1,9 @@
</font><font color='#000088'>+2011-06-24 Arnout Vandecappelle <arnout@mind.be>
+ Sebastien Bourdeauducq <sebastien@milkymist.org>
+
+ PR 1724/cpukit
+ * ftpd/ftpd.h, ftpd/ftpd.c: Added USER/PASS authentication.
+
</font> 2011-06-17 Joel Sherrill <joel.sherrill@oarcorp.com>
* rtems/include/rtems/rtems/tasks.h: Complete manager description.
<font color='#006600'>diff -u rtems/cpukit/ftpd/ftpd.h:1.10 rtems/cpukit/ftpd/ftpd.h:1.11
--- rtems/cpukit/ftpd/ftpd.h:1.10 Wed Feb 23 08:08:45 2011
+++ rtems/cpukit/ftpd/ftpd.h Fri Jun 24 05:00:36 2011
</font><font color='#997700'>@@ -25,6 +25,8 @@
</font>
typedef int (*rtems_ftpd_hookfunction)(char *, size_t);
<font color='#000088'>+#include <rtems/shell.h>
+
</font> struct rtems_ftpd_hook
{
char *filename;
<font color='#997700'>@@ -45,6 +47,8 @@
</font> int access; /* 0 - r/w, 1 - read-only,
2 - write-only,
3 - browse-only */
<font color='#000088'>+ rtems_shell_login_check_t login; /* Login check or 0 to ignore
+ user/passwd. */
</font> };
/*
<font color='#006600'>diff -u rtems/cpukit/ftpd/ftpd.c:1.25 rtems/cpukit/ftpd/ftpd.c:1.26
--- rtems/cpukit/ftpd/ftpd.c:1.25 Tue Jun 7 04:08:37 2011
+++ rtems/cpukit/ftpd/ftpd.c Fri Jun 24 05:00:36 2011
</font><font color='#997700'>@@ -1,17 +1,19 @@
</font> /* FIXME: 1. Parse command is a hack. We can do better.
<font color='#880000'>- * 2. Some sort of access control?
- * 3. OSV: hooks support seems to be bad, as it requires storing of
</font><font color='#000088'>+ * 2. OSV: hooks support seems to be bad, as it requires storing of
</font> * entire input file in memory. Seem to be better to change it to
* something more reasonable, like having
* 'hook_write(void const *buf, int count)' routine that will be
* called multiple times while file is being received.
<font color='#880000'>- * 4. OSV: Remove hack with "/dev/null"?
</font><font color='#000088'>+ * 3. OSV: Remove hack with "/dev/null"?
</font> *
* FTP Server Daemon
*
* Submitted by: Jake Janovetz <janovetz@tempest.ece.uiuc.edu>
*
* Changed by: Sergei Organov <osv@javad.ru> (OSV)
<font color='#000088'>+ * Arnout Vandecappelle <arnout@mind.be> (AV)
+ * Sebastien Bourdeauducq <sebastien@milkymist.org> (MM)
+ *<span style="background-color: #FF0000"> </span>
</font> *
* Changes:
*
<font color='#997700'>@@ -19,6 +21,10 @@
</font> *
* * Support spaces in filenames
*<span style="background-color: #FF0000"> </span>
<font color='#000088'>+ * 2010-04-29 Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
+ *<span style="background-color: #FF0000"> </span>
+ * * Added USER/PASS authentication.
+ *<span style="background-color: #FF0000"> </span>
</font> * 2001-01-31 Sergei Organov <osv@javad.ru>
*
* * Hacks with current dir and root dir removed in favor of new libio
<font color='#997700'>@@ -153,6 +159,7 @@
</font> * Change History:
* 12/01/97 - Creation (JWJ)
* 2001-01-08 - Changes by OSV
<font color='#000088'>+ * 2010-04-29 - Authentication added by AV
</font> *************************************************************************/
/*************************************************************************
<font color='#997700'>@@ -267,6 +274,9 @@
</font> int idle; /* Timeout in seconds */
int xfer_mode; /* Transfer mode (ASCII/binary) */
rtems_id tid; /* Task id */
<font color='#000088'>+ char *user; /* user name (0 if not supplied) */
+ char *pass; /* password (0 if not supplied) */
+ bool auth; /* true if user/pass was valid, false if not or not supplied */
</font> } FTPD_SessionInfo_t;
<font color='#997700'>@@ -798,7 +808,7 @@
</font> struct stat stat_buf;
int res = 0;
<font color='#880000'>- if(!can_read())
</font><font color='#000088'>+ if(!can_read() || !info->auth)
</font> {
send_reply(info, 550, "Access denied.");
return;
<font color='#997700'>@@ -944,7 +954,7 @@
</font> typedef ssize_t (*WriteProc)(int, void const*, size_t);
WriteProc wrt = &write;
<font color='#880000'>- if(!can_write())
</font><font color='#000088'>+ if(!can_write() || !info->auth)
</font> {
send_reply(info, 550, "Access denied.");
return;
<font color='#997700'>@@ -1270,6 +1280,12 @@
</font> time_t curTime;
int sc = 1;
<font color='#000088'>+ if(!info->auth)
+ {
+ send_reply(info, 550, "Access denied.");
+ return;
+ }
+
</font> send_reply(info, 150, "Opening ASCII mode data connection for LIST.");
s = data_socket(info);
<font color='#997700'>@@ -1338,6 +1354,12 @@
</font> static void
command_cwd(FTPD_SessionInfo_t *info, char *dir)
{
<font color='#000088'>+ if(!info->auth)
+ {
+ send_reply(info, 550, "Access denied.");
+ return;
+ }
+
</font> if(chdir(dir) == 0)
send_reply(info, 250, "CWD command successful.");
else
<font color='#997700'>@@ -1364,6 +1386,13 @@
</font> char const* cwd;
errno = 0;
buf[0] = '"';
<font color='#000088'>+
+ if(!info->auth)
+ {
+ send_reply(info, 550, "Access denied.");
+ return;
+ }
+
</font> cwd = getcwd(buf + 1, FTPD_BUFSIZE - 4);
if(cwd)
{
<font color='#997700'>@@ -1401,6 +1430,12 @@
</font> struct stat stbuf;
char buf[FTPD_BUFSIZE];
<font color='#000088'>+ if(!info->auth)
+ {
+ send_reply(info, 550, "Access denied.");
+ return;
+ }
+
</font> if (0 > stat(fname, &stbuf))
{
snprintf(buf, FTPD_BUFSIZE, "%s: %s.", fname, serr());
<font color='#997700'>@@ -1725,13 +1760,46 @@
</font> send_reply(info, 504, "Type not implemented. Set to I.");
}
}
<font color='#880000'>- else if (!strcmp("USER", cmd) || !strcmp("PASS", cmd))
</font><font color='#000088'>+ else if (!strcmp("USER", cmd))
</font> {
<font color='#880000'>- send_reply(info, 230, "User logged in.");
</font><font color='#000088'>+ sscanf(args, "%254s", fname);
+ if (info->user)
+ free(info->user);
+ if (info->pass)
+ free(info->pass);
+ info->pass = NULL;
+ info->user = strdup(fname);
+ if (rtems_ftpd_configuration.login &&
+ !rtems_ftpd_configuration.login(info->user, NULL)) {
+ info->auth = false;
+ send_reply(info, 331, "User name okay, need password.");
+ } else {
+ info->auth = true;
+ send_reply(info, 230, "User logged in.");
+ }
+ }
+ else if (!strcmp("PASS", cmd))
+ {
+ sscanf(args, "%254s", fname);
+ if (info->pass)
+ free(info->pass);
+ info->pass = strdup(fname);
+ if (!info->user) {
+ send_reply(info, 332, "Need account to log in");
+ } else {
+ if (rtems_ftpd_configuration.login &&
+ !rtems_ftpd_configuration.login(info->user, info->pass)) {
+ info->auth = false;
+ send_reply(info, 530, "Not logged in.");
+ } else {
+ info->auth = true;
+ send_reply(info, 230, "User logged in.");
+ }
+ }
</font> }
else if (!strcmp("DELE", cmd))
{
<font color='#880000'>- if(!can_write())
</font><font color='#000088'>+ if(!can_write() || !info->auth)
</font> {
send_reply(info, 550, "Access denied.");
}
<font color='#997700'>@@ -1754,7 +1822,7 @@
</font> {
int mask;
<font color='#880000'>- if(!can_write())
</font><font color='#000088'>+ if(!can_write() || !info->auth)
</font> {
send_reply(info, 550, "Access denied.");
}
<font color='#997700'>@@ -1773,7 +1841,7 @@
</font> }
else if (!strcmp("RMD", cmd))
{
<font color='#880000'>- if(!can_write())
</font><font color='#000088'>+ if(!can_write() || !info->auth)
</font> {
send_reply(info, 550, "Access denied.");
}
<font color='#997700'>@@ -1790,7 +1858,7 @@
</font> }
else if (!strcmp("MKD", cmd))
{
<font color='#880000'>- if(!can_write())
</font><font color='#000088'>+ if(!can_write() || !info->auth)
</font> {
send_reply(info, 550, "Access denied.");
}
<font color='#997700'>@@ -1894,6 +1962,8 @@
</font> /* Close connection and put ourselves back into the task pool. */
close_data_socket(info);
close_stream(info);
<font color='#000088'>+ free(info->user);
+ free(info->pass);
</font> task_pool_release(info);
}
}
<font color='#997700'>@@ -1980,6 +2050,12 @@
</font> info->data_addr.sin_port =
htons(ntohs(info->ctrl_addr.sin_port) - 1);
info->idle = ftpd_timeout;
<font color='#000088'>+ info->user = NULL;
+ info->pass = NULL;
+ if (rtems_ftpd_configuration.login)
+ info->auth = false;
+ else
+ info->auth = true;
</font> /* Wakeup the session task. The task will call task_pool_release
after it closes connection. */
rtems_event_send(info->tid, FTPD_RTEMS_EVENT);
</pre>
<p> </p>
<p>--<br />
<small>Generated by <a href="http://www.codewiz.org/projects/index.html#loginfo">Deluxe Loginfo</a> 2.122 by Bernardo Innocenti <bernie@develer.com></small></p>
</body>
</html>