summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-11-01 04:02:47 +0100
committerJelmer Vernooij <jelmer@samba.org>2008-11-01 04:02:47 +0100
commit31fa08dcbdc643ec738474c0be471e77925f76fc (patch)
treec4337b4bd77a31f4f593d8c94bbd15b796123117 /lib
parent5a56c0adf2c63602b819d052644cb14caf732438 (diff)
parent7b186c48d365ae8eda81ae9a0af100d2214bee32 (diff)
downloadsamba-31fa08dcbdc643ec738474c0be471e77925f76fc.tar.gz
samba-31fa08dcbdc643ec738474c0be471e77925f76fc.tar.bz2
samba-31fa08dcbdc643ec738474c0be471e77925f76fc.zip
Merge branch 'master' of /home/jelmer/samba3
Conflicts: lib/replace/README lib/replace/libreplace.m4 lib/replace/replace.c source3/include/proto.h source3/lib/system.c
Diffstat (limited to 'lib')
-rw-r--r--lib/replace/README6
-rw-r--r--lib/replace/libreplace.m42
-rw-r--r--lib/replace/replace.c52
-rw-r--r--lib/replace/replace.h35
-rw-r--r--lib/util/util.h34
-rw-r--r--lib/util/util_ldb.h2
6 files changed, 121 insertions, 10 deletions
diff --git a/lib/replace/README b/lib/replace/README
index 108534d29b..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
@@ -65,6 +67,10 @@ freeifaddrs
utime
utimes
dup2
+link
+readlink
+symlink
+realpath
Types:
bool
diff --git a/lib/replace/libreplace.m4 b/lib/replace/libreplace.m4
index 6c72cf8a2c..30d7017d0f 100644
--- a/lib/replace/libreplace.m4
+++ b/lib/replace/libreplace.m4
@@ -108,7 +108,7 @@ 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 dup2)
-AC_CHECK_FUNCS(isatty)
+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 4aa84b886d..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
@@ -623,3 +624,54 @@ int rep_dup2(int oldfd, int newfd)
}
#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 70b29722bf..8483d934d8 100644
--- a/lib/replace/replace.h
+++ b/lib/replace/replace.h
@@ -215,6 +215,41 @@ int rep_seteuid(uid_t);
int rep_setegid(gid_t);
#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
+int 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 *);
diff --git a/lib/util/util.h b/lib/util/util.h
index 6a341b218d..66861fba8b 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -49,12 +49,22 @@ extern const char *panic_action;
/**
* assert macros
*/
+#ifdef DEVELOPER
#define SMB_ASSERT(b) do { if (!(b)) { \
- DEBUG(0,("PANIC: assert failed at %s(%d)\n", __FILE__, __LINE__)); \
- smb_panic("assert failed"); }} while (0)
+ DEBUG(0,("PANIC: assert failed at %s(%d): %s\n", \
+ __FILE__, __LINE__, #b)), smb_panic("assert failed: " #b); }} while(0)
+#else
+/* redefine the assert macro for non-developer builds */
+#define SMB_ASSERT(b) do { if (!(b)) { \
+ DEBUG(0,("PANIC: assert failed at %s(%d): %s\n", \
+ __FILE__, __LINE__, #b)); }} while (0)
+#endif
-#if defined(VALGRIND)
+#if _SAMBA_BUILD_ == 4
+#ifdef VALGRIND
#define strlen(x) valgrind_strlen(x)
+size_t valgrind_strlen(const char *s);
+#endif
#endif
#include "../lib/util/memory.h"
@@ -69,10 +79,12 @@ _PUBLIC_ void call_backtrace(void);
**/
_PUBLIC_ _NORETURN_ void smb_panic(const char *why);
+#if _SAMBA_BUILD_ == 4
/**
setup our fault handlers
**/
_PUBLIC_ void fault_setup(const char *pname);
+#endif
/**
register a fault handler.
@@ -168,12 +180,14 @@ _PUBLIC_ char *generate_random_str_list(TALLOC_CTX *mem_ctx, size_t len, const c
_PUBLIC_ char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len);
/* The following definitions come from lib/util/dprintf.c */
+#if _SAMBA_BUILD_ == 4
_PUBLIC_ void d_set_iconv(smb_iconv_t);
_PUBLIC_ int d_vfprintf(FILE *f, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
_PUBLIC_ int d_fprintf(FILE *f, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
_PUBLIC_ int d_printf(const char *format, ...) PRINTF_ATTRIBUTE(1,2);
_PUBLIC_ void display_set_stderr(void);
+#endif
/* The following definitions come from lib/util/util_str.c */
@@ -256,7 +270,6 @@ _PUBLIC_ void all_string_sub(char *s,const char *pattern,const char *insert, siz
Unescape a URL encoded string, in place.
**/
_PUBLIC_ void rfc1738_unescape(char *buf);
-size_t valgrind_strlen(const char *s);
/**
format a string into length-prefixed dotted domain format, as used in NBT
@@ -286,11 +299,6 @@ limited by 'n' bytes
_PUBLIC_ size_t ascii_len_n(const char *src, size_t n);
/**
- Return a string representing a CIFS attribute for a file.
-**/
-_PUBLIC_ char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib);
-
-/**
Set a boolean variable from the text value stored in the passed string.
Returns true in success, false if the passed string does not correctly
represent a boolean.
@@ -306,10 +314,12 @@ _PUBLIC_ bool set_boolean(const char *boolean_string, bool *boolean);
*/
_PUBLIC_ bool conv_str_bool(const char * str, bool * val);
+#if _SAMBA_BUILD_ == 4
/**
* Convert a size specification like 16K into an integral number of bytes.
**/
_PUBLIC_ bool conv_str_size(const char * str, uint64_t * val);
+#endif
/**
* Parse a uint64_t value from a string
@@ -354,7 +364,9 @@ _PUBLIC_ bool strequal(const char *s1, const char *s2);
/* The following definitions come from lib/util/util_strlist.c */
/* separators for lists */
+#ifndef LIST_SEP
#define LIST_SEP " \t,\n\r"
+#endif
/**
build a null terminated list of strings from a input string and a
@@ -642,6 +654,7 @@ _PUBLIC_ int sys_fsusage(const char *path, uint64_t *dfree, uint64_t *dsize);
* @brief MS-style Filename matching
*/
+#if _SAMBA_BUILD_ == 4
/* protocol types. It assumes that higher protocols include lower protocols
as subsets. FIXME: Move to one of the smb-specific headers */
enum protocol_types {
@@ -658,6 +671,7 @@ int ms_fnmatch(const char *pattern, const char *string, enum protocol_types prot
/** a generic fnmatch function - uses for non-CIFS pattern matching */
int gen_fnmatch(const char *pattern, const char *string);
+#endif
/* The following definitions come from lib/util/mutex.c */
@@ -707,10 +721,12 @@ _PUBLIC_ int idr_remove(struct idr_context *idp, int id);
/* The following definitions come from lib/util/become_daemon.c */
+#if _SAMBA_BUILD_ == 4
/**
Become a daemon, discarding the controlling terminal.
**/
_PUBLIC_ void become_daemon(bool fork);
+#endif
/**
* Load a ini-style file.
diff --git a/lib/util/util_ldb.h b/lib/util/util_ldb.h
index 43f98ae1a9..f9eb028916 100644
--- a/lib/util/util_ldb.h
+++ b/lib/util/util_ldb.h
@@ -1,6 +1,8 @@
#ifndef __LIB_UTIL_UTIL_LDB_H__
#define __LIB_UTIL_UTIL_LDB_H__
+struct ldb_dn;
+
/* The following definitions come from lib/util/util_ldb.c */
int gendb_search_v(struct ldb_context *ldb,