[SCM] Samba Shared Repository - branch master updated -
593549fc004de05aea23e17c59f9a12254eff33d
Jelmer Vernooij
jelmer at samba.org
Sat Oct 18 12:57:13 GMT 2008
The branch, master has been updated
via 593549fc004de05aea23e17c59f9a12254eff33d (commit)
via 2d89b52be8104261aa8f028f49210f016cbf4742 (commit)
via 519458a2fa01ae7e8eadebbe1d7895740861c468 (commit)
from 93310970e307c766a7fccbd38aaa82b376c1769e (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 593549fc004de05aea23e17c59f9a12254eff33d
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Fri Oct 17 12:49:11 2008 +0200
Fix build of 'everything'
commit 2d89b52be8104261aa8f028f49210f016cbf4742
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Fri Oct 17 12:48:19 2008 +0200
Use separate make variables for libutil and libcrypto.
commit 519458a2fa01ae7e8eadebbe1d7895740861c468
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Fri Oct 17 12:26:46 2008 +0200
Use shared util.c.
-----------------------------------------------------------------------
Summary of changes:
lib/util/config.mk | 1 +
lib/util/util.c | 165 ++++++-----------
lib/util/util.h | 2 +-
lib/util/util_net.c | 128 +++++++++++++
source3/Makefile.in | 28 ++-
source3/client/client.c | 6 +-
source3/client/smbspool.c | 2 +-
source3/groupdb/mapping_ldb.c | 4 +-
source3/include/proto.h | 8 +-
source3/lib/smbconf/smbconf_txt.c | 2 +-
source3/lib/util.c | 328 +--------------------------------
source3/librpc/ndr/util.c | 14 --
source3/nmbd/nmbd.c | 4 +-
source3/nmbd/nmbd_processlogon.c | 2 +-
source3/param/loadparm.c | 2 +-
source3/registry/reg_perfcount.c | 2 +-
source3/rpc_client/cli_pipe.c | 2 +-
source3/rpc_server/srv_eventlog_lib.c | 2 +-
source3/smbd/server.c | 4 +-
source3/torture/torture.c | 2 +-
source3/torture/vfstest.c | 2 +-
source3/utils/testparm.c | 4 +-
source3/web/cgi.c | 2 +-
source3/web/swat.c | 4 +-
source3/winbindd/idmap_tdb.c | 2 +-
source3/winbindd/winbindd.c | 4 +-
source4/smbd/pidfile.c | 2 +-
27 files changed, 242 insertions(+), 486 deletions(-)
create mode 100644 lib/util/util_net.c
Changeset truncated at 500 lines:
diff --git a/lib/util/config.mk b/lib/util/config.mk
index 6873c1b..aa3c94c 100644
--- a/lib/util/config.mk
+++ b/lib/util/config.mk
@@ -18,6 +18,7 @@ LIBSAMBA-UTIL_OBJ_FILES = $(addprefix $(libutilsrcdir)/, \
util_file.o \
data_blob.o \
util.o \
+ util_net.o \
fsusage.o \
ms_fnmatch.o \
mutex.o \
diff --git a/lib/util/util.c b/lib/util/util.c
index 4c5ae97..fc55629 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -25,6 +25,10 @@
#include "system/network.h"
#include "system/filesys.h"
#include "system/locale.h"
+#undef malloc
+#undef strcasecmp
+#undef strdup
+#undef realloc
/**
* @file
@@ -217,112 +221,10 @@ _PUBLIC_ char *get_myname(void)
}
/**
- Return true if a string could be a pure IP address.
-**/
-
-_PUBLIC_ bool is_ipaddress(const char *str)
-{
- bool pure_address = true;
- int i;
-
- if (str == NULL) return false;
-
- for (i=0; pure_address && str[i]; i++)
- if (!(isdigit((int)str[i]) || str[i] == '.'))
- pure_address = false;
-
- /* Check that a pure number is not misinterpreted as an IP */
- pure_address = pure_address && (strchr(str, '.') != NULL);
-
- return pure_address;
-}
-
-/**
- Interpret an internet address or name into an IP address in 4 byte form.
-**/
-_PUBLIC_ uint32_t interpret_addr(const char *str)
-{
- struct hostent *hp;
- uint32_t res;
-
- if (str == NULL || *str == 0 ||
- strcmp(str,"0.0.0.0") == 0) {
- return 0;
- }
- if (strcmp(str,"255.255.255.255") == 0) {
- return 0xFFFFFFFF;
- }
- /* recognise 'localhost' as a special name. This fixes problems with
- some hosts that don't have localhost in /etc/hosts */
- if (strcasecmp(str,"localhost") == 0) {
- str = "127.0.0.1";
- }
-
- /* if it's in the form of an IP address then get the lib to interpret it */
- if (is_ipaddress(str)) {
- res = inet_addr(str);
- } else {
- /* otherwise assume it's a network name of some sort and use
- sys_gethostbyname */
- if ((hp = sys_gethostbyname(str)) == 0) {
- DEBUG(3,("sys_gethostbyname: Unknown host. %s\n",str));
- return 0;
- }
-
- if(hp->h_addr == NULL) {
- DEBUG(3,("sys_gethostbyname: host address is invalid for host %s\n",str));
- return 0;
- }
- memcpy((char *)&res,(char *)hp->h_addr, 4);
- }
-
- if (res == (uint32_t)-1)
- return(0);
-
- return(res);
-}
-
-/**
- A convenient addition to interpret_addr().
-**/
-_PUBLIC_ struct in_addr interpret_addr2(const char *str)
-{
- struct in_addr ret;
- uint32_t a = interpret_addr(str);
- ret.s_addr = a;
- return ret;
-}
-
-/**
- Check if an IP is the 0.0.0.0.
-**/
-
-_PUBLIC_ bool is_zero_ip(struct in_addr ip)
-{
- return ip.s_addr == 0;
-}
-
-/**
- Are two IPs on the same subnet?
-**/
-
-_PUBLIC_ bool same_net(struct in_addr ip1, struct in_addr ip2, struct in_addr mask)
-{
- uint32_t net1,net2,nmask;
-
- nmask = ntohl(mask.s_addr);
- net1 = ntohl(ip1.s_addr);
- net2 = ntohl(ip2.s_addr);
-
- return((net1 & nmask) == (net2 & nmask));
-}
-
-
-/**
Check if a process exists. Does this work on all unixes?
**/
-_PUBLIC_ bool process_exists(pid_t pid)
+_PUBLIC_ bool process_exists_by_pid(pid_t pid)
{
/* Doing kill with a non-positive pid causes messages to be
* sent to places we don't want. */
@@ -381,7 +283,7 @@ _PUBLIC_ bool fcntl_lock(int fd, int op, off_t offset, off_t count, int type)
}
-static void print_asc(int level, const uint8_t *buf,int len)
+void print_asc(int level, const uint8_t *buf,int len)
{
int i;
for (i=0;i<len;i++)
@@ -509,15 +411,64 @@ _PUBLIC_ void *smb_xmemdup(const void *p, size_t size)
strdup that aborts on malloc fail.
**/
-_PUBLIC_ char *smb_xstrdup(const char *s)
+char *smb_xstrdup(const char *s)
{
+#if defined(PARANOID_MALLOC_CHECKER)
+#ifdef strdup
+#undef strdup
+#endif
+#endif
+
+#ifndef HAVE_STRDUP
+#define strdup rep_strdup
+#endif
+
char *s1 = strdup(s);
- if (!s1)
- smb_panic("smb_xstrdup: malloc fail\n");
+#if defined(PARANOID_MALLOC_CHECKER)
+#ifdef strdup
+#undef strdup
+#endif
+#define strdup(s) __ERROR_DONT_USE_STRDUP_DIRECTLY
+#endif
+ if (!s1) {
+ smb_panic("smb_xstrdup: malloc failed");
+ }
+ return s1;
+
+}
+
+/**
+ strndup that aborts on malloc fail.
+**/
+
+char *smb_xstrndup(const char *s, size_t n)
+{
+#if defined(PARANOID_MALLOC_CHECKER)
+#ifdef strndup
+#undef strndup
+#endif
+#endif
+
+#if (defined(BROKEN_STRNDUP) || !defined(HAVE_STRNDUP))
+#undef HAVE_STRNDUP
+#define strndup rep_strndup
+#endif
+
+ char *s1 = strndup(s, n);
+#if defined(PARANOID_MALLOC_CHECKER)
+#ifdef strndup
+#undef strndup
+#endif
+#define strndup(s,n) __ERROR_DONT_USE_STRNDUP_DIRECTLY
+#endif
+ if (!s1) {
+ smb_panic("smb_xstrndup: malloc failed");
+ }
return s1;
}
+
/**
Like strdup but for memory.
**/
diff --git a/lib/util/util.h b/lib/util/util.h
index e4a5a0c..47adf06 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -574,7 +574,7 @@ _PUBLIC_ bool same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask
/**
Check if a process exists. Does this work on all unixes?
**/
-_PUBLIC_ bool process_exists(pid_t pid);
+_PUBLIC_ bool process_exists_by_pid(pid_t pid);
/**
Simple routine to do POSIX file locking. Cruft in NFS and 64->32 bit mapping
diff --git a/lib/util/util_net.c b/lib/util/util_net.c
new file mode 100644
index 0000000..7718d02
--- /dev/null
+++ b/lib/util/util_net.c
@@ -0,0 +1,128 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+ Copyright (C) Jelmer Vernooij <jelmer at samba.org> 2008
+ Copyright (C) Andrew Tridgell 1992-1998
+ Copyright (C) Jeremy Allison 2001-2002
+ Copyright (C) Simo Sorce 2001
+ Copyright (C) Jim McDonough (jmcd at us.ibm.com) 2003.
+ Copyright (C) James J Myers 2003
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+
+/**
+ Interpret an internet address or name into an IP address in 4 byte form.
+**/
+_PUBLIC_ uint32_t interpret_addr(const char *str)
+{
+ struct hostent *hp;
+ uint32_t res;
+
+ if (str == NULL || *str == 0 ||
+ strcmp(str,"0.0.0.0") == 0) {
+ return 0;
+ }
+ if (strcmp(str,"255.255.255.255") == 0) {
+ return 0xFFFFFFFF;
+ }
+ /* recognise 'localhost' as a special name. This fixes problems with
+ some hosts that don't have localhost in /etc/hosts */
+ if (strcasecmp(str,"localhost") == 0) {
+ str = "127.0.0.1";
+ }
+
+ /* if it's in the form of an IP address then get the lib to interpret it */
+ if (is_ipaddress(str)) {
+ res = inet_addr(str);
+ } else {
+ /* otherwise assume it's a network name of some sort and use
+ sys_gethostbyname */
+ if ((hp = sys_gethostbyname(str)) == 0) {
+ DEBUG(3,("sys_gethostbyname: Unknown host. %s\n",str));
+ return 0;
+ }
+
+ if(hp->h_addr == NULL) {
+ DEBUG(3,("sys_gethostbyname: host address is invalid for host %s\n",str));
+ return 0;
+ }
+ memcpy((char *)&res,(char *)hp->h_addr, 4);
+ }
+
+ if (res == (uint32_t)-1)
+ return(0);
+
+ return(res);
+}
+
+/**
+ A convenient addition to interpret_addr().
+**/
+_PUBLIC_ struct in_addr interpret_addr2(const char *str)
+{
+ struct in_addr ret;
+ uint32_t a = interpret_addr(str);
+ ret.s_addr = a;
+ return ret;
+}
+
+/**
+ Check if an IP is the 0.0.0.0.
+**/
+
+_PUBLIC_ bool is_zero_ip(struct in_addr ip)
+{
+ return ip.s_addr == 0;
+}
+
+/**
+ Are two IPs on the same subnet?
+**/
+
+_PUBLIC_ bool same_net(struct in_addr ip1, struct in_addr ip2, struct in_addr mask)
+{
+ uint32_t net1,net2,nmask;
+
+ nmask = ntohl(mask.s_addr);
+ net1 = ntohl(ip1.s_addr);
+ net2 = ntohl(ip2.s_addr);
+
+ return((net1 & nmask) == (net2 & nmask));
+}
+
+/**
+ Return true if a string could be a pure IP address.
+**/
+
+_PUBLIC_ bool is_ipaddress(const char *str)
+{
+ bool pure_address = true;
+ int i;
+
+ if (str == NULL) return false;
+
+ for (i=0; pure_address && str[i]; i++)
+ if (!(isdigit((int)str[i]) || str[i] == '.'))
+ pure_address = false;
+
+ /* Check that a pure number is not misinterpreted as an IP */
+ pure_address = pure_address && (strchr(str, '.') != NULL);
+
+ return pure_address;
+}
+
+
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 2665b05..1b460f4 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -315,29 +315,35 @@ LIBSAMBAUTIL_OBJ = @LIBTALLOC_STATIC@ \
$(SOCKET_WRAPPER_OBJ) \
$(NSS_WRAPPER_OBJ)
-LIB_OBJ = $(LIBSAMBAUTIL_OBJ) \
+UTIL_OBJ = ../lib/util/rbtree.o ../lib/util/signal.o ../lib/util/time.o \
+ ../lib/util/xfile.o ../lib/util/util_strlist.o \
+ ../lib/util/util_file.o ../lib/util/data_blob.o \
+ ../lib/util/util.o ../lib/util/fsusage.o
+
+CRYPTO_OBJ = ../lib/crypto/crc32.o ../lib/crypto/md5.o \
+ ../lib/crypto/hmacmd5.o ../lib/crypto/arcfour.o \
+ ../lib/crypto/md4.o
+
+LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) \
lib/messages.o librpc/gen_ndr/ndr_messaging.o lib/messages_local.o \
lib/messages_ctdbd.o lib/packet.o lib/ctdbd_conn.o lib/talloc_stack.o \
- lib/interfaces.o ../lib/util/rbtree.o lib/memcache.o \
+ lib/interfaces.o lib/memcache.o \
lib/util_transfer_file.o lib/async_req.o \
lib/async_sock.o \
$(TDB_LIB_OBJ) \
$(VERSION_OBJ) lib/charcnv.o lib/debug.o lib/fault.o \
- lib/interface.o ../lib/crypto/md4.o \
- lib/pidfile.o \
- ../lib/util/signal.o lib/system.o lib/sendfile.o lib/recvfile.o lib/time.o \
- ../lib/util/time.o \
+ lib/interface.o lib/pidfile.o \
+ lib/system.o lib/sendfile.o lib/recvfile.o lib/time.o \
lib/ufc.o lib/genrand.o lib/username.o \
lib/util_pw.o lib/access.o lib/smbrun.o \
- lib/bitmap.o ../lib/crypto/crc32.o lib/dprintf.o $(UTIL_REG_OBJ) \
- ../lib/util/xfile.o ../lib/util/util_strlist.o lib/wins_srv.o \
+ lib/bitmap.o lib/dprintf.o $(UTIL_REG_OBJ) \
+ lib/wins_srv.o \
lib/util_str.o lib/clobber.o lib/util_sid.o lib/util_uuid.o \
- lib/util_unistr.o ../lib/util/util_file.o lib/util_file.o ../lib/util/data_blob.o \
+ lib/util_unistr.o lib/util_file.o \
lib/util.o lib/util_sock.o lib/sock_exec.o lib/util_sec.o \
- lib/substitute.o ../lib/util/fsusage.o lib/dbwrap_util.o \
+ lib/substitute.o lib/dbwrap_util.o \
lib/ms_fnmatch.o lib/select.o lib/errmap_unix.o \
lib/tallocmsg.o lib/dmallocmsg.o libsmb/smb_signing.o \
- ../lib/crypto/md5.o ../lib/crypto/hmacmd5.o ../lib/crypto/arcfour.o \
lib/iconv.o lib/pam_errors.o intl/lang_tdb.o lib/conn_tdb.o \
lib/adt_tree.o lib/gencache.o \
lib/module.o lib/events.o lib/ldap_escape.o @CHARSET_STATIC@ \
diff --git a/source3/client/client.c b/source3/client/client.c
index 0fbf56f..26badc4 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -1203,7 +1203,7 @@ static void do_mget(file_info *finfo, const char *dir)
strlower_m(finfo->name);
}
- if (!directory_exist(finfo->name,NULL) &&
+ if (!directory_exist(finfo->name) &&
mkdir(finfo->name,0777) != 0) {
d_printf("failed to create directory %s\n",finfo->name);
client_set_cur_dir(saved_curdir);
@@ -1752,7 +1752,7 @@ static int cmd_put(void)
SMB_STRUCT_STAT st;
/* allow '-' to represent stdin
jdblair, 24.jun.98 */
- if (!file_exist(lname,&st) &&
+ if (!file_exist_stat(lname,&st) &&
(strcmp(lname,"-"))) {
d_printf("%s does not exist\n",lname);
return 1;
@@ -3566,7 +3566,7 @@ static int cmd_reput(void)
return 1;
}
- if (!file_exist(local_name, &st)) {
+ if (!file_exist_stat(local_name, &st)) {
d_printf("%s does not exist\n", local_name);
return 1;
}
diff --git a/source3/client/smbspool.c b/source3/client/smbspool.c
index 4a17371..1910ccd 100644
--- a/source3/client/smbspool.c
+++ b/source3/client/smbspool.c
@@ -482,7 +482,7 @@ smb_connect(const char *workgroup, /* I - Workgroup */
/*
* Get the names and addresses of the client and server...
*/
- myname = get_myname(talloc_tos());
+ myname = talloc_get_myname(talloc_tos());
if (!myname) {
return NULL;
}
diff --git a/source3/groupdb/mapping_ldb.c b/source3/groupdb/mapping_ldb.c
index 7ce879f..1a6b99f 100644
--- a/source3/groupdb/mapping_ldb.c
+++ b/source3/groupdb/mapping_ldb.c
@@ -63,7 +63,7 @@ static bool init_group_mapping(void)
/* Ensure this db is created read/write for root only. */
ldb_set_create_perms(ldb, 0600);
- existed = file_exist(db_path, NULL);
+ existed = file_exist(db_path);
if (lp_parm_bool(-1, "groupmap", "nosync", False)) {
flags |= LDB_FLG_NOSYNC;
@@ -99,7 +99,7 @@ static bool init_group_mapping(void)
/* possibly upgrade */
tdb_path = state_path("group_mapping.tdb");
- if (file_exist(tdb_path, NULL) && !mapping_upgrade(tdb_path)) {
+ if (file_exist(tdb_path) && !mapping_upgrade(tdb_path)) {
unlink(state_path("group_mapping.ldb"));
goto failed;
}
diff --git a/source3/include/proto.h b/source3/include/proto.h
index dd9f022..cb21f89 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1232,10 +1232,12 @@ const char *tmpdir(void);
bool add_gid_to_array_unique(TALLOC_CTX *mem_ctx, gid_t gid,
gid_t **gids, size_t *num_gids);
const char *get_numlist(const char *p, uint32 **num, int *count);
-bool file_exist(const char *fname,SMB_STRUCT_STAT *sbuf);
+bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf);
+bool file_exist(const char *fname);
bool socket_exist(const char *fname);
time_t file_modtime(const char *fname);
-bool directory_exist(char *dname,SMB_STRUCT_STAT *st);
+bool directory_exist_stat(char *dname,SMB_STRUCT_STAT *st);
+bool directory_exist(char *dname);
SMB_OFF_T get_file_size(char *file_name);
char *attrib_string(uint16 mode);
--
Samba Shared Repository
More information about the samba-cvs
mailing list