summaryrefslogtreecommitdiff
path: root/source3/msdfs
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2004-03-26 22:26:33 +0000
committerVolker Lendecke <vlendec@samba.org>2004-03-26 22:26:33 +0000
commit87280e9a798895de827e5d1526fbac28a548f710 (patch)
tree94a3ac83b9b9ae1635ffabaedee37e6adf5abab1 /source3/msdfs
parent1a50cf19d065bd3edf97ea975a7db6087e6139a5 (diff)
downloadsamba-87280e9a798895de827e5d1526fbac28a548f710.tar.gz
samba-87280e9a798895de827e5d1526fbac28a548f710.tar.bz2
samba-87280e9a798895de827e5d1526fbac28a548f710.zip
Move the Client-IP based msdfs target expansion to a VFS module.
Volker (This used to be commit 9cb6a4d76f87b28077861d3f4220541fbf704ddf)
Diffstat (limited to 'source3/msdfs')
-rw-r--r--source3/msdfs/msdfs.c139
1 files changed, 5 insertions, 134 deletions
diff --git a/source3/msdfs/msdfs.c b/source3/msdfs/msdfs.c
index 340e5c6750..2ac7bda175 100644
--- a/source3/msdfs/msdfs.c
+++ b/source3/msdfs/msdfs.c
@@ -158,134 +158,13 @@ static BOOL create_conn_struct( connection_struct *conn, int snum, char *path)
}
-/**********************************************************
- Under mapfile we expect a table of the following format:
-
- IP-Prefix whitespace expansion
-
- For example:
- 192.168.234 local.samba.org
- 192.168 remote.samba.org
- default.samba.org
-
- This is to redirect a DFS client to a host close to it.
-***********************************************************/
-
-static BOOL read_target_host(const char *mapfile, pstring targethost)
-{
- XFILE *f;
- pstring buf;
- char *s, *space = buf;
- BOOL found = False;
-
- f = x_fopen(mapfile, O_RDONLY, 0);
-
- if (f == NULL) {
- DEBUG(0,("can't open IP map %s. Error %s\n",
- mapfile, strerror(errno) ));
- return False;
- }
-
- DEBUG(10, ("Scanning mapfile [%s]\n", mapfile));
-
- while ((s=fgets_slash(buf, sizeof(buf), f)) != NULL) {
- space = strchr_m(buf, ' ');
-
- if (space == NULL) {
- DEBUG(0, ("Ignoring invalid line %s\n", buf));
- continue;
- }
-
- *space = '\0';
-
- if (strncmp(client_addr(), buf, strlen(buf)) == 0) {
- found = True;
- break;
- }
- }
-
- x_fclose(f);
-
- if (!found)
- return False;
-
- space += 1;
-
- while (isspace(*space))
- space += 1;
-
- pstrcpy(targethost, space);
- return True;
-}
-
-/**********************************************************
-
- Expand the msdfs target host using read_target_host
- explained above. The syntax used in the msdfs link is
-
- msdfs:@table-filename@/share
-
- Everything between and including the two @-signs is
- replaced by the substitution string found in the table
- described above.
-
-***********************************************************/
-
-static BOOL expand_msdfs_target(connection_struct* conn, pstring target)
-{
- pstring mapfilename;
- char *filename_start = strchr_m(target, '@');
- char *filename_end;
- int filename_len;
- pstring targethost;
- pstring new_target;
-
- if (filename_start == NULL) {
- DEBUG(10, ("No filename start in %s\n", target));
- return False;
- }
-
- filename_end = strchr_m(filename_start+1, '@');
-
- if (filename_end == NULL) {
- DEBUG(10, ("No filename end in %s\n", target));
- return False;
- }
-
- filename_len = PTR_DIFF(filename_end, filename_start+1);
- pstrcpy(mapfilename, filename_start+1);
- mapfilename[filename_len] = '\0';
-
- DEBUG(10, ("Expanding from table [%s]\n", mapfilename));
-
- if (!read_target_host(mapfilename, targethost)) {
- DEBUG(1, ("Could not expand target host from file %s\n",
- mapfilename));
- return False;
- }
-
- standard_sub_conn(conn, mapfilename, sizeof(mapfilename));
-
- DEBUG(10, ("Expanded targethost to %s\n", targethost));
-
- *filename_start = '\0';
- pstrcpy(new_target, target);
- pstrcat(new_target, targethost);
- pstrcat(new_target, filename_end+1);
-
- DEBUG(10, ("New DFS target: %s\n", new_target));
- pstrcpy(target, new_target);
- return True;
-}
-
-
/**********************************************************************
Parse the contents of a symlink to verify if it is an msdfs referral
A valid referral is of the form: msdfs:server1\share1,server2\share2
**********************************************************************/
-static BOOL parse_symlink(connection_struct* conn, char* buf,
- struct referral** preflist, int* refcount)
+static BOOL parse_symlink(char* buf,struct referral** preflist,
+ int* refcount)
{
pstring temp;
char* prot;
@@ -318,22 +197,14 @@ static BOOL parse_symlink(connection_struct* conn, char* buf,
for(i=0;i<count;i++) {
char *p;
- pstring target;
-
- pstrcpy(target, alt_path[i]);
-
- if (strchr_m(target, '@') != NULL) {
- if (!expand_msdfs_target(conn, target))
- return False;
- }
/* replace all /'s in the alternate path by a \ */
- for(p = target; *p && ((p = strchr_m(p,'/'))!=NULL); p++) {
+ for(p = alt_path[i]; *p && ((p = strchr_m(p,'/'))!=NULL); p++) {
*p = '\\';
}
/* Remove leading '\\'s */
- p = target;
+ p = alt_path[i];
while (*p && (*p == '\\')) {
p++;
}
@@ -385,7 +256,7 @@ BOOL is_msdfs_link(connection_struct* conn, char * path,
referral[referral_len] = '\0';
DEBUG(5,("is_msdfs_link: %s -> %s\n",path,referral));
- if (parse_symlink(conn, referral, reflistp, refcnt))
+ if (parse_symlink(referral, reflistp, refcnt))
return True;
}
return False;