/**************************************************************************** close all conn structures ****************************************************************************/ void conn_close_all(void) { connection_struct *conn, *next; for (conn=Connections;conn;conn=next) { next=conn->next; close_cnum(conn, (uint16)-1); } }
void conn_close_all(void) { connection_struct *conn, *next; for (conn=Connections;conn;conn=next) { next=conn->next; set_current_service(conn, 0, True); close_cnum(conn, conn->vuid); } }
/**************************************************************************** receive a smbcontrol message to forcibly unmount a share the message contains just a share name and all instances of that share are unmounted the special sharename '*' forces unmount of all shares ****************************************************************************/ void msg_force_tdis(int msg_type, pid_t pid, void *buf, size_t len) { connection_struct *conn, *next; fstring sharename; fstrcpy(sharename, buf); if (strcmp(sharename, "*") == 0) { DEBUG(1,("Forcing close of all shares\n")); conn_close_all(); return; } for (conn=Connections;conn;conn=next) { next=conn->next; if (strequal(lp_servicename(conn->service), sharename)) { DEBUG(1,("Forcing close of share %s cnum=%d\n", sharename, conn->cnum)); close_cnum(conn, (uint16)-1); } } }
static int smbd_smb2_tcon_destructor(struct smbd_smb2_tcon *tcon) { if (tcon->session == NULL) { return 0; } idr_remove(tcon->session->tcons.idtree, tcon->tid); DLIST_REMOVE(tcon->session->tcons.list, tcon); SMB_ASSERT(tcon->session->sconn->num_tcons_open > 0); tcon->session->sconn->num_tcons_open--; if (tcon->compat_conn) { set_current_service(tcon->compat_conn, 0, true); close_cnum(tcon->compat_conn, tcon->session->vuid); } tcon->compat_conn = NULL; tcon->tid = 0; tcon->session = NULL; return 0; }
NTSTATUS smbXsrv_tcon_disconnect(struct smbXsrv_tcon *tcon, uint64_t vuid) { struct smbXsrv_tcon_table *table; struct db_record *local_rec = NULL; struct db_record *global_rec = NULL; NTSTATUS status; NTSTATUS error = NT_STATUS_OK; if (tcon->table == NULL) { return NT_STATUS_OK; } table = tcon->table; tcon->table = NULL; tcon->status = NT_STATUS_NETWORK_NAME_DELETED; global_rec = tcon->global->db_rec; tcon->global->db_rec = NULL; if (global_rec == NULL) { uint8_t key_buf[SMBXSRV_TCON_GLOBAL_TDB_KEY_SIZE]; TDB_DATA key; key = smbXsrv_tcon_global_id_to_key( tcon->global->tcon_global_id, key_buf); global_rec = dbwrap_fetch_locked(table->global.db_ctx, tcon->global, key); if (global_rec == NULL) { DEBUG(0, ("smbXsrv_tcon_disconnect(0x%08x, '%s'): " "Failed to lock global key '%s'\n", tcon->global->tcon_global_id, tcon->global->share_name, hex_encode_talloc(global_rec, key.dptr, key.dsize))); error = NT_STATUS_INTERNAL_ERROR; } } if (global_rec != NULL) { status = dbwrap_record_delete(global_rec); if (!NT_STATUS_IS_OK(status)) { TDB_DATA key = dbwrap_record_get_key(global_rec); DEBUG(0, ("smbXsrv_tcon_disconnect(0x%08x, '%s'): " "failed to delete global key '%s': %s\n", tcon->global->tcon_global_id, tcon->global->share_name, hex_encode_talloc(global_rec, key.dptr, key.dsize), nt_errstr(status))); error = status; } } TALLOC_FREE(global_rec); local_rec = tcon->db_rec; if (local_rec == NULL) { uint8_t key_buf[SMBXSRV_TCON_LOCAL_TDB_KEY_SIZE]; TDB_DATA key; key = smbXsrv_tcon_local_id_to_key(tcon->local_id, key_buf); local_rec = dbwrap_fetch_locked(table->local.db_ctx, tcon, key); if (local_rec == NULL) { DEBUG(0, ("smbXsrv_tcon_disconnect(0x%08x, '%s'): " "Failed to lock local key '%s'\n", tcon->global->tcon_global_id, tcon->global->share_name, hex_encode_talloc(local_rec, key.dptr, key.dsize))); error = NT_STATUS_INTERNAL_ERROR; } } if (local_rec != NULL) { status = dbwrap_record_delete(local_rec); if (!NT_STATUS_IS_OK(status)) { TDB_DATA key = dbwrap_record_get_key(local_rec); DEBUG(0, ("smbXsrv_tcon_disconnect(0x%08x, '%s'): " "failed to delete local key '%s': %s\n", tcon->global->tcon_global_id, tcon->global->share_name, hex_encode_talloc(local_rec, key.dptr, key.dsize), nt_errstr(status))); error = status; } table->local.num_tcons -= 1; } if (tcon->db_rec == NULL) { TALLOC_FREE(local_rec); } tcon->db_rec = NULL; if (tcon->compat) { bool ok; ok = set_current_service(tcon->compat, 0, true); if (!ok) { status = NT_STATUS_INTERNAL_ERROR; DEBUG(0, ("smbXsrv_tcon_disconnect(0x%08x, '%s'): " "set_current_service() failed: %s\n", tcon->global->tcon_global_id, tcon->global->share_name, nt_errstr(status))); tcon->compat = NULL; return status; } close_cnum(tcon->compat, vuid); tcon->compat = NULL; } return error; }