**********************************************************************/
static NTSTATUS parse_dfs_path(const char *pathname,
- BOOL allow_wcards,
+ bool allow_wcards,
struct dfs_path *pdp, /* MUST BE TALLOCED */
- BOOL *ppath_contains_wcard)
+ bool *ppath_contains_wcard)
{
char *pathname_local;
char *p,*temp;
Note this CHANGES CWD !!!! JRA.
*********************************************************/
-static NTSTATUS create_conn_struct(connection_struct *conn,
+static NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
+ connection_struct *conn,
int snum,
const char *path)
{
- pstring connpath;
+ char *connpath;
ZERO_STRUCTP(conn);
- pstrcpy(connpath, path);
- pstring_sub(connpath , "%S", lp_servicename(snum));
+ connpath = talloc_strdup(ctx, path);
+ if (!connpath) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ connpath = talloc_string_sub(ctx,
+ connpath,
+ "%S",
+ lp_servicename(snum));
+ if (!connpath) {
+ return NT_STATUS_NO_MEMORY;
+ }
/* needed for smbd_vfs_init() */
server we're referring to understands posix paths.
**********************************************************************/
-static BOOL parse_msdfs_symlink(TALLOC_CTX *ctx,
+static bool parse_msdfs_symlink(TALLOC_CTX *ctx,
const char *target,
struct referral **preflist,
int *refcount)
returns the target string from inside the link.
**********************************************************************/
-static BOOL is_msdfs_link_internal(TALLOC_CTX *ctx,
+static bool is_msdfs_link_internal(TALLOC_CTX *ctx,
connection_struct *conn,
const char *path,
char **pp_link_target,
Returns true if the unix path is a valid msdfs symlink.
**********************************************************************/
-BOOL is_msdfs_link(connection_struct *conn,
+bool is_msdfs_link(connection_struct *conn,
const char *path,
SMB_STRUCT_STAT *sbufp)
{
const char *dfspath, /* Incoming complete dfs path */
const struct dfs_path *pdp, /* Parsed out
server+share+extrapath. */
- BOOL search_flag, /* Called from a findfirst ? */
+ bool search_flag, /* Called from a findfirst ? */
int *consumedcntp,
char **pp_targetpath)
{
static NTSTATUS dfs_redirect(TALLOC_CTX *ctx,
connection_struct *conn,
const char *path_in,
- BOOL search_wcard_flag,
+ bool search_wcard_flag,
char **pp_path_out,
- BOOL *ppath_contains_wcard)
+ bool *ppath_contains_wcard)
{
NTSTATUS status;
struct dfs_path *pdp = TALLOC_P(ctx, struct dfs_path);
const char *dfs_path,
struct junction_map *jucn,
int *consumedcntp,
- BOOL *self_referralp)
+ bool *self_referralp)
{
struct referral *ref;
const char *dfs_path,
struct junction_map *jucn,
int *consumedcntp,
- BOOL *self_referralp)
+ bool *self_referralp)
{
struct connection_struct conns;
struct connection_struct *conn = &conns;
char *targetpath = NULL;
int snum;
NTSTATUS status = NT_STATUS_NOT_FOUND;
- BOOL dummy;
+ bool dummy;
struct dfs_path *pdp = TALLOC_P(ctx, struct dfs_path);
if (!pdp) {
}
}
- if (!lp_msdfs_root(snum)) {
+ if (!lp_msdfs_root(snum) && (*lp_msdfs_proxy(snum) == '\0')) {
DEBUG(3,("get_referred_path: |%s| in dfs path %s is not "
"a dfs root.\n",
pdp->servicename, dfs_path));
*/
if (pdp->reqpath[0] == '\0') {
+ char *tmp;
struct referral *ref;
if (*lp_msdfs_proxy(snum) == '\0') {
return NT_STATUS_NO_MEMORY;
}
- ref->alternate_path = talloc_strdup(ctx, lp_msdfs_proxy(snum));
+ if (!(tmp = talloc_strdup(ctx, lp_msdfs_proxy(snum)))) {
+ TALLOC_FREE(pdp);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ trim_string(tmp, "\\", 0);
+
+ ref->alternate_path = talloc_asprintf(ctx, "\\%s", tmp);
+ TALLOC_FREE(tmp);
+
if (!ref->alternate_path) {
TALLOC_FREE(pdp);
return NT_STATUS_NO_MEMORY;
return NT_STATUS_OK;
}
- status = create_conn_struct(conn, snum, lp_pathname(snum));
+ status = create_conn_struct(ctx, conn, snum, lp_pathname(snum));
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(pdp);
return status;
char **ppdata,
struct junction_map *junction,
int consumedcnt,
- BOOL self_referral)
+ bool self_referral)
{
char* pdata = *ppdata;
- unsigned char uni_requestedpath[sizeof(pstring)];
+ smb_ucs2_t *uni_requestedpath = NULL;
int uni_reqpathoffset1,uni_reqpathoffset2;
int uni_curroffset;
int requestedpathlen=0;
DEBUG(10,("Setting up version2 referral\nRequested path:\n"));
- requestedpathlen = rpcstr_push(uni_requestedpath,
- pathname, sizeof(pstring),
- STR_TERMINATE);
+ requestedpathlen = rpcstr_push_talloc(talloc_tos(),
+ &uni_requestedpath, pathname);
+ if (uni_requestedpath == NULL || requestedpathlen == 0) {
+ return -1;
+ }
if (DEBUGLVL(10)) {
- dump_data(0, uni_requestedpath,requestedpathlen);
+ dump_data(0, (unsigned char *)uni_requestedpath,
+ requestedpathlen);
}
DEBUG(10,("ref count = %u\n",junction->referral_count));
SSVAL(pdata,offset+16,uni_reqpathoffset1-offset);
SSVAL(pdata,offset+18,uni_reqpathoffset2-offset);
/* copy referred path into current offset */
- unilen = rpcstr_push(pdata+uni_curroffset, ref->alternate_path,
- sizeof(pstring), STR_UNICODE);
+ unilen = rpcstr_push(pdata+uni_curroffset,
+ ref->alternate_path,
+ reply_size - uni_curroffset,
+ STR_UNICODE);
SSVAL(pdata,offset+20,uni_curroffset-offset);
char **ppdata,
struct junction_map *junction,
int consumedcnt,
- BOOL self_referral)
+ bool self_referral)
{
char *pdata = *ppdata;
- unsigned char uni_reqpath[sizeof(pstring)];
+ smb_ucs2_t *uni_reqpath = NULL;
int uni_reqpathoffset1, uni_reqpathoffset2;
int uni_curroffset;
int reply_size = 0;
DEBUG(10,("setting up version3 referral\n"));
- reqpathlen = rpcstr_push(uni_reqpath, pathname,
- sizeof(pstring), STR_TERMINATE);
+ reqpathlen = rpcstr_push_talloc(talloc_tos(), &uni_reqpath, pathname);
+ if (uni_reqpath == NULL || reqpathlen == 0) {
+ return -1;
+ }
if (DEBUGLVL(10)) {
- dump_data(0, uni_reqpath,reqpathlen);
+ dump_data(0, (unsigned char *)uni_reqpath,
+ reqpathlen);
}
uni_reqpathoffset1 = REFERRAL_HEADER_SIZE +
SSVAL(pdata,offset+14,uni_reqpathoffset2-offset);
/* copy referred path into current offset */
unilen = rpcstr_push(pdata+uni_curroffset,ref->alternate_path,
- sizeof(pstring),
- STR_UNICODE | STR_TERMINATE);
+ reply_size - uni_curroffset,
+ STR_UNICODE | STR_TERMINATE);
SSVAL(pdata,offset+16,uni_curroffset-offset);
/* copy 0x10 bytes of 00's in the ServiceSite GUID */
memset(pdata+offset+18,'\0',16);
{
struct junction_map *junction = NULL;
int consumedcnt = 0;
- BOOL self_referral = False;
+ bool self_referral = False;
int reply_size = 0;
char *pathnamep = NULL;
char *local_dfs_path = NULL;
Creates a junction structure from a DFS pathname
**********************************************************************/
-BOOL create_junction(TALLOC_CTX *ctx,
+bool create_junction(TALLOC_CTX *ctx,
const char *dfs_path,
struct junction_map *jucn)
{
int snum;
- BOOL dummy;
+ bool dummy;
struct dfs_path *pdp = TALLOC_P(ctx,struct dfs_path);
NTSTATUS status;
Forms a valid Unix pathname from the junction
**********************************************************************/
-static BOOL junction_to_local_path(const struct junction_map *jucn,
+static bool junction_to_local_path(const struct junction_map *jucn,
char **pp_path_out,
connection_struct *conn_out)
{
if(snum < 0) {
return False;
}
- if (!NT_STATUS_IS_OK(create_conn_struct(conn_out, snum,
+ if (!NT_STATUS_IS_OK(create_conn_struct(talloc_tos(),
+ conn_out, snum,
lp_pathname(snum)))) {
return False;
}
return True;
}
-BOOL create_msdfs_link(const struct junction_map *jucn,
- BOOL exists)
+bool create_msdfs_link(const struct junction_map *jucn,
+ bool exists)
{
char *path = NULL;
char *msdfs_link = NULL;
connection_struct conns;
connection_struct *conn = &conns;
int i=0;
- BOOL insert_comma = False;
- BOOL ret = False;
+ bool insert_comma = False;
+ bool ret = False;
ZERO_STRUCT(conns);
return ret;
}
-BOOL remove_msdfs_link(const struct junction_map *jucn)
+bool remove_msdfs_link(const struct junction_map *jucn)
{
char *path = NULL;
connection_struct conns;
connection_struct *conn = &conns;
- BOOL ret = False;
+ bool ret = False;
ZERO_STRUCT(conns);
* Fake up a connection struct for the VFS layer.
*/
- if (!NT_STATUS_IS_OK(create_conn_struct(&conn, snum, connect_path))) {
+ if (!NT_STATUS_IS_OK(create_conn_struct(talloc_tos(),
+ &conn, snum, connect_path))) {
return 0;
}
* Fake up a connection struct for the VFS layer.
*/
- if (!NT_STATUS_IS_OK(create_conn_struct(&conn, snum, connect_path))) {
+ if (!NT_STATUS_IS_OK(create_conn_struct(ctx, &conn, snum, connect_path))) {
return 0;
}
{
struct junction_map *jn = NULL;
int i=0;
- size_t jn_count;
+ size_t jn_count = 0;
int sharecount = 0;
*p_num_jn = 0;
NTSTATUS resolve_dfspath(TALLOC_CTX *ctx,
connection_struct *conn,
- BOOL dfs_pathnames,
+ bool dfs_pathnames,
const char *name_in,
char **pp_name_out)
{
NTSTATUS status = NT_STATUS_OK;
- BOOL dummy;
+ bool dummy;
if (dfs_pathnames) {
status = dfs_redirect(ctx,
conn,
/******************************************************************************
Core function to resolve a dfs pathname possibly containing a wildcard.
- This function is identical to the above except for the BOOL param to
+ This function is identical to the above except for the bool param to
dfs_redirect but I need this to be separate so it's really clear when
we're allowing wildcards and when we're not. JRA.
******************************************************************************/
NTSTATUS resolve_dfspath_wcard(TALLOC_CTX *ctx,
connection_struct *conn,
- BOOL dfs_pathnames,
+ bool dfs_pathnames,
const char *name_in,
char **pp_name_out,
- BOOL *ppath_contains_wcard)
+ bool *ppath_contains_wcard)
{
NTSTATUS status = NT_STATUS_OK;
if (dfs_pathnames) {