summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-03-18 02:17:20 +0000
committerJeremy Allison <jra@samba.org>2004-03-18 02:17:20 +0000
commit9305cd4f2d8c2c18daaa197f1513da1c3d3ee7c1 (patch)
tree116bd74aeb0bf46030ec9eb8e3c8a75a5548570b
parent5a2fd8e76587a572cdb97fa87a99cda3e450ce0e (diff)
downloadsamba-9305cd4f2d8c2c18daaa197f1513da1c3d3ee7c1.tar.gz
Added a varient of Volker's patch to fix the "self-referrals as anonymous user"
problem. Jeremy.
-rw-r--r--source/msdfs/msdfs.c68
1 files changed, 49 insertions, 19 deletions
diff --git a/source/msdfs/msdfs.c b/source/msdfs/msdfs.c
index b77e2111bc9..2df5fcf4f5a 100644
--- a/source/msdfs/msdfs.c
+++ b/source/msdfs/msdfs.c
@@ -151,10 +151,8 @@ static BOOL create_conn_struct( connection_struct *conn, int snum, char *path)
if (vfs_ChDir(conn,conn->connectpath) != 0) {
DEBUG(3,("create_conn_struct: Can't ChDir to new conn path %s. Error was %s\n",
conn->connectpath, strerror(errno) ));
-#if 0 /* JRATEST ? */
talloc_destroy( conn->mem_ctx );
return False;
-#endif
}
return True;
}
@@ -407,12 +405,40 @@ BOOL dfs_redirect(pstring pathname, connection_struct* conn,
}
/**********************************************************************
+ Return a self referral.
+**********************************************************************/
+
+static BOOL self_ref(char *pathname, struct junction_map *jucn,
+ int *consumedcntp, BOOL *self_referralp)
+{
+ struct referral *ref;
+
+ if (self_referralp != NULL)
+ *self_referralp = True;
+
+ jucn->referral_count = 1;
+ if((ref = (struct referral*) malloc(sizeof(struct referral))) == NULL) {
+ DEBUG(0,("self_ref: malloc failed for referral\n"));
+ return False;
+ }
+
+ pstrcpy(ref->alternate_path,pathname);
+ ref->proximity = 0;
+ ref->ttl = REFERRAL_TTL;
+ jucn->referral_list = ref;
+ if (consumedcntp)
+ *consumedcntp = strlen(pathname);
+
+ return True;
+}
+
+/**********************************************************************
Gets valid referrals for a dfs path and fills up the
junction_map structure
- **********************************************************************/
+**********************************************************************/
-BOOL get_referred_path(char *pathname, struct junction_map* jucn,
- int* consumedcntp, BOOL* self_referralp)
+BOOL get_referred_path(char *pathname, struct junction_map *jucn,
+ int *consumedcntp, BOOL *self_referralp)
{
struct dfs_path dp;
@@ -421,12 +447,13 @@ BOOL get_referred_path(char *pathname, struct junction_map* jucn,
pstring conn_path;
int snum;
BOOL ret = False;
-
BOOL self_referral = False;
if (!pathname || !jucn)
return False;
+ ZERO_STRUCT(conns);
+
if (self_referralp)
*self_referralp = False;
else
@@ -453,7 +480,18 @@ BOOL get_referred_path(char *pathname, struct junction_map* jucn,
if ((snum = find_service(jucn->service_name)) < 0)
return False;
}
-
+
+ /*
+ * Self referrals are tested with a anonymous IPC connection and
+ * 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.
+ */
+
+ if (dp.reqpath[0] == '\0') {
+ return self_ref(pathname, jucn, consumedcntp, self_referralp);
+ }
+
pstrcpy(conn_path, lp_pathname(snum));
if (!create_conn_struct(conn, snum, conn_path))
return False;
@@ -496,24 +534,16 @@ BOOL get_referred_path(char *pathname, struct junction_map* jucn,
/* if self_referral, fill up the junction map */
if (*self_referralp) {
- struct referral* ref;
- jucn->referral_count = 1;
- if((ref = (struct referral*) malloc(sizeof(struct referral))) == NULL) {
- DEBUG(0,("malloc failed for referral\n"));
+ if (self_ref(pathname, jucn, consumedcntp, self_referralp) == False) {
goto out;
}
-
- pstrcpy(ref->alternate_path,pathname);
- ref->proximity = 0;
- ref->ttl = REFERRAL_TTL;
- jucn->referral_list = ref;
- if (consumedcntp)
- *consumedcntp = strlen(pathname);
}
ret = True;
+
out:
- talloc_destroy( conn->mem_ctx );
+ if (conn->mem_ctx)
+ talloc_destroy( conn->mem_ctx );
return ret;
}