Back to product page

ServiceRequest method


Called when user requests some service from the server.

Type

None

Syntax

  • Basic
object.ServiceRequest Owner, User, ServiceIndex, ServiceType, ServicePath, Action    
The ServiceRequest(object,Owner,User,ServiceIndex,ServiceType,ServicePath,Action) syntax has these parts:
objectAn expression evaluating to an object of type IwodSSHDNotify.
OwnerA wodSSHDcom object. Instance of wodSSHServer that called this notification method.
UserA SSHUser object.
ServiceIndexAn Integer value. Index of new service, starts from 0.
ServiceTypeA SSHServiceTypes enumeration, as described in settings. Type of the service.
ServicePathA String value. Full path to the program that will be executed.
ActionA SSHActions enumeration, as described in settings. Determines if user is allowed to use a service, or not.

Remarks

Constant Value Description
stNone0 No service.
stShell 1 Command prompt.
stExecute2 Execute program.
stSubsystem 3 External subsystem.
stPortForwarding4 Port forwarding.
ReasonMacError 5 Mac error.
ReasonCompessionError6 Compression error.
ReasonServiceNotAvailable 7 Service not available.
ReasonProtocolVersionNotSupported8 Protocol version not supported.
ReasonHostKeyNotVerifiable 9 Host key not verifiable.
ReasonConnectionLost10 Connection lost.
ReasonDisconnectByApplication 11 Disconnect by application.
ReasonTooManyConnections12 Too many connections.
ReasonAuthCancelledByUser 13 Authentication cancelled by user.
ReasonNoMoreAuthMethodsAvailable14 No more authentication methods available.
ReasonIllegalUserName15 Illegal user name.


The settings for Action are:

Constant Value Description
Deny0 Deny execution of the action.
Allow 1 Allow to execute action.


This method is called only if you implemented IwodSSHNotify interface in your application, and wodSSHD.Notification property has received reference to instance of your implementation.

ServiceRequest is called after successful authentication of the user with your server. At this point (but also it is possible later to occur) user will request some service, such as to execute shell or some program on your system, or to start SFTP server (implemented internally by wodSSHD). Most important thing you should do is to decide whether you will allow the user to use requested service, or not. If you allow such request, set Action variable to Allow, otherwise set it to Deny.

You should make your choices based mostly on ServiceType argument, so make sure to check its value. It will never contain stNone constant, because such service is not known by the client (client cannot request 'no new service'). However, it is possible that you change it to stNone if client requests, for example, stShell. You may do is if you don't want client to see shell command prompt, but rather to see some dialog your prepared for him.

It is also possible to redirect shShell requests to stExecute. For example, user requests the shell, but you set ServiceType to stExecute, and point ServicePath to some program and the client will never know the difference. This is very practical when you want clients to use some restricted environments, such as BBS (bulletin board systems) or similar.

It makes no sense to change ServiceType if, for example, SFTP subsystem was requested. You can change it to something else, like stNone, but since the client is not prepared to accept data in different format than requested, it will most probably disconnect after first received (unknown) packet.

ServicePath variable will hold information about actual EXE file that will be executed for this service. For stShell it will point to your CMD.EXE file (on Windows 9x this will be COMMAND.COM), and for stExecute it will point to file user requested. Be sure to check this value so you don't allow user to execute just anything.

Since version 1.1.1 you can change any of requested services to stPortForwarding - to force redirection of the service to external system. For example, you might want to redirect stShell requests to some other UNIX system's TELNET protocol service, etc. When you do this, wodSSHServer will call PortForwardRequest notification method with RemoteHost="" and RemotePort=0 arguments, where you must change them to redirect to the service you want.

Since version 1.2.4. SCP transfers can be used also. When client tries to SCP (secure copy) file to/from wodSSHServer, ServiceRequest will contain stSCP value in ServiceType argument. After you accept it, SftpDownloadFile or SftpUploadFile notification methods will be called providing you with information about file that is to be downloaded/uploaded. /tr

Platforms

Windows