2 Unix SMB/CIFS implementation.
3 client connect/disconnect routines
4 Copyright (C) Andrew Tridgell 1994-1998
5 Copyright (C) Gerald (Jerry) Carter 2004
6 Copyright (C) Jeremy Allison 2007-2009
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "libsmb/libsmb.h"
24 #include "libsmb/clirap.h"
27 #include "libsmb/nmblib.h"
29 /********************************************************************
32 DFS paths are *always* of the form \server\share\<pathname> (the \ characters
33 are not C escaped here).
35 - but if we're using POSIX paths then <pathname> may contain
36 '/' separators, not '\\' separators. So cope with '\\' or '/'
37 as a separator when looking at the pathname part.... JRA.
38 ********************************************************************/
40 /********************************************************************
41 Ensure a connection is encrypted.
42 ********************************************************************/
44 NTSTATUS
cli_cm_force_encryption(struct cli_state
*c
,
48 const char *sharename
)
50 NTSTATUS status
= cli_force_encryption(c
,
55 if (NT_STATUS_EQUAL(status
,NT_STATUS_NOT_SUPPORTED
)) {
56 d_printf("Encryption required and "
57 "server that doesn't support "
58 "UNIX extensions - failing connect\n");
59 } else if (NT_STATUS_EQUAL(status
,NT_STATUS_UNKNOWN_REVISION
)) {
60 d_printf("Encryption required and "
61 "can't get UNIX CIFS extensions "
62 "version from server.\n");
63 } else if (NT_STATUS_EQUAL(status
,NT_STATUS_UNSUPPORTED_COMPRESSION
)) {
64 d_printf("Encryption required and "
65 "share %s doesn't support "
66 "encryption.\n", sharename
);
67 } else if (!NT_STATUS_IS_OK(status
)) {
68 d_printf("Encryption required and "
69 "setup failed with error %s.\n",
76 /********************************************************************
77 Return a connection to a server.
78 ********************************************************************/
80 static NTSTATUS
do_connect(TALLOC_CTX
*ctx
,
83 const struct user_auth_info
*auth_info
,
89 struct cli_state
**pcli
)
91 struct cli_state
*c
= NULL
;
94 char *newserver
, *newshare
;
100 /* make a copy so we don't modify the global string 'service' */
101 servicename
= talloc_strdup(ctx
,share
);
103 return NT_STATUS_NO_MEMORY
;
105 sharename
= servicename
;
106 if (*sharename
== '\\') {
108 if (server
== NULL
) {
111 sharename
= strchr_m(sharename
,'\\');
113 return NT_STATUS_NO_MEMORY
;
118 if (server
== NULL
) {
119 return NT_STATUS_INVALID_PARAMETER
;
122 if (get_cmdline_auth_info_use_kerberos(auth_info
)) {
123 flags
|= CLI_FULL_CONNECTION_USE_KERBEROS
;
125 if (get_cmdline_auth_info_fallback_after_kerberos(auth_info
)) {
126 flags
|= CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS
;
128 if (get_cmdline_auth_info_use_ccache(auth_info
)) {
129 flags
|= CLI_FULL_CONNECTION_USE_CCACHE
;
132 status
= cli_connect_nb(
133 server
, NULL
, port
, name_type
, NULL
,
134 get_cmdline_auth_info_signing_state(auth_info
),
137 if (!NT_STATUS_IS_OK(status
)) {
138 d_printf("Connection to %s failed (Error %s)\n",
144 if (max_protocol
== 0) {
145 max_protocol
= PROTOCOL_NT1
;
147 DEBUG(4,(" session request ok\n"));
149 status
= cli_negprot(c
, max_protocol
);
151 if (!NT_STATUS_IS_OK(status
)) {
152 d_printf("protocol negotiation failed: %s\n",
158 username
= get_cmdline_auth_info_username(auth_info
);
159 password
= get_cmdline_auth_info_password(auth_info
);
161 status
= cli_session_setup(c
, username
,
162 password
, strlen(password
),
163 password
, strlen(password
),
165 if (!NT_STATUS_IS_OK(status
)) {
166 /* If a password was not supplied then
167 * try again with a null username. */
168 if (password
[0] || !username
[0] ||
169 get_cmdline_auth_info_use_kerberos(auth_info
) ||
170 !NT_STATUS_IS_OK(status
= cli_session_setup(c
, "",
174 d_printf("session setup failed: %s\n",
176 if (NT_STATUS_EQUAL(status
,
177 NT_STATUS_MORE_PROCESSING_REQUIRED
))
178 d_printf("did you forget to run kinit?\n");
182 d_printf("Anonymous login successful\n");
183 status
= cli_init_creds(c
, "", lp_workgroup(), "");
185 status
= cli_init_creds(c
, username
, lp_workgroup(), password
);
188 if (!NT_STATUS_IS_OK(status
)) {
189 DEBUG(10,("cli_init_creds() failed: %s\n", nt_errstr(status
)));
194 if ( show_sessetup
) {
195 if (*c
->server_domain
) {
196 DEBUG(0,("Domain=[%s] OS=[%s] Server=[%s]\n",
197 c
->server_domain
,c
->server_os
,c
->server_type
));
198 } else if (*c
->server_os
|| *c
->server_type
) {
199 DEBUG(0,("OS=[%s] Server=[%s]\n",
200 c
->server_os
,c
->server_type
));
203 DEBUG(4,(" session setup ok\n"));
205 /* here's the fun part....to support 'msdfs proxy' shares
206 (on Samba or windows) we have to issues a TRANS_GET_DFS_REFERRAL
207 here before trying to connect to the original share.
208 cli_check_msdfs_proxy() will fail if it is a normal share. */
210 if ((cli_state_capabilities(c
) & CAP_DFS
) &&
211 cli_check_msdfs_proxy(ctx
, c
, sharename
,
212 &newserver
, &newshare
,
218 return do_connect(ctx
, newserver
,
219 newshare
, auth_info
, false,
220 force_encrypt
, max_protocol
,
221 port
, name_type
, pcli
);
224 /* must be a normal share */
226 status
= cli_tree_connect(c
, sharename
, "?????",
227 password
, strlen(password
)+1);
228 if (!NT_STATUS_IS_OK(status
)) {
229 d_printf("tree connect failed: %s\n", nt_errstr(status
));
235 status
= cli_cm_force_encryption(c
,
240 if (!NT_STATUS_IS_OK(status
)) {
246 DEBUG(4,(" tconx ok\n"));
251 /****************************************************************************
252 ****************************************************************************/
254 static void cli_set_mntpoint(struct cli_state
*cli
, const char *mnt
)
256 char *name
= clean_name(NULL
, mnt
);
260 TALLOC_FREE(cli
->dfs_mountpoint
);
261 cli
->dfs_mountpoint
= talloc_strdup(cli
, name
);
265 /********************************************************************
266 Add a new connection to the list.
267 referring_cli == NULL means a new initial connection.
268 ********************************************************************/
270 static NTSTATUS
cli_cm_connect(TALLOC_CTX
*ctx
,
271 struct cli_state
*referring_cli
,
274 const struct user_auth_info
*auth_info
,
280 struct cli_state
**pcli
)
282 struct cli_state
*cli
;
285 status
= do_connect(ctx
, server
, share
,
287 show_hdr
, force_encrypt
, max_protocol
,
288 port
, name_type
, &cli
);
290 if (!NT_STATUS_IS_OK(status
)) {
294 /* Enter into the list. */
296 DLIST_ADD_END(referring_cli
, cli
, struct cli_state
*);
299 if (referring_cli
&& referring_cli
->requested_posix_capabilities
) {
301 uint32 caplow
, caphigh
;
302 status
= cli_unix_extensions_version(cli
, &major
, &minor
,
304 if (NT_STATUS_IS_OK(status
)) {
305 cli_set_unix_extensions_capabilities(cli
,
315 /********************************************************************
316 Return a connection to a server on a particular share.
317 ********************************************************************/
319 static struct cli_state
*cli_cm_find(struct cli_state
*cli
,
329 /* Search to the start of the list. */
330 for (p
= cli
; p
; p
= DLIST_PREV(p
)) {
331 const char *remote_name
=
332 cli_state_remote_name(p
);
334 if (strequal(server
, remote_name
) &&
335 strequal(share
,p
->share
)) {
340 /* Search to the end of the list. */
341 for (p
= cli
->next
; p
; p
= p
->next
) {
342 const char *remote_name
=
343 cli_state_remote_name(p
);
345 if (strequal(server
, remote_name
) &&
346 strequal(share
,p
->share
)) {
354 /****************************************************************************
355 Open a client connection to a \\server\share.
356 ****************************************************************************/
358 NTSTATUS
cli_cm_open(TALLOC_CTX
*ctx
,
359 struct cli_state
*referring_cli
,
362 const struct user_auth_info
*auth_info
,
368 struct cli_state
**pcli
)
370 /* Try to reuse an existing connection in this list. */
371 struct cli_state
*c
= cli_cm_find(referring_cli
, server
, share
);
379 if (auth_info
== NULL
) {
380 /* Can't do a new connection
381 * without auth info. */
382 d_printf("cli_cm_open() Unable to open connection [\\%s\\%s] "
383 "without auth info\n",
385 return NT_STATUS_INVALID_PARAMETER
;
388 status
= cli_cm_connect(ctx
,
399 if (!NT_STATUS_IS_OK(status
)) {
406 /****************************************************************************
407 ****************************************************************************/
409 void cli_cm_display(struct cli_state
*cli
)
413 for (i
=0; cli
; cli
= cli
->next
,i
++ ) {
414 d_printf("%d:\tserver=%s, share=%s\n",
415 i
, cli_state_remote_name(cli
), cli
->share
);
419 /****************************************************************************
420 ****************************************************************************/
422 /****************************************************************************
423 ****************************************************************************/
426 void cli_cm_set_credentials(struct user_auth_info
*auth_info
)
428 SAFE_FREE(cm_creds
.username
);
429 cm_creds
.username
= SMB_STRDUP(get_cmdline_auth_info_username(
432 if (get_cmdline_auth_info_got_pass(auth_info
)) {
433 cm_set_password(get_cmdline_auth_info_password(auth_info
));
436 cm_creds
.use_kerberos
= get_cmdline_auth_info_use_kerberos(auth_info
);
437 cm_creds
.fallback_after_kerberos
= false;
438 cm_creds
.signing_state
= get_cmdline_auth_info_signing_state(auth_info
);
442 /**********************************************************************
443 split a dfs path into the server, share name, and extrapath components
444 **********************************************************************/
446 static bool split_dfs_path(TALLOC_CTX
*ctx
,
447 const char *nodepath
,
457 *pp_extrapath
= NULL
;
459 path
= talloc_strdup(ctx
, nodepath
);
464 if ( path
[0] != '\\' ) {
468 p
= strchr_m( path
+ 1, '\\' );
476 /* Look for any extra/deep path */
477 q
= strchr_m(p
, '\\');
481 *pp_extrapath
= talloc_strdup(ctx
, q
);
483 *pp_extrapath
= talloc_strdup(ctx
, "");
485 if (*pp_extrapath
== NULL
) {
489 *pp_share
= talloc_strdup(ctx
, p
);
490 if (*pp_share
== NULL
) {
494 *pp_server
= talloc_strdup(ctx
, &path
[1]);
495 if (*pp_server
== NULL
) {
503 TALLOC_FREE(*pp_share
);
504 TALLOC_FREE(*pp_extrapath
);
509 /****************************************************************************
510 Return the original path truncated at the directory component before
511 the first wildcard character. Trust the caller to provide a NULL
513 ****************************************************************************/
515 static char *clean_path(TALLOC_CTX
*ctx
, const char *path
)
521 /* No absolute paths. */
522 while (IS_DIRECTORY_SEP(*path
)) {
526 path_out
= talloc_strdup(ctx
, path
);
531 p1
= strchr_m(path_out
, '*');
532 p2
= strchr_m(path_out
, '?');
544 /* Now go back to the start of this component. */
545 p1
= strrchr_m(path_out
, '/');
546 p2
= strrchr_m(path_out
, '\\');
553 /* Strip any trailing separator */
555 len
= strlen(path_out
);
556 if ( (len
> 0) && IS_DIRECTORY_SEP(path_out
[len
-1])) {
557 path_out
[len
-1] = '\0';
563 /****************************************************************************
564 ****************************************************************************/
566 static char *cli_dfs_make_full_path(TALLOC_CTX
*ctx
,
567 struct cli_state
*cli
,
570 char path_sep
= '\\';
572 /* Ensure the extrapath doesn't start with a separator. */
573 while (IS_DIRECTORY_SEP(*dir
)) {
577 if (cli
->requested_posix_capabilities
& CIFS_UNIX_POSIX_PATHNAMES_CAP
) {
580 return talloc_asprintf(ctx
, "%c%s%c%s%c%s",
582 cli_state_remote_name(cli
),
589 /********************************************************************
590 check for dfs referral
591 ********************************************************************/
593 static bool cli_dfs_check_error(struct cli_state
*cli
, NTSTATUS expected
,
596 /* only deal with DS when we negotiated NT_STATUS codes and UNICODE */
598 if (!(cli_state_capabilities(cli
) & CAP_UNICODE
)) {
601 if (!(cli_state_capabilities(cli
) & CAP_STATUS32
)) {
604 if (NT_STATUS_EQUAL(status
, expected
)) {
610 /********************************************************************
611 Get the dfs referral link.
612 ********************************************************************/
614 NTSTATUS
cli_dfs_get_referral(TALLOC_CTX
*ctx
,
615 struct cli_state
*cli
,
617 struct client_dfs_referral
**refs
,
621 unsigned int data_len
= 0;
622 unsigned int param_len
= 0;
624 uint16_t recv_flags2
;
625 uint8_t *param
= NULL
;
626 uint8_t *rdata
= NULL
;
629 smb_ucs2_t
*path_ucs
;
630 char *consumed_path
= NULL
;
631 uint16_t consumed_ucs
;
632 uint16 num_referrals
;
633 struct client_dfs_referral
*referrals
= NULL
;
635 TALLOC_CTX
*frame
= talloc_stackframe();
640 SSVAL(setup
, 0, TRANSACT2_GET_DFS_REFERRAL
);
642 param
= talloc_array(talloc_tos(), uint8_t, 2);
644 status
= NT_STATUS_NO_MEMORY
;
647 SSVAL(param
, 0, 0x03); /* max referral level */
649 param
= trans2_bytes_push_str(param
, cli_ucs2(cli
),
650 path
, strlen(path
)+1,
653 status
= NT_STATUS_NO_MEMORY
;
656 param_len
= talloc_get_size(param
);
657 path_ucs
= (smb_ucs2_t
*)¶m
[2];
659 status
= cli_trans(talloc_tos(), cli
, SMBtrans2
,
663 NULL
, 0, CLI_BUFFER_SIZE
,
665 NULL
, 0, NULL
, /* rsetup */
667 &rdata
, 4, &data_len
);
668 if (!NT_STATUS_IS_OK(status
)) {
672 endp
= (char *)rdata
+ data_len
;
674 consumed_ucs
= SVAL(rdata
, 0);
675 num_referrals
= SVAL(rdata
, 2);
677 /* consumed_ucs is the number of bytes
678 * of the UCS2 path consumed not counting any
679 * terminating null. We need to convert
680 * back to unix charset and count again
681 * to get the number of bytes consumed from
682 * the incoming path. */
685 if (pull_string_talloc(talloc_tos(),
693 status
= map_nt_error_from_unix(errno
);
695 status
= NT_STATUS_INVALID_NETWORK_RESPONSE
;
699 if (consumed_path
== NULL
) {
700 status
= map_nt_error_from_unix(errno
);
703 *consumed
= strlen(consumed_path
);
705 if (num_referrals
!= 0) {
711 referrals
= talloc_array(ctx
, struct client_dfs_referral
,
715 status
= NT_STATUS_NO_MEMORY
;
718 /* start at the referrals array */
721 for (i
=0; i
<num_referrals
&& p
< endp
; i
++) {
725 ref_version
= SVAL(p
, 0);
726 ref_size
= SVAL(p
, 2);
727 node_offset
= SVAL(p
, 16);
729 if (ref_version
!= 3) {
734 referrals
[i
].proximity
= SVAL(p
, 8);
735 referrals
[i
].ttl
= SVAL(p
, 10);
737 if (p
+ node_offset
> endp
) {
738 status
= NT_STATUS_INVALID_NETWORK_RESPONSE
;
741 clistr_pull_talloc(referrals
,
744 &referrals
[i
].dfspath
,
746 PTR_DIFF(endp
, p
+node_offset
),
747 STR_TERMINATE
|STR_UNICODE
);
749 if (!referrals
[i
].dfspath
) {
750 status
= map_nt_error_from_unix(errno
);
755 if (i
< num_referrals
) {
756 status
= NT_STATUS_INVALID_NETWORK_RESPONSE
;
761 *num_refs
= num_referrals
;
770 /********************************************************************
771 ********************************************************************/
773 NTSTATUS
cli_resolve_path(TALLOC_CTX
*ctx
,
775 const struct user_auth_info
*dfs_auth_info
,
776 struct cli_state
*rootcli
,
778 struct cli_state
**targetcli
,
779 char **pp_targetpath
)
781 struct client_dfs_referral
*refs
= NULL
;
784 struct cli_state
*cli_ipc
= NULL
;
785 char *dfs_path
= NULL
;
786 char *cleanpath
= NULL
;
787 char *extrapath
= NULL
;
791 struct cli_state
*newcli
= NULL
;
792 char *newpath
= NULL
;
793 char *newmount
= NULL
;
795 SMB_STRUCT_STAT sbuf
;
799 if ( !rootcli
|| !path
|| !targetcli
) {
800 return NT_STATUS_INVALID_PARAMETER
;
803 /* Don't do anything if this is not a DFS root. */
805 if ( !rootcli
->dfsroot
) {
806 *targetcli
= rootcli
;
807 *pp_targetpath
= talloc_strdup(ctx
, path
);
808 if (!*pp_targetpath
) {
809 return NT_STATUS_NO_MEMORY
;
816 /* Send a trans2_query_path_info to check for a referral. */
818 cleanpath
= clean_path(ctx
, path
);
820 return NT_STATUS_NO_MEMORY
;
823 dfs_path
= cli_dfs_make_full_path(ctx
, rootcli
, cleanpath
);
825 return NT_STATUS_NO_MEMORY
;
828 status
= cli_qpathinfo_basic( rootcli
, dfs_path
, &sbuf
, &attributes
);
829 if (NT_STATUS_IS_OK(status
)) {
830 /* This is an ordinary path, just return it. */
831 *targetcli
= rootcli
;
832 *pp_targetpath
= talloc_strdup(ctx
, path
);
833 if (!*pp_targetpath
) {
834 return NT_STATUS_NO_MEMORY
;
839 /* Special case where client asked for a path that does not exist */
841 if (cli_dfs_check_error(rootcli
, NT_STATUS_OBJECT_NAME_NOT_FOUND
,
843 *targetcli
= rootcli
;
844 *pp_targetpath
= talloc_strdup(ctx
, path
);
845 if (!*pp_targetpath
) {
846 return NT_STATUS_NO_MEMORY
;
851 /* We got an error, check for DFS referral. */
853 if (!cli_dfs_check_error(rootcli
, NT_STATUS_PATH_NOT_COVERED
,
858 /* Check for the referral. */
860 status
= cli_cm_open(ctx
,
862 cli_state_remote_name(rootcli
),
866 cli_state_encryption_on(rootcli
),
867 cli_state_protocol(rootcli
),
871 if (!NT_STATUS_IS_OK(status
)) {
875 status
= cli_dfs_get_referral(ctx
, cli_ipc
, dfs_path
, &refs
,
876 &num_refs
, &consumed
);
877 if (!NT_STATUS_IS_OK(status
) || !num_refs
) {
881 /* Just store the first referral for now. */
883 if (!refs
[0].dfspath
) {
884 return NT_STATUS_NOT_FOUND
;
886 if (!split_dfs_path(ctx
, refs
[0].dfspath
, &server
, &share
,
888 return NT_STATUS_NOT_FOUND
;
891 /* Make sure to recreate the original string including any wildcards. */
893 dfs_path
= cli_dfs_make_full_path(ctx
, rootcli
, path
);
895 return NT_STATUS_NO_MEMORY
;
897 pathlen
= strlen(dfs_path
);
898 consumed
= MIN(pathlen
, consumed
);
899 *pp_targetpath
= talloc_strdup(ctx
, &dfs_path
[consumed
]);
900 if (!*pp_targetpath
) {
901 return NT_STATUS_NO_MEMORY
;
903 dfs_path
[consumed
] = '\0';
906 * *pp_targetpath is now the unconsumed part of the path.
907 * dfs_path is now the consumed part of the path
908 * (in \server\share\path format).
911 /* Open the connection to the target server & share */
912 status
= cli_cm_open(ctx
, rootcli
,
917 cli_state_encryption_on(rootcli
),
918 cli_state_protocol(rootcli
),
922 if (!NT_STATUS_IS_OK(status
)) {
923 d_printf("Unable to follow dfs referral [\\%s\\%s]\n",
928 if (extrapath
&& strlen(extrapath
) > 0) {
929 /* EMC Celerra NAS version 5.6.50 (at least) doesn't appear to */
930 /* put the trailing \ on the path, so to be save we put one in if needed */
931 if (extrapath
[strlen(extrapath
)-1] != '\\' && **pp_targetpath
!= '\\') {
932 *pp_targetpath
= talloc_asprintf(ctx
,
937 *pp_targetpath
= talloc_asprintf(ctx
,
942 if (!*pp_targetpath
) {
943 return NT_STATUS_NO_MEMORY
;
947 /* parse out the consumed mount path */
948 /* trim off the \server\share\ */
952 if (*ppath
!= '\\') {
953 d_printf("cli_resolve_path: "
954 "dfs_path (%s) not in correct format.\n",
956 return NT_STATUS_NOT_FOUND
;
959 ppath
++; /* Now pointing at start of server name. */
961 if ((ppath
= strchr_m( dfs_path
, '\\' )) == NULL
) {
962 return NT_STATUS_NOT_FOUND
;
965 ppath
++; /* Now pointing at start of share name. */
967 if ((ppath
= strchr_m( ppath
+1, '\\' )) == NULL
) {
968 return NT_STATUS_NOT_FOUND
;
971 ppath
++; /* Now pointing at path component. */
973 newmount
= talloc_asprintf(ctx
, "%s\\%s", mountpt
, ppath
);
975 return NT_STATUS_NOT_FOUND
;
978 cli_set_mntpoint(*targetcli
, newmount
);
980 /* Check for another dfs referral, note that we are not
981 checking for loops here. */
983 if (!strequal(*pp_targetpath
, "\\") && !strequal(*pp_targetpath
, "/")) {
984 status
= cli_resolve_path(ctx
,
991 if (NT_STATUS_IS_OK(status
)) {
993 * When cli_resolve_path returns true here it's always
994 * returning the complete path in newpath, so we're done
998 *pp_targetpath
= newpath
;
1005 /* If returning true ensure we return a dfs root full path. */
1006 if ((*targetcli
)->dfsroot
) {
1007 dfs_path
= talloc_strdup(ctx
, *pp_targetpath
);
1009 return NT_STATUS_NO_MEMORY
;
1011 *pp_targetpath
= cli_dfs_make_full_path(ctx
, *targetcli
, dfs_path
);
1012 if (*pp_targetpath
== NULL
) {
1013 return NT_STATUS_NO_MEMORY
;
1017 return NT_STATUS_OK
;
1020 /********************************************************************
1021 ********************************************************************/
1023 bool cli_check_msdfs_proxy(TALLOC_CTX
*ctx
,
1024 struct cli_state
*cli
,
1025 const char *sharename
,
1026 char **pp_newserver
,
1029 const char *username
,
1030 const char *password
,
1033 struct client_dfs_referral
*refs
= NULL
;
1034 size_t num_refs
= 0;
1035 size_t consumed
= 0;
1036 char *fullpath
= NULL
;
1039 char *newextrapath
= NULL
;
1041 const char *remote_name
;
1043 if (!cli
|| !sharename
) {
1047 remote_name
= cli_state_remote_name(cli
);
1048 cnum
= cli_state_get_tid(cli
);
1050 /* special case. never check for a referral on the IPC$ share */
1052 if (strequal(sharename
, "IPC$")) {
1056 /* send a trans2_query_path_info to check for a referral */
1058 fullpath
= talloc_asprintf(ctx
, "\\%s\\%s", remote_name
, sharename
);
1063 /* check for the referral */
1065 if (!NT_STATUS_IS_OK(cli_tree_connect(cli
, "IPC$", "IPC", NULL
, 0))) {
1069 if (force_encrypt
) {
1070 status
= cli_cm_force_encryption(cli
,
1075 if (!NT_STATUS_IS_OK(status
)) {
1080 status
= cli_dfs_get_referral(ctx
, cli
, fullpath
, &refs
,
1081 &num_refs
, &consumed
);
1082 res
= NT_STATUS_IS_OK(status
);
1084 status
= cli_tdis(cli
);
1085 if (!NT_STATUS_IS_OK(status
)) {
1089 cli_state_set_tid(cli
, cnum
);
1091 if (!res
|| !num_refs
) {
1095 if (!refs
[0].dfspath
) {
1099 if (!split_dfs_path(ctx
, refs
[0].dfspath
, pp_newserver
,
1100 pp_newshare
, &newextrapath
)) {
1104 /* check that this is not a self-referral */
1106 if (strequal(remote_name
, *pp_newserver
) &&
1107 strequal(sharename
, *pp_newshare
)) {