s3:smbd: move all globals and static variables in globals.[ch]
[tprouty/samba.git] / source3 / smbd / service.c
index 0b851f1e481b71a3b743474ae65fedcd8c561d05..dcdd69f997cea0861ec7c539751ab31740331384 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include "includes.h"
+#include "smbd/globals.h"
 
 extern userdom_struct current_user_info;
 
@@ -167,8 +168,6 @@ bool set_conn_connectpath(connection_struct *conn, const char *connectpath)
 
 bool set_current_service(connection_struct *conn, uint16 flags, bool do_chdir)
 {
-       static connection_struct *last_conn;
-       static uint16 last_flags;
        int snum;
 
        if (!conn)  {
@@ -235,6 +234,10 @@ static int load_registry_service(const char *servicename)
                return -1;
        }
 
+       if ((servicename == NULL) || (*servicename == '\0')) {
+               return -1;
+       }
+
        if (strequal(servicename, GLOBAL_NAME)) {
                return -2;
        }
@@ -1123,38 +1126,6 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
        return NULL;
 }
 
-/***************************************************************************************
- Simple wrapper function for make_connection() to include a call to 
- vfs_chdir()
- **************************************************************************************/
-connection_struct *make_connection_with_chdir(const char *service_in,
-                                             DATA_BLOB password, 
-                                             const char *dev, uint16 vuid,
-                                             NTSTATUS *status)
-{
-       connection_struct *conn = NULL;
-       
-       conn = make_connection(service_in, password, dev, vuid, status);
-       
-       /*
-        * make_connection() does not change the directory for us any more
-        * so we have to do it as a separate step  --jerry
-        */
-        
-       if ( conn && vfs_ChDir(conn,conn->connectpath) != 0 ) {
-               DEBUG(0,("make_connection_with_chdir: Can't change "
-                        "directory to %s for [print$] (%s)\n",
-                        conn->connectpath,strerror(errno)));
-               yield_connection(conn, lp_servicename(SNUM(conn)));
-               conn_free(conn);
-               *status = NT_STATUS_UNSUCCESSFUL;
-               return NULL;
-       }
-       
-       return conn;
-}
-
 /****************************************************************************
  Make a connection to a service.
  *
@@ -1296,10 +1267,9 @@ connection_struct *make_connection(const char *service_in, DATA_BLOB password,
 
 void close_cnum(connection_struct *conn, uint16 vuid)
 {
-       if (IS_IPC(conn)) {
-               pipe_close_conn(conn);
-       } else {
-               file_close_conn(conn);
+       file_close_conn(conn);
+
+       if (!IS_IPC(conn)) {
                dptr_closecnum(conn);
        }