1
0
mirror of https://github.com/samba-team/samba.git synced 2025-11-27 08:23:49 +03:00

r7981: MS-DFS tidyup patches from James Peach <jpeach@sgi.com>.

Looking forward to the day he can commit these himself :-).
Jeremy.
This commit is contained in:
Jeremy Allison
2005-06-28 19:25:48 +00:00
committed by Gerald (Jerry) Carter
parent 97ee7c970c
commit 12ff297829
6 changed files with 42 additions and 32 deletions

View File

@@ -96,6 +96,7 @@ extern int DEBUGLEVEL;
#define DBGC_ACLS 15 #define DBGC_ACLS 15
#define DBGC_PRINTERDB 16 #define DBGC_PRINTERDB 16
#define DBGC_LOCKING 17 #define DBGC_LOCKING 17
#define DBGC_MSDFS 18
/* So you can define DBGC_CLASS before including debug.h */ /* So you can define DBGC_CLASS before including debug.h */
#ifndef DBGC_CLASS #ifndef DBGC_CLASS

View File

@@ -36,6 +36,7 @@
/* Maximum number of referrals for each Dfs volume */ /* Maximum number of referrals for each Dfs volume */
#define MAX_REFERRAL_COUNT 256 #define MAX_REFERRAL_COUNT 256
#define MAX_MSDFS_JUNCTIONS 256
typedef struct _client_referral { typedef struct _client_referral {
uint32 proximity; uint32 proximity;

View File

@@ -166,6 +166,7 @@ static const char *default_classname_table[] = {
"acls", /* DBGC_ACLS */ "acls", /* DBGC_ACLS */
"printerdb", /* DBGC_PRINTERDB */ "printerdb", /* DBGC_PRINTERDB */
"locking", /* DBGC_LOCKING */ "locking", /* DBGC_LOCKING */
"msdfs", /* DBGC_MSDFS */
NULL NULL
}; };

View File

@@ -27,10 +27,8 @@
#include "includes.h" #include "includes.h"
#include "nterr.h" #include "nterr.h"
#define MAX_MSDFS_JUNCTIONS 256
#undef DBGC_CLASS #undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV #define DBGC_CLASS DBGC_MSDFS
/********************************************************************** /**********************************************************************
api_dfs_exist api_dfs_exist

View File

@@ -27,9 +27,7 @@
#include "nterr.h" #include "nterr.h"
#undef DBGC_CLASS #undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV #define DBGC_CLASS DBGC_MSDFS
#define MAX_MSDFS_JUNCTIONS 256
/* This function does not return a WERROR or NTSTATUS code but rather 1 if /* This function does not return a WERROR or NTSTATUS code but rather 1 if
dfs exists, or 0 otherwise. */ dfs exists, or 0 otherwise. */
@@ -321,7 +319,7 @@ WERROR _dfs_enum(pipes_struct *p, DFS_Q_DFS_ENUM *q_u, DFS_R_DFS_ENUM *r_u)
struct junction_map jn[MAX_MSDFS_JUNCTIONS]; struct junction_map jn[MAX_MSDFS_JUNCTIONS];
int num_jn = 0; int num_jn = 0;
num_jn = enum_msdfs_links(jn); num_jn = enum_msdfs_links(jn, ARRAY_SIZE(jn));
vfs_ChDir(p->conn,p->conn->connectpath); vfs_ChDir(p->conn,p->conn->connectpath);
DEBUG(5,("make_reply_dfs_enum: %d junctions found in Dfs, doing level %d\n", num_jn, level)); DEBUG(5,("make_reply_dfs_enum: %d junctions found in Dfs, doing level %d\n", num_jn, level));

View File

@@ -20,6 +20,7 @@
*/ */
#define DBGC_CLASS DBGC_MSDFS
#include "includes.h" #include "includes.h"
extern uint32 global_client_caps; extern uint32 global_client_caps;
@@ -576,7 +577,9 @@ static int setup_ver2_dfs_referral(char* pathname, char** ppdata,
requestedpathlen = rpcstr_push(uni_requestedpath, pathname, -1, requestedpathlen = rpcstr_push(uni_requestedpath, pathname, -1,
STR_TERMINATE); STR_TERMINATE);
dump_data(10, (const char *) uni_requestedpath,requestedpathlen); if (DEBUGLVL(10)) {
dump_data(0, (const char *) uni_requestedpath,requestedpathlen);
}
DEBUG(10,("ref count = %u\n",junction->referral_count)); DEBUG(10,("ref count = %u\n",junction->referral_count));
@@ -671,7 +674,9 @@ static int setup_ver3_dfs_referral(char* pathname, char** ppdata,
reqpathlen = rpcstr_push(uni_reqpath, pathname, -1, STR_TERMINATE); reqpathlen = rpcstr_push(uni_reqpath, pathname, -1, STR_TERMINATE);
dump_data(10, (char *) uni_reqpath,reqpathlen); if (DEBUGLVL(10)) {
dump_data(0, (char *) uni_reqpath,reqpathlen);
}
uni_reqpathoffset1 = REFERRAL_HEADER_SIZE + VERSION3_REFERRAL_SIZE * junction->referral_count; uni_reqpathoffset1 = REFERRAL_HEADER_SIZE + VERSION3_REFERRAL_SIZE * junction->referral_count;
uni_reqpathoffset2 = uni_reqpathoffset1 + reqpathlen; uni_reqpathoffset2 = uni_reqpathoffset1 + reqpathlen;
@@ -797,8 +802,11 @@ int setup_dfs_referral(connection_struct *orig_conn, char *pathname, int max_ref
return -1; return -1;
} }
DEBUG(10,("DFS Referral pdata:\n")); if (DEBUGLVL(10)) {
dump_data(10,*ppdata,reply_size); DEBUGADD(0,("DFS Referral pdata:\n"));
dump_data(0,*ppdata,reply_size);
}
return reply_size; return reply_size;
} }
@@ -937,29 +945,30 @@ BOOL remove_msdfs_link(struct junction_map* jucn)
return ret; return ret;
} }
static BOOL form_junctions(int snum, struct junction_map* jucn, int* jn_count) static int form_junctions(int snum, struct junction_map* jucn, int jn_remain)
{ {
int cnt = *jn_count; int cnt = 0;
DIR *dirp; DIR *dirp;
char* dname; char* dname;
pstring connect_path; pstring connect_path;
char* service_name = lp_servicename(snum); char* service_name = lp_servicename(snum);
connection_struct conns; connection_struct conn;
connection_struct *conn = &conns;
struct referral *ref = NULL; struct referral *ref = NULL;
BOOL ret = False;
if (jn_remain <= 0)
return(0);
pstrcpy(connect_path,lp_pathname(snum)); pstrcpy(connect_path,lp_pathname(snum));
if(*connect_path == '\0') if(*connect_path == '\0')
return False; return 0;
/* /*
* Fake up a connection struct for the VFS layer. * Fake up a connection struct for the VFS layer.
*/ */
if (!create_conn_struct(conn, snum, connect_path)) if (!create_conn_struct(&conn, snum, connect_path))
return False; return 0;
/* form a junction for the msdfs root - convention /* form a junction for the msdfs root - convention
DO NOT REMOVE THIS: NT clients will not work with us DO NOT REMOVE THIS: NT clients will not work with us
@@ -979,22 +988,25 @@ static BOOL form_junctions(int snum, struct junction_map* jucn, int* jn_count)
ref->ttl = REFERRAL_TTL; ref->ttl = REFERRAL_TTL;
if (*lp_msdfs_proxy(snum) != '\0') { if (*lp_msdfs_proxy(snum) != '\0') {
pstrcpy(ref->alternate_path, lp_msdfs_proxy(snum)); pstrcpy(ref->alternate_path, lp_msdfs_proxy(snum));
*jn_count = ++cnt;
ret = True;
goto out; goto out;
} }
slprintf(ref->alternate_path, sizeof(pstring)-1, slprintf(ref->alternate_path, sizeof(pstring)-1,
"\\\\%s\\%s", get_local_machine_name(), service_name); "\\\\%s\\%s", get_local_machine_name(), service_name);
cnt++; cnt++;
/* Now enumerate all dfs links */ /* Now enumerate all dfs links */
dirp = SMB_VFS_OPENDIR(conn, ".", NULL, 0); dirp = SMB_VFS_OPENDIR(&conn, ".", NULL, 0);
if(!dirp) if(!dirp)
goto out; goto out;
while((dname = vfs_readdirname(conn, dirp)) != NULL) { while ((dname = vfs_readdirname(&conn, dirp)) != NULL) {
if (is_msdfs_link(conn, dname, &(jucn[cnt].referral_list), if (cnt >= jn_remain) {
SMB_VFS_CLOSEDIR(&conn,dirp);
DEBUG(2, ("ran out of MSDFS junction slots"));
goto out;
}
if (is_msdfs_link(&conn, dname, &(jucn[cnt].referral_list),
&(jucn[cnt].referral_count), NULL)) { &(jucn[cnt].referral_count), NULL)) {
pstrcpy(jucn[cnt].service_name, service_name); pstrcpy(jucn[cnt].service_name, service_name);
pstrcpy(jucn[cnt].volume_name, dname); pstrcpy(jucn[cnt].volume_name, dname);
@@ -1002,14 +1014,13 @@ static BOOL form_junctions(int snum, struct junction_map* jucn, int* jn_count)
} }
} }
SMB_VFS_CLOSEDIR(conn,dirp); SMB_VFS_CLOSEDIR(&conn,dirp);
*jn_count = cnt;
out: out:
talloc_destroy(conn->mem_ctx); conn_free(&conn);
return ret; return cnt;
} }
int enum_msdfs_links(struct junction_map* jucn) int enum_msdfs_links(struct junction_map* jucn, int jn_max)
{ {
int i=0; int i=0;
int jn_count = 0; int jn_count = 0;
@@ -1017,9 +1028,9 @@ int enum_msdfs_links(struct junction_map* jucn)
if(!lp_host_msdfs()) if(!lp_host_msdfs())
return 0; return 0;
for(i=0;i < lp_numservices();i++) { for(i=0;i < lp_numservices() && (jn_max - jn_count) > 0;i++) {
if(lp_msdfs_root(i)) if(lp_msdfs_root(i))
form_junctions(i,jucn,&jn_count); jn_count += form_junctions(i,jucn,jn_max - jn_count);
} }
return jn_count; return jn_count;
} }