/** \details Logoff an Exchange store This function uninitializes the MAPI session associated to the object. \param obj_store pointer to the store object \return MAPI_E_SUCCESS on success, otherwise MAPI_E_NOT_FOUND */ _PUBLIC_ enum MAPISTATUS Logoff(mapi_object_t *obj_store) { struct mapi_context *mapi_ctx; struct mapi_session *session; struct mapi_session *el; bool found = false; /* Sanity checks */ session = mapi_object_get_session(obj_store); OPENCHANGE_RETVAL_IF(!session, MAPI_E_INVALID_PARAMETER, NULL); mapi_ctx = session->mapi_ctx; OPENCHANGE_RETVAL_IF(!mapi_ctx, MAPI_E_NOT_INITIALIZED, NULL); for (el = mapi_ctx->session; el; el = el->next) { if (session == el) { found = true; mapi_object_release(obj_store); DLIST_REMOVE(mapi_ctx->session, el); MAPIFreeBuffer(session); break; } } return (found == true) ? MAPI_E_SUCCESS : MAPI_E_NOT_FOUND; }
/* mark all pending requests as dead - called when a socket error happens */ static void wrepl_socket_dead(struct wrepl_socket *wrepl_socket, NTSTATUS status) { wrepl_socket->dead = True; if (wrepl_socket->packet) { packet_recv_disable(wrepl_socket->packet); packet_set_fde(wrepl_socket->packet, NULL); packet_set_socket(wrepl_socket->packet, NULL); } if (wrepl_socket->event.fde) { talloc_free(wrepl_socket->event.fde); wrepl_socket->event.fde = NULL; } if (wrepl_socket->sock) { talloc_free(wrepl_socket->sock); wrepl_socket->sock = NULL; } if (NT_STATUS_EQUAL(NT_STATUS_UNSUCCESSFUL, status)) { status = NT_STATUS_UNEXPECTED_NETWORK_ERROR; } while (wrepl_socket->recv_queue) { struct wrepl_request *req = wrepl_socket->recv_queue; DLIST_REMOVE(wrepl_socket->recv_queue, req); wrepl_request_finished(req, status); } talloc_set_destructor(wrepl_socket, NULL); if (wrepl_socket->free_skipped) { talloc_free(wrepl_socket); } }
/* destroy a signal event */ static int tevent_signal_destructor(struct tevent_signal *se) { struct tevent_common_signal_list *sl; sl = talloc_get_type(se->additional_data, struct tevent_common_signal_list); if (se->event_ctx) { DLIST_REMOVE(se->event_ctx->signal_events, se); } talloc_free(sl); if (sig_state->sig_handlers[se->signum] == NULL) { /* restore old handler, if any */ if (sig_state->oldact[se->signum]) { sigaction(se->signum, sig_state->oldact[se->signum], NULL); sig_state->oldact[se->signum] = NULL; } #ifdef SA_SIGINFO if (se->sa_flags & SA_SIGINFO) { if (sig_state->sig_info[se->signum]) { talloc_free(sig_state->sig_info[se->signum]); sig_state->sig_info[se->signum] = NULL; } } #endif } return 0; }
static void process_blocking_lock_cancel_message(struct messaging_context *ctx, void *private_data, uint32_t msg_type, struct server_id server_id, DATA_BLOB *data) { NTSTATUS err; const char *msg = (const char *)data->data; struct blocking_lock_record *blr; if (data->data == NULL) { smb_panic("process_blocking_lock_cancel_message: null msg"); } if (data->length != MSG_BLOCKING_LOCK_CANCEL_SIZE) { DEBUG(0, ("process_blocking_lock_cancel_message: " "Got invalid msg len %d\n", (int)data->length)); smb_panic("process_blocking_lock_cancel_message: bad msg"); } memcpy(&blr, msg, sizeof(blr)); memcpy(&err, &msg[sizeof(blr)], sizeof(NTSTATUS)); DEBUG(10,("process_blocking_lock_cancel_message: returning error %s\n", nt_errstr(err) )); blocking_lock_reply_error(blr, err); DLIST_REMOVE(blocking_lock_cancelled_queue, blr); TALLOC_FREE(blr); }
/* close a file */ static NTSTATUS svfs_close(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_close *io) { struct svfs_private *p = ntvfs->private_data; struct svfs_file *f; if (io->generic.level != RAW_CLOSE_CLOSE) { /* we need a mapping function */ return NT_STATUS_INVALID_LEVEL; } f = find_fd(p, io->close.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } if (close(f->fd) == -1) { return map_nt_error_from_unix(errno); } DLIST_REMOVE(p->open_files, f); talloc_free(f->name); talloc_free(f); return NT_STATUS_OK; }
static int tevent_common_signal_list_destructor(struct tevent_common_signal_list *sl) { if (sig_state->sig_handlers[sl->se->signum]) { DLIST_REMOVE(sig_state->sig_handlers[sl->se->signum], sl); } return 0; }
int elog_close_tdb( ELOG_TDB *etdb, bool force_close ) { TDB_CONTEXT *tdb; if ( !etdb ) return 0; etdb->ref_count--; SMB_ASSERT( etdb->ref_count >= 0 ); if ( etdb->ref_count == 0 ) { tdb = etdb->tdb; DLIST_REMOVE( open_elog_list, etdb ); TALLOC_FREE( etdb ); return tdb_close( tdb ); } if ( force_close ) { tdb = etdb->tdb; etdb->tdb = NULL; return tdb_close( tdb ); } return 0; }
void fsp_free(files_struct *fsp) { struct smbd_server_connection *sconn = fsp->conn->sconn; DLIST_REMOVE(sconn->files, fsp); SMB_ASSERT(sconn->num_files > 0); sconn->num_files--; TALLOC_FREE(fsp->fake_file_handle); if (fsp->fh->ref_count == 1) { TALLOC_FREE(fsp->fh); } else { fsp->fh->ref_count--; } fsp->conn->num_files_open--; /* this is paranoia, just in case someone tries to reuse the information */ ZERO_STRUCTP(fsp); /* fsp->fsp_name is a talloc child and is free'd automatically. */ TALLOC_FREE(fsp); }
bool srv_epmapper_delete_endpoints(struct pipes_struct *p) { struct epm_Delete r; struct dcesrv_ep_entry_list *el = p->ep_entries; error_status_t result; while (el) { struct dcesrv_ep_entry_list *next = el->next; r.in.num_ents = el->num_ents; r.in.entries = el->entries; DEBUG(10, ("Delete_endpoints for: %s\n", el->entries[0].annotation)); result = _epm_Delete(p, &r); if (result != EPMAPPER_STATUS_OK) { return false; } DLIST_REMOVE(p->ep_entries, el); TALLOC_FREE(el); el = next; } return true; }
void query_one_hostname(){ smb_srv_info_t *p; for (p = smb_srv_info_list; p; p = p->next) { if(strcmp(p->name->ptr, "")!=0){ continue; } if(p->id==0){ Cdbg(DBE, "query_one_hostname [%s]\n", p->ip->ptr); //continue; } char* hostname = smbc_nmblookup(p->ip->ptr); if(hostname==NULL){ //Cdbg(DBE, "\t\tCan't query samba server name[%s]\n", p->ip->ptr); buffer_free(p->ip); buffer_free(p->mac); buffer_free(p->name); DLIST_REMOVE(smb_srv_info_list, p); free(p); } else{ buffer_copy_string(p->name, hostname); } } }
/* * Remove a server from the cached server list it's unused. * On success, 0 is returned. 1 is returned if the server could not be removed. * * Also useable outside libsmbclient */ int SMBC_remove_unused_server(SMBCCTX * context, SMBCSRV * srv) { SMBCFILE * file; /* are we being fooled ? */ if (!context || !context->internal->initialized || !srv) { return 1; } /* Check all open files/directories for a relation with this server */ for (file = context->internal->files; file; file = file->next) { if (file->srv == srv) { /* Still used */ DEBUG(3, ("smbc_remove_usused_server: " "%p still used by %p.\n", srv, file)); return 1; } } DLIST_REMOVE(context->internal->servers, srv); cli_shutdown(srv->cli); srv->cli = NULL; DEBUG(3, ("smbc_remove_usused_server: %p removed.\n", srv)); smbc_getFunctionRemoveCachedServer(context)(context, srv); SAFE_FREE(srv); return 0; }
void invalidate_vuid(uint16 vuid) { user_struct *vuser = get_valid_user_struct(vuid); if (vuser == NULL) return; SAFE_FREE(vuser->homedir); SAFE_FREE(vuser->unix_homedir); SAFE_FREE(vuser->logon_script); session_yield(vuser); SAFE_FREE(vuser->session_keystr); free_server_info(&vuser->server_info); data_blob_free(&vuser->session_key); DLIST_REMOVE(validated_users, vuser); /* clear the vuid from the 'cache' on each connection, and from the vuid 'owner' of connections */ conn_clear_vuid_cache(vuid); SAFE_FREE(vuser->groups); delete_nt_token(&vuser->nt_user_token); SAFE_FREE(vuser); num_validated_vuids--; }
bool cli_rpc_pipe_close(struct rpc_pipe_client *cli) { bool ret; if (!cli) { return false; } ret = cli_close(cli->cli, cli->fnum); if (!ret) { DEBUG(1,("cli_rpc_pipe_close: cli_close failed on pipe %s, " "fnum 0x%x " "to machine %s. Error was %s\n", cli->pipe_name, (int) cli->fnum, cli->cli->desthost, cli_errstr(cli->cli))); } if (cli->auth.cli_auth_data_free_func) { (*cli->auth.cli_auth_data_free_func)(&cli->auth); } DEBUG(10,("cli_rpc_pipe_close: closed pipe %s to machine %s\n", cli->pipe_name, cli->cli->desthost )); DLIST_REMOVE(cli->cli->pipe_list, cli); talloc_destroy(cli->mem_ctx); return ret; }
static void remove_child_pid(struct smbd_parent_context *parent, pid_t pid, bool unclean_shutdown) { struct smbd_child_pid *child; struct server_id child_id; int ret; child_id = pid_to_procid(pid); ret = messaging_cleanup(parent->msg_ctx, pid); if ((ret != 0) && (ret != ENOENT)) { DEBUG(10, ("%s: messaging_cleanup returned %s\n", __func__, strerror(ret))); } smbprofile_cleanup(pid); for (child = parent->children; child != NULL; child = child->next) { if (child->pid == pid) { struct smbd_child_pid *tmp = child; DLIST_REMOVE(parent->children, child); TALLOC_FREE(tmp); parent->num_children -= 1; break; } } if (child == NULL) { /* not all forked child processes are added to the children list */ DEBUG(2, ("Could not find child %d -- ignoring\n", (int)pid)); return; } if (unclean_shutdown) { /* a child terminated uncleanly so tickle all processes to see if they can grab any of the pending locks */ DEBUG(3,(__location__ " Unclean shutdown of pid %u\n", (unsigned int)pid)); if (parent->cleanup_te == NULL) { /* call the cleanup timer, but not too often */ int cleanup_time = lp_parm_int(-1, "smbd", "cleanuptime", 20); parent->cleanup_te = tevent_add_timer(parent->ev_ctx, parent, timeval_current_ofs(cleanup_time, 0), cleanup_timeout_fn, parent); DEBUG(1,("Scheduled cleanup of brl and lock database after unclean shutdown\n")); } } if (!serverid_deregister(child_id)) { DEBUG(1, ("Could not remove pid %d from serverid.tdb\n", (int)pid)); } }
static int smb2srv_request_destructor(struct smb2srv_request *req) { DLIST_REMOVE(req->smb_conn->requests2.list, req); if (req->pending_id) { idr_remove(req->smb_conn->requests2.idtree_req, req->pending_id); } return 0; }
/* destroy a wrepl_request */ static int wrepl_request_destructor(struct wrepl_request *req) { if (req->state == WREPL_REQUEST_RECV) { DLIST_REMOVE(req->wrepl_socket->recv_queue, req); } req->state = WREPL_REQUEST_ERROR; return 0; }
static int ibw_conn_destruct(struct ibw_conn *conn) { DEBUG(DEBUG_DEBUG, ("ibw_conn_destruct(%p)\n", conn)); /* important here: ctx is a talloc _parent_ */ DLIST_REMOVE(conn->ctx->conn_list, conn); return 0; }
int SMBC_close_ctx(SMBCCTX *context, SMBCFILE *file) { TALLOC_CTX *frame = talloc_stackframe(); if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); return -1; } if (!file || !SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; } /* IS a dir ... */ if (!file->file) { TALLOC_FREE(frame); return smbc_getFunctionClosedir(context)(context, file); } if (!NT_STATUS_IS_OK(cli_close(file->targetcli, file->cli_fd))) { SMBCSRV *srv; DEBUG(3, ("cli_close failed on %s. purging server.\n", file->fname)); /* Deallocate slot and remove the server * from the server cache if unused */ errno = SMBC_errno(context, file->targetcli); srv = file->srv; DLIST_REMOVE(context->internal->files, file); SAFE_FREE(file->fname); SAFE_FREE(file); smbc_getFunctionRemoveUnusedServer(context)(context, srv); TALLOC_FREE(frame); return -1; } DLIST_REMOVE(context->internal->files, file); SAFE_FREE(file->fname); SAFE_FREE(file); TALLOC_FREE(frame); return 0; }
void Worker::run() { int ret; __dlist_t head; __dlist_t *next; Connection *conn; NOTICE("worker is running now."); while (!_stopped) { DLIST_INIT(&head); pthread_mutex_lock(&_mutex); while (DLIST_EMPTY(&_queue)) pthread_cond_wait(&_cond, &_mutex); next = DLIST_NEXT(&_queue); DLIST_REMOVE(&_queue); pthread_mutex_unlock(&_mutex); DLIST_INSERT_B(&head, next); while (!DLIST_EMPTY(&head)) { next = DLIST_NEXT(&head); DLIST_REMOVE(next); conn = GET_OWNER(next, Connection, _list); TRACE("start to process conn, sock[%d].", conn->_sock_fd); try { ret = conn->on_process(); if (ret == 0) { conn->_status = Connection::ST_PROCESSING_REQUEST_OK; TRACE("process conn ok, sock[%d].", conn->_sock_fd); } else { conn->_status = Connection::ST_PROCESSING_REQUEST_FAIL; WARNING("failed to process conn, sock[%d], ret=%d.", conn->_sock_fd, ret); } } catch (...) { WARNING("failed to process conn, sock[%d], exception catched.", conn->_sock_fd); } _server_manager->done(conn); } } NOTICE("worker is stopped by user, exiting now."); }
/**************************************************************************** destroy a session structure ****************************************************************************/ static int smbsrv_session_destructor(struct smbsrv_session *sess) { struct smbsrv_connection *smb_conn = sess->smb_conn; idr_remove(smb_conn->sessions.idtree_vuid, sess->vuid); DLIST_REMOVE(smb_conn->sessions.list, sess); return 0; }
/* destroy a struct pvfs_file */ static int pvfs_fnum_destructor(struct pvfs_file *f) { DLIST_REMOVE(f->pvfs->files.list, f); pvfs_lock_close(f->pvfs, f); ntvfs_handle_remove_backend_data(f->ntvfs, f->pvfs->ntvfs); return 0; }
/* remove elements */ DLIST_SAFE_LOOP(head, in, in_safe) { if (in->me->data > 1) { DLIST_REMOVE(*in); FREE(in->me); FREE(in); } }
static int opd_destructor(struct aio_open_private_data *opd) { if (opd->dir_fd != -1) { close(opd->dir_fd); } DLIST_REMOVE(open_pd_list, opd); return 0; }
static int timed_event_destructor(void *p) { struct timed_event *te = talloc_get_type_abort(p, struct timed_event); DEBUG(10, ("Destroying timed event %lx \"%s\"\n", (unsigned long)te, te->event_name)); DLIST_REMOVE(timed_events, te); return 0; }
/**************************************************************************** load the list of network interfaces ****************************************************************************/ void load_interfaces(void) { char *ptr; fstring token; int i; struct iface_struct ifaces[MAX_INTERFACES]; ptr = lp_interfaces(); ipzero = *interpret_addr2("0.0.0.0"); allones_ip = *interpret_addr2("255.255.255.255"); loopback_ip = *interpret_addr2("127.0.0.1"); if (probed_ifaces) { free(probed_ifaces); probed_ifaces = NULL; } /* dump the current interfaces if any */ while (local_interfaces) { struct interface *iface = local_interfaces; DLIST_REMOVE(local_interfaces, local_interfaces); ZERO_STRUCTPN(iface); free(iface); } /* probe the kernel for interfaces */ total_probed = get_interfaces(ifaces, MAX_INTERFACES); if (total_probed > 0) { probed_ifaces = memdup(ifaces, sizeof(ifaces[0])*total_probed); } /* if we don't have a interfaces line then use all broadcast capable interfaces except loopback */ if (!ptr || !*ptr) { if (total_probed <= 0) { DEBUG(0,("ERROR: Could not determine network interfaces, you must use a interfaces config line\n")); exit(1); } for (i=0;i<total_probed;i++) { if (probed_ifaces[i].netmask.s_addr != allones_ip.s_addr && probed_ifaces[i].ip.s_addr != loopback_ip.s_addr) { add_interface(probed_ifaces[i].ip, probed_ifaces[i].netmask); } } return; } while (next_token(&ptr,token,NULL,sizeof(token))) { interpret_interface(token); } if (!local_interfaces) { DEBUG(0,("WARNING: no network interfaces found\n")); } }
void free_userlist(struct sys_userlist *list_head) { while (list_head) { struct sys_userlist *old_head = list_head; DLIST_REMOVE(list_head, list_head); SAFE_FREE(old_head->unix_name); SAFE_FREE(old_head); } }
static void rb_smbfile_close_and_deref_by_data(RB_SMBFILE_DATA *data) { rb_smbfile_close_by_data(data); data->smbcctx = NULL; data->smbcfile = NULL; DLIST_REMOVE(data->smb_data->smbfile_data_list, data); }
static void delete_partial_auth(struct pending_auth_data *pad) { if (!pad) { return; } DLIST_REMOVE(pd_list, pad); data_blob_free(&pad->partial_data); SAFE_FREE(pad); }
static int watch_destructor(void *mem) { struct sbus_watch_ctx *watch; watch = talloc_get_type(mem, struct sbus_watch_ctx); DLIST_REMOVE(watch->conn->watch_list, watch); return 0; }
void conn_free(connection_struct *conn) { DLIST_REMOVE(Connections, conn); bitmap_clear(bmap, conn->cnum); num_open--; conn_free_internal(conn); }