]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Simplify users of fsp_fullbasepath()
authorVolker Lendecke <vl@samba.org>
Sun, 4 Feb 2024 10:10:18 +0000 (11:10 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 28 Mar 2024 08:05:34 +0000 (08:05 +0000)
All three users had to strip a trailing "/.". Centralize this.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/smbd/files.c
source3/smbd/notify.c

index ef1eb1a78a82a14f6082280579885e60af3969f7..ca929cc94a12f71168c54f797fab804997ce4c8c 100644 (file)
@@ -2238,15 +2238,6 @@ void fsp_unbind_smb(struct smb_request *req, files_struct *fsp)
 
                fsp_fullbasepath(fsp, fullpath, sizeof(fullpath));
 
-               /*
-                * Avoid /. at the end of the path name. notify can't
-                * deal with it.
-                */
-               if (len > 1 && fullpath[len-1] == '.' &&
-                   fullpath[len-2] == '/') {
-                       fullpath[len-2] = '\0';
-               }
-
                notify_remove(fsp->conn->sconn->notify_ctx, fsp, fullpath);
                TALLOC_FREE(fsp->notify);
        }
@@ -2581,9 +2572,16 @@ size_t fsp_fullbasepath(struct files_struct *fsp, char *buf, size_t buflen)
                SMB_ASSERT(buflen == 0);
        }
 
-       len = snprintf(buf, buflen, "%s/%s", fsp->conn->connectpath,
-                      fsp->fsp_name->base_name);
-       SMB_ASSERT(len>0);
+       if (ISDOT(fsp->fsp_name->base_name)) {
+               len = snprintf(buf, buflen, "%s", fsp->conn->connectpath);
+       } else {
+               len = snprintf(buf,
+                              buflen,
+                              "%s/%s",
+                              fsp->conn->connectpath,
+                              fsp->fsp_name->base_name);
+       }
+       SMB_ASSERT(len > 0);
 
        return len;
 }
index 156fbf700c3e718c605d03f3da4db6bca08cd72b..850193eccf33898ff7672872597fb3906f060c63 100644 (file)
@@ -316,13 +316,6 @@ NTSTATUS change_notify_create(struct files_struct *fsp,
 
        fsp_fullbasepath(fsp, fullpath, sizeof(fullpath));
 
-       /*
-        * Avoid /. at the end of the path name. notify can't deal with it.
-        */
-       if (len > 1 && fullpath[len-1] == '.' && fullpath[len-2] == '/') {
-               fullpath[len-2] = '\0';
-       }
-
        if ((fsp->notify->filter != 0) ||
            (fsp->notify->subdir_filter != 0)) {
                status = notify_add(fsp->conn->sconn->notify_ctx,
@@ -533,10 +526,6 @@ static struct files_struct *smbd_notifyd_reregister(struct files_struct *fsp,
                NTSTATUS status;
 
                fsp_fullbasepath(fsp, fullpath, sizeof(fullpath));
-               if (len > 1 && fullpath[len-1] == '.' &&
-                   fullpath[len-2] == '/') {
-                       fullpath[len-2] = '\0';
-               }
 
                status = notify_add(fsp->conn->sconn->notify_ctx,
                                    fullpath, fsp->notify->filter,