summaryrefslogtreecommitdiff
path: root/lib/replace
diff options
context:
space:
mode:
Diffstat (limited to 'lib/replace')
-rw-r--r--lib/replace/README7
-rw-r--r--lib/replace/libreplace.m44
-rw-r--r--lib/replace/replace.c61
-rw-r--r--lib/replace/replace.h50
4 files changed, 119 insertions, 3 deletions
diff --git a/lib/replace/README b/lib/replace/README
index 2f3b37340f..26383bc89a 100644
--- a/lib/replace/README
+++ b/lib/replace/README
@@ -46,6 +46,8 @@ mkdtemp
mkstemp (a secure one!)
pread
pwrite
+chown
+lchown
getpass
readline (the library)
inet_ntoa
@@ -64,6 +66,11 @@ getifaddrs
freeifaddrs
utime
utimes
+dup2
+link
+readlink
+symlink
+realpath
Types:
bool
diff --git a/lib/replace/libreplace.m4 b/lib/replace/libreplace.m4
index 6f1543863a..30d7017d0f 100644
--- a/lib/replace/libreplace.m4
+++ b/lib/replace/libreplace.m4
@@ -107,8 +107,8 @@ AC_CHECK_HEADERS(stropts.h)
AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup)
-AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp)
-AC_CHECK_FUNCS(isatty)
+AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp dup2)
+AC_CHECK_FUNCS(isatty chown lchown link readlink symlink realpath)
AC_HAVE_DECL(setresuid, [#include <unistd.h>])
AC_HAVE_DECL(setresgid, [#include <unistd.h>])
AC_HAVE_DECL(errno, [#include <errno.h>])
diff --git a/lib/replace/replace.c b/lib/replace/replace.c
index 98d799b07e..78c688d50c 100644
--- a/lib/replace/replace.c
+++ b/lib/replace/replace.c
@@ -2,6 +2,7 @@
Unix SMB/CIFS implementation.
replacement routines for broken systems
Copyright (C) Andrew Tridgell 1992-1998
+ Copyright (C) Jelmer Vernooij 2005-2008
** NOTE! The following LGPL license applies to the replace
** library. This does NOT imply that all of Samba is released
@@ -614,3 +615,63 @@ int rep_utimes(const char *filename, const struct timeval tv[2])
return utime(filename, &u);
}
#endif
+
+#ifndef HAVE_DUP2
+int rep_dup2(int oldfd, int newfd)
+{
+ errno = ENOSYS;
+ return -1;
+}
+#endif
+
+#ifndef HAVE_CHOWN
+/**
+chown isn't used much but OS/2 doesn't have it
+**/
+int rep_chown(const char *fname, uid_t uid, gid_t gid)
+{
+ errno = ENOSYS;
+ return -1;
+}
+#endif
+
+#ifndef HAVE_LINK
+int rep_link(const char *oldpath, const char *newpath)
+{
+ errno = ENOSYS;
+ return -1;
+}
+#endif
+
+#ifndef HAVE_READLINK
+int rep_readlink(const char *path, char *buf, size_t bufsiz)
+{
+ errno = ENOSYS;
+ return -1;
+}
+#endif
+
+#ifndef HAVE_SYMLINK
+int rep_symlink(const char *oldpath, const char *newpath)
+{
+ errno = ENOSYS;
+ return -1;
+}
+#endif
+
+#ifndef HAVE_LCHOWN
+int rep_lchown(const char *fname,uid_t uid,gid_t gid)
+{
+ errno = ENOSYS;
+ return -1;
+}
+#endif
+
+#ifndef HAVE_REALPATH
+char *rep_realpath(const char *path, char *resolved_path)
+{
+ /* As realpath is not a system call we can't return ENOSYS. */
+ errno = EINVAL;
+ return NULL;
+}
+#endif
diff --git a/lib/replace/replace.h b/lib/replace/replace.h
index a8164b642b..c3b0604a2c 100644
--- a/lib/replace/replace.h
+++ b/lib/replace/replace.h
@@ -4,7 +4,7 @@
macros to go along with the lib/replace/ portability layer code
Copyright (C) Andrew Tridgell 2005
- Copyright (C) Jelmer Vernooij 2006
+ Copyright (C) Jelmer Vernooij 2006-2008
Copyright (C) Jeremy Allison 2007.
** NOTE! The following LGPL license applies to the replace
@@ -215,6 +215,49 @@ int rep_seteuid(uid_t);
int rep_setegid(gid_t);
#endif
+#if (defined(USE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
+/* stupid glibc */
+int setresuid(uid_t ruid, uid_t euid, uid_t suid);
+#endif
+#if (defined(USE_SETRESUID) && !defined(HAVE_SETRESGID_DECL))
+int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
+#endif
+
+#ifndef HAVE_CHOWN
+#define chown rep_chown
+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);
+#endif
+
+#ifndef HAVE_READLINK
+#define readlink rep_readlink
+ssize_t rep_readlink(const char *path, char *buf, size_t bufsize);
+#endif
+
+#ifndef HAVE_SYMLINK
+#define symlink rep_symlink
+int rep_symlink(const char *oldpath, const char *newpath);
+#endif
+
+#ifndef HAVE_REALPATH
+#define realpath rep_realpath
+char *rep_realpath(const char *path, char *resolved_path);
+#endif
+
+#ifndef HAVE_LCHOWN
+#define lchown rep_lchown
+int rep_lchown(const char *fname,uid_t uid,gid_t gid);
+#endif
+
#ifndef HAVE_SETLINEBUF
#define setlinebuf rep_setlinebuf
void rep_setlinebuf(FILE *);
@@ -358,6 +401,11 @@ struct tm;
char *rep_strptime(const char *buf, const char *format, struct tm *tm);
#endif
+#ifndef HAVE_DUP2
+#define dup2 rep_dup2
+int rep_dup2(int oldfd, int newfd);
+#endif
+
/* Load header file for dynamic linking stuff */
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>