summaryrefslogtreecommitdiff
path: root/source3/modules/vfs_default.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2010-11-19 16:29:26 -0800
committerJeremy Allison <jra@samba.org>2010-11-20 02:15:50 +0100
commit2b788aa6ce41c5c0a6892cb412cf40a7cbc73f2a (patch)
tree38d9b916b7f46705d0fe027e86ccef413b5b2374 /source3/modules/vfs_default.c
parent8585de88815490ed3c41571030bf20bff02a67d4 (diff)
downloadsamba-2b788aa6ce41c5c0a6892cb412cf40a7cbc73f2a.tar.gz
samba-2b788aa6ce41c5c0a6892cb412cf40a7cbc73f2a.tar.bz2
samba-2b788aa6ce41c5c0a6892cb412cf40a7cbc73f2a.zip
Move the uglyness of #ifdef REALPATH_TAKES_NULL into the vfs_default
module, change the signature of VFS_REALPATH to always return a malloc'ed string. Needed to make some privileges work I plan on doing shortly easier to code. Jeremy. Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Sat Nov 20 02:15:50 CET 2010 on sn-devel-104
Diffstat (limited to 'source3/modules/vfs_default.c')
-rw-r--r--source3/modules/vfs_default.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 6f5b09a5a9..eb0e0b95a6 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -1064,12 +1064,25 @@ static int vfswrap_mknod(vfs_handle_struct *handle, const char *pathname, mode_
return result;
}
-static char *vfswrap_realpath(vfs_handle_struct *handle, const char *path, char *resolved_path)
+static char *vfswrap_realpath(vfs_handle_struct *handle, const char *path)
{
char *result;
START_PROFILE(syscall_realpath);
- result = realpath(path, resolved_path);
+#ifdef REALPATH_TAKES_NULL
+ result = realpath(path, NULL);
+#else
+ result = SMB_MALLOC_ARRAY(char, PATH_MAX+1);
+ if (result) {
+ char *resolved_path = realpath(path, result);
+ if (!resolved_path) {
+ SAFE_FREE(result);
+ } else {
+ /* SMB_ASSERT(result == resovled_path) ? */
+ result = resolved_path;
+ }
+ }
+#endif
END_PROFILE(syscall_realpath);
return result;
}