IdRSHServer.pas 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. {
  2. $Project$
  3. $Workfile$
  4. $Revision$
  5. $DateUTC$
  6. $Id$
  7. This file is part of the Indy (Internet Direct) project, and is offered
  8. under the dual-licensing agreement described on the Indy website.
  9. (http://www.indyproject.org/)
  10. Copyright:
  11. (c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
  12. }
  13. {
  14. $Log$
  15. }
  16. {
  17. Rev 1.2 1/21/2004 3:27:22 PM JPMugaas
  18. InitComponent
  19. Rev 1.1 1/31/2003 02:32:14 PM JPMugaas
  20. Should now compile.
  21. Rev 1.0 11/13/2002 08:00:02 AM JPMugaas
  22. }
  23. unit IdRSHServer;
  24. {
  25. based on
  26. http://www.private.org.il/mini-tcpip.faq.html
  27. 2001, Feb 17 - J. Peter Mugaas
  28. based this unit on the simplied IdRexec unit with extremely
  29. minor modifications (the parameters for our event had to be modified
  30. to better represent what they are in this protocol. The only difference
  31. between this protocol and Rexec is that the server handles authoriation
  32. differently and the port is different. In RSH, authentication is usually
  33. done by refusing connections from ports which are NOT reserved, and from
  34. .rhosts files in Unix.
  35. WARNING:
  36. RSH should ONLY be considered for computer systems behind a firewall as there
  37. are no passwords and it is easy to falsify user names (you even have to evesdrop
  38. on network traffic to do it. Even then, you should consider other protocols.
  39. You assume any and all risks involved with RSH.
  40. !!!YOU HAVE BEEN WANRED!!!
  41. The only reason we provide this component is to complement the RSH client
  42. and it does have one merit (CVS is partly based on it). I personally have
  43. agonized over writing this component at all due to these risks.
  44. }
  45. interface
  46. {$i IdCompilerDefines.inc}
  47. uses
  48. IdAssignedNumbers, IdContext, IdRemoteCMDServer, IdTCPClient;
  49. const
  50. RSH_FORCEPORTSINRANGE = True;
  51. type
  52. TIdRSHCommandEvent = procedure (AThread: TIdContext;
  53. AStdError : TIdTCPClient; AClientUserName, AHostUserName, ACommand : String) of object;
  54. TIdRSHServer = class(TIdRemoteCMDServer)
  55. protected
  56. FOnCommand : TIdRSHCommandEvent;
  57. //
  58. procedure DoCMD(AThread: TIdContext;
  59. AStdError : TIdTCPClient; AParam1, AParam2, ACommand : String); override;
  60. procedure InitComponent; override;
  61. published
  62. property OnCommand : TIdRSHCommandEvent read FOnCommand write FOnCommand;
  63. property DefaultPort default IdPORT_cmd;
  64. property ForcePortsInRange : Boolean read FForcePortsInRange write FForcePortsInRange default RSH_FORCEPORTSINRANGE;
  65. end;
  66. implementation
  67. { TIdRSHServer }
  68. procedure TIdRSHServer.InitComponent;
  69. begin
  70. inherited;
  71. DefaultPort := IdPORT_cmd;
  72. FForcePortsInRange := RSH_FORCEPORTSINRANGE;
  73. FStdErrorPortsInRange := True;
  74. end;
  75. procedure TIdRSHServer.DoCMD(AThread: TIdContext;
  76. AStdError: TIdTCPClient; AParam1, AParam2, ACommand: String);
  77. begin
  78. if Assigned(FOnCommand) then begin
  79. FOnCommand(AThread,AStdError,AParam1,AParam2,ACommand);
  80. end;
  81. end;
  82. end.