Browse Source

Server: Minor logging improvement

Tal Aloni 7 years ago
parent
commit
ebcb2cf20a

+ 7 - 7
SMBLibrary/Server/SMB1/ReadWriteResponseHelper.cs

@@ -42,7 +42,7 @@ namespace SMBLibrary.Server.SMB1
             header.Status = share.FileStore.ReadFile(out data, openFile.Handle, request.ReadOffsetInBytes, request.CountOfBytesToRead);
             if (header.Status != NTStatus.STATUS_SUCCESS)
             {
-                state.LogToServer(Severity.Verbose, "Read from '{0}{1}' failed. NTStatus: {2}.", share.Name, openFile.Path, header.Status);
+                state.LogToServer(Severity.Verbose, "Read from '{0}{1}' failed. NTStatus: {2}. (FID: {3})", share.Name, openFile.Path, header.Status, request.FID);
                 return new ErrorResponse(request.CommandName);
             }
 
@@ -67,7 +67,7 @@ namespace SMBLibrary.Server.SMB1
             {
                 if (!((FileSystemShare)share).HasReadAccess(session.SecurityContext, openFile.Path))
                 {
-                    state.LogToServer(Severity.Verbose, "ReadAndX from '{0}{1}' failed. User '{2}' was denied access.", share.Name, openFile.Path, session.UserName);
+                    state.LogToServer(Severity.Verbose, "Read from '{0}{1}' failed. User '{2}' was denied access.", share.Name, openFile.Path, session.UserName);
                     header.Status = NTStatus.STATUS_ACCESS_DENIED;
                     return new ErrorResponse(request.CommandName);
                 }
@@ -89,7 +89,7 @@ namespace SMBLibrary.Server.SMB1
             }
             else if (header.Status != NTStatus.STATUS_SUCCESS)
             {
-                state.LogToServer(Severity.Verbose, "Read from '{0}{1}' failed. NTStatus: {2}.", share.Name, openFile.Path, header.Status);
+                state.LogToServer(Severity.Verbose, "Read from '{0}{1}' failed. NTStatus: {2}. (FID: {3})", share.Name, openFile.Path, header.Status, request.FID);
                 return new ErrorResponse(request.CommandName);
             }
 
@@ -128,7 +128,7 @@ namespace SMBLibrary.Server.SMB1
             header.Status = share.FileStore.WriteFile(out numberOfBytesWritten, openFile.Handle, request.WriteOffsetInBytes, request.Data);
             if (header.Status != NTStatus.STATUS_SUCCESS)
             {
-                state.LogToServer(Severity.Verbose, "Write to '{0}{1}' failed. NTStatus: {2}.", share.Name, openFile.Path, header.Status);
+                state.LogToServer(Severity.Verbose, "Write to '{0}{1}' failed. NTStatus: {2}. (FID: {3})", share.Name, openFile.Path, header.Status, request.FID);
                 return new ErrorResponse(request.CommandName);
             }
             WriteResponse response = new WriteResponse();
@@ -151,7 +151,7 @@ namespace SMBLibrary.Server.SMB1
             {
                 if (!((FileSystemShare)share).HasWriteAccess(session.SecurityContext, openFile.Path))
                 {
-                    state.LogToServer(Severity.Verbose, "WriteAndX to '{0}{1}' failed. User '{2}' was denied access.", share.Name, openFile.Path, session.UserName);
+                    state.LogToServer(Severity.Verbose, "Write to '{0}{1}' failed. User '{2}' was denied access.", share.Name, openFile.Path, session.UserName);
                     header.Status = NTStatus.STATUS_ACCESS_DENIED;
                     return new ErrorResponse(request.CommandName);
                 }
@@ -161,7 +161,7 @@ namespace SMBLibrary.Server.SMB1
             header.Status = share.FileStore.WriteFile(out numberOfBytesWritten, openFile.Handle, (long)request.Offset, request.Data);
             if (header.Status != NTStatus.STATUS_SUCCESS)
             {
-                state.LogToServer(Severity.Verbose, "Write to '{0}{1}' failed. NTStatus: {2}.", share.Name, openFile.Path, header.Status);
+                state.LogToServer(Severity.Verbose, "Write to '{0}{1}' failed. NTStatus: {2}. (FID: {3})", share.Name, openFile.Path, header.Status, request.FID);
                 return new ErrorResponse(request.CommandName);
             }
             WriteAndXResponse response = new WriteAndXResponse();
@@ -195,7 +195,7 @@ namespace SMBLibrary.Server.SMB1
             header.Status = share.FileStore.FlushFileBuffers(openFile.Handle);
             if (header.Status != NTStatus.STATUS_SUCCESS)
             {
-                state.LogToServer(Severity.Verbose, "Flush '{0}{1}' failed. NTStatus: {2}.", share.Name, openFile.Path, header.Status);
+                state.LogToServer(Severity.Verbose, "Flush '{0}{1}' failed. NTStatus: {2}. (FID: {3})", share.Name, openFile.Path, header.Status, request.FID);
                 return new ErrorResponse(request.CommandName);
             }
             return new FlushResponse();

+ 3 - 3
SMBLibrary/Server/SMB2/ReadWriteResponseHelper.cs

@@ -37,7 +37,7 @@ namespace SMBLibrary.Server.SMB2
             NTStatus readStatus = share.FileStore.ReadFile(out data, openFile.Handle, (long)request.Offset, (int)request.ReadLength);
             if (readStatus != NTStatus.STATUS_SUCCESS)
             {
-                state.LogToServer(Severity.Verbose, "Read from '{0}{1}' failed. NTStatus: {2}.", share.Name, openFile.Path, readStatus);
+                state.LogToServer(Severity.Verbose, "Read from '{0}{1}' failed. NTStatus: {2}. (FileId: {3})", share.Name, openFile.Path, readStatus, request.FileId.Volatile);
                 return new ErrorResponse(request.CommandName, readStatus);
             }
             ReadResponse response = new ReadResponse();
@@ -68,7 +68,7 @@ namespace SMBLibrary.Server.SMB2
             NTStatus writeStatus = share.FileStore.WriteFile(out numberOfBytesWritten, openFile.Handle, (long)request.Offset, request.Data);
             if (writeStatus != NTStatus.STATUS_SUCCESS)
             {
-                state.LogToServer(Severity.Verbose, "Write to '{0}{1}' failed. NTStatus: {2}.", share.Name, openFile.Path, writeStatus);
+                state.LogToServer(Severity.Verbose, "Write to '{0}{1}' failed. NTStatus: {2}. (FileId: {3})", share.Name, openFile.Path, writeStatus, request.FileId.Volatile);
                 return new ErrorResponse(request.CommandName, writeStatus);
             }
             WriteResponse response = new WriteResponse();
@@ -88,7 +88,7 @@ namespace SMBLibrary.Server.SMB2
             NTStatus status = share.FileStore.FlushFileBuffers(openFile.Handle);
             if (status != NTStatus.STATUS_SUCCESS)
             {
-                state.LogToServer(Severity.Verbose, "Flush '{0}{1}' failed. NTStatus: {2}.", share.Name, openFile.Path, status);
+                state.LogToServer(Severity.Verbose, "Flush '{0}{1}' failed. NTStatus: {2}. (FileId: {3})", share.Name, openFile.Path, status, request.FileId.Volatile);
                 return new ErrorResponse(request.CommandName, status);
             }
             return new FlushResponse();