Export (0) Print
Expand All
Expand Minimize

3.3.5.35 Receiving an SMB_COM_OPEN_ANDX Request

Upon receipt of an SMB_COM_OPEN_ANDX Request (section 2.2.4.41.1), the server MUST validate the TID and UID, as defined in section 3.3.5.2.

If the ShareType property of the Server.Share specified by the SMB_Header.TID is equal to Named Pipe and if Server.Session.IsAnonymous is TRUE, the server MUST invoke the event specified in [MS-SRVS] section 3.1.6.17 by providing the SMB_Parameters.Words.FileName field with the "\PIPE\" prefix removed as input parameter. If the event returns FALSE, indicating that no matching named pipe is found that allows an anonymous user, the server MUST fail the request with STATUS_ACCESS_DENIED and MUST increase Server.Statistics.sts0_permerrors by 1. Otherwise, the server MUST continue the open processing.

The server MUST search within the share indicated by the Server.Share identified by the SMB_Header.TID for an object with matching SMB_Parameters.Words.FileName.<293>

If a matching file is found and:

  • The user indicated by the Server.Session.UserSecurityContext identified by UID has sufficient privileges to open the file with AccessMode access;

  • The file is not currently open in a conflicting mode, and:

    • The FileExistsOpts flag in the OpenMode field is 0, the server SHOULD fail the request with error code STATUS_OBJECT_NAME_COLLISION.

    • The FileExistsOpts flag is 1, the server permits opening the file in append mode.

    • The FileExistsOpts flag is 2, the server permits overwriting the file.

If no matching file is found, but:

  • Server.Share represents a disk share;

  • Server.Session.UserSecurityContext has sufficient privileges to create and open the file with AccessMode access;

  • The CreateFile flag in the OpenMode field is 0, the server SHOULD<294> fail the file creation and return STATUS_OS2_INVALID_ACCESS (ERRDOS/ERRbadaccess).

  • The CreateFile flag in the OpenMode field is 1, the server permits file creation.

The server MUST attempt to create the file with the attributes specified in FileAttrs. If CreationTime is nonzero, then the creation time of the file MUST be set to the value of CreationTime.

If the underlying object store returns STATUS_ACCESS_DENIED, the server MUST increase Server.Statistics.sts0_permerrors by 1.

If the file cannot be opened, the server MUST return an error response.<295>

If the command is successful, the server MUST increase Server.Statistics.sts0_fopens by 1 and MUST allocate an Open object and insert it into Server.Connection.FileOpenTable with the following default values:

  • A new FID MUST be created to uniquely identify this Open in Server.Connection.FileOpenTable.

  • If Server.EnableOplock is TRUE and a requested OpLock was granted, the type of OpLock MUST be set in Server.Open.OpLock and Server.Open.OplockState MUST be set to Held; otherwise, Server.Open.OpLock MUST be set to None and Server.Open.OplockState MUST be set to None.

  • Server.Open.TreeConnect MUST be set to the TreeConnect on which the open request was performed, and Server.Open.TreeConnect.OpenCount MUST be increased by 1.

  • Server.Open.Session MUST be set to Server.Open.TreeConnect.Session.

  • Server.Open.Connection MUST be set to the Server.Open.Session.Connection.

  • Server.Open.Locks MUST be set to an empty list.

  • Server.Open.PID MUST be set to the PID provided in the request.

  • Server.Open.PathName MUST be set to the FileName field of the request.

  • Server.Open.GrantedAccess MUST be set to the AccessMode field of the request.

The server MUST register the Open by invoking the event Server Registers a New Open ([MS-SRVS] section 3.1.6.4) and MUST assign the return value to Server.Open.FileGlobalId.

The server MUST instantiate an SMB_COM_OPEN_ANDX Response (section 2.2.4.41.2) message and MUST set SMB_Header.Status to indicate success.<296>

If the REQ_ATTRIB flag is set in the SMB_Parameters.Words.Flags field of the request, the values of the following response fields MUST be filled in by the server; otherwise, they SHOULD be set to zero and MUST be ignored by the client:

  • FileAttrs

  • LastWriteTime

  • FileDataSize

  • AccessRights

  • ResourceType

  • NMPipeStatus

  • OpenResults

If the REQ_OPLOCK flag is set in the SMB_Parameters.Words.Flags field of the request, the client requests an exclusive OpLock. If REQ_OPLOCK_BATCH is also set, the client requests a batch OpLock. If the OpLock is granted, the LockStatus bit in the OpenResults field of the response MUST be set.

The response MUST be sent to the client as specified in section 3.3.4.1.

 
Show:
© 2015 Microsoft