Ñò pØcJc @ s d Z d d k Z d d k Z d d k l Z l Z d d k Td d k l Z d d k Td d k Td d k Th e d 6e d 6Z d e e f d „ ƒ YZ d d k l Z d S( s Server-mode SFTP support. iÿÿÿÿN( t MD5t SHA( t *( t SubsystemHandlert sha1t md5t SFTPServerc B s e Z d Z e d „ Z d „ Z d „ Z d „ Z d „ Z e e ƒ Z d „ Z e e ƒ Z d „ Z e d „ Z d d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z RS( sä Server-side SFTP subsystem support. Since this is a L{SubsystemHandler}, it can be (and is meant to be) set as the handler for C{"sftp"} requests. Use L{Transport.set_subsystem_handler} to activate this class. c O sŽ t i | ƒ t i | | | | ƒ | i ƒ } t i | i ƒ d ƒ | _ | i ƒ | _ d | _ h | _ h | _ | | | | Ž | _ d S( sâ The constructor for SFTPServer is meant to be called from within the L{Transport} as a subsystem handler. C{server} and any additional parameters or keyword parameters are passed from the original call to L{Transport.set_subsystem_handler}. @param channel: channel passed from the L{Transport}. @type channel: L{Channel} @param name: name of the requested subsystem. @type name: str @param server: the server object associated with this channel and subsystem @type server: L{ServerInterface} @param sftp_si: a subclass of L{SFTPServerInterface} to use for handling individual requests. @type sftp_si: class s .sftpi N( t BaseSFTPt __init__R t get_transportt utilt get_loggert get_log_channelt loggert get_hexdumpt ultra_debugt next_handlet file_tablet folder_tablet server( t selft channelt nameR t sftp_sit largst kwargst transport( ( s8 /usr/lib/python2.6/site-packages/paramiko/sftp_server.pyR 0 s c C s‹ t t | ƒ t ƒ oC xn | D]4 } t t | ƒ i | d | i i ƒ d | ƒ q Wn/ t t | ƒ i | d | i i ƒ d | ƒ d S( Ns [chan s ] ( t issubclasst typet listt superR t _logt sockt get_name( R t levelt msgt m( ( s8 /usr/lib/python2.6/site-packages/paramiko/sftp_server.pyR M s 6c C sd | | _ | i t d t | ƒ ƒ | i ƒ | i i ƒ x#t oy | i ƒ \ } } Wni t j o | i t d ƒ d St j o: } | i t d t | ƒ ƒ | i t t i ƒ ƒ d SXt | ƒ } | i ƒ } y | i | | | ƒ Wq= t j oW } | i t d t | ƒ ƒ | i t t i ƒ ƒ y | i | t ƒ Wq[q[Xq= Xq= Wd S( Ns! Started sftp server on channel %ss EOF -- end of sessions Exception on channel: s Exception in server processing: ( R R t DEBUGt reprt _send_server_versionR t session_startedt Truet _read_packett EOFErrort Exceptiont strR t tb_stringst Messaget get_intt _processt _send_statust SFTP_FAILURE( R R R R t tt datat eR# t request_number( ( s8 /usr/lib/python2.6/site-packages/paramiko/sftp_server.pyt start_subsystemT s4 c C s~ | i i ƒ t t | ƒ i ƒ x! | i i ƒ D] } | i ƒ q0 Wx! | i i ƒ D] } | i ƒ qT Wh | _ h | _ d S( N( R t session_endedR R t finish_subsystemR t itervaluest closeR ( R t f( ( s8 /usr/lib/python2.6/site-packages/paramiko/sftp_server.pyR: p s c C sB | t i j o t S| t i j p | t i j o t St Sd S( s Convert an errno value (as from an C{OSError} or C{IOError}) into a standard SFTP result code. This is a convenience function for trapping exceptions in server code and returning an appropriate result. @param e: an errno code, as from C{OSError.errno}. @type e: int @return: an SFTP error code like L{SFTP_NO_SUCH_FILE}. @rtype: int N( t errnot EACCESt SFTP_PERMISSION_DENIEDt ENOENTt ENOTDIRt SFTP_NO_SUCH_FILER3 ( R6 ( ( s8 /usr/lib/python2.6/site-packages/paramiko/sftp_server.pyt convert_errno{ s c C sÍ t i d j oZ | i | i @o t i | | i ƒ n | i | i @o t i | | i | i ƒ qj n | i | i @o t i | | i | i f ƒ n | i | i @o t | d ƒ i | i ƒ n d S( sn Change a file's attributes on the local filesystem. The contents of C{attr} are used to change the permissions, owner, group ownership, and/or modification & access time of the file, depending on which attributes are present in C{attr}. This is meant to be a handy helper function for translating SFTP file requests into local file operations. @param filename: name of the file to alter (should usually be an absolute path). @type filename: str @param attr: attributes to change. @type attr: L{SFTPAttributes} t win32s w+N( t syst platformt _flagst FLAG_PERMISSIONSt ost chmodt st_modet FLAG_UIDGIDt chownt st_uidt st_gidt FLAG_AMTIMEt utimet st_atimet st_mtimet FLAG_SIZEt opent truncatet st_size( t filenamet attr( ( s8 /usr/lib/python2.6/site-packages/paramiko/sftp_server.pyt set_file_attr s ! c G sû t ƒ } | i | ƒ xÈ | D]À } t | ƒ t j o | i | ƒ q t | ƒ t j o | i | ƒ q t | ƒ t j o | i | ƒ q t | ƒ t j o | i | ƒ q t d t | ƒ d t t | ƒ ƒ ƒ ‚ q W| i | t | ƒ ƒ d S( Ns unknown type for s type ( R/ t add_intR t intt longt add_int64R- t add_stringt SFTPAttributest _packR, R&