Move the is_known_pipename check into np_open
authorVolker Lendecke <vl@samba.org>
Sat, 25 Oct 2008 13:23:36 +0000 (15:23 +0200)
committerVolker Lendecke <vl@samba.org>
Sat, 25 Oct 2008 13:23:36 +0000 (15:23 +0200)
source3/rpc_server/srv_pipe_hnd.c
source3/smbd/nttrans.c
source3/smbd/pipes.c

index aaa355790d49f7d89f6aac48ae9986e950e2ce69..822d50aa54ca46df6bbb5b6cda0fadd75901fcd6 100644 (file)
@@ -925,6 +925,12 @@ NTSTATUS np_open(struct smb_request *smb_req, struct connection_struct *conn,
        struct files_struct *fsp;
        struct pipes_struct *p;
 
+       /* See if it is one we want to handle. */
+
+       if (!is_known_pipename(name)) {
+               return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+       }
+
        status = file_new(smb_req, conn, &fsp);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("file_new failed: %s\n", nt_errstr(status)));
index b78c946388eff77de8e12ef11b802108eb5fd240..30841686fb4139470bfe174b2aa70ce697c7246c 100644 (file)
@@ -276,21 +276,16 @@ static void nt_open_pipe(char *fname, connection_struct *conn,
 
        DEBUG(4,("nt_open_pipe: Opening pipe %s.\n", fname));
 
-       /* See if it is one we want to handle. */
-
-       if (!is_known_pipename(fname)) {
-               reply_botherror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND,
-                               ERRDOS, ERRbadpipe);
-               return;
-       }
-
        /* Strip \\ off the name. */
        fname++;
 
-       DEBUG(3,("nt_open_pipe: Known pipe %s opening.\n", fname));
-
        status = np_open(req, conn, fname, &fsp);
        if (!NT_STATUS_IS_OK(status)) {
+               if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
+                       reply_botherror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND,
+                                       ERRDOS, ERRbadpipe);
+                       return;
+               }
                reply_nterror(req, status);
                return;
        }
index 25a1fe2e634045259cc00b118ffff0eb33eb5a5e..d971e9dc6201941da435e5d21a41e073780fead2 100644 (file)
@@ -66,13 +66,6 @@ void reply_open_pipe_and_X(connection_struct *conn, struct smb_request *req)
 
        DEBUG(4,("Opening pipe %s.\n", pipe_name));
 
-       /* See if it is one we want to handle. */
-       if (!is_known_pipename(pipe_name)) {
-               reply_botherror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND,
-                               ERRDOS, ERRbadpipe);
-               return;
-       }
-
        /* Strip \PIPE\ off the name. */
        fname = pipe_name + PIPELEN;
 
@@ -86,12 +79,13 @@ void reply_open_pipe_and_X(connection_struct *conn, struct smb_request *req)
        }
 #endif
 
-       /* Known pipes arrive with DIR attribs. Remove it so a regular file */
-       /* can be opened and add it in after the open. */
-       DEBUG(3,("Known pipe %s opening.\n",fname));
-
        status = np_open(req, conn, fname, &fsp);
        if (!NT_STATUS_IS_OK(status)) {
+               if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
+                       reply_botherror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND,
+                                       ERRDOS, ERRbadpipe);
+                       return;
+               }
                reply_nterror(req, status);
                return;
        }