SecureBlackbox 2020 C++ Edition

Questions / Feedback?

OpenFile Event

This event instructs the application to handle the file open request.

Syntax

ANSI (Cross Platform)
virtual int FireOpenFile(SFTPServerOpenFileEventParams *e);
typedef struct {
int64 ConnectionID;
const char *Path;
int Modes;
int Access;
int OperationStatus;
char *Handle; int reserved; } SFTPServerOpenFileEventParams; Unicode (Windows) virtual INT FireOpenFile(SFTPServerOpenFileEventParams *e);
typedef struct {
LONG64 ConnectionID;
LPCWSTR Path;
INT Modes;
INT Access;
INT OperationStatus;
LPWSTR Handle; INT reserved; } SFTPServerOpenFileEventParams;
- (void)onOpenFile:(long long)connectionID :(NSString*)path :(int)modes :(int)access :(int*)operationStatus :(NSString**)handle;
#define EID_SFTPSERVER_OPENFILE 30

virtual INT SECUREBLACKBOX_CALL FireOpenFile(LONG64 &lConnectionID, LPSTR &lpszPath, INT &iModes, INT &iAccess, INT &iOperationStatus, LPSTR &lpszHandle);

Remarks

This event is fired when a file open request is received from the client and needs to be handled (virtualized) by the server. The ConnectionID parameter specifies in which session the request was received, and Path specifies the location of the file.

Modes can be a combination of one or several file open mode flags:

cfmRead1
cfmWrite2
cfmAppend4
cfmCreate8
cfmTruncate16
cfmExcl32
cfmText64
cfmOpenOrCreate128
cfmAppendAtomic256
cfmNoFollow512
cfmDeleteOnClose1024

Different client applications may provide different selections of mode flags. For example, some clients specify (cfmCreate + cfmTruncate) when overwriting files, whereas others would specify cfmOpenOrCreate. Please make sure your code is prepared to receive different combinations of flags here and handles them gracefully.

The Access parameter provides additional file access modifiers:

cfaReadLock1
cfaWriteLock2
cfaDeleteLock4
cfaBlockAdvisory8

These parameter may also contain a combination of the above flags. Access modifiers are only supported in SFTPv6, and in practice are rarely used by client applications.

The Handle string represents a unique identifier of the opened file, similar to file handles used in Windows or Unix APIs. Handles are unique across all files opened at the same time. Class generates handles automatically, but you can update the auto-generated values with your own in this event handler (just remember to keep them unique).

Set OperationStatus parameter in accordance with the outcome of the operation to one of the values given below:

ostOk1
ostNoSuchFile2
ostAccessDenied3
ostWriteProtect4
ostUnsupported5
ostInvalidParameter6
ostEOF7

Copyright (c) 2022 /n software inc. - All rights reserved.
SecureBlackbox 2020 C++ Edition - Version 20.0 [Build 8166]