Commit c3bab08b authored by Amos Latteier's avatar Amos Latteier

Finished cookie support for FTP server. This allows you to use UserDB and...

Finished cookie support for FTP server. This allows you to use UserDB and etcUserDB cookie authentication with FTP.
parent 03087c40
......@@ -104,11 +104,16 @@ class FTPRequest(HTTPRequest):
stdin=StringIO()
env=self._get_env(path, command, channel, stdin)
HTTPRequest.__init__(self, stdin, env, response, clean=1)
# support for cookies and cookie authentication
self.cookies=channel.cookies
if not self.cookies.has_key('__ac') and channel.userid != 'anonymous':
self.cookies['__ac']=encodestring('%s:%s' %
(channel.userid, channel.password))
for k,v in self.cookies.items():
if not self.other.has_key(k):
self.other[k]=v
def _get_env(self, path, command, channel, stdin):
"Returns a CGI style environment"
env={}
......@@ -122,7 +127,7 @@ class FTPRequest(HTTPRequest):
env['SERVER_PORT']=str(channel.server.port)
env['REMOTE_ADDR']=channel.client_addr[0]
env['GATEWAY_INTERFACE']='CGI/1.1' # that's stretching it ;-)
# FTP commands
#
if type(command)==type(()):
......
......@@ -97,6 +97,18 @@ class FTPResponse(HTTPResponse):
Response to an FTP command
"""
def setCookie(self, name, value, **kw):
self.cookies[name]=value
def appendCookie(self, name, value):
self.cookies[name]=self.cookies[name] + value
def expireCookie(self, name, **kw):
del self.cookies[name]
def _cookie_list(self):
return []
def _finish(self):
self.stdout.finish(self)
......
......@@ -104,11 +104,16 @@ class FTPRequest(HTTPRequest):
stdin=StringIO()
env=self._get_env(path, command, channel, stdin)
HTTPRequest.__init__(self, stdin, env, response, clean=1)
# support for cookies and cookie authentication
self.cookies=channel.cookies
if not self.cookies.has_key('__ac') and channel.userid != 'anonymous':
self.cookies['__ac']=encodestring('%s:%s' %
(channel.userid, channel.password))
for k,v in self.cookies.items():
if not self.other.has_key(k):
self.other[k]=v
def _get_env(self, path, command, channel, stdin):
"Returns a CGI style environment"
env={}
......@@ -122,7 +127,7 @@ class FTPRequest(HTTPRequest):
env['SERVER_PORT']=str(channel.server.port)
env['REMOTE_ADDR']=channel.client_addr[0]
env['GATEWAY_INTERFACE']='CGI/1.1' # that's stretching it ;-)
# FTP commands
#
if type(command)==type(()):
......
......@@ -97,6 +97,18 @@ class FTPResponse(HTTPResponse):
Response to an FTP command
"""
def setCookie(self, name, value, **kw):
self.cookies[name]=value
def appendCookie(self, name, value):
self.cookies[name]=self.cookies[name] + value
def expireCookie(self, name, **kw):
del self.cookies[name]
def _cookie_list(self):
return []
def _finish(self):
self.stdout.finish(self)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment