Use the same logic from shadow_copy2 module to always prepend the
connectpath to the relative snapshot path so as to return converted
path corresponding to the file's share root.
Please note that with the current working directory staying at the
connectpath level we are safe to prefix it to the smb_filename. In
other words it seems we never get past the connectpath internally
during normal file system operations via chdir(). Since all relative
paths are now based on dirfsp we could constitute absolute path by
prepending the connectpath to full_path_from_dirfsp_atname() output
ignoring the current working directory.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15819
Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Wed Apr 30 11:32:59 UTC 2025 on atb-devel-224
(cherry picked from commit
95a2b50b1983a6ba810a96f50b27db7c992c02c0)
Autobuild-User(v4-22-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-22-test): Thu May 8 12:54:02 UTC 2025 on atb-devel-224
* Temporally use the caller's return buffer for this.
*/
if (strlen(name) == 0) {
- ret = strlcpy(_converted_buf, snapdir, buflen);
+ ret = snprintf(_converted_buf, buflen, "%s/%s",
+ handle->conn->connectpath, snapdir);
} else {
- ret = snprintf(_converted_buf, buflen, "%s/%s", name, snapdir);
+ ret = snprintf(_converted_buf, buflen, "%s/%s/%s",
+ handle->conn->connectpath, name, snapdir);
}
+
if (ret >= buflen) {
ret = -EINVAL;
goto err_out;