The Trunk: Network-tpr.226.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Network-tpr.226.mcz

commits-2
tim Rowledge uploaded a new version of Network to project The Trunk:
http://source.squeak.org/trunk/Network-tpr.226.mcz

==================== Summary ====================

Name: Network-tpr.226
Author: tpr
Time: 22 May 2018, 5:17:49.262652 pm
UUID: ca28ea3c-7b03-4b6e-b1ad-26c1c2efa2ba
Ancestors: Network-ul.225

If one has a server directory included in the FileList but do not enter the password when it is requested, a never ending cycle can be entered. The
#poenFTPClient method will ask if yu want to give up and if you do, will try open a notifier. Either proceeding or abandoning will just throw you back into the drug den of horror.

A simple improvement - though not really a full solution - is to not open the notifier. At least that way you get back to the real world.

Added comment to explain a little of this in  FTPClient>login, which is where the real problem lies; the rather odd seeming decision that #requestPassword: should return an empty string on cancel means that we can never tell whether the intent was an actual empty password (permitted and used in some places) or a cancellation. As it is, the login is attempted (and takes up user time) with the empty string, and if that fails to login correctly, the user is asked if they meant to cancel. This is a very poor UI. Much ncer would be for a cancellation to be recognised correctly and for things to be, well, cancelled.
There aren't really any good reasons for returning an in-band value when an out-of-band action was requested. It's also not the best of ideas for non-UI systems to be explicitly requesting UI actions rather than using a more indirect method such as exception raising.

=============== Diff against Network-ul.225 ===============

Item was changed:
  ----- Method: FTPClient>>login (in category 'private') -----
  login
 
  self initiateSession.
 
  self user ifNil: [^self].
 
  ["repeat both USER and PASS since some servers require it"
  self sendCommand: 'USER ', self user.
 
  "331 Password required"
  self lookForCode: 331.
+
+ self sendCommand: 'PASS ', self password."will ask user, if needed. An extra delight is that either accepting an empty string or cancelling the dialog will return an empty string. So how do we know whether to try to log in with an empty password or give up?"
- "will ask user, if needed"
- self sendCommand: 'PASS ', self password.
 
  "230 User logged in"
  ([self lookForCode: 230.]
  on: TelnetProtocolError
  do: [false]) == false
  ] whileTrue: [
  (LoginFailedException protocolInstance: self) signal: self lastResponse]
 
  !

Item was changed:
  ----- Method: ServerDirectory>>openFTPClient (in category 'dis/connect') -----
  openFTPClient
 
  | loginSuccessful |
  client
  ifNotNil: [client isConnected
  ifTrue: [^client]
  ifFalse: [client := nil]].
  client := FTPClient openOnHostNamed: server.
  loginSuccessful := false.
  [loginSuccessful]
  whileFalse: [
  [loginSuccessful := true.
  client loginUser: self user password: self password]
  on: LoginFailedException
  do: [:ex |
  | what |
  passwordHolder := nil.
  what := UIManager default
  chooseFrom: #('enter password' 'give up')
  title: 'Would you like to try another password?'.
+ what = 1 ifFalse: [ ^nil].
- what = 1 ifFalse: [self error: 'Login failed.'. ^nil].
  loginSuccessful := false]].
  client changeDirectoryTo: directory.
  ^client!