summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-01-31 13:09:07 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:17:34 -0500
commit37a3339a1891f0189ff62891e6be85ace23efc33 (patch)
treec9ebe817b0b99c677b46df209b3a9094c77c20d1 /source3
parent6490e114b8e9ffc9d35a0eaee66f9bdef65708fc (diff)
downloadsamba-37a3339a1891f0189ff62891e6be85ace23efc33.tar.gz
samba-37a3339a1891f0189ff62891e6be85ace23efc33.tar.bz2
samba-37a3339a1891f0189ff62891e6be85ace23efc33.zip
r21082: Make canonicalize_path static to service.c -- we do have conn->connectpath
(This used to be commit 06f58096e3785d0e2e0b9f2053d4975e44568e15)
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/notify_fam.c21
-rw-r--r--source3/smbd/notify_hash.c19
-rw-r--r--source3/smbd/service.c25
-rw-r--r--source3/smbd/vfs.c25
4 files changed, 31 insertions, 59 deletions
diff --git a/source3/smbd/notify_fam.c b/source3/smbd/notify_fam.c
index aba1f5dcb3..08dc4eabb0 100644
--- a/source3/smbd/notify_fam.c
+++ b/source3/smbd/notify_fam.c
@@ -189,7 +189,6 @@ static void *fam_notify_add(TALLOC_CTX *mem_ctx,
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 @@ static void *fam_notify_add(TALLOC_CTX *mem_ctx,
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 @@ static void *fam_notify_add(TALLOC_CTX *mem_ctx,
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;
}
diff --git a/source3/smbd/notify_hash.c b/source3/smbd/notify_hash.c
index 5f563419bd..2cd8fbc6bc 100644
--- a/source3/smbd/notify_hash.c
+++ b/source3/smbd/notify_hash.c
@@ -222,7 +222,6 @@ static void *hash_notify_add(TALLOC_CTX *mem_ctx,
{
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 @@ static void *hash_notify_add(TALLOC_CTX *mem_ctx,
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;
}
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index 9efe63a82c..ff6f9d1c1a 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -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 /.
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index 643c48cd27..df81b2936d 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -792,31 +792,6 @@ char *vfs_GetWd(connection_struct *conn, char *path)
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.