s3:smbd: move pending_auth_data list to struct smbd_server_connection
[kai/samba.git] / source3 / smbd / service.c
index dcdd69f997cea0861ec7c539751ab31740331384..75c19ce131f35aa83503b78c06b1a33ffbddd66b 100644 (file)
@@ -220,16 +220,6 @@ bool set_current_service(connection_struct *conn, uint16 flags, bool do_chdir)
 
 static int load_registry_service(const char *servicename)
 {
-       struct registry_key *key;
-       char *path;
-       WERROR err;
-
-       uint32 i;
-       char *value_name;
-       struct registry_value *value;
-
-       int res = -1;
-
        if (!lp_registry_shares()) {
                return -1;
        }
@@ -242,79 +232,22 @@ static int load_registry_service(const char *servicename)
                return -2;
        }
 
-       if (asprintf(&path, "%s\\%s", KEY_SMBCONF, servicename) == -1) {
-               return -1;
-       }
-
-       err = reg_open_path(NULL, path, REG_KEY_READ, get_root_nt_token(),
-                           &key);
-       SAFE_FREE(path);
-
-       if (!W_ERROR_IS_OK(err)) {
+       if (!process_registry_service(servicename)) {
                return -1;
        }
 
-       res = lp_add_service(servicename, -1);
-       if (res == -1) {
-               goto error;
-       }
-
-       for (i=0;
-            W_ERROR_IS_OK(reg_enumvalue(key, key, i, &value_name, &value));
-            i++) {
-               switch (value->type) {
-               case REG_DWORD: { 
-                       char *tmp;
-                       if (asprintf(&tmp, "%d", value->v.dword) == -1) {
-                               continue;
-                       }
-                       lp_do_parameter(res, value_name, tmp);
-                       SAFE_FREE(tmp);
-                       break;
-               }
-               case REG_SZ: {
-                       lp_do_parameter(res, value_name, value->v.sz.str);
-                       break;
-               }
-               default:
-                       /* Ignore all the rest */
-                       break;
-               }
-
-               TALLOC_FREE(value_name);
-               TALLOC_FREE(value);
-       }
-
- error:
-
-       TALLOC_FREE(key);
-       return res;
+       return lp_servicenumber(servicename);
 }
 
 void load_registry_shares(void)
 {
-       struct registry_key *key;
-       char *name;
-       WERROR err;
-       int i;
-
        DEBUG(8, ("load_registry_shares()\n"));
        if (!lp_registry_shares()) {
                return;
        }
 
-       err = reg_open_path(NULL, KEY_SMBCONF, REG_KEY_READ,
-                           get_root_nt_token(), &key);
-       if (!(W_ERROR_IS_OK(err))) {
-               return;
-       }
+       process_registry_shares();
 
-       for (i=0; W_ERROR_IS_OK(reg_enumkey(key, key, i, &name, NULL)); i++) {
-               load_registry_service(name);
-               TALLOC_FREE(name);
-       }
-
-       TALLOC_FREE(key);
        return;
 }
 
@@ -735,7 +668,7 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
                &conn->server_info);
 
        if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(0, ("create_connection_server_info failed: %s\n",
+               DEBUG(1, ("create_connection_server_info failed: %s\n",
                          nt_errstr(status)));
                *pstatus = status;
                conn_free(conn);
@@ -833,6 +766,14 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
                        *pstatus = status;
                        return NULL;
                }
+
+               /*
+                * We need to cache this gid, to use within
+                * change_to_user() separately from the conn->server_info
+                * struct. We only use conn->server_info directly if
+                * "force_user" was set.
+                */
+               conn->force_group_gid = conn->server_info->utok.gid;
        }
 
        conn->vuid = (vuser != NULL) ? vuser->vuid : UID_FIELD_INVALID;
@@ -1052,8 +993,8 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
           I have disabled this chdir check (tridge) */
        /* the alternative is just to check the directory exists */
        if ((ret = SMB_VFS_STAT(conn, conn->connectpath, &st)) != 0 ||
-           !S_ISDIR(st.st_mode)) {
-               if (ret == 0 && !S_ISDIR(st.st_mode)) {
+           !S_ISDIR(st.st_ex_mode)) {
+               if (ret == 0 && !S_ISDIR(st.st_ex_mode)) {
                        DEBUG(0,("'%s' is not a directory, when connecting to "
                                 "[%s]\n", conn->connectpath,
                                 lp_servicename(snum)));
@@ -1102,7 +1043,7 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
        if( DEBUGLVL( IS_IPC(conn) ? 3 : 1 ) ) {
                dbgtext( "%s (%s) ", get_remote_machine_name(),
                         conn->client_address );
-               dbgtext( "%s", srv_is_signing_active() ? "signed " : "");
+               dbgtext( "%s", srv_is_signing_active(smbd_server_conn) ? "signed " : "");
                dbgtext( "connect to service %s ", lp_servicename(snum) );
                dbgtext( "initially as user %s ",
                         conn->server_info->unix_name );