If the system supports O_PATH we use that, otherwise we fallback to root opens.
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
int flags,
mode_t mode)
{
+ bool have_opath = false;
+ bool became_root = false;
int result;
START_PROFILE(syscall_openat);
goto out;
}
+#ifdef O_PATH
+ have_opath = true;
+ if (fsp->fsp_flags.is_pathref) {
+ flags |= O_PATH;
+ }
+#endif
+
+ if (fsp->fsp_flags.is_pathref && !have_opath) {
+ become_root();
+ became_root = true;
+ }
+
result = openat(fsp_get_pathref_fd(dirfsp),
smb_fname->base_name,
flags,
mode);
+ if (became_root) {
+ unbecome_root();
+ }
+
+ fsp->fsp_flags.have_proc_fds = fsp->conn->have_proc_fds;
+
out:
END_PROFILE(syscall_openat);
return result;