From 6a2caa34b24c2225dba9da011eaa5cc3eb8752be Mon Sep 17 00:00:00 2001
From: Jelmer Vernooij <jelmer@samba.org>
Date: Sat, 1 Nov 2008 03:46:09 +0100
Subject: Remove sys_chroot() - libreplace already provides an alternative.

---
 lib/replace/replace.c   |  2 --
 lib/replace/replace.h   |  5 +++++
 source3/configure.in    |  2 +-
 source3/include/proto.h |  1 -
 source3/lib/system.c    | 18 ------------------
 source3/smbd/server.c   |  2 +-
 6 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/lib/replace/replace.c b/lib/replace/replace.c
index d757a0154e..0683f556eb 100644
--- a/lib/replace/replace.c
+++ b/lib/replace/replace.c
@@ -667,5 +667,3 @@ char *rep_realpath(const char *path, char *resolved_path)
 	return NULL;
 }
 #endif
-
-
diff --git a/lib/replace/replace.h b/lib/replace/replace.h
index 8d0dd57064..d717d6391c 100644
--- a/lib/replace/replace.h
+++ b/lib/replace/replace.h
@@ -220,6 +220,11 @@ int rep_setegid(gid_t);
 int rep_chown(const char *path, uid_t uid, gid_t gid);
 #endif
 
+#ifndef HAVE_CHROOT
+#define chroot rep_chroot
+int rep_chroot(const char *dirname);
+#endif
+
 #ifndef HAVE_LINK
 #define link rep_link
 int rep_link(const char *oldpath, const char *newpath);
diff --git a/source3/configure.in b/source3/configure.in
index 4e5ce99b78..c2a5d1a75f 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -1025,7 +1025,7 @@ if test x"$ac_cv_func_execl" = x"no"; then
     EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
 fi
 
-AC_CHECK_FUNCS(waitpid getcwd strdup strndup strnlen strerror fchown chmod fchmod chroot mknod mknod64)
+AC_CHECK_FUNCS(waitpid getcwd strdup strndup strnlen strerror fchown chmod fchmod mknod mknod64)
 AC_CHECK_FUNCS(strtol strtoll strtoul strtoull strtouq __strtoull)
 AC_CHECK_FUNCS(fstat strchr chflags)
 AC_CHECK_FUNCS(getrlimit fsync fdatasync memset strlcpy strlcat setpgid)
diff --git a/source3/include/proto.h b/source3/include/proto.h
index e8b25667ab..ee6dcc1601 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1002,7 +1002,6 @@ int sys_closedir(SMB_STRUCT_DIR *dirp);
 int sys_mknod(const char *path, mode_t mode, SMB_DEV_T dev);
 int sys_waitpid(pid_t pid,int *status,int options);
 char *sys_getwd(char *s);
-int sys_chroot(const char *dname);
 void set_effective_capability(enum smbd_capability capability);
 void drop_effective_capability(enum smbd_capability capability);
 long sys_random(void);
diff --git a/source3/lib/system.c b/source3/lib/system.c
index da2797322a..d23e7ae6db 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -565,24 +565,6 @@ char *sys_getwd(char *s)
 	return wd;
 }
 
-/*******************************************************************
-os/2 also doesn't have chroot
-********************************************************************/
-int sys_chroot(const char *dname)
-{
-#ifndef HAVE_CHROOT
-	static int done;
-	if (!done) {
-		DEBUG(1,("WARNING: no chroot!\n"));
-		done=1;
-	}
-	errno = ENOSYS;
-	return -1;
-#else
-	return(chroot(dname));
-#endif
-}
-
 #if defined(HAVE_POSIX_CAPABILITIES)
 
 /**************************************************************************
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 4e81263ee4..7583da65a5 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -1415,7 +1415,7 @@ extern void build_options(bool screen);
 	}
 
 	if (*lp_rootdir()) {
-		if (sys_chroot(lp_rootdir()) == 0)
+		if (chroot(lp_rootdir()) == 0)
 			DEBUG(2,("Changed root to %s\n", lp_rootdir()));
 	}
 
-- 
cgit