Overview
| Artifact ID: | 1b5fdb36d5b0b29c4b2dd16ec0e453f5c81695ab7279788e6854dd862e825b8b |
|---|---|
| Ticket: | 3fff267fc4318b7a8bd2417f74f68d33a8788d89 |
| Date: | 2018-11-06 10:31:37 |
| User: | anonymous |
| Artifact Attached: | e6a8c0605cac62b28ce85c2c72c4643c4673fca804e0a09160ac6859cebf5570 |
| Filename: | diff.txt |
| Description: |
Content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299--- /opt/tclrad/lib/tcllib1.19/ftp/ftp.tcl 2017-08-08 01:35:08.000000000 +0200 +++ ./ftp.tcl 2018-11-06 11:28:44.438296964 +0100 @@ -319,6 +319,9 @@ # still readable, still eof). [SF Tcllib Bug 15822535]. set rc 421 + if { [info exists ftp(Tls)] } { + catch {tls::unimport $ftp(CtrlSock)} + } catch {close $ftp(CtrlSock)} catch {unset ftp(CtrlSock)} catch {unset ftp(state.data)} @@ -361,9 +364,17 @@ if {$VERBOSE} { DisplayMsg $s StateBegin////////($ftp(State)) } switch -exact -- $ftp(State) { + tls { + PutsCtrlSock $s "AUTH TLS" + set ftp(State) user + Command $ftp(Command) tls + } user { - switch -exact -- $rc { + switch -exact -- $rc { 2 { + if { [info exists ftp(Tls)] } { + tls::import $ftp(CtrlSock) + } PutsCtrlSock $s "USER $ftp(User)" set ftp(State) passwd Command $ftp(Command) user @@ -380,10 +391,14 @@ 2 { set complete_with 1 Command $ftp(Command) password - } + } 3 { PutsCtrlSock $s "PASS $ftp(Passwd)" - set ftp(State) connect + if { [info exists ftp(Tls)] } { + set ftp(State) opts + } else { + set ftp(State) connect + } Command $ftp(Command) password } default { @@ -393,6 +408,42 @@ } } } + opts { + switch -exact -- $rc { + 2 { + PutsCtrlSock $s "OPTS UTF8 ON" + set ftp(State) pbsz + } default { + set errmsg "Error connecting! $msgtext" + set complete_with 0 + Command $ftp(Command) error $msgtext + } + } + } + pbsz { + switch -exact -- $rc { + 2 { + PutsCtrlSock $s "PBSZ 0" + set ftp(State) prot + } default { + set errmsg "Error connecting! $msgtext" + set complete_with 0 + Command $ftp(Command) error $msgtext + } + } + } + prot { + switch -exact -- $rc { + 2 { + PutsCtrlSock $s "PROT P" + set ftp(State) connect + } default { + set errmsg "Error connecting! $msgtext" + set complete_with 0 + Command $ftp(Command) error $msgtext + } + } + } connect { switch -exact -- $rc { 2 { @@ -552,6 +603,9 @@ switch -exact -- $rc { 1 - 2 { + if { [info exists ftp(Tls)] } { + tls::handshake $ftp(DataSock) + } set ftp(State) list_close } default { @@ -801,6 +855,9 @@ switch -exact -- $rc { 1 - 2 { + if { [info exists ftp(Tls)] } { + tls::handshake $ftp(DataSock) + } set ftp(State) put_close } default { @@ -879,6 +936,9 @@ append_sent { switch -exact -- $rc { 1 { + if { [info exists ftp(Tls)] } { + tls::handshake $ftp(DataSock) + } set ftp(State) append_close } default { @@ -969,6 +1029,9 @@ reget_sent { switch -exact -- $rc { 1 { + if { [info exists ftp(Tls)] } { + tls::handshake $ftp(DataSock) + } set ftp(State) reget_close } default { @@ -1043,6 +1106,9 @@ get_sent { switch -exact -- $rc { 1 { + if { [info exists ftp(Tls)] } { + tls::handshake $ftp(DataSock) + } set ftp(State) get_close } default { @@ -2392,6 +2458,9 @@ # wait for synchronization WaitOrTimeout $s + if { [info exists ftp(Tls)] } { + catch {tls::unimport $ftp(CtrlSock)} + } catch {close $ftp(CtrlSock)} catch {unset ftp} return 1 @@ -2495,7 +2564,7 @@ set ftp(state.control) "" # Get and set possible options - set options {-blocksize -timeout -mode -port -progress -output -command} + set options {-blocksize -timeout -mode -port -progress -output -command -tls} foreach {option value} $args { if { [lsearch -exact $options $option] != "-1" } { if { $DEBUG } { @@ -2517,6 +2586,10 @@ return $connections($ftp(User),$ftp(Passwd),$ftp(RemoteHost)) } + if { [info exists ftp(Tls)] } { + uplevel #0 [list package require tls] + set ftp(State) tls + } # No call of StateHandler is required at this time. # StateHandler at first time is called automatically @@ -2602,8 +2675,14 @@ # from the caller. Closing it is not our responsibility in that case. if {![info exists ftp(get:channel)]} { + if { [info exists ftp(Tls)] } { + catch {tls::unimport $ftp(DestCI)} + } catch {close $ftp(DestCI)} } + if { [info exists ftp(Tls)] } { + catch {tls::unimport $ftp(SourceCI)} + } catch {close $ftp(SourceCI)} catch {unset ftp(state.data)} DisplayMsg $s $error error @@ -2613,8 +2692,14 @@ # from the caller. Closing it is not our responsibility in that case. if {![info exists ftp(get:channel)]} { + if { [info exists ftp(Tls)] } { + catch {tls::unimport $ftp(DestCI)} + } close $ftp(DestCI) } + if { [info exists ftp(Tls)] } { + catch {tls::unimport $ftp(SourceCI)} + } close $ftp(SourceCI) catch {unset ftp(state.data)} if { $VERBOSE } { @@ -2732,6 +2817,9 @@ set ftp(List) [append ftp(List) $buffer] } } else { + if { [info exists ftp(Tls)] } { + catch {tls::unimport $sock} + } close $sock catch {unset ftp(state.data)} if { $VERBOSE } { @@ -2766,6 +2854,9 @@ incr ftp(Total) [string length $buffer] } } else { + if { [info exists ftp(Tls)] } { + catch {tls::unimport $sock} + } close $sock catch {unset ftp(state.data)} if { $VERBOSE } { @@ -2797,6 +2888,9 @@ set substr [string range $ftp(PutData) $ftp(Total) \ [expr {$ftp(Total) + $ftp(Blocksize)}]] if {[catch {puts -nonewline $sock "$substr"} result]} { + if { [info exists ftp(Tls)] } { + catch {tls::unimport $sock} + } close $sock catch {unset ftp(state.data)} if { $VERBOSE } { @@ -2807,6 +2901,9 @@ } } else { fileevent $sock writable {} + if { [info exists ftp(Tls)] } { + catch {tls::unimport $sock} + } close $sock catch {unset ftp(state.data)} if { $VERBOSE } { @@ -2842,9 +2939,21 @@ catch { unset ftp(AC) } catch {after cancel $ftp(Wait)} catch {fileevent $ftp(DataSock) readable {}} + if { [info exists ftp(Tls)] } { + catch {tls::unimport $ftp(DataSock)} + } catch {close $ftp(DataSock); unset ftp(DataSock)} + if { [info exists ftp(Tls)] } { + catch {tls::unimport $ftp(DestCI)} + } catch {close $ftp(DestCI); unset ftp(DestCI)} + if { [info exists ftp(Tls)] } { + catch {tls::unimport $ftp(SourceCI)} + } catch {close $ftp(SourceCI); unset ftp(SourceCI)} + if { [info exists ftp(Tls)] } { + catch {tls::unimport $ftp(DummySock)} + } catch {close $ftp(DummySock); unset ftp(DummySock)} return } @@ -2867,6 +2976,7 @@ upvar ::ftp::ftp$s ftp variable VERBOSE + if { $VERBOSE } { DisplayMsg $s "D: New Connection from $addr:$port" data DisplayMsg $s "D: Sequencer state $ftp(State)" data @@ -2930,6 +3040,9 @@ DisplayMsg $s "D: ... Connection from $addr:$port ... initialized" data } + if { [info exists ftp(Tls)] } { + tls::import $sock + } # Marker for WaitDataConn set ftp(AC) 1 return @@ -3096,7 +3209,7 @@ } # configure control channel - + fconfigure $ftp(CtrlSock) -buffering line -blocking $block -translation {auto crlf} fileevent $ftp(CtrlSock) readable [list [namespace current]::StateHandler $s $ftp(CtrlSock)] @@ -3105,7 +3218,7 @@ if { $VERBOSE } { DisplayMsg $s "C: Connection to $ftp(RemoteHost):$ftp(Port)" control } - + return 1 }
