Author: vlendec Date: 2007-01-31 13:09:07 +0000 (Wed, 31 Jan 2007) New Revision: 21082
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21082 Log: Make canonicalize_path static to service.c -- we do have conn->connectpath Modified: branches/SAMBA_3_0/source/smbd/notify_fam.c branches/SAMBA_3_0/source/smbd/notify_hash.c branches/SAMBA_3_0/source/smbd/service.c branches/SAMBA_3_0/source/smbd/vfs.c Changeset: Modified: branches/SAMBA_3_0/source/smbd/notify_fam.c =================================================================== --- branches/SAMBA_3_0/source/smbd/notify_fam.c 2007-01-31 13:05:36 UTC (rev 21081) +++ branches/SAMBA_3_0/source/smbd/notify_fam.c 2007-01-31 13:09:07 UTC (rev 21082) @@ -189,7 +189,6 @@ files_struct *fsp, uint32 *filter) { struct fam_notify_ctx *ctx; - pstring fullpath; if ((*filter & FILE_NOTIFY_CHANGE_FILE_NAME) == 0) { DEBUG(10, ("filter = %u, no FILE_NOTIFY_CHANGE_FILE_NAME\n", @@ -197,21 +196,6 @@ return NULL; } - /* FAM needs an absolute pathname. */ - - pstrcpy(fullpath, fsp->fsp_name); - if (!canonicalize_path(fsp->conn, fullpath)) { - DEBUG(0, ("failed to canonicalize path '%s'\n", fullpath)); - return NULL; - } - - if (*fullpath != '/') { - DEBUG(0, ("canonicalized path '%s' into `%s`\n", fsp->fsp_name, - fullpath)); - DEBUGADD(0, ("but expected an absolute path\n")); - return NULL; - } - if (!(ctx = TALLOC_P(mem_ctx, struct fam_notify_ctx))) { return NULL; } @@ -226,8 +210,9 @@ ctx->filter = FILE_NOTIFY_CHANGE_FILE_NAME; - if (!(ctx->path = talloc_strdup(ctx, fullpath))) { - DEBUG(0, ("talloc_strdup failed\n")); + if (!(ctx->path = talloc_asprintf(ctx, "%s/%s", fsp->conn->connectpath, + fsp->fsp_name))) { + DEBUG(0, ("talloc_asprintf failed\n")); TALLOC_FREE(ctx); return NULL; } Modified: branches/SAMBA_3_0/source/smbd/notify_hash.c =================================================================== --- branches/SAMBA_3_0/source/smbd/notify_hash.c 2007-01-31 13:05:36 UTC (rev 21081) +++ branches/SAMBA_3_0/source/smbd/notify_hash.c 2007-01-31 13:09:07 UTC (rev 21082) @@ -222,7 +222,6 @@ { struct hash_notify_ctx *ctx; int timeout = lp_change_notify_timeout(SNUM(fsp->conn)); - pstring fullpath; if (timeout <= 0) { /* It change notify timeout has been disabled, never scan the @@ -230,26 +229,14 @@ return NULL; } - pstrcpy(fullpath, fsp->fsp_name); - if (!canonicalize_path(fsp->conn, fullpath)) { - DEBUG(0, ("failed to canonicalize path '%s'\n", fullpath)); - return NULL; - } - - if (*fullpath != '/') { - DEBUG(0, ("canonicalized path '%s' into `%s`\n", fsp->fsp_name, - fullpath)); - DEBUGADD(0, ("but expected an absolute path\n")); - return NULL; - } - if (!(ctx = TALLOC_P(mem_ctx, struct hash_notify_ctx))) { DEBUG(0, ("talloc failed\n")); return NULL; } - if (!(ctx->path = talloc_strdup(ctx, fullpath))) { - DEBUG(0, ("talloc_strdup failed\n")); + if (!(ctx->path = talloc_asprintf(ctx, "%s/%s", fsp->conn->connectpath, + fsp->fsp_name))) { + DEBUG(0, ("talloc_asprintf failed\n")); TALLOC_FREE(ctx); return NULL; } Modified: branches/SAMBA_3_0/source/smbd/service.c =================================================================== --- branches/SAMBA_3_0/source/smbd/service.c 2007-01-31 13:05:36 UTC (rev 21081) +++ branches/SAMBA_3_0/source/smbd/service.c 2007-01-31 13:09:07 UTC (rev 21082) @@ -22,6 +22,31 @@ extern userdom_struct current_user_info; +BOOL canonicalize_path(connection_struct *conn, pstring path) +{ +#ifdef REALPATH_TAKES_NULL + char *resolved_name = SMB_VFS_REALPATH(conn,path,NULL); + if (!resolved_name) { + return False; + } + pstrcpy(path, resolved_name); + SAFE_FREE(resolved_name); + return True; +#else +#ifdef PATH_MAX + char resolved_name_buf[PATH_MAX+1]; +#else + pstring resolved_name_buf; +#endif + char *resolved_name = SMB_VFS_REALPATH(conn,path,resolved_name_buf); + if (!resolved_name) { + return False; + } + pstrcpy(path, resolved_name); + return True; +#endif /* REALPATH_TAKES_NULL */ +} + /**************************************************************************** Ensure when setting connectpath it is a canonicalized (no ./ // or ../) absolute path stating in / and not ending in /. Modified: branches/SAMBA_3_0/source/smbd/vfs.c =================================================================== --- branches/SAMBA_3_0/source/smbd/vfs.c 2007-01-31 13:05:36 UTC (rev 21081) +++ branches/SAMBA_3_0/source/smbd/vfs.c 2007-01-31 13:09:07 UTC (rev 21082) @@ -792,31 +792,6 @@ return (path); } -BOOL canonicalize_path(connection_struct *conn, pstring path) -{ -#ifdef REALPATH_TAKES_NULL - char *resolved_name = SMB_VFS_REALPATH(conn,path,NULL); - if (!resolved_name) { - return False; - } - pstrcpy(path, resolved_name); - SAFE_FREE(resolved_name); - return True; -#else -#ifdef PATH_MAX - char resolved_name_buf[PATH_MAX+1]; -#else - pstring resolved_name_buf; -#endif - char *resolved_name = SMB_VFS_REALPATH(conn,path,resolved_name_buf); - if (!resolved_name) { - return False; - } - pstrcpy(path, resolved_name); - return True; -#endif /* REALPATH_TAKES_NULL */ -} - /******************************************************************* Reduce a file name, removing .. elements and checking that it is below dir in the heirachy. This uses realpath.