2007-09-11 22:31:29 +04:00
/*
2002-07-15 14:35:28 +04:00
Unix SMB / Netbios implementation .
Version 3.0
2007-03-12 20:55:24 +03:00
MSDFS services for Samba
2000-03-09 01:14:30 +03:00
Copyright ( C ) Shirish Kalele 2000
2007-03-08 01:12:58 +03:00
Copyright ( C ) Jeremy Allison 2007
2000-03-09 01:14:30 +03:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-09 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
2000-03-09 01:14:30 +03:00
( at your option ) any later version .
2007-09-11 22:31:29 +04:00
2000-03-09 01:14:30 +03:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2007-09-11 22:31:29 +04:00
2000-03-09 01:14:30 +03:00
You should have received a copy of the GNU General Public License
2007-07-10 04:52:41 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2002-07-15 14:35:28 +04:00
2000-03-09 01:14:30 +03:00
*/
2005-06-28 23:25:48 +04:00
# define DBGC_CLASS DBGC_MSDFS
2000-03-09 01:14:30 +03:00
# include "includes.h"
2011-02-26 01:20:06 +03:00
# include "system/filesys.h"
2011-03-22 18:57:01 +03:00
# include "smbd/smbd.h"
2009-01-08 14:03:45 +03:00
# include "smbd/globals.h"
2011-02-25 00:58:08 +03:00
# include "msdfs.h"
2011-03-24 15:46:20 +03:00
# include "auth.h"
2011-06-29 09:33:54 +04:00
# include "lib/param/loadparm.h"
2011-07-11 20:09:44 +04:00
# include "libcli/security/security.h"
2011-10-01 11:13:50 +04:00
# include "librpc/gen_ndr/ndr_dfsblobs.h"
2000-03-09 01:14:30 +03:00
2000-05-18 22:43:53 +04:00
/**********************************************************************
2007-03-12 20:55:24 +03:00
Parse a DFS pathname of the form \ hostname \ service \ reqpath
into the dfs_path structure .
If POSIX pathnames is true , the pathname may also be of the
form / hostname / service / reqpath .
We cope with either here .
Unfortunately , due to broken clients who might set the
SVAL ( inbuf , smb_flg2 ) & FLAGS2_DFS_PATHNAMES bit and then
send a local path , we have to cope with that too . . . .
2008-05-20 00:11:00 +04:00
If conn ! = NULL then ensure the provided service is
the one pointed to by the connection .
2007-09-11 22:31:29 +04:00
This version does everything using pointers within one copy of the
pathname string , talloced on the struct dfs_path pointer ( which
must be talloced ) . This may be too clever to live . . . .
2007-03-12 20:55:24 +03:00
JRA .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-06-30 02:32:24 +04:00
2008-05-20 00:11:00 +04:00
static NTSTATUS parse_dfs_path ( connection_struct * conn ,
const char * pathname ,
2007-10-19 04:40:25 +04:00
bool allow_wcards ,
2011-09-24 07:28:08 +04:00
bool allow_broken_path ,
2007-09-11 22:31:29 +04:00
struct dfs_path * pdp , /* MUST BE TALLOCED */
2007-10-19 04:40:25 +04:00
bool * ppath_contains_wcard )
2000-03-09 01:14:30 +03:00
{
2007-09-11 22:31:29 +04:00
char * pathname_local ;
2007-03-12 20:55:24 +03:00
char * p , * temp ;
2008-05-14 02:02:11 +04:00
char * servicename ;
2007-09-11 22:31:29 +04:00
char * eos_ptr ;
2007-03-12 20:55:24 +03:00
NTSTATUS status = NT_STATUS_OK ;
char sepchar ;
ZERO_STRUCTP ( pdp ) ;
2001-06-30 02:32:24 +04:00
2007-09-11 22:31:29 +04:00
/*
* This is the only talloc we should need to do
* on the struct dfs_path . All the pointers inside
* it should point to offsets within this string .
*/
pathname_local = talloc_strdup ( pdp , pathname ) ;
if ( ! pathname_local ) {
return NT_STATUS_NO_MEMORY ;
}
/* Get a pointer to the terminating '\0' */
eos_ptr = & pathname_local [ strlen ( pathname_local ) ] ;
2001-06-30 02:32:24 +04:00
p = temp = pathname_local ;
2007-03-12 20:55:24 +03:00
pdp - > posix_path = ( lp_posix_pathnames ( ) & & * pathname = = ' / ' ) ;
2001-06-30 02:32:24 +04:00
2007-03-12 20:55:24 +03:00
sepchar = pdp - > posix_path ? ' / ' : ' \\ ' ;
2001-06-30 02:32:24 +04:00
2011-09-24 07:28:08 +04:00
if ( allow_broken_path & & ( * pathname ! = sepchar ) ) {
2007-03-12 20:55:24 +03:00
DEBUG ( 10 , ( " parse_dfs_path: path %s doesn't start with %c \n " ,
pathname , sepchar ) ) ;
/*
* Possibly client sent a local path by mistake .
* Try and convert to a local path .
*/
2001-06-30 02:32:24 +04:00
2007-09-11 22:31:29 +04:00
pdp - > hostname = eos_ptr ; /* "" */
pdp - > servicename = eos_ptr ; /* "" */
2007-03-12 20:55:24 +03:00
/* We've got no info about separators. */
pdp - > posix_path = lp_posix_pathnames ( ) ;
p = temp ;
2007-09-11 22:31:29 +04:00
DEBUG ( 10 , ( " parse_dfs_path: trying to convert %s to a "
" local path \n " ,
2007-03-12 20:55:24 +03:00
temp ) ) ;
goto local_path ;
2001-06-30 02:32:24 +04:00
}
2007-09-11 22:31:29 +04:00
/*
* Safe to use on talloc ' ed string as it only shrinks .
* It also doesn ' t affect the eos_ptr .
*/
2007-03-12 20:55:24 +03:00
trim_char ( temp , sepchar , sepchar ) ;
2001-06-30 02:32:24 +04:00
2007-03-12 20:55:24 +03:00
DEBUG ( 10 , ( " parse_dfs_path: temp = |%s| after trimming %c's \n " ,
temp , sepchar ) ) ;
2004-03-10 05:38:39 +03:00
2007-03-12 20:55:24 +03:00
/* Now tokenize. */
/* Parse out hostname. */
p = strchr_m ( temp , sepchar ) ;
if ( p = = NULL ) {
DEBUG ( 10 , ( " parse_dfs_path: can't parse hostname from path %s \n " ,
temp ) ) ;
/*
* Possibly client sent a local path by mistake .
* Try and convert to a local path .
*/
2004-03-10 05:38:39 +03:00
2007-09-11 22:31:29 +04:00
pdp - > hostname = eos_ptr ; /* "" */
pdp - > servicename = eos_ptr ; /* "" */
2004-03-10 05:38:39 +03:00
2007-03-12 20:55:24 +03:00
p = temp ;
2007-09-11 22:31:29 +04:00
DEBUG ( 10 , ( " parse_dfs_path: trying to convert %s "
" to a local path \n " ,
2007-03-12 20:55:24 +03:00
temp ) ) ;
goto local_path ;
}
* p = ' \0 ' ;
2007-09-11 22:31:29 +04:00
pdp - > hostname = temp ;
2007-03-12 20:55:24 +03:00
DEBUG ( 10 , ( " parse_dfs_path: hostname: %s \n " , pdp - > hostname ) ) ;
2004-03-10 05:38:39 +03:00
2007-03-12 20:55:24 +03:00
/* Parse out servicename. */
2008-05-14 02:02:11 +04:00
servicename = p + 1 ;
p = strchr_m ( servicename , sepchar ) ;
if ( p ) {
* p = ' \0 ' ;
}
/* Is this really our servicename ? */
2012-07-18 09:37:23 +04:00
if ( conn & & ! ( strequal ( servicename , lp_servicename ( talloc_tos ( ) , SNUM ( conn ) ) )
2008-05-20 00:11:00 +04:00
| | ( strequal ( servicename , HOMES_NAME )
2012-07-18 09:37:23 +04:00
& & strequal ( lp_servicename ( talloc_tos ( ) , SNUM ( conn ) ) ,
2008-05-20 00:11:00 +04:00
get_current_username ( ) ) ) ) ) {
2008-05-14 02:02:11 +04:00
DEBUG ( 10 , ( " parse_dfs_path: %s is not our servicename \n " ,
servicename ) ) ;
/*
* Possibly client sent a local path by mistake .
* Try and convert to a local path .
*/
pdp - > hostname = eos_ptr ; /* "" */
pdp - > servicename = eos_ptr ; /* "" */
/* Repair the path - replace the sepchar's
we nulled out */
servicename - - ;
* servicename = sepchar ;
if ( p ) {
* p = sepchar ;
}
p = temp ;
DEBUG ( 10 , ( " parse_dfs_path: trying to convert %s "
" to a local path \n " ,
temp ) ) ;
goto local_path ;
}
pdp - > servicename = servicename ;
2008-05-14 02:25:26 +04:00
DEBUG ( 10 , ( " parse_dfs_path: servicename: %s \n " , pdp - > servicename ) ) ;
2004-03-10 05:38:39 +03:00
if ( p = = NULL ) {
2008-05-14 02:02:11 +04:00
/* Client sent self referral \server\share. */
2007-09-11 22:31:29 +04:00
pdp - > reqpath = eos_ptr ; /* "" */
2007-03-12 20:55:24 +03:00
return NT_STATUS_OK ;
2004-03-10 05:38:39 +03:00
}
2008-05-14 02:02:11 +04:00
2007-03-12 20:55:24 +03:00
p + + ;
local_path :
2004-03-10 05:38:39 +03:00
2007-03-12 20:55:24 +03:00
* ppath_contains_wcard = False ;
2007-09-11 22:31:29 +04:00
pdp - > reqpath = p ;
2007-06-16 22:07:44 +04:00
2007-03-12 20:55:24 +03:00
/* Rest is reqpath. */
if ( pdp - > posix_path ) {
2007-06-16 22:07:44 +04:00
status = check_path_syntax_posix ( pdp - > reqpath ) ;
2005-03-25 03:58:15 +03:00
} else {
2007-03-12 20:55:24 +03:00
if ( allow_wcards ) {
2007-09-11 22:31:29 +04:00
status = check_path_syntax_wcard ( pdp - > reqpath ,
ppath_contains_wcard ) ;
2007-03-12 20:55:24 +03:00
} else {
2007-06-16 22:07:44 +04:00
status = check_path_syntax ( pdp - > reqpath ) ;
2007-03-12 20:55:24 +03:00
}
2005-03-25 03:58:15 +03:00
}
2004-03-10 05:38:39 +03:00
2007-03-12 20:55:24 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
DEBUG ( 10 , ( " parse_dfs_path: '%s' failed with %s \n " ,
p , nt_errstr ( status ) ) ) ;
return status ;
}
DEBUG ( 10 , ( " parse_dfs_path: rest of the path: %s \n " , pdp - > reqpath ) ) ;
return NT_STATUS_OK ;
2001-06-30 02:32:24 +04:00
}
/********************************************************
2012-10-10 06:47:49 +04:00
Fake up a connection struct for the VFS layer , for use in
applications ( such as the python bindings ) , that do not want the
global working directory changed under them .
2001-06-30 02:32:24 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-07-27 19:56:48 +04:00
NTSTATUS create_conn_struct ( TALLOC_CTX * ctx ,
2012-05-23 15:06:55 +04:00
struct tevent_context * ev ,
struct messaging_context * msg ,
connection_struct * * pconn ,
int snum ,
const char * path ,
2012-10-10 06:47:49 +04:00
const struct auth_session_info * session_info )
2001-06-30 02:32:24 +04:00
{
2008-04-28 12:31:49 +04:00
connection_struct * conn ;
2007-11-11 09:31:34 +03:00
char * connpath ;
2011-03-01 21:17:49 +03:00
const char * vfs_user ;
2013-01-09 01:02:23 +04:00
struct smbd_server_connection * sconn ;
2013-01-09 04:26:50 +04:00
const char * servicename = lp_const_servicename ( snum ) ;
2005-08-03 00:50:16 +04:00
2013-01-09 01:02:23 +04:00
sconn = talloc_zero ( ctx , struct smbd_server_connection ) ;
if ( sconn = = NULL ) {
return NT_STATUS_NO_MEMORY ;
}
sconn - > ev_ctx = ev ;
sconn - > msg_ctx = msg ;
sconn - > sock = - 1 ;
sconn - > smb1 . echo_handler . trusted_fd = - 1 ;
sconn - > smb1 . echo_handler . socket_lock_fd = - 1 ;
conn = conn_new ( sconn ) ;
2008-04-28 12:31:49 +04:00
if ( conn = = NULL ) {
2013-01-09 01:02:23 +04:00
TALLOC_FREE ( sconn ) ;
2008-04-28 12:31:49 +04:00
return NT_STATUS_NO_MEMORY ;
}
2005-08-03 03:55:38 +04:00
2013-01-09 01:02:23 +04:00
/* Now we have conn, we need to make sconn a child of conn,
* for a proper talloc tree */
talloc_steal ( conn , sconn ) ;
2013-01-09 04:26:50 +04:00
if ( snum = = - 1 & & servicename = = NULL ) {
servicename = " Unknown Service (snum == -1) " ;
}
2008-04-28 12:31:49 +04:00
connpath = talloc_strdup ( conn , path ) ;
2007-11-11 09:31:34 +03:00
if ( ! connpath ) {
2008-04-28 12:31:49 +04:00
TALLOC_FREE ( conn ) ;
2007-11-11 09:31:34 +03:00
return NT_STATUS_NO_MEMORY ;
}
2008-04-28 12:31:49 +04:00
connpath = talloc_string_sub ( conn ,
2012-10-10 06:47:49 +04:00
connpath ,
" %S " ,
2013-01-09 04:26:50 +04:00
servicename ) ;
2007-11-11 09:31:34 +03:00
if ( ! connpath ) {
2008-04-28 12:31:49 +04:00
TALLOC_FREE ( conn ) ;
2007-11-11 09:31:34 +03:00
return NT_STATUS_NO_MEMORY ;
}
2005-08-03 00:50:16 +04:00
2003-08-08 09:10:12 +04:00
/* needed for smbd_vfs_init() */
2006-07-11 22:01:26 +04:00
conn - > params - > service = snum ;
2012-06-06 17:22:31 +04:00
conn - > cnum = TID_FIELD_INVALID ;
2007-03-12 20:55:24 +03:00
2011-02-21 12:25:52 +03:00
if ( session_info ! = NULL ) {
2011-07-15 06:45:17 +04:00
conn - > session_info = copy_session_info ( conn , session_info ) ;
2011-02-21 12:25:52 +03:00
if ( conn - > session_info = = NULL ) {
2008-11-24 00:21:26 +03:00
DEBUG ( 0 , ( " copy_serverinfo failed \n " ) ) ;
TALLOC_FREE ( conn ) ;
return NT_STATUS_NO_MEMORY ;
}
2011-07-15 09:55:31 +04:00
vfs_user = conn - > session_info - > unix_info - > unix_name ;
2011-03-01 21:17:49 +03:00
} else {
/* use current authenticated user in absence of session_info */
vfs_user = get_current_username ( ) ;
2008-11-24 00:21:26 +03:00
}
2005-12-12 21:21:59 +03:00
set_conn_connectpath ( conn , connpath ) ;
2005-08-03 03:55:38 +04:00
2011-07-11 20:09:44 +04:00
/*
* New code to check if there ' s a share security descripter
* added from NT server manager . This is done after the
* smb . conf checks are done as we need a uid and token . JRA .
*
*/
if ( conn - > session_info ) {
share_access_check ( conn - > session_info - > security_token ,
2013-01-09 04:26:50 +04:00
servicename ,
2012-07-18 09:37:23 +04:00
MAXIMUM_ALLOWED_ACCESS ,
2011-07-11 20:09:44 +04:00
& conn - > share_access ) ;
if ( ( conn - > share_access & FILE_WRITE_DATA ) = = 0 ) {
if ( ( conn - > share_access & FILE_READ_DATA ) = = 0 ) {
/* No access, read or write. */
DEBUG ( 0 , ( " create_conn_struct: connection to %s "
" denied due to security "
" descriptor. \n " ,
2013-01-09 04:26:50 +04:00
servicename ) ) ;
2011-07-11 20:09:44 +04:00
conn_free ( conn ) ;
return NT_STATUS_ACCESS_DENIED ;
} else {
conn - > read_only = true ;
}
}
} else {
conn - > share_access = 0 ;
conn - > read_only = true ;
}
2001-10-18 04:27:20 +04:00
if ( ! smbd_vfs_init ( conn ) ) {
2007-04-04 02:59:55 +04:00
NTSTATUS status = map_nt_error_from_unix ( errno ) ;
2002-07-15 14:35:28 +04:00
DEBUG ( 0 , ( " create_conn_struct: smbd_vfs_init failed. \n " ) ) ;
2009-08-07 13:48:03 +04:00
conn_free ( conn ) ;
2007-04-04 02:59:55 +04:00
return status ;
2001-06-30 02:32:24 +04:00
}
2004-03-10 05:38:39 +03:00
2011-03-01 21:17:49 +03:00
/* this must be the first filesystem operation that we do */
2013-01-09 04:26:50 +04:00
if ( SMB_VFS_CONNECT ( conn , servicename , vfs_user ) < 0 ) {
2011-03-01 21:17:49 +03:00
DEBUG ( 0 , ( " VFS connect failed! \n " ) ) ;
conn_free ( conn ) ;
return NT_STATUS_UNSUCCESSFUL ;
}
2009-08-25 07:57:37 +04:00
conn - > fs_capabilities = SMB_VFS_FS_CAPABILITIES ( conn , & conn - > ts_res ) ;
2012-10-10 06:47:49 +04:00
* pconn = conn ;
return NT_STATUS_OK ;
}
/********************************************************
Fake up a connection struct for the VFS layer .
Note : this performs a vfs connect and CHANGES CWD ! ! ! ! JRA .
The old working directory is returned on * poldcwd , allocated on ctx .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
NTSTATUS create_conn_struct_cwd ( TALLOC_CTX * ctx ,
struct tevent_context * ev ,
struct messaging_context * msg ,
connection_struct * * pconn ,
int snum ,
const char * path ,
const struct auth_session_info * session_info ,
char * * poldcwd )
{
connection_struct * conn ;
char * oldcwd ;
NTSTATUS status = create_conn_struct ( ctx , ev ,
msg , & conn ,
snum , path ,
session_info ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
2009-05-01 04:17:23 +04:00
2004-03-10 05:38:39 +03:00
/*
2007-09-11 22:31:29 +04:00
* Windows seems to insist on doing trans2getdfsreferral ( ) calls on
* the IPC $ share as the anonymous user . If we try to chdir as that
* user we will fail . . . . WTF ? JRA .
2004-03-10 05:38:39 +03:00
*/
2008-06-23 00:19:10 +04:00
oldcwd = vfs_GetWd ( ctx , conn ) ;
if ( oldcwd = = NULL ) {
2012-10-10 06:47:49 +04:00
status = map_nt_error_from_unix ( errno ) ;
2008-06-23 00:19:10 +04:00
DEBUG ( 3 , ( " vfs_GetWd failed: %s \n " , strerror ( errno ) ) ) ;
2009-08-07 13:48:03 +04:00
conn_free ( conn ) ;
2008-06-23 00:19:10 +04:00
return status ;
}
2003-10-28 03:51:21 +03:00
if ( vfs_ChDir ( conn , conn - > connectpath ) ! = 0 ) {
2012-10-10 06:47:49 +04:00
status = map_nt_error_from_unix ( errno ) ;
2007-09-11 22:31:29 +04:00
DEBUG ( 3 , ( " create_conn_struct: Can't ChDir to new conn path %s. "
" Error was %s \n " ,
conn - > connectpath , strerror ( errno ) ) ) ;
2009-08-07 13:48:03 +04:00
conn_free ( conn ) ;
2007-04-04 02:59:55 +04:00
return status ;
2003-10-28 03:51:21 +03:00
}
2005-08-03 03:55:38 +04:00
2008-04-28 12:31:49 +04:00
* pconn = conn ;
2008-06-23 00:19:10 +04:00
* poldcwd = oldcwd ;
2008-04-28 12:31:49 +04:00
2007-04-04 02:59:55 +04:00
return NT_STATUS_OK ;
2000-03-09 01:14:30 +03:00
}
2000-05-16 05:13:16 +04:00
/**********************************************************************
Parse the contents of a symlink to verify if it is an msdfs referral
2007-03-12 20:55:24 +03:00
A valid referral is of the form :
msdfs : server1 \ share1 , server2 \ share2
msdfs : server1 \ share1 \ pathname , server2 \ share2 \ pathname
msdfs : server1 / share1 , server2 / share2
msdfs : server1 / share1 / pathname , server2 / share2 / pathname .
Note that the alternate paths returned here must be of the canonicalized
form :
\ server \ share or
\ server \ share \ path \ to \ file ,
even in posix path mode . This is because we have no knowledge if the
server we ' re referring to understands posix paths .
2000-05-16 05:13:16 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2004-03-10 05:38:39 +03:00
2007-10-19 04:40:25 +04:00
static bool parse_msdfs_symlink ( TALLOC_CTX * ctx ,
2007-09-11 22:31:29 +04:00
const char * target ,
2007-03-12 20:55:24 +03:00
struct referral * * preflist ,
int * refcount )
2000-05-16 05:13:16 +04:00
{
2007-09-11 22:31:29 +04:00
char * temp = NULL ;
2007-03-24 21:22:20 +03:00
char * prot ;
2007-09-11 22:31:29 +04:00
char * * alt_path = NULL ;
2005-08-03 03:24:32 +04:00
int count = 0 , i ;
struct referral * reflist ;
2008-01-23 13:04:10 +03:00
char * saveptr ;
2000-05-16 05:13:16 +04:00
2007-09-11 22:31:29 +04:00
temp = talloc_strdup ( ctx , target ) ;
if ( ! temp ) {
return False ;
}
2008-01-23 13:04:10 +03:00
prot = strtok_r ( temp , " : " , & saveptr ) ;
2007-03-24 21:22:20 +03:00
if ( ! prot ) {
DEBUG ( 0 , ( " parse_msdfs_symlink: invalid path ! \n " ) ) ;
return False ;
}
2001-06-30 02:32:24 +04:00
2011-06-07 05:30:12 +04:00
alt_path = talloc_array ( ctx , char * , MAX_REFERRAL_COUNT ) ;
2007-09-11 22:31:29 +04:00
if ( ! alt_path ) {
return False ;
}
2001-06-30 02:32:24 +04:00
/* parse out the alternate paths */
2006-06-13 23:40:28 +04:00
while ( ( count < MAX_REFERRAL_COUNT ) & &
2008-01-23 13:04:10 +03:00
( ( alt_path [ count ] = strtok_r ( NULL , " , " , & saveptr ) ) ! = NULL ) ) {
2001-06-30 02:32:24 +04:00
count + + ;
2005-08-03 03:24:32 +04:00
}
2001-06-30 02:32:24 +04:00
2007-03-12 20:55:24 +03:00
DEBUG ( 10 , ( " parse_msdfs_symlink: count=%d \n " , count ) ) ;
2001-06-30 02:32:24 +04:00
2007-04-30 06:51:26 +04:00
if ( count ) {
2011-06-07 05:58:39 +04:00
reflist = * preflist = talloc_zero_array ( ctx ,
2007-09-11 22:31:29 +04:00
struct referral , count ) ;
2007-04-30 06:51:26 +04:00
if ( reflist = = NULL ) {
2007-09-11 22:31:29 +04:00
TALLOC_FREE ( alt_path ) ;
2007-04-30 06:51:26 +04:00
return False ;
}
} else {
reflist = * preflist = NULL ;
2001-06-30 02:32:24 +04:00
}
2007-09-11 22:31:29 +04:00
2001-06-30 02:32:24 +04:00
for ( i = 0 ; i < count ; i + + ) {
2004-03-12 04:43:25 +03:00
char * p ;
2007-09-11 22:31:29 +04:00
/* Canonicalize link target.
* Replace all / ' s in the path by a \ */
2007-03-12 20:55:24 +03:00
string_replace ( alt_path [ i ] , ' / ' , ' \\ ' ) ;
2004-03-12 04:43:25 +03:00
/* Remove leading '\\'s */
2004-03-27 01:26:33 +03:00
p = alt_path [ i ] ;
2004-03-12 04:43:25 +03:00
while ( * p & & ( * p = = ' \\ ' ) ) {
p + + ;
}
2001-06-30 02:32:24 +04:00
2007-09-11 22:31:29 +04:00
reflist [ i ] . alternate_path = talloc_asprintf ( ctx ,
" \\ %s " ,
p ) ;
if ( ! reflist [ i ] . alternate_path ) {
return False ;
}
2007-03-12 20:55:24 +03:00
2001-06-30 02:32:24 +04:00
reflist [ i ] . proximity = 0 ;
reflist [ i ] . ttl = REFERRAL_TTL ;
2007-09-11 22:31:29 +04:00
DEBUG ( 10 , ( " parse_msdfs_symlink: Created alt path: %s \n " ,
reflist [ i ] . alternate_path ) ) ;
2005-08-03 03:24:32 +04:00
}
2001-06-30 02:32:24 +04:00
2008-06-22 14:50:30 +04:00
* refcount = count ;
2007-09-11 22:31:29 +04:00
TALLOC_FREE ( alt_path ) ;
2001-06-30 02:32:24 +04:00
return True ;
2000-05-16 05:13:16 +04:00
}
2007-09-11 22:31:29 +04:00
2000-05-26 21:10:40 +04:00
/**********************************************************************
2007-03-12 20:55:24 +03:00
Returns true if the unix path is a valid msdfs symlink and also
returns the target string from inside the link .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-10-28 03:51:21 +03:00
2007-10-19 04:40:25 +04:00
static bool is_msdfs_link_internal ( TALLOC_CTX * ctx ,
2007-09-11 22:31:29 +04:00
connection_struct * conn ,
2007-03-12 20:55:24 +03:00
const char * path ,
2007-09-11 22:31:29 +04:00
char * * pp_link_target ,
2007-03-12 20:55:24 +03:00
SMB_STRUCT_STAT * sbufp )
2000-05-16 05:13:16 +04:00
{
2001-06-30 02:32:24 +04:00
int referral_len = 0 ;
2009-05-08 22:31:34 +04:00
# if defined(HAVE_BROKEN_READLINK)
char link_target_buf [ PATH_MAX ] ;
# else
2007-09-11 22:31:29 +04:00
char link_target_buf [ 7 ] ;
2009-05-08 22:31:34 +04:00
# endif
2007-09-11 22:31:29 +04:00
size_t bufsize = 0 ;
char * link_target = NULL ;
2009-11-15 12:46:23 +03:00
struct smb_filename smb_fname ;
2007-09-11 22:31:29 +04:00
if ( pp_link_target ) {
bufsize = 1024 ;
2011-06-07 05:30:12 +04:00
link_target = talloc_array ( ctx , char , bufsize ) ;
2007-09-11 22:31:29 +04:00
if ( ! link_target ) {
return False ;
}
* pp_link_target = link_target ;
} else {
bufsize = sizeof ( link_target_buf ) ;
link_target = link_target_buf ;
}
2000-05-16 05:13:16 +04:00
2009-11-15 12:46:23 +03:00
ZERO_STRUCT ( smb_fname ) ;
smb_fname . base_name = discard_const_p ( char , path ) ;
2002-07-15 14:35:28 +04:00
2009-11-15 12:46:23 +03:00
if ( SMB_VFS_LSTAT ( conn , & smb_fname ) ! = 0 ) {
2007-09-11 22:31:29 +04:00
DEBUG ( 5 , ( " is_msdfs_link_read_target: %s does not exist. \n " ,
path ) ) ;
goto err ;
2001-06-30 02:32:24 +04:00
}
2009-11-15 12:46:23 +03:00
if ( ! S_ISLNK ( smb_fname . st . st_ex_mode ) ) {
2007-09-11 22:31:29 +04:00
DEBUG ( 5 , ( " is_msdfs_link_read_target: %s is not a link. \n " ,
path ) ) ;
goto err ;
2007-03-12 20:55:24 +03:00
}
2009-07-22 02:55:25 +04:00
if ( sbufp ! = NULL ) {
2009-11-15 12:46:23 +03:00
* sbufp = smb_fname . st ;
2009-07-22 02:55:25 +04:00
}
2001-06-30 02:32:24 +04:00
2007-09-11 22:31:29 +04:00
referral_len = SMB_VFS_READLINK ( conn , path , link_target , bufsize - 1 ) ;
2007-03-12 20:55:24 +03:00
if ( referral_len = = - 1 ) {
2007-09-11 22:31:29 +04:00
DEBUG ( 0 , ( " is_msdfs_link_read_target: Error reading "
" msdfs link %s: %s \n " ,
2007-03-12 20:55:24 +03:00
path , strerror ( errno ) ) ) ;
2007-09-11 22:31:29 +04:00
goto err ;
2001-06-30 02:32:24 +04:00
}
2007-03-12 20:55:24 +03:00
link_target [ referral_len ] = ' \0 ' ;
2007-09-11 22:31:29 +04:00
DEBUG ( 5 , ( " is_msdfs_link_internal: %s -> %s \n " , path ,
link_target ) ) ;
2007-03-12 20:55:24 +03:00
if ( ! strnequal ( link_target , " msdfs: " , 6 ) ) {
2007-09-11 22:31:29 +04:00
goto err ;
2007-03-12 20:55:24 +03:00
}
return True ;
2007-09-11 22:31:29 +04:00
err :
if ( link_target ! = link_target_buf ) {
TALLOC_FREE ( link_target ) ;
}
return False ;
}
/**********************************************************************
Returns true if the unix path is a valid msdfs symlink .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-19 04:40:25 +04:00
bool is_msdfs_link ( connection_struct * conn ,
2007-09-11 22:31:29 +04:00
const char * path ,
SMB_STRUCT_STAT * sbufp )
{
return is_msdfs_link_internal ( talloc_tos ( ) ,
conn ,
path ,
NULL ,
sbufp ) ;
2000-05-16 05:13:16 +04:00
}
2002-07-15 14:35:28 +04:00
/*****************************************************************
Used by other functions to decide if a dfs path is remote ,
2007-03-12 20:55:24 +03:00
and to get the list of referred locations for that remote path .
2007-09-11 22:31:29 +04:00
2007-03-12 20:55:24 +03:00
search_flag : For findfirsts , dfs links themselves are not
redirected , but paths beyond the links are . For normal smb calls ,
even dfs links need to be redirected .
2002-07-15 14:35:28 +04:00
2007-03-12 20:55:24 +03:00
consumedcntp : how much of the dfs path is being redirected . the client
should try the remaining path on the redirected server .
2005-08-03 03:24:32 +04:00
2007-03-12 20:55:24 +03:00
If this returns NT_STATUS_PATH_NOT_COVERED the contents of the msdfs
link redirect are in targetpath .
2002-07-15 14:35:28 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-10-28 03:51:21 +03:00
2007-09-11 22:31:29 +04:00
static NTSTATUS dfs_path_lookup ( TALLOC_CTX * ctx ,
connection_struct * conn ,
const char * dfspath , /* Incoming complete dfs path */
const struct dfs_path * pdp , /* Parsed out
server + share + extrapath . */
2007-10-19 04:40:25 +04:00
bool search_flag , /* Called from a findfirst ? */
2007-09-11 22:31:29 +04:00
int * consumedcntp ,
char * * pp_targetpath )
2002-07-15 14:35:28 +04:00
{
2007-03-12 20:55:24 +03:00
char * p = NULL ;
char * q = NULL ;
2007-01-13 02:47:16 +03:00
NTSTATUS status ;
s3: Change unix_convert (and its callers) to use struct smb_filename
This is the first of a series of patches that change path based
operations to operate on a struct smb_filename instead of a char *.
This same concept already exists in source4.
My goals for this series of patches are to eventually:
1) Solve the stream vs. posix filename that contains a colon ambiguity
that currently exists.
2) Make unix_convert the only function that parses the stream name.
3) Clean up the unix_convert API.
4) Change all path based vfs operation to take a struct smb_filename.
5) Make is_ntfs_stream_name() a constant operation that can simply
check the state of struct smb_filename rather than re-parse the
filename.
6) Eliminate the need for split_ntfs_stream_name() to exist.
My strategy is to start from the inside at unix_convert() and work my
way out through the vfs layer, call by call. This first patch does
just that, by changing unix_convert and all of its callers to operate
on struct smb_filename. Since this is such a large change, I plan on
pushing the patches in phases, where each phase keeps full
compatibility and passes make test.
The API of unix_convert has been simplified from:
NTSTATUS unix_convert(TALLOC_CTX *ctx,
connection_struct *conn,
const char *orig_path,
bool allow_wcard_last_component,
char **pp_conv_path,
char **pp_saved_last_component,
SMB_STRUCT_STAT *pst)
to:
NTSTATUS unix_convert(TALLOC_CTX *ctx,
connection_struct *conn,
const char *orig_path,
struct smb_filename *smb_fname,
uint32_t ucf_flags)
Currently the smb_filename struct looks like:
struct smb_filename {
char *base_name;
char *stream_name;
char *original_lcomp;
SMB_STRUCT_STAT st;
};
One key point here is the decision to break up the base_name and
stream_name. I have introduced a helper function called
get_full_smb_filename() that takes an smb_filename struct and
allocates the full_name. I changed the callers of unix_convert() to
subsequently call get_full_smb_filename() for the time being, but I
plan to eventually eliminate get_full_smb_filename().
2009-04-08 00:39:57 +04:00
struct smb_filename * smb_fname = NULL ;
2007-09-11 22:31:29 +04:00
char * canon_dfspath = NULL ; /* Canonicalized dfs path. (only '/'
components ) . */
2002-07-15 14:35:28 +04:00
2007-03-12 20:55:24 +03:00
DEBUG ( 10 , ( " dfs_path_lookup: Conn path = %s reqpath = %s \n " ,
conn - > connectpath , pdp - > reqpath ) ) ;
2003-10-28 03:51:21 +03:00
2007-09-11 22:31:29 +04:00
/*
2011-10-01 00:35:59 +04:00
* Note the unix path conversion here we ' re doing we
2007-02-08 01:20:31 +03:00
* throw away . We ' re looking for a symlink for a dfs
* resolution , if we don ' t find it we ' ll do another
* unix_convert later in the codepath .
*/
2007-01-13 02:47:16 +03:00
s3: Change unix_convert (and its callers) to use struct smb_filename
This is the first of a series of patches that change path based
operations to operate on a struct smb_filename instead of a char *.
This same concept already exists in source4.
My goals for this series of patches are to eventually:
1) Solve the stream vs. posix filename that contains a colon ambiguity
that currently exists.
2) Make unix_convert the only function that parses the stream name.
3) Clean up the unix_convert API.
4) Change all path based vfs operation to take a struct smb_filename.
5) Make is_ntfs_stream_name() a constant operation that can simply
check the state of struct smb_filename rather than re-parse the
filename.
6) Eliminate the need for split_ntfs_stream_name() to exist.
My strategy is to start from the inside at unix_convert() and work my
way out through the vfs layer, call by call. This first patch does
just that, by changing unix_convert and all of its callers to operate
on struct smb_filename. Since this is such a large change, I plan on
pushing the patches in phases, where each phase keeps full
compatibility and passes make test.
The API of unix_convert has been simplified from:
NTSTATUS unix_convert(TALLOC_CTX *ctx,
connection_struct *conn,
const char *orig_path,
bool allow_wcard_last_component,
char **pp_conv_path,
char **pp_saved_last_component,
SMB_STRUCT_STAT *pst)
to:
NTSTATUS unix_convert(TALLOC_CTX *ctx,
connection_struct *conn,
const char *orig_path,
struct smb_filename *smb_fname,
uint32_t ucf_flags)
Currently the smb_filename struct looks like:
struct smb_filename {
char *base_name;
char *stream_name;
char *original_lcomp;
SMB_STRUCT_STAT st;
};
One key point here is the decision to break up the base_name and
stream_name. I have introduced a helper function called
get_full_smb_filename() that takes an smb_filename struct and
allocates the full_name. I changed the callers of unix_convert() to
subsequently call get_full_smb_filename() for the time being, but I
plan to eventually eliminate get_full_smb_filename().
2009-04-08 00:39:57 +04:00
status = unix_convert ( ctx , conn , pdp - > reqpath , & smb_fname ,
2009-07-25 05:38:40 +04:00
search_flag ? UCF_ALWAYS_ALLOW_WCARD_LCOMP : 0 ) ;
s3: Change unix_convert (and its callers) to use struct smb_filename
This is the first of a series of patches that change path based
operations to operate on a struct smb_filename instead of a char *.
This same concept already exists in source4.
My goals for this series of patches are to eventually:
1) Solve the stream vs. posix filename that contains a colon ambiguity
that currently exists.
2) Make unix_convert the only function that parses the stream name.
3) Clean up the unix_convert API.
4) Change all path based vfs operation to take a struct smb_filename.
5) Make is_ntfs_stream_name() a constant operation that can simply
check the state of struct smb_filename rather than re-parse the
filename.
6) Eliminate the need for split_ntfs_stream_name() to exist.
My strategy is to start from the inside at unix_convert() and work my
way out through the vfs layer, call by call. This first patch does
just that, by changing unix_convert and all of its callers to operate
on struct smb_filename. Since this is such a large change, I plan on
pushing the patches in phases, where each phase keeps full
compatibility and passes make test.
The API of unix_convert has been simplified from:
NTSTATUS unix_convert(TALLOC_CTX *ctx,
connection_struct *conn,
const char *orig_path,
bool allow_wcard_last_component,
char **pp_conv_path,
char **pp_saved_last_component,
SMB_STRUCT_STAT *pst)
to:
NTSTATUS unix_convert(TALLOC_CTX *ctx,
connection_struct *conn,
const char *orig_path,
struct smb_filename *smb_fname,
uint32_t ucf_flags)
Currently the smb_filename struct looks like:
struct smb_filename {
char *base_name;
char *stream_name;
char *original_lcomp;
SMB_STRUCT_STAT st;
};
One key point here is the decision to break up the base_name and
stream_name. I have introduced a helper function called
get_full_smb_filename() that takes an smb_filename struct and
allocates the full_name. I changed the callers of unix_convert() to
subsequently call get_full_smb_filename() for the time being, but I
plan to eventually eliminate get_full_smb_filename().
2009-04-08 00:39:57 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2009-07-25 03:05:44 +04:00
if ( ! NT_STATUS_EQUAL ( status ,
NT_STATUS_OBJECT_PATH_NOT_FOUND ) ) {
return status ;
}
2011-10-01 00:35:59 +04:00
if ( smb_fname = = NULL | | smb_fname - > base_name = = NULL ) {
2009-07-25 03:05:44 +04:00
return status ;
}
}
s3: Change unix_convert (and its callers) to use struct smb_filename
This is the first of a series of patches that change path based
operations to operate on a struct smb_filename instead of a char *.
This same concept already exists in source4.
My goals for this series of patches are to eventually:
1) Solve the stream vs. posix filename that contains a colon ambiguity
that currently exists.
2) Make unix_convert the only function that parses the stream name.
3) Clean up the unix_convert API.
4) Change all path based vfs operation to take a struct smb_filename.
5) Make is_ntfs_stream_name() a constant operation that can simply
check the state of struct smb_filename rather than re-parse the
filename.
6) Eliminate the need for split_ntfs_stream_name() to exist.
My strategy is to start from the inside at unix_convert() and work my
way out through the vfs layer, call by call. This first patch does
just that, by changing unix_convert and all of its callers to operate
on struct smb_filename. Since this is such a large change, I plan on
pushing the patches in phases, where each phase keeps full
compatibility and passes make test.
The API of unix_convert has been simplified from:
NTSTATUS unix_convert(TALLOC_CTX *ctx,
connection_struct *conn,
const char *orig_path,
bool allow_wcard_last_component,
char **pp_conv_path,
char **pp_saved_last_component,
SMB_STRUCT_STAT *pst)
to:
NTSTATUS unix_convert(TALLOC_CTX *ctx,
connection_struct *conn,
const char *orig_path,
struct smb_filename *smb_fname,
uint32_t ucf_flags)
Currently the smb_filename struct looks like:
struct smb_filename {
char *base_name;
char *stream_name;
char *original_lcomp;
SMB_STRUCT_STAT st;
};
One key point here is the decision to break up the base_name and
stream_name. I have introduced a helper function called
get_full_smb_filename() that takes an smb_filename struct and
allocates the full_name. I changed the callers of unix_convert() to
subsequently call get_full_smb_filename() for the time being, but I
plan to eventually eliminate get_full_smb_filename().
2009-04-08 00:39:57 +04:00
2007-03-12 20:55:24 +03:00
/* Optimization - check if we can redirect the whole path. */
2009-07-25 03:05:44 +04:00
if ( is_msdfs_link_internal ( ctx , conn , smb_fname - > base_name ,
pp_targetpath , NULL ) ) {
2007-03-12 20:55:24 +03:00
if ( search_flag ) {
DEBUG ( 6 , ( " dfs_path_lookup (FindFirst) No redirection "
2005-04-07 23:43:19 +04:00
" for dfs link %s. \n " , dfspath ) ) ;
2009-07-25 03:05:44 +04:00
status = NT_STATUS_OK ;
goto out ;
2005-04-07 23:43:19 +04:00
}
2005-08-03 03:24:32 +04:00
2007-03-12 20:55:24 +03:00
DEBUG ( 6 , ( " dfs_path_lookup: %s resolves to a "
2007-09-11 22:31:29 +04:00
" valid dfs link %s. \n " , dfspath ,
pp_targetpath ? * pp_targetpath : " " ) ) ;
2007-03-12 20:55:24 +03:00
2005-08-03 03:24:32 +04:00
if ( consumedcntp ) {
2005-03-25 03:58:15 +03:00
* consumedcntp = strlen ( dfspath ) ;
2005-08-03 03:24:32 +04:00
}
2009-07-25 03:05:44 +04:00
status = NT_STATUS_PATH_NOT_COVERED ;
goto out ;
2005-03-25 03:58:15 +03:00
}
2002-07-15 14:35:28 +04:00
2007-03-08 06:00:42 +03:00
/* Prepare to test only for '/' components in the given path,
2007-03-12 20:55:24 +03:00
* so if a Windows path replace all ' \\ ' characters with ' / ' .
* For a POSIX DFS path we know all separators are already ' / ' . */
2007-03-08 06:00:42 +03:00
2007-09-11 22:31:29 +04:00
canon_dfspath = talloc_strdup ( ctx , dfspath ) ;
if ( ! canon_dfspath ) {
2009-07-25 03:05:44 +04:00
status = NT_STATUS_NO_MEMORY ;
goto out ;
2007-09-11 22:31:29 +04:00
}
2007-03-12 20:55:24 +03:00
if ( ! pdp - > posix_path ) {
string_replace ( canon_dfspath , ' \\ ' , ' / ' ) ;
}
2007-08-06 22:54:26 +04:00
/*
* localpath comes out of unix_convert , so it has
* no trailing backslash . Make sure that canon_dfspath hasn ' t either .
* Fix for bug # 4860 from Jan Martin < Jan . Martin @ rwedea . com > .
*/
trim_char ( canon_dfspath , 0 , ' / ' ) ;
2007-03-12 20:55:24 +03:00
/*
* Redirect if any component in the path is a link .
2007-09-11 22:31:29 +04:00
* We do this by walking backwards through the
2007-03-12 20:55:24 +03:00
* local path , chopping off the last component
* in both the local path and the canonicalized
* DFS path . If we hit a DFS link then we ' re done .
*/
2009-07-25 03:05:44 +04:00
p = strrchr_m ( smb_fname - > base_name , ' / ' ) ;
2007-03-12 20:55:24 +03:00
if ( consumedcntp ) {
q = strrchr_m ( canon_dfspath , ' / ' ) ;
}
2007-03-08 06:00:42 +03:00
2003-04-10 23:54:17 +04:00
while ( p ) {
2002-07-15 14:35:28 +04:00
* p = ' \0 ' ;
2007-03-12 20:55:24 +03:00
if ( q ) {
* q = ' \0 ' ;
}
2007-09-11 22:31:29 +04:00
if ( is_msdfs_link_internal ( ctx , conn ,
2009-07-25 03:05:44 +04:00
smb_fname - > base_name , pp_targetpath ,
NULL ) ) {
2007-03-12 20:55:24 +03:00
DEBUG ( 4 , ( " dfs_path_lookup: Redirecting %s because "
2009-07-25 03:05:44 +04:00
" parent %s is dfs link \n " , dfspath ,
smb_fname_str_dbg ( smb_fname ) ) ) ;
2007-03-12 20:55:24 +03:00
2002-07-15 14:35:28 +04:00
if ( consumedcntp ) {
2007-03-12 20:55:24 +03:00
* consumedcntp = strlen ( canon_dfspath ) ;
DEBUG ( 10 , ( " dfs_path_lookup: Path consumed: %s "
2007-09-11 22:31:29 +04:00
" (%d) \n " ,
canon_dfspath ,
* consumedcntp ) ) ;
2002-07-15 14:35:28 +04:00
}
2007-03-12 20:55:24 +03:00
2009-07-25 03:05:44 +04:00
status = NT_STATUS_PATH_NOT_COVERED ;
goto out ;
2007-03-12 20:55:24 +03:00
}
/* Step back on the filesystem. */
2009-07-25 03:05:44 +04:00
p = strrchr_m ( smb_fname - > base_name , ' / ' ) ;
2007-03-12 20:55:24 +03:00
if ( consumedcntp ) {
/* And in the canonicalized dfs path. */
q = strrchr_m ( canon_dfspath , ' / ' ) ;
2002-07-15 14:35:28 +04:00
}
2001-06-30 02:32:24 +04:00
}
2005-08-03 03:24:32 +04:00
2009-07-25 03:05:44 +04:00
status = NT_STATUS_OK ;
out :
TALLOC_FREE ( smb_fname ) ;
return status ;
2000-05-16 05:13:16 +04:00
}
2000-03-09 01:14:30 +03:00
2002-07-15 14:35:28 +04:00
/*****************************************************************
2007-03-12 20:55:24 +03:00
Decides if a dfs pathname should be redirected or not .
If not , the pathname is converted to a tcon - relative local unix path
2007-09-11 22:31:29 +04:00
search_wcard_flag : this flag performs 2 functions both related
2007-03-12 20:55:24 +03:00
to searches . See resolve_dfs_path ( ) and parse_dfs_path_XX ( )
for details .
This function can return NT_STATUS_OK , meaning use the returned path as - is
( mapped into a local path ) .
or NT_STATUS_NOT_COVERED meaning return a DFS redirect , or
any other NT_STATUS error which is a genuine error to be
2007-09-11 22:31:29 +04:00
returned to the client .
2002-07-15 14:35:28 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-10-28 03:51:21 +03:00
2007-09-11 22:31:29 +04:00
static NTSTATUS dfs_redirect ( TALLOC_CTX * ctx ,
connection_struct * conn ,
const char * path_in ,
2007-10-19 04:40:25 +04:00
bool search_wcard_flag ,
2011-09-24 07:35:20 +04:00
bool allow_broken_path ,
2007-09-11 22:31:29 +04:00
char * * pp_path_out ,
2007-10-19 04:40:25 +04:00
bool * ppath_contains_wcard )
2000-03-09 01:14:30 +03:00
{
2007-03-12 20:55:24 +03:00
NTSTATUS status ;
2011-06-07 05:38:41 +04:00
struct dfs_path * pdp = talloc ( ctx , struct dfs_path ) ;
2007-09-11 22:31:29 +04:00
if ( ! pdp ) {
return NT_STATUS_NO_MEMORY ;
}
2011-09-24 07:28:08 +04:00
status = parse_dfs_path ( conn , path_in , search_wcard_flag ,
2011-09-24 07:35:20 +04:00
allow_broken_path , pdp ,
2007-09-11 22:31:29 +04:00
ppath_contains_wcard ) ;
2007-03-12 20:55:24 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2007-09-11 22:31:29 +04:00
TALLOC_FREE ( pdp ) ;
2007-03-12 20:55:24 +03:00
return status ;
}
2007-09-11 22:31:29 +04:00
if ( pdp - > reqpath [ 0 ] = = ' \0 ' ) {
TALLOC_FREE ( pdp ) ;
* pp_path_out = talloc_strdup ( ctx , " " ) ;
if ( ! * pp_path_out ) {
return NT_STATUS_NO_MEMORY ;
}
2007-03-12 20:55:24 +03:00
DEBUG ( 5 , ( " dfs_redirect: self-referral. \n " ) ) ;
return NT_STATUS_OK ;
2005-08-03 03:24:32 +04:00
}
2001-06-30 02:32:24 +04:00
2007-03-12 20:55:24 +03:00
/* If dfs pathname for a non-dfs share, convert to tcon-relative
path and return OK */
2001-06-30 02:32:24 +04:00
2002-07-15 14:35:28 +04:00
if ( ! lp_msdfs_root ( SNUM ( conn ) ) ) {
2007-09-11 22:31:29 +04:00
* pp_path_out = talloc_strdup ( ctx , pdp - > reqpath ) ;
TALLOC_FREE ( pdp ) ;
if ( ! * pp_path_out ) {
return NT_STATUS_NO_MEMORY ;
}
2007-03-12 20:55:24 +03:00
return NT_STATUS_OK ;
2002-07-15 14:35:28 +04:00
}
2007-03-12 20:55:24 +03:00
/* If it looked like a local path (zero hostname/servicename)
2007-09-11 22:31:29 +04:00
* just treat as a tcon - relative path . */
2007-03-12 20:55:24 +03:00
2007-09-11 22:31:29 +04:00
if ( pdp - > hostname [ 0 ] = = ' \0 ' & & pdp - > servicename [ 0 ] = = ' \0 ' ) {
* pp_path_out = talloc_strdup ( ctx , pdp - > reqpath ) ;
TALLOC_FREE ( pdp ) ;
if ( ! * pp_path_out ) {
return NT_STATUS_NO_MEMORY ;
}
2007-03-12 20:55:24 +03:00
return NT_STATUS_OK ;
2005-08-03 03:24:32 +04:00
}
2001-06-30 02:32:24 +04:00
2012-07-18 09:37:23 +04:00
if ( ! ( strequal ( pdp - > servicename , lp_servicename ( talloc_tos ( ) , SNUM ( conn ) ) )
2008-05-11 13:26:33 +04:00
| | ( strequal ( pdp - > servicename , HOMES_NAME )
2012-07-18 09:37:23 +04:00
& & strequal ( lp_servicename ( talloc_tos ( ) , SNUM ( conn ) ) ,
2011-07-15 09:55:31 +04:00
conn - > session_info - > unix_info - > sanitized_username ) ) ) ) {
2008-05-11 13:26:33 +04:00
/* The given sharename doesn't match this connection. */
TALLOC_FREE ( pdp ) ;
return NT_STATUS_OBJECT_PATH_NOT_FOUND ;
}
2007-09-11 22:31:29 +04:00
status = dfs_path_lookup ( ctx , conn , path_in , pdp ,
search_wcard_flag , NULL , NULL ) ;
2007-03-12 20:55:24 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
if ( NT_STATUS_EQUAL ( status , NT_STATUS_PATH_NOT_COVERED ) ) {
2007-09-11 22:31:29 +04:00
DEBUG ( 3 , ( " dfs_redirect: Redirecting %s \n " , path_in ) ) ;
2007-03-12 20:55:24 +03:00
} else {
2007-09-11 22:31:29 +04:00
DEBUG ( 10 , ( " dfs_redirect: dfs_path_lookup "
" failed for %s with %s \n " ,
path_in , nt_errstr ( status ) ) ) ;
2007-03-12 20:55:24 +03:00
}
return status ;
2001-06-30 02:32:24 +04:00
}
2003-09-22 21:53:59 +04:00
2007-09-11 22:31:29 +04:00
DEBUG ( 3 , ( " dfs_redirect: Not redirecting %s. \n " , path_in ) ) ;
2007-03-12 20:55:24 +03:00
/* Form non-dfs tcon-relative path */
2007-09-11 22:31:29 +04:00
* pp_path_out = talloc_strdup ( ctx , pdp - > reqpath ) ;
TALLOC_FREE ( pdp ) ;
if ( ! * pp_path_out ) {
return NT_STATUS_NO_MEMORY ;
}
DEBUG ( 3 , ( " dfs_redirect: Path %s converted to non-dfs path %s \n " ,
path_in ,
* pp_path_out ) ) ;
2007-03-12 20:55:24 +03:00
return NT_STATUS_OK ;
2000-03-09 01:14:30 +03:00
}
2004-03-18 05:17:23 +03:00
/**********************************************************************
Return a self referral .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-04-04 02:59:55 +04:00
static NTSTATUS self_ref ( TALLOC_CTX * ctx ,
2007-03-12 20:55:24 +03:00
const char * dfs_path ,
struct junction_map * jucn ,
int * consumedcntp ,
2007-10-19 04:40:25 +04:00
bool * self_referralp )
2004-03-18 05:17:23 +03:00
{
struct referral * ref ;
2007-03-12 20:55:24 +03:00
* self_referralp = True ;
2004-03-18 05:17:23 +03:00
jucn - > referral_count = 1 ;
2011-06-07 05:44:43 +04:00
if ( ( ref = talloc_zero ( ctx , struct referral ) ) = = NULL ) {
2007-04-04 02:59:55 +04:00
return NT_STATUS_NO_MEMORY ;
2004-03-18 05:17:23 +03:00
}
2007-09-11 22:31:29 +04:00
ref - > alternate_path = talloc_strdup ( ctx , dfs_path ) ;
if ( ! ref - > alternate_path ) {
2012-07-30 16:45:25 +04:00
TALLOC_FREE ( ref ) ;
2007-09-11 22:31:29 +04:00
return NT_STATUS_NO_MEMORY ;
}
2004-03-18 05:17:23 +03:00
ref - > proximity = 0 ;
ref - > ttl = REFERRAL_TTL ;
jucn - > referral_list = ref ;
2007-03-12 20:55:24 +03:00
* consumedcntp = strlen ( dfs_path ) ;
2007-04-04 02:59:55 +04:00
return NT_STATUS_OK ;
2004-03-18 05:17:23 +03:00
}
2002-07-15 14:35:28 +04:00
/**********************************************************************
Gets valid referrals for a dfs path and fills up the
2005-08-03 03:24:32 +04:00
junction_map structure .
2004-03-18 05:17:23 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-10-28 03:51:21 +03:00
2007-04-04 02:59:55 +04:00
NTSTATUS get_referred_path ( TALLOC_CTX * ctx ,
2007-03-12 20:55:24 +03:00
const char * dfs_path ,
2012-05-23 15:09:40 +04:00
bool allow_broken_path ,
2007-03-12 20:55:24 +03:00
struct junction_map * jucn ,
int * consumedcntp ,
2007-10-19 04:40:25 +04:00
bool * self_referralp )
2000-03-09 01:14:30 +03:00
{
2008-04-28 12:31:49 +04:00
struct connection_struct * conn ;
2007-09-11 22:31:29 +04:00
char * targetpath = NULL ;
2002-07-15 14:35:28 +04:00
int snum ;
2007-04-04 02:59:55 +04:00
NTSTATUS status = NT_STATUS_NOT_FOUND ;
2007-10-19 04:40:25 +04:00
bool dummy ;
2011-06-07 05:38:41 +04:00
struct dfs_path * pdp = talloc ( ctx , struct dfs_path ) ;
2008-06-23 00:19:10 +04:00
char * oldpath ;
2002-07-15 14:35:28 +04:00
2007-09-11 22:31:29 +04:00
if ( ! pdp ) {
return NT_STATUS_NO_MEMORY ;
}
2004-03-18 05:17:23 +03:00
2007-03-12 20:55:24 +03:00
* self_referralp = False ;
2002-07-15 14:35:28 +04:00
2012-05-23 15:09:40 +04:00
status = parse_dfs_path ( NULL , dfs_path , False , allow_broken_path ,
2011-09-24 07:42:48 +04:00
pdp , & dummy ) ;
2007-03-12 20:55:24 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2007-04-04 02:59:55 +04:00
return status ;
2007-03-12 20:55:24 +03:00
}
2001-06-30 02:32:24 +04:00
2007-09-11 22:31:29 +04:00
jucn - > service_name = talloc_strdup ( ctx , pdp - > servicename ) ;
jucn - > volume_name = talloc_strdup ( ctx , pdp - > reqpath ) ;
if ( ! jucn - > service_name | | ! jucn - > volume_name ) {
TALLOC_FREE ( pdp ) ;
return NT_STATUS_NO_MEMORY ;
}
2002-07-15 14:35:28 +04:00
/* Verify the share is a dfs root */
2004-01-14 09:41:50 +03:00
snum = lp_servicenumber ( jucn - > service_name ) ;
2002-07-15 14:35:28 +04:00
if ( snum < 0 ) {
2010-11-10 02:07:49 +03:00
char * service_name = NULL ;
if ( ( snum = find_service ( ctx , jucn - > service_name , & service_name ) ) < 0 ) {
2007-04-04 02:59:55 +04:00
return NT_STATUS_NOT_FOUND ;
2005-08-03 03:24:32 +04:00
}
2010-11-10 02:07:49 +03:00
if ( ! service_name ) {
return NT_STATUS_NO_MEMORY ;
}
2007-09-11 22:31:29 +04:00
TALLOC_FREE ( jucn - > service_name ) ;
jucn - > service_name = talloc_strdup ( ctx , service_name ) ;
if ( ! jucn - > service_name ) {
TALLOC_FREE ( pdp ) ;
return NT_STATUS_NO_MEMORY ;
}
2002-07-15 14:35:28 +04:00
}
2004-03-18 05:17:23 +03:00
2012-07-18 09:37:23 +04:00
if ( ! lp_msdfs_root ( snum ) & & ( * lp_msdfs_proxy ( talloc_tos ( ) , snum ) = = ' \0 ' ) ) {
2007-09-11 22:31:29 +04:00
DEBUG ( 3 , ( " get_referred_path: |%s| in dfs path %s is not "
" a dfs root. \n " ,
pdp - > servicename , dfs_path ) ) ;
TALLOC_FREE ( pdp ) ;
2007-04-04 02:59:55 +04:00
return NT_STATUS_NOT_FOUND ;
2004-03-25 17:41:56 +03:00
}
2004-03-18 05:17:23 +03:00
/*
* Self referrals are tested with a anonymous IPC connection and
2007-09-11 22:31:29 +04:00
* a GET_DFS_REFERRAL call to \ \ server \ share . ( which means
* dp . reqpath [ 0 ] points to an empty string ) . create_conn_struct cd ' s
* into the directory and will fail if it cannot ( as the anonymous
* user ) . Cope with this .
2004-03-18 05:17:23 +03:00
*/
2007-09-11 22:31:29 +04:00
if ( pdp - > reqpath [ 0 ] = = ' \0 ' ) {
2007-09-26 03:26:05 +04:00
char * tmp ;
2007-03-12 20:55:24 +03:00
struct referral * ref ;
2004-04-11 14:33:05 +04:00
2012-07-18 09:37:23 +04:00
if ( * lp_msdfs_proxy ( talloc_tos ( ) , snum ) = = ' \0 ' ) {
2007-09-11 22:31:29 +04:00
TALLOC_FREE ( pdp ) ;
2007-03-12 20:55:24 +03:00
return self_ref ( ctx ,
dfs_path ,
jucn ,
consumedcntp ,
self_referralp ) ;
2005-08-03 03:24:32 +04:00
}
2004-04-11 14:33:05 +04:00
2007-09-11 22:31:29 +04:00
/*
2007-03-12 20:55:24 +03:00
* It ' s an msdfs proxy share . Redirect to
* the configured target share .
*/
2004-01-14 09:41:50 +03:00
jucn - > referral_count = 1 ;
2011-06-07 05:44:43 +04:00
if ( ( ref = talloc_zero ( ctx , struct referral ) ) = = NULL ) {
2007-09-11 22:31:29 +04:00
TALLOC_FREE ( pdp ) ;
2007-04-04 02:59:55 +04:00
return NT_STATUS_NO_MEMORY ;
2002-12-27 23:08:35 +03:00
}
2012-07-18 09:37:23 +04:00
if ( ! ( tmp = talloc_strdup ( ctx , lp_msdfs_proxy ( talloc_tos ( ) , snum ) ) ) ) {
2007-09-26 03:26:05 +04:00
TALLOC_FREE ( pdp ) ;
return NT_STATUS_NO_MEMORY ;
}
trim_string ( tmp , " \\ " , 0 ) ;
ref - > alternate_path = talloc_asprintf ( ctx , " \\ %s " , tmp ) ;
TALLOC_FREE ( tmp ) ;
2007-09-11 22:31:29 +04:00
if ( ! ref - > alternate_path ) {
TALLOC_FREE ( pdp ) ;
return NT_STATUS_NO_MEMORY ;
}
if ( pdp - > reqpath [ 0 ] ! = ' \0 ' ) {
2007-09-12 03:57:59 +04:00
ref - > alternate_path = talloc_asprintf_append (
2007-09-11 22:31:29 +04:00
ref - > alternate_path ,
2007-09-12 03:57:59 +04:00
" %s " ,
2007-09-11 22:31:29 +04:00
pdp - > reqpath ) ;
if ( ! ref - > alternate_path ) {
TALLOC_FREE ( pdp ) ;
return NT_STATUS_NO_MEMORY ;
}
2005-08-03 03:24:32 +04:00
}
2002-12-27 23:08:35 +03:00
ref - > proximity = 0 ;
ref - > ttl = REFERRAL_TTL ;
2004-01-14 09:41:50 +03:00
jucn - > referral_list = ref ;
2007-03-12 20:55:24 +03:00
* consumedcntp = strlen ( dfs_path ) ;
2007-09-11 22:31:29 +04:00
TALLOC_FREE ( pdp ) ;
2007-04-04 02:59:55 +04:00
return NT_STATUS_OK ;
2002-12-27 23:08:35 +03:00
}
2012-10-10 06:47:49 +04:00
status = create_conn_struct_cwd ( ctx ,
2013-01-08 02:29:48 +04:00
server_event_context ( ) ,
server_messaging_context ( ) ,
& conn , snum ,
lp_pathname ( talloc_tos ( ) , snum ) , NULL , & oldpath ) ;
2007-04-04 02:59:55 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2007-09-11 22:31:29 +04:00
TALLOC_FREE ( pdp ) ;
2007-04-04 02:59:55 +04:00
return status ;
2005-08-03 03:24:32 +04:00
}
2004-04-11 14:33:05 +04:00
2007-03-12 20:55:24 +03:00
/* If this is a DFS path dfs_lookup should return
* NT_STATUS_PATH_NOT_COVERED . */
2007-09-11 22:31:29 +04:00
status = dfs_path_lookup ( ctx , conn , dfs_path , pdp ,
False , consumedcntp , & targetpath ) ;
2007-03-12 20:55:24 +03:00
if ( ! NT_STATUS_EQUAL ( status , NT_STATUS_PATH_NOT_COVERED ) ) {
DEBUG ( 3 , ( " get_referred_path: No valid referrals for path %s \n " ,
dfs_path ) ) ;
2013-01-25 22:21:48 +04:00
if ( NT_STATUS_IS_OK ( status ) ) {
/*
* We are in an error path here ( we
* know it ' s not a DFS path ) , but
* dfs_path_lookup ( ) can return
* NT_STATUS_OK . Ensure we always
* return a valid error code .
*
* # 9588 - ACLs are not inherited to directories
* for DFS shares .
*/
status = NT_STATUS_NOT_FOUND ;
}
2011-03-01 21:17:49 +03:00
goto err_exit ;
2002-07-15 14:35:28 +04:00
}
2007-03-12 20:55:24 +03:00
/* We know this is a valid dfs link. Parse the targetpath. */
if ( ! parse_msdfs_symlink ( ctx , targetpath ,
& jucn - > referral_list ,
& jucn - > referral_count ) ) {
DEBUG ( 3 , ( " get_referred_path: failed to parse symlink "
" target %s \n " , targetpath ) ) ;
2011-03-01 21:17:49 +03:00
status = NT_STATUS_NOT_FOUND ;
goto err_exit ;
2001-06-30 02:32:24 +04:00
}
2007-03-12 20:55:24 +03:00
2011-03-01 21:17:49 +03:00
status = NT_STATUS_OK ;
err_exit :
2008-06-23 00:19:10 +04:00
vfs_ChDir ( conn , oldpath ) ;
2011-03-01 21:17:49 +03:00
SMB_VFS_DISCONNECT ( conn ) ;
2009-08-07 13:48:03 +04:00
conn_free ( conn ) ;
2007-09-11 22:31:29 +04:00
TALLOC_FREE ( pdp ) ;
2011-03-01 21:17:49 +03:00
return status ;
2000-03-09 01:14:30 +03:00
}
2000-05-18 22:43:53 +04:00
/******************************************************************
2007-03-12 20:55:24 +03:00
Set up the DFS referral for the dfs pathname . This call returns
the amount of the path covered by this server , and where the
client should be redirected to . This is the meat of the
TRANS2_GET_DFS_REFERRAL call .
2005-08-03 03:24:32 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-06-30 02:32:24 +04:00
2007-03-12 20:55:24 +03:00
int setup_dfs_referral ( connection_struct * orig_conn ,
const char * dfs_path ,
int max_referral_level ,
2007-04-04 02:59:55 +04:00
char * * ppdata , NTSTATUS * pstatus )
2000-05-18 22:43:53 +04:00
{
2011-10-01 11:13:50 +04:00
char * pdata = * ppdata ;
2001-06-30 02:32:24 +04:00
int reply_size = 0 ;
2011-10-01 11:13:50 +04:00
struct dfs_GetDFSReferral * r ;
DATA_BLOB blob = data_blob_null ;
NTSTATUS status ;
enum ndr_err_code ndr_err ;
2005-08-03 03:24:32 +04:00
2011-10-01 11:13:50 +04:00
r = talloc_zero ( talloc_tos ( ) , struct dfs_GetDFSReferral ) ;
if ( r = = NULL ) {
2007-04-04 02:59:55 +04:00
* pstatus = NT_STATUS_NO_MEMORY ;
2005-08-03 03:24:32 +04:00
return - 1 ;
}
2000-05-18 22:43:53 +04:00
2011-10-01 11:13:50 +04:00
r - > in . req . max_referral_level = max_referral_level ;
r - > in . req . servername = talloc_strdup ( r , dfs_path ) ;
if ( r - > in . req . servername = = NULL ) {
talloc_free ( r ) ;
2007-09-11 22:31:29 +04:00
* pstatus = NT_STATUS_NO_MEMORY ;
return - 1 ;
}
2002-07-15 14:35:28 +04:00
2011-10-01 11:13:50 +04:00
status = SMB_VFS_GET_DFS_REFERRALS ( orig_conn , r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
talloc_free ( r ) ;
* pstatus = status ;
2007-09-11 22:31:29 +04:00
return - 1 ;
}
2011-10-01 11:13:50 +04:00
ndr_err = ndr_push_struct_blob ( & blob , r ,
r - > out . resp ,
( ndr_push_flags_fn_t ) ndr_push_dfs_referral_resp ) ;
if ( ! NDR_ERR_CODE_IS_SUCCESS ( ndr_err ) ) {
TALLOC_FREE ( r ) ;
* pstatus = NT_STATUS_INVALID_PARAMETER ;
2002-07-15 14:35:28 +04:00
return - 1 ;
2003-10-28 03:51:21 +03:00
}
2002-12-27 23:08:35 +03:00
2011-10-01 11:13:50 +04:00
pdata = ( char * ) SMB_REALLOC ( pdata , blob . length ) ;
if ( pdata = = NULL ) {
TALLOC_FREE ( r ) ;
DEBUG ( 0 , ( " referral setup: "
" malloc failed for Realloc! \n " ) ) ;
2001-06-30 02:32:24 +04:00
return - 1 ;
2000-03-09 01:14:30 +03:00
}
2011-10-01 11:13:50 +04:00
* ppdata = pdata ;
reply_size = blob . length ;
memcpy ( pdata , blob . data , blob . length ) ;
TALLOC_FREE ( r ) ;
2007-09-11 22:31:29 +04:00
2007-04-04 02:59:55 +04:00
* pstatus = NT_STATUS_OK ;
2001-06-30 02:32:24 +04:00
return reply_size ;
2000-03-09 01:14:30 +03:00
}
2000-05-26 21:10:40 +04:00
/**********************************************************************
The following functions are called by the NETDFS RPC pipe functions
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-06-30 02:32:24 +04:00
2005-08-03 03:24:32 +04:00
/*********************************************************************
2007-03-12 20:55:24 +03:00
Creates a junction structure from a DFS pathname
2005-08-03 03:24:32 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-03-25 03:58:15 +03:00
2007-10-19 04:40:25 +04:00
bool create_junction ( TALLOC_CTX * ctx ,
2007-09-11 22:31:29 +04:00
const char * dfs_path ,
2011-09-24 07:53:28 +04:00
bool allow_broken_path ,
2007-09-11 22:31:29 +04:00
struct junction_map * jucn )
2002-07-15 14:35:28 +04:00
{
2007-03-12 20:55:24 +03:00
int snum ;
2007-10-19 04:40:25 +04:00
bool dummy ;
2011-06-07 05:38:41 +04:00
struct dfs_path * pdp = talloc ( ctx , struct dfs_path ) ;
2007-09-11 22:31:29 +04:00
NTSTATUS status ;
2007-03-12 20:55:24 +03:00
2007-09-11 22:31:29 +04:00
if ( ! pdp ) {
return False ;
}
2011-09-24 07:53:28 +04:00
status = parse_dfs_path ( NULL , dfs_path , False , allow_broken_path ,
pdp , & dummy ) ;
2007-03-12 20:55:24 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
return False ;
}
2002-07-15 14:35:28 +04:00
2007-03-12 20:55:24 +03:00
/* check if path is dfs : validate first token */
2007-09-11 22:31:29 +04:00
if ( ! is_myname_or_ipaddr ( pdp - > hostname ) ) {
DEBUG ( 4 , ( " create_junction: Invalid hostname %s "
" in dfs path %s \n " ,
pdp - > hostname , dfs_path ) ) ;
TALLOC_FREE ( pdp ) ;
2006-08-02 20:18:45 +04:00
return False ;
2005-08-03 03:24:32 +04:00
}
2002-07-15 14:35:28 +04:00
2005-08-03 03:24:32 +04:00
/* Check for a non-DFS share */
2007-09-11 22:31:29 +04:00
snum = lp_servicenumber ( pdp - > servicename ) ;
2007-03-12 20:55:24 +03:00
if ( snum < 0 | | ! lp_msdfs_root ( snum ) ) {
DEBUG ( 4 , ( " create_junction: %s is not an msdfs root. \n " ,
2007-09-11 22:31:29 +04:00
pdp - > servicename ) ) ;
TALLOC_FREE ( pdp ) ;
2005-08-03 03:24:32 +04:00
return False ;
}
2002-07-15 14:35:28 +04:00
2007-09-11 22:31:29 +04:00
jucn - > service_name = talloc_strdup ( ctx , pdp - > servicename ) ;
jucn - > volume_name = talloc_strdup ( ctx , pdp - > reqpath ) ;
2012-07-18 09:37:23 +04:00
jucn - > comment = lp_comment ( ctx , snum ) ;
2007-09-11 22:31:29 +04:00
TALLOC_FREE ( pdp ) ;
if ( ! jucn - > service_name | | ! jucn - > volume_name | | ! jucn - > comment ) {
return False ;
}
2005-08-03 03:24:32 +04:00
return True ;
2002-07-15 14:35:28 +04:00
}
/**********************************************************************
2007-09-11 22:31:29 +04:00
Forms a valid Unix pathname from the junction
2002-07-15 14:35:28 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-19 04:40:25 +04:00
static bool junction_to_local_path ( const struct junction_map * jucn ,
2008-06-23 00:19:10 +04:00
char * * pp_path_out ,
connection_struct * * conn_out ,
char * * oldpath )
2002-07-15 14:35:28 +04:00
{
int snum ;
2008-06-23 00:19:10 +04:00
NTSTATUS status ;
2002-07-15 14:35:28 +04:00
2004-01-14 09:41:50 +03:00
snum = lp_servicenumber ( jucn - > service_name ) ;
2005-08-03 03:24:32 +04:00
if ( snum < 0 ) {
2002-07-15 14:35:28 +04:00
return False ;
2005-08-03 03:24:32 +04:00
}
2012-10-10 06:47:49 +04:00
status = create_conn_struct_cwd ( talloc_tos ( ) ,
2013-01-08 02:29:48 +04:00
server_event_context ( ) ,
server_messaging_context ( ) ,
conn_out ,
snum , lp_pathname ( talloc_tos ( ) , snum ) , NULL , oldpath ) ;
2008-06-23 00:19:10 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2002-07-15 14:35:28 +04:00
return False ;
2005-08-03 03:24:32 +04:00
}
2002-07-15 14:35:28 +04:00
2008-06-22 20:36:37 +04:00
* pp_path_out = talloc_asprintf ( * conn_out ,
2007-09-11 22:31:29 +04:00
" %s/%s " ,
2012-07-18 09:37:23 +04:00
lp_pathname ( talloc_tos ( ) , snum ) ,
2007-09-11 22:31:29 +04:00
jucn - > volume_name ) ;
if ( ! * pp_path_out ) {
2008-06-23 00:19:10 +04:00
vfs_ChDir ( * conn_out , * oldpath ) ;
2011-03-01 21:17:49 +03:00
SMB_VFS_DISCONNECT ( * conn_out ) ;
2009-08-07 13:48:03 +04:00
conn_free ( * conn_out ) ;
2007-09-11 22:31:29 +04:00
return False ;
}
2002-07-15 14:35:28 +04:00
return True ;
}
2008-06-22 22:33:28 +04:00
bool create_msdfs_link ( const struct junction_map * jucn )
2000-05-26 21:10:40 +04:00
{
2007-09-11 22:31:29 +04:00
char * path = NULL ;
2008-06-23 00:19:10 +04:00
char * cwd ;
2007-09-11 22:31:29 +04:00
char * msdfs_link = NULL ;
2008-04-28 12:31:49 +04:00
connection_struct * conn ;
2001-06-30 02:32:24 +04:00
int i = 0 ;
2007-10-19 04:40:25 +04:00
bool insert_comma = False ;
bool ret = False ;
2001-06-30 02:32:24 +04:00
2008-06-23 00:19:10 +04:00
if ( ! junction_to_local_path ( jucn , & path , & conn , & cwd ) ) {
2001-06-30 02:32:24 +04:00
return False ;
2005-08-03 03:24:32 +04:00
}
2007-09-11 22:31:29 +04:00
2007-03-12 20:55:24 +03:00
/* Form the msdfs_link contents */
2008-04-28 12:31:49 +04:00
msdfs_link = talloc_strdup ( conn , " msdfs: " ) ;
2007-09-11 22:31:29 +04:00
if ( ! msdfs_link ) {
goto out ;
}
2004-01-14 09:41:50 +03:00
for ( i = 0 ; i < jucn - > referral_count ; i + + ) {
2007-09-11 22:31:29 +04:00
char * refpath = jucn - > referral_list [ i ] . alternate_path ;
2007-03-12 20:55:24 +03:00
/* Alternate paths always use Windows separators. */
2003-09-05 23:59:55 +04:00
trim_char ( refpath , ' \\ ' , ' \\ ' ) ;
2002-07-15 14:35:28 +04:00
if ( * refpath = = ' \0 ' ) {
2005-08-03 03:24:32 +04:00
if ( i = = 0 ) {
2002-07-15 14:35:28 +04:00
insert_comma = False ;
2005-08-03 03:24:32 +04:00
}
2001-06-30 02:32:24 +04:00
continue ;
2002-07-15 14:35:28 +04:00
}
2005-08-03 03:24:32 +04:00
if ( i > 0 & & insert_comma ) {
2007-09-15 02:27:27 +04:00
msdfs_link = talloc_asprintf_append_buffer ( msdfs_link ,
2007-09-12 03:57:59 +04:00
" ,%s " ,
2007-09-11 22:31:29 +04:00
refpath ) ;
} else {
2007-09-15 02:27:27 +04:00
msdfs_link = talloc_asprintf_append_buffer ( msdfs_link ,
2007-09-12 03:57:59 +04:00
" %s " ,
2007-09-11 22:31:29 +04:00
refpath ) ;
2005-08-03 03:24:32 +04:00
}
2002-07-15 14:35:28 +04:00
2007-09-11 22:31:29 +04:00
if ( ! msdfs_link ) {
goto out ;
}
2005-08-03 03:24:32 +04:00
if ( ! insert_comma ) {
2002-07-15 14:35:28 +04:00
insert_comma = True ;
2005-08-03 03:24:32 +04:00
}
2001-06-30 02:32:24 +04:00
}
2007-03-12 20:55:24 +03:00
DEBUG ( 5 , ( " create_msdfs_link: Creating new msdfs link: %s -> %s \n " ,
path , msdfs_link ) ) ;
2001-06-30 02:32:24 +04:00
2008-06-22 22:33:28 +04:00
if ( SMB_VFS_SYMLINK ( conn , msdfs_link , path ) < 0 ) {
if ( errno = = EEXIST ) {
2013-04-15 13:06:57 +04:00
struct smb_filename * smb_fname ;
smb_fname = synthetic_smb_fname ( talloc_tos ( ) , path ,
NULL , NULL ) ;
if ( smb_fname = = NULL ) {
errno = ENOMEM ;
2008-06-22 22:33:28 +04:00
goto out ;
}
2009-07-02 20:27:44 +04:00
if ( SMB_VFS_UNLINK ( conn , smb_fname ) ! = 0 ) {
TALLOC_FREE ( smb_fname ) ;
goto out ;
}
TALLOC_FREE ( smb_fname ) ;
2008-06-22 22:33:28 +04:00
}
if ( SMB_VFS_SYMLINK ( conn , msdfs_link , path ) < 0 ) {
DEBUG ( 1 , ( " create_msdfs_link: symlink failed "
" %s -> %s \n Error: %s \n " ,
path , msdfs_link , strerror ( errno ) ) ) ;
2003-08-08 09:10:12 +04:00
goto out ;
2005-08-03 03:24:32 +04:00
}
}
2001-06-30 02:32:24 +04:00
2003-08-08 09:10:12 +04:00
ret = True ;
2007-03-12 20:55:24 +03:00
2003-08-08 09:10:12 +04:00
out :
2008-06-23 00:19:10 +04:00
vfs_ChDir ( conn , cwd ) ;
2011-03-01 21:17:49 +03:00
SMB_VFS_DISCONNECT ( conn ) ;
2009-08-07 13:48:03 +04:00
conn_free ( conn ) ;
2003-08-08 09:10:12 +04:00
return ret ;
2000-05-26 21:10:40 +04:00
}
2007-10-19 04:40:25 +04:00
bool remove_msdfs_link ( const struct junction_map * jucn )
2000-05-26 21:10:40 +04:00
{
2007-09-11 22:31:29 +04:00
char * path = NULL ;
2008-06-23 00:19:10 +04:00
char * cwd ;
2008-04-28 12:31:49 +04:00
connection_struct * conn ;
2007-10-19 04:40:25 +04:00
bool ret = False ;
2013-04-15 13:08:15 +04:00
struct smb_filename * smb_fname ;
2000-05-26 21:10:40 +04:00
2008-06-23 00:19:10 +04:00
if ( ! junction_to_local_path ( jucn , & path , & conn , & cwd ) ) {
return false ;
}
2013-04-15 13:08:15 +04:00
smb_fname = synthetic_smb_fname ( talloc_tos ( ) , path , NULL , NULL ) ;
if ( smb_fname = = NULL ) {
errno = ENOMEM ;
2009-07-02 20:27:44 +04:00
return false ;
}
if ( SMB_VFS_UNLINK ( conn , smb_fname ) = = 0 ) {
2008-06-23 00:19:10 +04:00
ret = True ;
2003-08-08 09:10:12 +04:00
}
2005-08-03 03:24:32 +04:00
2009-07-02 20:27:44 +04:00
TALLOC_FREE ( smb_fname ) ;
2008-06-23 00:19:10 +04:00
vfs_ChDir ( conn , cwd ) ;
2011-03-01 21:17:49 +03:00
SMB_VFS_DISCONNECT ( conn ) ;
2009-08-07 13:48:03 +04:00
conn_free ( conn ) ;
2003-08-08 09:10:12 +04:00
return ret ;
2000-05-26 21:10:40 +04:00
}
2000-05-16 05:13:16 +04:00
2007-09-11 22:31:29 +04:00
/*********************************************************************
Return the number of DFS links at the root of this share .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static int count_dfs_links ( TALLOC_CTX * ctx , int snum )
{
size_t cnt = 0 ;
2012-03-28 06:22:03 +04:00
DIR * dirp = NULL ;
2009-11-16 11:49:23 +03:00
const char * dname = NULL ;
char * talloced = NULL ;
2012-07-18 09:37:23 +04:00
const char * connect_path = lp_pathname ( talloc_tos ( ) , snum ) ;
const char * msdfs_proxy = lp_msdfs_proxy ( talloc_tos ( ) , snum ) ;
2008-04-28 12:31:49 +04:00
connection_struct * conn ;
2008-06-23 00:19:10 +04:00
NTSTATUS status ;
char * cwd ;
2007-09-11 22:31:29 +04:00
if ( * connect_path = = ' \0 ' ) {
return 0 ;
}
/*
* Fake up a connection struct for the VFS layer .
*/
2012-10-10 06:47:49 +04:00
status = create_conn_struct_cwd ( talloc_tos ( ) ,
2013-01-08 02:29:48 +04:00
server_event_context ( ) ,
server_messaging_context ( ) ,
& conn ,
snum , connect_path , NULL , & cwd ) ;
2008-06-23 00:19:10 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
DEBUG ( 3 , ( " create_conn_struct failed: %s \n " ,
nt_errstr ( status ) ) ) ;
2007-09-11 22:31:29 +04:00
return 0 ;
}
/* Count a link for the msdfs root - convention */
cnt = 1 ;
/* No more links if this is an msdfs proxy. */
if ( * msdfs_proxy ! = ' \0 ' ) {
goto out ;
}
/* Now enumerate all dfs links */
2008-04-28 12:31:49 +04:00
dirp = SMB_VFS_OPENDIR ( conn , " . " , NULL , 0 ) ;
2007-09-11 22:31:29 +04:00
if ( ! dirp ) {
goto out ;
}
2009-11-16 11:49:23 +03:00
while ( ( dname = vfs_readdirname ( conn , dirp , NULL , & talloced ) )
! = NULL ) {
2008-04-28 12:31:49 +04:00
if ( is_msdfs_link ( conn ,
2007-09-11 22:31:29 +04:00
dname ,
NULL ) ) {
cnt + + ;
}
2009-11-16 11:49:23 +03:00
TALLOC_FREE ( talloced ) ;
2007-09-11 22:31:29 +04:00
}
2008-04-28 12:31:49 +04:00
SMB_VFS_CLOSEDIR ( conn , dirp ) ;
2007-09-11 22:31:29 +04:00
out :
2008-06-23 00:19:10 +04:00
vfs_ChDir ( conn , cwd ) ;
2011-03-01 21:17:49 +03:00
SMB_VFS_DISCONNECT ( conn ) ;
2009-08-07 13:48:03 +04:00
conn_free ( conn ) ;
2007-09-11 22:31:29 +04:00
return cnt ;
}
/*********************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-03-12 20:55:24 +03:00
static int form_junctions ( TALLOC_CTX * ctx ,
int snum ,
struct junction_map * jucn ,
2007-09-11 22:31:29 +04:00
size_t jn_remain )
2000-05-18 22:43:53 +04:00
{
2007-09-11 22:31:29 +04:00
size_t cnt = 0 ;
2012-03-28 06:22:03 +04:00
DIR * dirp = NULL ;
2009-11-16 11:49:23 +03:00
const char * dname = NULL ;
char * talloced = NULL ;
2012-07-18 09:37:23 +04:00
const char * connect_path = lp_pathname ( talloc_tos ( ) , snum ) ;
char * service_name = lp_servicename ( talloc_tos ( ) , snum ) ;
const char * msdfs_proxy = lp_msdfs_proxy ( talloc_tos ( ) , snum ) ;
2008-04-28 12:31:49 +04:00
connection_struct * conn ;
2002-12-28 03:18:23 +03:00
struct referral * ref = NULL ;
2008-06-23 00:19:10 +04:00
char * cwd ;
NTSTATUS status ;
2007-09-11 22:31:29 +04:00
if ( jn_remain = = 0 ) {
2005-08-03 03:24:32 +04:00
return 0 ;
}
2005-06-28 23:25:48 +04:00
2005-08-03 03:24:32 +04:00
if ( * connect_path = = ' \0 ' ) {
2005-06-28 23:25:48 +04:00
return 0 ;
2005-08-03 03:24:32 +04:00
}
2001-06-30 02:32:24 +04:00
/*
* Fake up a connection struct for the VFS layer .
*/
2012-10-10 06:47:49 +04:00
status = create_conn_struct_cwd ( ctx ,
2013-01-08 02:29:48 +04:00
server_event_context ( ) ,
server_messaging_context ( ) ,
& conn , snum , connect_path , NULL ,
& cwd ) ;
2008-06-23 00:19:10 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
DEBUG ( 3 , ( " create_conn_struct failed: %s \n " ,
nt_errstr ( status ) ) ) ;
2005-06-28 23:25:48 +04:00
return 0 ;
2005-08-03 03:24:32 +04:00
}
2001-06-30 02:32:24 +04:00
2007-09-11 22:31:29 +04:00
/* form a junction for the msdfs root - convention
2002-12-28 03:18:23 +03:00
DO NOT REMOVE THIS : NT clients will not work with us
if this is not present
2007-09-11 22:31:29 +04:00
*/
jucn [ cnt ] . service_name = talloc_strdup ( ctx , service_name ) ;
jucn [ cnt ] . volume_name = talloc_strdup ( ctx , " " ) ;
2008-05-05 14:45:12 +04:00
if ( ! jucn [ cnt ] . service_name | | ! jucn [ cnt ] . volume_name ) {
2007-09-11 22:31:29 +04:00
goto out ;
}
2008-06-22 15:06:35 +04:00
jucn [ cnt ] . comment = " " ;
2004-01-14 09:41:50 +03:00
jucn [ cnt ] . referral_count = 1 ;
2002-12-28 03:18:23 +03:00
2011-06-07 05:44:43 +04:00
ref = jucn [ cnt ] . referral_list = talloc_zero ( ctx , struct referral ) ;
2004-01-14 09:41:50 +03:00
if ( jucn [ cnt ] . referral_list = = NULL ) {
2003-08-08 09:10:12 +04:00
goto out ;
2002-07-15 14:35:28 +04:00
}
2001-06-30 02:32:24 +04:00
2002-12-28 03:18:23 +03:00
ref - > proximity = 0 ;
ref - > ttl = REFERRAL_TTL ;
2007-09-11 22:31:29 +04:00
if ( * msdfs_proxy ! = ' \0 ' ) {
ref - > alternate_path = talloc_strdup ( ctx ,
msdfs_proxy ) ;
} else {
ref - > alternate_path = talloc_asprintf ( ctx ,
" \\ \\ %s \\ %s " ,
2007-03-12 20:55:24 +03:00
get_local_machine_name ( ) ,
service_name ) ;
2007-09-11 22:31:29 +04:00
}
if ( ! ref - > alternate_path ) {
goto out ;
}
2002-12-28 03:18:23 +03:00
cnt + + ;
2005-06-28 23:25:48 +04:00
2007-09-11 22:31:29 +04:00
/* Don't enumerate if we're an msdfs proxy. */
if ( * msdfs_proxy ! = ' \0 ' ) {
goto out ;
}
2002-12-28 03:18:23 +03:00
/* Now enumerate all dfs links */
2008-04-28 12:31:49 +04:00
dirp = SMB_VFS_OPENDIR ( conn , " . " , NULL , 0 ) ;
2005-08-03 03:24:32 +04:00
if ( ! dirp ) {
2003-08-08 09:10:12 +04:00
goto out ;
2005-08-03 03:24:32 +04:00
}
2001-06-30 02:32:24 +04:00
2009-11-16 11:49:23 +03:00
while ( ( dname = vfs_readdirname ( conn , dirp , NULL , & talloced ) )
! = NULL ) {
2007-09-11 22:31:29 +04:00
char * link_target = NULL ;
2005-06-28 23:25:48 +04:00
if ( cnt > = jn_remain ) {
2007-09-11 22:31:29 +04:00
DEBUG ( 2 , ( " form_junctions: ran out of MSDFS "
" junction slots " ) ) ;
2009-11-16 11:49:23 +03:00
TALLOC_FREE ( talloced ) ;
2005-06-28 23:25:48 +04:00
goto out ;
}
2007-09-11 22:31:29 +04:00
if ( is_msdfs_link_internal ( ctx ,
2008-04-28 12:31:49 +04:00
conn ,
2007-09-11 22:31:29 +04:00
dname , & link_target ,
NULL ) ) {
2007-03-12 20:55:24 +03:00
if ( parse_msdfs_symlink ( ctx ,
link_target ,
& jucn [ cnt ] . referral_list ,
& jucn [ cnt ] . referral_count ) ) {
2007-09-11 22:31:29 +04:00
jucn [ cnt ] . service_name = talloc_strdup ( ctx ,
service_name ) ;
jucn [ cnt ] . volume_name = talloc_strdup ( ctx ,
dname ) ;
if ( ! jucn [ cnt ] . service_name | |
! jucn [ cnt ] . volume_name ) {
2009-11-16 11:49:23 +03:00
TALLOC_FREE ( talloced ) ;
2007-09-11 22:31:29 +04:00
goto out ;
}
2008-06-22 15:06:35 +04:00
jucn [ cnt ] . comment = " " ;
2007-03-12 20:55:24 +03:00
cnt + + ;
}
2008-06-22 13:28:57 +04:00
TALLOC_FREE ( link_target ) ;
2001-06-30 02:32:24 +04:00
}
2009-11-16 11:49:23 +03:00
TALLOC_FREE ( talloced ) ;
2000-05-18 22:43:53 +04:00
}
2005-08-03 03:24:32 +04:00
2003-08-08 09:10:12 +04:00
out :
2005-08-03 03:55:38 +04:00
2007-09-11 22:31:29 +04:00
if ( dirp ) {
2008-04-28 12:31:49 +04:00
SMB_VFS_CLOSEDIR ( conn , dirp ) ;
2007-09-11 22:31:29 +04:00
}
2008-06-23 00:19:10 +04:00
vfs_ChDir ( conn , cwd ) ;
2009-08-07 13:48:03 +04:00
conn_free ( conn ) ;
2005-06-28 23:25:48 +04:00
return cnt ;
2000-05-18 22:43:53 +04:00
}
2011-12-13 15:29:54 +04:00
struct junction_map * enum_msdfs_links ( TALLOC_CTX * ctx , size_t * p_num_jn )
2000-05-18 22:43:53 +04:00
{
2007-09-11 22:31:29 +04:00
struct junction_map * jn = NULL ;
2001-06-30 02:32:24 +04:00
int i = 0 ;
2007-09-16 00:24:35 +04:00
size_t jn_count = 0 ;
2006-02-04 01:19:41 +03:00
int sharecount = 0 ;
2001-06-30 02:32:24 +04:00
2007-09-11 22:31:29 +04:00
* p_num_jn = 0 ;
2005-08-03 03:24:32 +04:00
if ( ! lp_host_msdfs ( ) ) {
2007-09-11 22:31:29 +04:00
return NULL ;
2005-08-03 03:24:32 +04:00
}
2001-06-30 02:32:24 +04:00
2006-02-04 01:19:41 +03:00
/* Ensure all the usershares are loaded. */
become_root ( ) ;
2006-11-30 10:38:40 +03:00
load_registry_shares ( ) ;
2011-12-13 15:24:03 +04:00
sharecount = load_usershare_shares ( NULL , connections_snum_used ) ;
2006-02-04 01:19:41 +03:00
unbecome_root ( ) ;
2007-09-11 22:31:29 +04:00
for ( i = 0 ; i < sharecount ; i + + ) {
2005-08-03 03:24:32 +04:00
if ( lp_msdfs_root ( i ) ) {
2007-09-11 22:31:29 +04:00
jn_count + = count_dfs_links ( ctx , i ) ;
2005-08-03 03:24:32 +04:00
}
2001-06-30 02:32:24 +04:00
}
2007-09-11 22:31:29 +04:00
if ( jn_count = = 0 ) {
return NULL ;
}
2011-06-07 05:30:12 +04:00
jn = talloc_array ( ctx , struct junction_map , jn_count ) ;
2007-09-11 22:31:29 +04:00
if ( ! jn ) {
return NULL ;
}
for ( i = 0 ; i < sharecount ; i + + ) {
if ( * p_num_jn > = jn_count ) {
break ;
}
if ( lp_msdfs_root ( i ) ) {
* p_num_jn + = form_junctions ( ctx , i ,
& jn [ * p_num_jn ] ,
jn_count - * p_num_jn ) ;
}
}
return jn ;
2000-05-18 22:43:53 +04:00
}
2007-03-08 01:12:58 +03:00
/******************************************************************************
2009-07-24 23:13:07 +04:00
Core function to resolve a dfs pathname possibly containing a wildcard . If
ppath_contains_wcard ! = NULL , it will be set to true if a wildcard is
detected during dfs resolution .
2007-03-08 01:12:58 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-09-11 22:31:29 +04:00
NTSTATUS resolve_dfspath_wcard ( TALLOC_CTX * ctx ,
connection_struct * conn ,
2007-10-19 04:40:25 +04:00
bool dfs_pathnames ,
2007-09-11 22:31:29 +04:00
const char * name_in ,
2010-04-09 07:32:36 +04:00
bool allow_wcards ,
2012-05-23 15:22:47 +04:00
bool allow_broken_path ,
2007-09-11 22:31:29 +04:00
char * * pp_name_out ,
2007-10-19 04:40:25 +04:00
bool * ppath_contains_wcard )
2007-03-08 01:12:58 +03:00
{
2009-07-24 23:13:07 +04:00
bool path_contains_wcard ;
2007-03-12 20:55:24 +03:00
NTSTATUS status = NT_STATUS_OK ;
2009-07-24 23:13:07 +04:00
2007-03-23 01:15:35 +03:00
if ( dfs_pathnames ) {
2007-09-11 22:31:29 +04:00
status = dfs_redirect ( ctx ,
conn ,
name_in ,
2010-04-09 07:32:36 +04:00
allow_wcards ,
2012-05-23 15:22:47 +04:00
allow_broken_path ,
2007-09-11 22:31:29 +04:00
pp_name_out ,
2009-07-24 23:13:07 +04:00
& path_contains_wcard ) ;
if ( NT_STATUS_IS_OK ( status ) & & ppath_contains_wcard ! = NULL ) {
* ppath_contains_wcard = path_contains_wcard ;
}
2007-09-11 22:31:29 +04:00
} else {
/*
* Cheat and just return a copy of the in ptr .
* Once srvstr_get_path ( ) uses talloc it ' ll
* be a talloced ptr anyway .
*/
2011-05-06 01:22:11 +04:00
* pp_name_out = discard_const_p ( char , name_in ) ;
2007-03-08 01:12:58 +03:00
}
2007-03-12 20:55:24 +03:00
return status ;
2007-03-08 01:12:58 +03:00
}