librpc: Shorten dcerpc_binding_handle_call a bit
[Samba/gebeck_regimport.git] / source3 / libsmb / libsmb_server.c
blob1fe8fd0b8fcb639e77c3ccfb68929aa5a37787f8
1 /*
2 Unix SMB/Netbios implementation.
3 SMB client library implementation
4 Copyright (C) Andrew Tridgell 1998
5 Copyright (C) Richard Sharpe 2000, 2002
6 Copyright (C) John Terpstra 2000
7 Copyright (C) Tom Jansen (Ninja ISD) 2002
8 Copyright (C) Derrell Lipman 2003-2008
9 Copyright (C) Jeremy Allison 2007, 2008
10 Copyright (C) SATOH Fumiyasu <fumiyas@osstech.co.jp> 2009.
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 3 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include "includes.h"
27 #include "libsmb/libsmb.h"
28 #include "libsmbclient.h"
29 #include "libsmb_internal.h"
30 #include "../librpc/gen_ndr/ndr_lsa.h"
31 #include "rpc_client/cli_pipe.h"
32 #include "rpc_client/cli_lsarpc.h"
33 #include "libcli/security/security.h"
34 #include "libsmb/nmblib.h"
35 #include "../libcli/smb/smbXcli_base.h"
37 /*
38 * Check a server for being alive and well.
39 * returns 0 if the server is in shape. Returns 1 on error
41 * Also useable outside libsmbclient to enable external cache
42 * to do some checks too.
44 int
45 SMBC_check_server(SMBCCTX * context,
46 SMBCSRV * server)
48 if (!cli_state_is_connected(server->cli)) {
49 return 1;
52 return 0;
55 /*
56 * Remove a server from the cached server list it's unused.
57 * On success, 0 is returned. 1 is returned if the server could not be removed.
59 * Also useable outside libsmbclient
61 int
62 SMBC_remove_unused_server(SMBCCTX * context,
63 SMBCSRV * srv)
65 SMBCFILE * file;
67 /* are we being fooled ? */
68 if (!context || !context->internal->initialized || !srv) {
69 return 1;
72 /* Check all open files/directories for a relation with this server */
73 for (file = context->internal->files; file; file = file->next) {
74 if (file->srv == srv) {
75 /* Still used */
76 DEBUG(3, ("smbc_remove_usused_server: "
77 "%p still used by %p.\n",
78 srv, file));
79 return 1;
83 DLIST_REMOVE(context->internal->servers, srv);
85 cli_shutdown(srv->cli);
86 srv->cli = NULL;
88 DEBUG(3, ("smbc_remove_usused_server: %p removed.\n", srv));
90 smbc_getFunctionRemoveCachedServer(context)(context, srv);
92 SAFE_FREE(srv);
93 return 0;
96 /****************************************************************
97 * Call the auth_fn with fixed size (fstring) buffers.
98 ***************************************************************/
99 static void
100 SMBC_call_auth_fn(TALLOC_CTX *ctx,
101 SMBCCTX *context,
102 const char *server,
103 const char *share,
104 char **pp_workgroup,
105 char **pp_username,
106 char **pp_password)
108 fstring workgroup;
109 fstring username;
110 fstring password;
111 smbc_get_auth_data_with_context_fn auth_with_context_fn;
113 strlcpy(workgroup, *pp_workgroup, sizeof(workgroup));
114 strlcpy(username, *pp_username, sizeof(username));
115 strlcpy(password, *pp_password, sizeof(password));
117 /* See if there's an authentication with context function provided */
118 auth_with_context_fn = smbc_getFunctionAuthDataWithContext(context);
119 if (auth_with_context_fn)
121 (* auth_with_context_fn)(context,
122 server, share,
123 workgroup, sizeof(workgroup),
124 username, sizeof(username),
125 password, sizeof(password));
127 else
129 smbc_getFunctionAuthData(context)(server, share,
130 workgroup, sizeof(workgroup),
131 username, sizeof(username),
132 password, sizeof(password));
135 TALLOC_FREE(*pp_workgroup);
136 TALLOC_FREE(*pp_username);
137 TALLOC_FREE(*pp_password);
139 *pp_workgroup = talloc_strdup(ctx, workgroup);
140 *pp_username = talloc_strdup(ctx, username);
141 *pp_password = talloc_strdup(ctx, password);
145 void
146 SMBC_get_auth_data(const char *server, const char *share,
147 char *workgroup_buf, int workgroup_buf_len,
148 char *username_buf, int username_buf_len,
149 char *password_buf, int password_buf_len)
151 /* Default function just uses provided data. Nothing to do. */
156 SMBCSRV *
157 SMBC_find_server(TALLOC_CTX *ctx,
158 SMBCCTX *context,
159 const char *server,
160 const char *share,
161 char **pp_workgroup,
162 char **pp_username,
163 char **pp_password)
165 SMBCSRV *srv;
166 int auth_called = 0;
168 if (!pp_workgroup || !pp_username || !pp_password) {
169 return NULL;
172 check_server_cache:
174 srv = smbc_getFunctionGetCachedServer(context)(context,
175 server, share,
176 *pp_workgroup,
177 *pp_username);
179 if (!auth_called && !srv && (!*pp_username || !(*pp_username)[0] ||
180 !*pp_password || !(*pp_password)[0])) {
181 SMBC_call_auth_fn(ctx, context, server, share,
182 pp_workgroup, pp_username, pp_password);
185 * However, smbc_auth_fn may have picked up info relating to
186 * an existing connection, so try for an existing connection
187 * again ...
189 auth_called = 1;
190 goto check_server_cache;
194 if (srv) {
195 if (smbc_getFunctionCheckServer(context)(context, srv)) {
197 * This server is no good anymore
198 * Try to remove it and check for more possible
199 * servers in the cache
201 if (smbc_getFunctionRemoveUnusedServer(context)(context,
202 srv)) {
204 * We could not remove the server completely,
205 * remove it from the cache so we will not get
206 * it again. It will be removed when the last
207 * file/dir is closed.
209 smbc_getFunctionRemoveCachedServer(context)(context,
210 srv);
214 * Maybe there are more cached connections to this
215 * server
217 goto check_server_cache;
220 return srv;
223 return NULL;
227 * Connect to a server, possibly on an existing connection
229 * Here, what we want to do is: If the server and username
230 * match an existing connection, reuse that, otherwise, establish a
231 * new connection.
233 * If we have to create a new connection, call the auth_fn to get the
234 * info we need, unless the username and password were passed in.
237 static SMBCSRV *
238 SMBC_server_internal(TALLOC_CTX *ctx,
239 SMBCCTX *context,
240 bool connect_if_not_found,
241 const char *server,
242 uint16_t port,
243 const char *share,
244 char **pp_workgroup,
245 char **pp_username,
246 char **pp_password,
247 bool *in_cache)
249 SMBCSRV *srv=NULL;
250 char *workgroup = NULL;
251 struct cli_state *c = NULL;
252 const char *server_n = server;
253 int is_ipc = (share != NULL && strcmp(share, "IPC$") == 0);
254 uint32 fs_attrs = 0;
255 const char *username_used;
256 NTSTATUS status;
257 char *newserver, *newshare;
258 int flags = 0;
260 ZERO_STRUCT(c);
261 *in_cache = false;
263 if (server[0] == 0) {
264 errno = EPERM;
265 return NULL;
268 /* Look for a cached connection */
269 srv = SMBC_find_server(ctx, context, server, share,
270 pp_workgroup, pp_username, pp_password);
273 * If we found a connection and we're only allowed one share per
274 * server...
276 if (srv &&
277 share != NULL && *share != '\0' &&
278 smbc_getOptionOneSharePerServer(context)) {
281 * ... then if there's no current connection to the share,
282 * connect to it. SMBC_find_server(), or rather the function
283 * pointed to by context->get_cached_srv_fn which
284 * was called by SMBC_find_server(), will have issued a tree
285 * disconnect if the requested share is not the same as the
286 * one that was already connected.
290 * Use srv->cli->desthost and srv->cli->share instead of
291 * server and share below to connect to the actual share,
292 * i.e., a normal share or a referred share from
293 * 'msdfs proxy' share.
295 if (!cli_state_has_tcon(srv->cli)) {
296 /* Ensure we have accurate auth info */
297 SMBC_call_auth_fn(ctx, context,
298 smbXcli_conn_remote_name(srv->cli->conn),
299 srv->cli->share,
300 pp_workgroup,
301 pp_username,
302 pp_password);
304 if (!*pp_workgroup || !*pp_username || !*pp_password) {
305 errno = ENOMEM;
306 cli_shutdown(srv->cli);
307 srv->cli = NULL;
308 smbc_getFunctionRemoveCachedServer(context)(context,
309 srv);
310 return NULL;
314 * We don't need to renegotiate encryption
315 * here as the encryption context is not per
316 * tid.
319 status = cli_tree_connect(srv->cli,
320 srv->cli->share,
321 "?????",
322 *pp_password,
323 strlen(*pp_password)+1);
324 if (!NT_STATUS_IS_OK(status)) {
325 errno = map_errno_from_nt_status(status);
326 cli_shutdown(srv->cli);
327 srv->cli = NULL;
328 smbc_getFunctionRemoveCachedServer(context)(context,
329 srv);
330 srv = NULL;
333 /* Determine if this share supports case sensitivity */
334 if (is_ipc) {
335 DEBUG(4,
336 ("IPC$ so ignore case sensitivity\n"));
337 status = NT_STATUS_OK;
338 } else {
339 status = cli_get_fs_attr_info(c, &fs_attrs);
342 if (!NT_STATUS_IS_OK(status)) {
343 DEBUG(4, ("Could not retrieve "
344 "case sensitivity flag: %s.\n",
345 nt_errstr(status)));
348 * We can't determine the case sensitivity of
349 * the share. We have no choice but to use the
350 * user-specified case sensitivity setting.
352 if (smbc_getOptionCaseSensitive(context)) {
353 cli_set_case_sensitive(c, True);
354 } else {
355 cli_set_case_sensitive(c, False);
357 } else if (!is_ipc) {
358 DEBUG(4,
359 ("Case sensitive: %s\n",
360 (fs_attrs & FILE_CASE_SENSITIVE_SEARCH
361 ? "True"
362 : "False")));
363 cli_set_case_sensitive(
365 (fs_attrs & FILE_CASE_SENSITIVE_SEARCH
366 ? True
367 : False));
371 * Regenerate the dev value since it's based on both
372 * server and share
374 if (srv) {
375 const char *remote_name =
376 smbXcli_conn_remote_name(srv->cli->conn);
378 srv->dev = (dev_t)(str_checksum(remote_name) ^
379 str_checksum(srv->cli->share));
384 /* If we have a connection... */
385 if (srv) {
387 /* ... then we're done here. Give 'em what they came for. */
388 *in_cache = true;
389 goto done;
392 /* If we're not asked to connect when a connection doesn't exist... */
393 if (! connect_if_not_found) {
394 /* ... then we're done here. */
395 return NULL;
398 if (!*pp_workgroup || !*pp_username || !*pp_password) {
399 errno = ENOMEM;
400 return NULL;
403 DEBUG(4,("SMBC_server: server_n=[%s] server=[%s]\n", server_n, server));
405 DEBUG(4,(" -> server_n=[%s] server=[%s]\n", server_n, server));
407 status = NT_STATUS_UNSUCCESSFUL;
409 if (smbc_getOptionUseKerberos(context)) {
410 flags |= CLI_FULL_CONNECTION_USE_KERBEROS;
413 if (smbc_getOptionFallbackAfterKerberos(context)) {
414 flags |= CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS;
417 if (smbc_getOptionUseCCache(context)) {
418 flags |= CLI_FULL_CONNECTION_USE_CCACHE;
421 if (smbc_getOptionUseNTHash(context)) {
422 flags |= CLI_FULL_CONNECTION_USE_NT_HASH;
425 if (port == 0) {
426 if (share == NULL || *share == '\0' || is_ipc) {
428 * Try 139 first for IPC$
430 status = cli_connect_nb(server_n, NULL, NBT_SMB_PORT, 0x20,
431 smbc_getNetbiosName(context),
432 SMB_SIGNING_DEFAULT, flags, &c);
436 if (!NT_STATUS_IS_OK(status)) {
438 * No IPC$ or 139 did not work
440 status = cli_connect_nb(server_n, NULL, port, 0x20,
441 smbc_getNetbiosName(context),
442 SMB_SIGNING_DEFAULT, flags, &c);
445 if (!NT_STATUS_IS_OK(status)) {
446 errno = map_errno_from_nt_status(status);
447 return NULL;
450 cli_set_timeout(c, smbc_getTimeout(context));
452 status = smbXcli_negprot(c->conn, c->timeout, PROTOCOL_CORE,
453 PROTOCOL_NT1);
455 if (!NT_STATUS_IS_OK(status)) {
456 cli_shutdown(c);
457 errno = ETIMEDOUT;
458 return NULL;
461 username_used = *pp_username;
463 if (!NT_STATUS_IS_OK(cli_session_setup(c, username_used,
464 *pp_password,
465 strlen(*pp_password),
466 *pp_password,
467 strlen(*pp_password),
468 *pp_workgroup))) {
470 /* Failed. Try an anonymous login, if allowed by flags. */
471 username_used = "";
473 if (smbc_getOptionNoAutoAnonymousLogin(context) ||
474 !NT_STATUS_IS_OK(cli_session_setup(c, username_used,
475 *pp_password, 1,
476 *pp_password, 0,
477 *pp_workgroup))) {
479 cli_shutdown(c);
480 errno = EPERM;
481 return NULL;
485 status = cli_init_creds(c, username_used,
486 *pp_workgroup, *pp_password);
487 if (!NT_STATUS_IS_OK(status)) {
488 errno = map_errno_from_nt_status(status);
489 cli_shutdown(c);
490 return NULL;
493 DEBUG(4,(" session setup ok\n"));
495 /* here's the fun part....to support 'msdfs proxy' shares
496 (on Samba or windows) we have to issues a TRANS_GET_DFS_REFERRAL
497 here before trying to connect to the original share.
498 cli_check_msdfs_proxy() will fail if it is a normal share. */
500 if ((smb1cli_conn_capabilities(c->conn) & CAP_DFS) &&
501 cli_check_msdfs_proxy(ctx, c, share,
502 &newserver, &newshare,
503 /* FIXME: cli_check_msdfs_proxy() does
504 not support smbc_smb_encrypt_level type */
505 context->internal->smb_encryption_level ?
506 true : false,
507 *pp_username,
508 *pp_password,
509 *pp_workgroup)) {
510 cli_shutdown(c);
511 srv = SMBC_server_internal(ctx, context, connect_if_not_found,
512 newserver, port, newshare, pp_workgroup,
513 pp_username, pp_password, in_cache);
514 TALLOC_FREE(newserver);
515 TALLOC_FREE(newshare);
516 return srv;
519 /* must be a normal share */
521 status = cli_tree_connect(c, share, "?????", *pp_password,
522 strlen(*pp_password)+1);
523 if (!NT_STATUS_IS_OK(status)) {
524 errno = map_errno_from_nt_status(status);
525 cli_shutdown(c);
526 return NULL;
529 DEBUG(4,(" tconx ok\n"));
531 /* Determine if this share supports case sensitivity */
532 if (is_ipc) {
533 DEBUG(4, ("IPC$ so ignore case sensitivity\n"));
534 status = NT_STATUS_OK;
535 } else {
536 status = cli_get_fs_attr_info(c, &fs_attrs);
539 if (!NT_STATUS_IS_OK(status)) {
540 DEBUG(4, ("Could not retrieve case sensitivity flag: %s.\n",
541 nt_errstr(status)));
544 * We can't determine the case sensitivity of the share. We
545 * have no choice but to use the user-specified case
546 * sensitivity setting.
548 if (smbc_getOptionCaseSensitive(context)) {
549 cli_set_case_sensitive(c, True);
550 } else {
551 cli_set_case_sensitive(c, False);
553 } else if (!is_ipc) {
554 DEBUG(4, ("Case sensitive: %s\n",
555 (fs_attrs & FILE_CASE_SENSITIVE_SEARCH
556 ? "True"
557 : "False")));
558 cli_set_case_sensitive(c,
559 (fs_attrs & FILE_CASE_SENSITIVE_SEARCH
560 ? True
561 : False));
564 if (context->internal->smb_encryption_level) {
565 /* Attempt UNIX smb encryption. */
566 if (!NT_STATUS_IS_OK(cli_force_encryption(c,
567 username_used,
568 *pp_password,
569 *pp_workgroup))) {
572 * context->smb_encryption_level == 1
573 * means don't fail if encryption can't be negotiated,
574 * == 2 means fail if encryption can't be negotiated.
577 DEBUG(4,(" SMB encrypt failed\n"));
579 if (context->internal->smb_encryption_level == 2) {
580 cli_shutdown(c);
581 errno = EPERM;
582 return NULL;
585 DEBUG(4,(" SMB encrypt ok\n"));
589 * Ok, we have got a nice connection
590 * Let's allocate a server structure.
593 srv = SMB_MALLOC_P(SMBCSRV);
594 if (!srv) {
595 cli_shutdown(c);
596 errno = ENOMEM;
597 return NULL;
600 ZERO_STRUCTP(srv);
601 srv->cli = c;
602 srv->dev = (dev_t)(str_checksum(server) ^ str_checksum(share));
603 srv->no_pathinfo = False;
604 srv->no_pathinfo2 = False;
605 srv->no_nt_session = False;
607 done:
608 if (!pp_workgroup || !*pp_workgroup || !**pp_workgroup) {
609 workgroup = talloc_strdup(ctx, smbc_getWorkgroup(context));
610 } else {
611 workgroup = *pp_workgroup;
613 if(!workgroup) {
614 if (c != NULL) {
615 cli_shutdown(c);
617 SAFE_FREE(srv);
618 return NULL;
621 /* set the credentials to make DFS work */
622 smbc_set_credentials_with_fallback(context,
623 workgroup,
624 *pp_username,
625 *pp_password);
627 return srv;
630 SMBCSRV *
631 SMBC_server(TALLOC_CTX *ctx,
632 SMBCCTX *context,
633 bool connect_if_not_found,
634 const char *server,
635 uint16_t port,
636 const char *share,
637 char **pp_workgroup,
638 char **pp_username,
639 char **pp_password)
641 SMBCSRV *srv=NULL;
642 bool in_cache = false;
644 srv = SMBC_server_internal(ctx, context, connect_if_not_found,
645 server, port, share, pp_workgroup,
646 pp_username, pp_password, &in_cache);
648 if (!srv) {
649 return NULL;
651 if (in_cache) {
652 return srv;
655 /* Now add it to the cache (internal or external) */
656 /* Let the cache function set errno if it wants to */
657 errno = 0;
658 if (smbc_getFunctionAddCachedServer(context)(context, srv,
659 server, share,
660 *pp_workgroup,
661 *pp_username)) {
662 int saved_errno = errno;
663 DEBUG(3, (" Failed to add server to cache\n"));
664 errno = saved_errno;
665 if (errno == 0) {
666 errno = ENOMEM;
668 SAFE_FREE(srv);
669 return NULL;
672 DEBUG(2, ("Server connect ok: //%s/%s: %p\n",
673 server, share, srv));
675 DLIST_ADD(context->internal->servers, srv);
676 return srv;
680 * Connect to a server for getting/setting attributes, possibly on an existing
681 * connection. This works similarly to SMBC_server().
683 SMBCSRV *
684 SMBC_attr_server(TALLOC_CTX *ctx,
685 SMBCCTX *context,
686 const char *server,
687 uint16_t port,
688 const char *share,
689 char **pp_workgroup,
690 char **pp_username,
691 char **pp_password)
693 int flags;
694 struct cli_state *ipc_cli = NULL;
695 struct rpc_pipe_client *pipe_hnd = NULL;
696 NTSTATUS nt_status;
697 SMBCSRV *srv=NULL;
698 SMBCSRV *ipc_srv=NULL;
701 * Use srv->cli->desthost and srv->cli->share instead of
702 * server and share below to connect to the actual share,
703 * i.e., a normal share or a referred share from
704 * 'msdfs proxy' share.
706 srv = SMBC_server(ctx, context, true, server, port, share,
707 pp_workgroup, pp_username, pp_password);
708 if (!srv) {
709 return NULL;
711 server = smbXcli_conn_remote_name(srv->cli->conn);
712 share = srv->cli->share;
715 * See if we've already created this special connection. Reference
716 * our "special" share name '*IPC$', which is an impossible real share
717 * name due to the leading asterisk.
719 ipc_srv = SMBC_find_server(ctx, context, server, "*IPC$",
720 pp_workgroup, pp_username, pp_password);
721 if (!ipc_srv) {
723 /* We didn't find a cached connection. Get the password */
724 if (!*pp_password || (*pp_password)[0] == '\0') {
725 /* ... then retrieve it now. */
726 SMBC_call_auth_fn(ctx, context, server, share,
727 pp_workgroup,
728 pp_username,
729 pp_password);
730 if (!*pp_workgroup || !*pp_username || !*pp_password) {
731 errno = ENOMEM;
732 return NULL;
736 flags = 0;
737 if (smbc_getOptionUseKerberos(context)) {
738 flags |= CLI_FULL_CONNECTION_USE_KERBEROS;
740 if (smbc_getOptionUseCCache(context)) {
741 flags |= CLI_FULL_CONNECTION_USE_CCACHE;
744 nt_status = cli_full_connection(&ipc_cli,
745 lp_netbios_name(), server,
746 NULL, 0, "IPC$", "?????",
747 *pp_username,
748 *pp_workgroup,
749 *pp_password,
750 flags,
751 SMB_SIGNING_DEFAULT);
752 if (! NT_STATUS_IS_OK(nt_status)) {
753 DEBUG(1,("cli_full_connection failed! (%s)\n",
754 nt_errstr(nt_status)));
755 errno = ENOTSUP;
756 return NULL;
759 if (context->internal->smb_encryption_level) {
760 /* Attempt UNIX smb encryption. */
761 if (!NT_STATUS_IS_OK(cli_force_encryption(ipc_cli,
762 *pp_username,
763 *pp_password,
764 *pp_workgroup))) {
767 * context->smb_encryption_level ==
768 * 1 means don't fail if encryption can't be
769 * negotiated, == 2 means fail if encryption
770 * can't be negotiated.
773 DEBUG(4,(" SMB encrypt failed on IPC$\n"));
775 if (context->internal->smb_encryption_level == 2) {
776 cli_shutdown(ipc_cli);
777 errno = EPERM;
778 return NULL;
781 DEBUG(4,(" SMB encrypt ok on IPC$\n"));
784 ipc_srv = SMB_MALLOC_P(SMBCSRV);
785 if (!ipc_srv) {
786 errno = ENOMEM;
787 cli_shutdown(ipc_cli);
788 return NULL;
791 ZERO_STRUCTP(ipc_srv);
792 ipc_srv->cli = ipc_cli;
794 nt_status = cli_rpc_pipe_open_noauth(
795 ipc_srv->cli, &ndr_table_lsarpc.syntax_id, &pipe_hnd);
796 if (!NT_STATUS_IS_OK(nt_status)) {
797 DEBUG(1, ("cli_nt_session_open fail!\n"));
798 errno = ENOTSUP;
799 cli_shutdown(ipc_srv->cli);
800 free(ipc_srv);
801 return NULL;
805 * Some systems don't support
806 * SEC_FLAG_MAXIMUM_ALLOWED, but NT sends 0x2000000
807 * so we might as well do it too.
810 nt_status = rpccli_lsa_open_policy(
811 pipe_hnd,
812 talloc_tos(),
813 True,
814 GENERIC_EXECUTE_ACCESS,
815 &ipc_srv->pol);
817 if (!NT_STATUS_IS_OK(nt_status)) {
818 errno = SMBC_errno(context, ipc_srv->cli);
819 cli_shutdown(ipc_srv->cli);
820 free(ipc_srv);
821 return NULL;
824 /* now add it to the cache (internal or external) */
826 errno = 0; /* let cache function set errno if it likes */
827 if (smbc_getFunctionAddCachedServer(context)(context, ipc_srv,
828 server,
829 "*IPC$",
830 *pp_workgroup,
831 *pp_username)) {
832 DEBUG(3, (" Failed to add server to cache\n"));
833 if (errno == 0) {
834 errno = ENOMEM;
836 cli_shutdown(ipc_srv->cli);
837 free(ipc_srv);
838 return NULL;
841 DLIST_ADD(context->internal->servers, ipc_srv);
844 return ipc_srv;