From 8f8c56bfbcbfe8f80afb09eb1d481a108b252bee Mon Sep 17 00:00:00 2001 From: Andrew Kroeger Date: Fri, 28 Mar 2008 01:08:49 -0500 Subject: Convert some more files to GPLv3. (This used to be commit ebe5e8399422eb7e2ff4deb546338823e2718907) --- source4/lib/policy/adm.h | 2 +- source4/lib/policy/dumpadm.c | 2 +- source4/lib/policy/lex.c | 2 +- source4/lib/policy/lex.l | 2 +- source4/lib/policy/parse_adm.y | 2 +- source4/lib/registry/hive.c | 2 +- source4/lib/registry/hive.h | 2 +- source4/lib/registry/local.c | 2 +- source4/lib/registry/patchfile.h | 2 +- source4/lib/registry/patchfile_dotreg.c | 2 +- source4/lib/registry/patchfile_preg.c | 2 +- source4/lib/registry/tests/hive.c | 2 +- source4/lib/registry/tests/registry.c | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/policy/adm.h b/source4/lib/policy/adm.h index 90889fe5fa..c541ced6ff 100644 --- a/source4/lib/policy/adm.h +++ b/source4/lib/policy/adm.h @@ -5,7 +5,7 @@ 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 2 of the License, or + 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, diff --git a/source4/lib/policy/dumpadm.c b/source4/lib/policy/dumpadm.c index 1553ce62f6..2ed5abf111 100644 --- a/source4/lib/policy/dumpadm.c +++ b/source4/lib/policy/dumpadm.c @@ -5,7 +5,7 @@ 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 2 of the License, or + 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, diff --git a/source4/lib/policy/lex.c b/source4/lib/policy/lex.c index c2899aa808..6d524445c9 100644 --- a/source4/lib/policy/lex.c +++ b/source4/lib/policy/lex.c @@ -572,7 +572,7 @@ char *yytext; 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 2 of the License, or + 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, diff --git a/source4/lib/policy/lex.l b/source4/lib/policy/lex.l index 199cd228c0..dc1f0aa34e 100644 --- a/source4/lib/policy/lex.l +++ b/source4/lib/policy/lex.l @@ -5,7 +5,7 @@ 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 2 of the License, or + 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, diff --git a/source4/lib/policy/parse_adm.y b/source4/lib/policy/parse_adm.y index 1dc21cf1d3..23c5e7730e 100644 --- a/source4/lib/policy/parse_adm.y +++ b/source4/lib/policy/parse_adm.y @@ -5,7 +5,7 @@ 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 2 of the License, or + 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, diff --git a/source4/lib/registry/hive.c b/source4/lib/registry/hive.c index ad6a6421ab..fc2d0fe869 100644 --- a/source4/lib/registry/hive.c +++ b/source4/lib/registry/hive.c @@ -6,7 +6,7 @@ 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 2 of the License, or + 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, diff --git a/source4/lib/registry/hive.h b/source4/lib/registry/hive.h index 87f335663d..2410885718 100644 --- a/source4/lib/registry/hive.h +++ b/source4/lib/registry/hive.h @@ -5,7 +5,7 @@ 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 2 of the License, or + 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, diff --git a/source4/lib/registry/local.c b/source4/lib/registry/local.c index 3e463100c9..5bf2d86588 100644 --- a/source4/lib/registry/local.c +++ b/source4/lib/registry/local.c @@ -5,7 +5,7 @@ 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 2 of the License, or + 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, diff --git a/source4/lib/registry/patchfile.h b/source4/lib/registry/patchfile.h index 9289390685..d586aa4c31 100644 --- a/source4/lib/registry/patchfile.h +++ b/source4/lib/registry/patchfile.h @@ -6,7 +6,7 @@ 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 2 of the License, or + 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, diff --git a/source4/lib/registry/patchfile_dotreg.c b/source4/lib/registry/patchfile_dotreg.c index 6de642ecb8..5150c90291 100644 --- a/source4/lib/registry/patchfile_dotreg.c +++ b/source4/lib/registry/patchfile_dotreg.c @@ -7,7 +7,7 @@ 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 2 of the License, or + 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, diff --git a/source4/lib/registry/patchfile_preg.c b/source4/lib/registry/patchfile_preg.c index 0d39e67450..8f02a0b5e3 100644 --- a/source4/lib/registry/patchfile_preg.c +++ b/source4/lib/registry/patchfile_preg.c @@ -6,7 +6,7 @@ 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 2 of the License, or + 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, diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c index 1e56f125c5..70b0241b04 100644 --- a/source4/lib/registry/tests/hive.c +++ b/source4/lib/registry/tests/hive.c @@ -7,7 +7,7 @@ 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 2 of the License, or + 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, diff --git a/source4/lib/registry/tests/registry.c b/source4/lib/registry/tests/registry.c index 7d14b3a412..e5e34c11e0 100644 --- a/source4/lib/registry/tests/registry.c +++ b/source4/lib/registry/tests/registry.c @@ -7,7 +7,7 @@ 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 2 of the License, or + 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, -- cgit From 02e8a32f5986dff252ca4f801a612d2030ee92bb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 28 Mar 2008 07:56:20 +0100 Subject: libreplace(samba4): let LIBREPLACE depend on LIBREPLACE_NETWORK for now This should fix the build on solaris. Later this needs better fixing... metze (This used to be commit 89b7955733c34e9699a3b43ee54de92cb9469b90) --- source4/lib/replace/samba.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib') diff --git a/source4/lib/replace/samba.m4 b/source4/lib/replace/samba.m4 index e62c3d3cd1..7984ef31db 100644 --- a/source4/lib/replace/samba.m4 +++ b/source4/lib/replace/samba.m4 @@ -23,7 +23,7 @@ done SMB_SUBSYSTEM(LIBREPLACE, [${LIBREPLACE_OBJS}], - [LIBREPLACE_EXT], + [LIBREPLACE_EXT LIBREPLACE_NETWORK], [-Ilib/replace]) LIBREPLACE_HOSTCC_OBJS=`echo ${LIBREPLACE_OBJS} |sed -e 's/\.o/\.ho/g'` -- cgit From 142fbfb3c1f9f8cda7f0edaa801f8345f23d805f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 28 Mar 2008 21:57:15 +1100 Subject: Fix and test python scripts and kerberos This fixes up the python credentials interface in a number of areas, with the aim of supporting '-k yes' as a command line option. (This enables the use of kerberos). As such, I've had to change the get_credentials call to take a loadparm context, so that the credentials can be initialised correctly. The test_kinit script has been modified to prove that this continues to work, as well as to provide greater code coverage of the kerberos paths. Andrew Bartlett (This used to be commit 727ef40c2b56910028ef3c1092b8eab1bfa6ce63) --- source4/lib/ldb/tests/python/ldap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib') diff --git a/source4/lib/ldb/tests/python/ldap.py b/source4/lib/ldb/tests/python/ldap.py index f75bb8124d..ead5796b7b 100755 --- a/source4/lib/ldb/tests/python/ldap.py +++ b/source4/lib/ldb/tests/python/ldap.py @@ -25,7 +25,6 @@ parser.add_option_group(options.VersionOptions(parser)) # use command line creds if available credopts = options.CredentialsOptions(parser) parser.add_option_group(credopts) -creds = credopts.get_credentials() opts, args = parser.parse_args() if len(args) < 1: @@ -35,6 +34,7 @@ if len(args) < 1: host = args[0] lp = sambaopts.get_loadparm() +creds = credopts.get_credentials(lp) class BasicTests(unittest.TestCase): def delete_force(self, ldb, dn): -- cgit From 14a54761d98e2c4345e3e667d02279d2765617c1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 1 Apr 2008 14:51:06 +0200 Subject: Move ini-like file parser to the utility library. (This used to be commit 2dc2bb800dab3f7dbdba01f5ca5076edd1a2b0f3) --- source4/lib/util/config.mk | 3 ++- source4/lib/util/util.h | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'source4/lib') diff --git a/source4/lib/util/config.mk b/source4/lib/util/config.mk index 22e6617f7c..c6afad1e3f 100644 --- a/source4/lib/util/config.mk +++ b/source4/lib/util/config.mk @@ -18,7 +18,8 @@ OBJ_FILES = xfile.o \ ms_fnmatch.o \ mutex.o \ idtree.o \ - become_daemon.o + become_daemon.o \ + params.o PUBLIC_DEPENDENCIES = \ LIBTALLOC LIBCRYPTO \ SOCKET_WRAPPER LIBREPLACE_NETWORK \ diff --git a/source4/lib/util/util.h b/source4/lib/util/util.h index 550b60c625..26700587ef 100644 --- a/source4/lib/util/util.h +++ b/source4/lib/util/util.h @@ -795,4 +795,12 @@ _PUBLIC_ int idr_remove(struct idr_context *idp, int id); **/ _PUBLIC_ void become_daemon(bool fork); +/** + * Load a ini-style file. + */ +bool pm_process( const char *fileName, + bool (*sfunc)(const char *, void *), + bool (*pfunc)(const char *, const char *, void *), + void *userdata); + #endif /* _SAMBA_UTIL_H_ */ -- cgit From f41b9a9dde0dcad17e3a137537548f9bd9ab3901 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 1 Apr 2008 15:08:30 +0200 Subject: Rename libsamba-config to libsamba-hostconfig. (This used to be commit c46b7e90e347da76156ddcae4866adb88e9fec21) --- source4/lib/policy/config.mk | 4 ++-- source4/lib/registry/config.mk | 8 ++++---- source4/lib/tls/config.mk | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/policy/config.mk b/source4/lib/policy/config.mk index aae98b86b2..6763884b48 100644 --- a/source4/lib/policy/config.mk +++ b/source4/lib/policy/config.mk @@ -1,7 +1,7 @@ [SUBSYSTEM::LIBPOLICY] CFLAGS = -Iheimdal/lib/roken OBJ_FILES = lex.o parse_adm.o -PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBSAMBA-CONFIG LIBTALLOC CHARSET +PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG LIBTALLOC CHARSET lib/policy/lex.l: lib/policy/parse_adm.h @@ -9,4 +9,4 @@ lib/policy/parse_adm.h: lib/policy/parse_adm.c [BINARY::dumpadm] OBJ_FILES = dumpadm.o -PRIVATE_DEPENDENCIES = LIBPOLICY LIBPOPT LIBSAMBA-CONFIG LIBTALLOC LIBSAMBA-UTIL CHARSET +PRIVATE_DEPENDENCIES = LIBPOLICY LIBPOPT LIBSAMBA-HOSTCONFIG LIBTALLOC LIBSAMBA-UTIL CHARSET diff --git a/source4/lib/registry/config.mk b/source4/lib/registry/config.mk index b2d7ce202e..70ffce020a 100644 --- a/source4/lib/registry/config.mk +++ b/source4/lib/registry/config.mk @@ -52,7 +52,7 @@ PRIVATE_PROTO_HEADER = tools/common.h INSTALLDIR = BINDIR OBJ_FILES = tools/regdiff.o PRIVATE_DEPENDENCIES = \ - LIBSAMBA-CONFIG registry LIBPOPT POPT_SAMBA POPT_CREDENTIALS + LIBSAMBA-HOSTCONFIG registry LIBPOPT POPT_SAMBA POPT_CREDENTIALS # End BINARY regdiff ################################################ @@ -64,7 +64,7 @@ MANPAGES += lib/registry/man/regdiff.1 INSTALLDIR = BINDIR OBJ_FILES = tools/regpatch.o PRIVATE_DEPENDENCIES = \ - LIBSAMBA-CONFIG registry LIBPOPT POPT_SAMBA POPT_CREDENTIALS \ + LIBSAMBA-HOSTCONFIG registry LIBPOPT POPT_SAMBA POPT_CREDENTIALS \ registry_common # End BINARY regpatch ################################################ @@ -77,7 +77,7 @@ MANPAGES += lib/registry/man/regpatch.1 INSTALLDIR = BINDIR OBJ_FILES = tools/regshell.o PRIVATE_DEPENDENCIES = \ - LIBSAMBA-CONFIG LIBPOPT registry POPT_SAMBA POPT_CREDENTIALS \ + LIBSAMBA-HOSTCONFIG LIBPOPT registry POPT_SAMBA POPT_CREDENTIALS \ SMBREADLINE registry_common # End BINARY regshell ################################################ @@ -90,7 +90,7 @@ MANPAGES += lib/registry/man/regshell.1 INSTALLDIR = BINDIR OBJ_FILES = tools/regtree.o PRIVATE_DEPENDENCIES = \ - LIBSAMBA-CONFIG LIBPOPT registry POPT_SAMBA POPT_CREDENTIALS \ + LIBSAMBA-HOSTCONFIG LIBPOPT registry POPT_SAMBA POPT_CREDENTIALS \ registry_common # End BINARY regtree ################################################ diff --git a/source4/lib/tls/config.mk b/source4/lib/tls/config.mk index f75c613e73..8e8330f709 100644 --- a/source4/lib/tls/config.mk +++ b/source4/lib/tls/config.mk @@ -5,7 +5,7 @@ OBJ_FILES = \ tls.o \ tlscert.o PUBLIC_DEPENDENCIES = \ - LIBTALLOC GNUTLS LIBSAMBA-CONFIG samba-socket + LIBTALLOC GNUTLS LIBSAMBA-HOSTCONFIG samba-socket # # End SUBSYSTEM LIBTLS ################################################ -- cgit From 7fd96c5b04177a412d9ef12b2f4620b587fe8ed6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 1 Apr 2008 15:17:18 +0200 Subject: Add userdata argument to reseed callback function. (This used to be commit d4272bc6bcfcd71fa93edb25bb33d6458e8b33cd) --- source4/lib/util/genrand.c | 8 +++++--- source4/lib/util/tests/genrand.c | 4 ++-- source4/lib/util/util.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/util/genrand.c b/source4/lib/util/genrand.c index 5751db23d6..7df4ec4e20 100644 --- a/source4/lib/util/genrand.c +++ b/source4/lib/util/genrand.c @@ -37,15 +37,17 @@ static unsigned int bytes_since_reseed = 0; static int urand_fd = -1; -static void (*reseed_callback)(int *newseed); +static void (*reseed_callback)(void *userdata, int *newseed); +static void *reseed_callback_userdata = NULL; /** Copy any user given reseed data. **/ -_PUBLIC_ void set_rand_reseed_callback(void (*fn)(int *)) +_PUBLIC_ void set_rand_reseed_callback(void (*fn)(void *, int *), void *userdata) { reseed_callback = fn; + reseed_callback_userdata = userdata; set_need_random_reseed(); } @@ -61,7 +63,7 @@ _PUBLIC_ void set_need_random_reseed(void) static void get_rand_reseed_data(int *reseed_data) { if (reseed_callback) { - reseed_callback(reseed_data); + reseed_callback(reseed_callback_userdata, reseed_data); } else { *reseed_data = 0; } diff --git a/source4/lib/util/tests/genrand.c b/source4/lib/util/tests/genrand.c index 205a66352f..5fe229c089 100644 --- a/source4/lib/util/tests/genrand.c +++ b/source4/lib/util/tests/genrand.c @@ -22,14 +22,14 @@ #include "includes.h" #include "torture/torture.h" -static void dummy_reseed(int *d) +static void dummy_reseed(void *userdata, int *d) { *d = 42; } static bool test_reseed_callback(struct torture_context *tctx) { - set_rand_reseed_callback(dummy_reseed); + set_rand_reseed_callback(dummy_reseed, NULL); return true; } diff --git a/source4/lib/util/util.h b/source4/lib/util/util.h index 26700587ef..60c8437634 100644 --- a/source4/lib/util/util.h +++ b/source4/lib/util/util.h @@ -218,7 +218,7 @@ _PUBLIC_ struct in_addr sys_inet_makeaddr(int net, int host); /** Copy any user given reseed data. **/ -_PUBLIC_ void set_rand_reseed_callback(void (*fn)(int *)); +_PUBLIC_ void set_rand_reseed_callback(void (*fn)(void *, int *), void *); /** * Tell the random number generator it needs to reseed. -- cgit From bebb7b890c754b05cbb5f4cf83da5b10478ff368 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 1 Apr 2008 16:18:31 +0200 Subject: Add warning to public headers. (This used to be commit 7bfe359c73aac96f8e983e8d5e9621235cf79a3a) --- source4/lib/util/data_blob.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib') diff --git a/source4/lib/util/data_blob.h b/source4/lib/util/data_blob.h index 1442438dd7..e9dca67772 100644 --- a/source4/lib/util/data_blob.h +++ b/source4/lib/util/data_blob.h @@ -16,6 +16,10 @@ along with this program. If not, see . */ +/* This is a public header file that is installed as part of Samba. + * If you remove any functions or change their signature, update + * the so version number. */ + #ifndef _SAMBA_DATABLOB_H_ #define _SAMBA_DATABLOB_H_ -- cgit From afe3e8172ddaa5e4aa811faceecda4f943d6e2ef Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 04:53:27 +0200 Subject: Install public header files again and include required prototypes. (This used to be commit 47ffbbf67435904754469544390b67d34c958343) --- source4/lib/charset/charcnv.c | 2 +- source4/lib/charset/charset.h | 68 ++++++++++++++++++++++++++++++++++-- source4/lib/charset/iconv.c | 8 ++--- source4/lib/charset/util_unistr.c | 6 ++-- source4/lib/registry/tests/generic.c | 2 +- source4/lib/talloc/config.mk | 1 - source4/lib/util/config.mk | 3 +- source4/lib/util/dprintf.c | 6 ++-- source4/lib/util/util_file.c | 4 +-- source4/lib/util/util_ldb.c | 4 +-- source4/lib/util/util_ldb.h | 26 ++++++++++++++ source4/lib/util/wrap_xattr.h | 12 +++++++ 12 files changed, 121 insertions(+), 21 deletions(-) create mode 100644 source4/lib/util/util_ldb.h create mode 100644 source4/lib/util/wrap_xattr.h (limited to 'source4/lib') diff --git a/source4/lib/charset/charcnv.c b/source4/lib/charset/charcnv.c index 0465be689e..3e384304cf 100644 --- a/source4/lib/charset/charcnv.c +++ b/source4/lib/charset/charcnv.c @@ -83,7 +83,7 @@ static int close_iconv(struct smb_iconv_convenience *data) return 0; } -struct smb_iconv_convenience *smb_iconv_convenience_init(TALLOC_CTX *mem_ctx, +_PUBLIC_ struct smb_iconv_convenience *smb_iconv_convenience_init(TALLOC_CTX *mem_ctx, const char *dos_charset, const char *unix_charset, bool native_iconv) diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h index 1d42a0ad91..baa7df532b 100644 --- a/source4/lib/charset/charset.h +++ b/source4/lib/charset/charset.h @@ -18,6 +18,10 @@ along with this program. If not, see . */ +/* This is a public header file that is installed as part of Samba. + * If you remove any functions or change their signature, update + * the so version number. */ + #ifndef __CHARSET_H__ #define __CHARSET_H__ @@ -74,11 +78,71 @@ struct loadparm_context; struct smb_iconv_convenience; extern struct smb_iconv_convenience *global_smb_iconv_convenience; -#include "lib/charset/charset_proto.h" - /* replace some string functions with multi-byte versions */ #define strlower(s) strlower_m(s) #define strupper(s) strupper_m(s) +char *strchr_m(const char *s, char c); +size_t strlen_m_term(const char *s); +size_t strlen_m(const char *s); +char *alpha_strcpy(char *dest, const char *src, const char *other_safe_chars, size_t maxlength); +void string_replace_w(char *s, char oldc, char newc); +bool strcsequal_w(const char *s1,const char *s2); +bool strequal_w(const char *s1, const char *s2); +int strncasecmp_m(const char *s1, const char *s2, size_t n); +bool next_token(const char **ptr,char *buff, const char *sep, size_t bufsize); +int strcasecmp_m(const char *s1, const char *s2); +size_t count_chars_w(const char *s, char c); +void strupper_m(char *s); +void strlower_m(char *s); +char *strupper_talloc(TALLOC_CTX *ctx, const char *src); +char *strlower_talloc(TALLOC_CTX *ctx, const char *src); +bool strhasupper(const char *string); +bool strhaslower(const char *string); +char *strrchr_m(const char *s, char c); +char *strchr_m(const char *s, char c); + +/* codepoints */ +codepoint_t next_codepoint(struct smb_iconv_convenience *ic, + const char *str, size_t *size); +ssize_t push_codepoint(struct smb_iconv_convenience *ic, + char *str, codepoint_t c); +codepoint_t toupper_w(codepoint_t val); +codepoint_t tolower_w(codepoint_t val); +int codepoint_cmpi(codepoint_t c1, codepoint_t c2); +ssize_t push_string(struct smb_iconv_convenience *ic, void *dest, const char *src, size_t dest_len, int flags); +ssize_t pull_string(struct smb_iconv_convenience *ic, + char *dest, const void *src, size_t dest_len, size_t src_len, int flags); +ssize_t convert_string(struct smb_iconv_convenience *ic, + charset_t from, charset_t to, + void const *src, size_t srclen, + void *dest, size_t destlen); +ssize_t convert_string_talloc_descriptor(TALLOC_CTX *ctx, smb_iconv_t descriptor, void const *src, size_t srclen, void **dest); +ssize_t convert_string_talloc(TALLOC_CTX *ctx, + struct smb_iconv_convenience *ic, + charset_t from, charset_t to, + void const *src, size_t srclen, + void **dest); +ssize_t push_ascii_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src); +ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, void **dest, const char *src); +ssize_t push_utf8_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src); +ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src); +ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const void *src); +ssize_t pull_utf8_talloc(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, char **dest, const char *src); + +/* iconv */ +smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode); +int smb_iconv_close(smb_iconv_t cd); +size_t smb_iconv(smb_iconv_t cd, + const char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft); +smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode, + const char *fromcode, bool native_iconv); + +/* iconv convenience */ +struct smb_iconv_convenience *smb_iconv_convenience_init(TALLOC_CTX *mem_ctx, + const char *dos_charset, + const char *unix_charset, + bool native_iconv); #endif /* __CHARSET_H__ */ diff --git a/source4/lib/charset/iconv.c b/source4/lib/charset/iconv.c index db212a83c4..4f4bc8fd2d 100644 --- a/source4/lib/charset/iconv.c +++ b/source4/lib/charset/iconv.c @@ -113,7 +113,7 @@ static size_t sys_iconv(void *cd, * It only knows about a very small number of character sets - just * enough that Samba works on systems that don't have iconv. **/ -size_t smb_iconv(smb_iconv_t cd, +_PUBLIC_ size_t smb_iconv(smb_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) { @@ -156,7 +156,7 @@ static bool is_utf16(const char *name) -smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode, +_PUBLIC_ smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode, const char *fromcode, bool native_iconv) { smb_iconv_t ret; @@ -263,7 +263,7 @@ failed: /* simple iconv_open() wrapper */ -smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode) +_PUBLIC_ smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode) { return smb_iconv_open_ex(NULL, tocode, fromcode, true); } @@ -271,7 +271,7 @@ smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode) /* simple iconv_close() wrapper */ -int smb_iconv_close(smb_iconv_t cd) +_PUBLIC_ int smb_iconv_close(smb_iconv_t cd) { #ifdef HAVE_NATIVE_ICONV if (cd->cd_direct) iconv_close((iconv_t)cd->cd_direct); diff --git a/source4/lib/charset/util_unistr.c b/source4/lib/charset/util_unistr.c index 9b87f49800..c496c5d905 100644 --- a/source4/lib/charset/util_unistr.c +++ b/source4/lib/charset/util_unistr.c @@ -67,7 +67,7 @@ static void load_case_tables(void) /** Convert a codepoint_t to upper case. **/ -codepoint_t toupper_w(codepoint_t val) +_PUBLIC_ codepoint_t toupper_w(codepoint_t val) { if (val < 128) { return toupper(val); @@ -87,7 +87,7 @@ codepoint_t toupper_w(codepoint_t val) /** Convert a codepoint_t to lower case. **/ -codepoint_t tolower_w(codepoint_t val) +_PUBLIC_ codepoint_t tolower_w(codepoint_t val) { if (val < 128) { return tolower(val); @@ -107,7 +107,7 @@ codepoint_t tolower_w(codepoint_t val) /** compare two codepoints case insensitively */ -int codepoint_cmpi(codepoint_t c1, codepoint_t c2) +_PUBLIC_ int codepoint_cmpi(codepoint_t c1, codepoint_t c2) { if (c1 == c2 || toupper_w(c1) == toupper_w(c2)) { diff --git a/source4/lib/registry/tests/generic.c b/source4/lib/registry/tests/generic.c index 145e599504..6eae26bc46 100644 --- a/source4/lib/registry/tests/generic.c +++ b/source4/lib/registry/tests/generic.c @@ -112,7 +112,7 @@ static bool test_reg_val_description_nullname(struct torture_context *ctx) return true; } -_PUBLIC_ struct torture_suite *torture_registry(TALLOC_CTX *mem_ctx) +struct torture_suite *torture_registry(TALLOC_CTX *mem_ctx) { struct torture_suite *suite = torture_suite_create(mem_ctx, "REGISTRY"); torture_suite_add_simple_test(suite, "str_regtype", diff --git a/source4/lib/talloc/config.mk b/source4/lib/talloc/config.mk index 33241ffac7..3eab90b9ae 100644 --- a/source4/lib/talloc/config.mk +++ b/source4/lib/talloc/config.mk @@ -5,4 +5,3 @@ CFLAGS = -Ilib/talloc MANPAGES += $(tallocdir)/talloc.3 -PUBLIC_HEADERS += $(tallocdir)/talloc.h diff --git a/source4/lib/util/config.mk b/source4/lib/util/config.mk index c6afad1e3f..483e835e00 100644 --- a/source4/lib/util/config.mk +++ b/source4/lib/util/config.mk @@ -33,6 +33,7 @@ PUBLIC_HEADERS += $(addprefix lib/util/, util.h \ mutex.h \ safe_string.h \ time.h \ + util_ldb.h \ xfile.h) [SUBSYSTEM::ASN1_UTIL] @@ -48,7 +49,6 @@ OBJ_FILES = unix_privs.o ################################################ # Start SUBSYSTEM WRAP_XATTR [SUBSYSTEM::WRAP_XATTR] -PRIVATE_PROTO_HEADER = wrap_xattr.h OBJ_FILES = \ wrap_xattr.o PUBLIC_DEPENDENCIES = XATTR @@ -63,7 +63,6 @@ OBJ_FILES = \ PUBLIC_DEPENDENCIES = LIBTDB [SUBSYSTEM::UTIL_LDB] -PRIVATE_PROTO_HEADER = util_ldb.h OBJ_FILES = \ util_ldb.o PUBLIC_DEPENDENCIES = LIBLDB diff --git a/source4/lib/util/dprintf.c b/source4/lib/util/dprintf.c index 308d81b105..e4f02758eb 100644 --- a/source4/lib/util/dprintf.c +++ b/source4/lib/util/dprintf.c @@ -42,7 +42,7 @@ void d_set_iconv(smb_iconv_t cd) display_cd = cd; } -_PUBLIC_ int d_vfprintf(FILE *f, const char *format, va_list ap) _PRINTF_ATTRIBUTE(2,0) +_PUBLIC_ int d_vfprintf(FILE *f, const char *format, va_list ap) { char *p, *p2; int ret, clen; @@ -85,7 +85,7 @@ _PUBLIC_ int d_vfprintf(FILE *f, const char *format, va_list ap) _PRINTF_ATTRIBU } -_PUBLIC_ int d_fprintf(FILE *f, const char *format, ...) _PRINTF_ATTRIBUTE(2,3) +_PUBLIC_ int d_fprintf(FILE *f, const char *format, ...) { int ret; va_list ap; @@ -97,7 +97,7 @@ _PUBLIC_ int d_fprintf(FILE *f, const char *format, ...) _PRINTF_ATTRIBUTE(2,3) return ret; } -_PUBLIC_ int d_printf(const char *format, ...) _PRINTF_ATTRIBUTE(1,2) +_PUBLIC_ int d_printf(const char *format, ...) { int ret; va_list ap; diff --git a/source4/lib/util/util_file.c b/source4/lib/util/util_file.c index 836e188ac1..c3e22196c0 100644 --- a/source4/lib/util/util_file.c +++ b/source4/lib/util/util_file.c @@ -356,7 +356,7 @@ _PUBLIC_ bool file_save(const char *fname, const void *packet, size_t length) return true; } -_PUBLIC_ int vfdprintf(int fd, const char *format, va_list ap) _PRINTF_ATTRIBUTE(2,0) +_PUBLIC_ int vfdprintf(int fd, const char *format, va_list ap) { char *p; int len, ret; @@ -371,7 +371,7 @@ _PUBLIC_ int vfdprintf(int fd, const char *format, va_list ap) _PRINTF_ATTRIBUTE return ret; } -_PUBLIC_ int fdprintf(int fd, const char *format, ...) _PRINTF_ATTRIBUTE(2,3) +_PUBLIC_ int fdprintf(int fd, const char *format, ...) { va_list ap; int ret; diff --git a/source4/lib/util/util_ldb.c b/source4/lib/util/util_ldb.c index f1b42effd8..38f53c2c66 100644 --- a/source4/lib/util/util_ldb.c +++ b/source4/lib/util/util_ldb.c @@ -33,7 +33,7 @@ int gendb_search_v(struct ldb_context *ldb, struct ldb_message ***msgs, const char * const *attrs, const char *format, - va_list ap) _PRINTF_ATTRIBUTE(6,0) + va_list ap) { enum ldb_scope scope = LDB_SCOPE_SUBTREE; struct ldb_result *res; @@ -85,7 +85,7 @@ int gendb_search(struct ldb_context *ldb, struct ldb_dn *basedn, struct ldb_message ***res, const char * const *attrs, - const char *format, ...) _PRINTF_ATTRIBUTE(6,7) + const char *format, ...) { va_list ap; int count; diff --git a/source4/lib/util/util_ldb.h b/source4/lib/util/util_ldb.h new file mode 100644 index 0000000000..864ce7e8c6 --- /dev/null +++ b/source4/lib/util/util_ldb.h @@ -0,0 +1,26 @@ +#ifndef __LIB_UTIL_UTIL_LDB_H__ +#define __LIB_UTIL_UTIL_LDB_H__ + +int gendb_search_v(struct ldb_context *ldb, + TALLOC_CTX *mem_ctx, + struct ldb_dn *basedn, + struct ldb_message ***msgs, + const char * const *attrs, + const char *format, + va_list ap) _PRINTF_ATTRIBUTE(6,0); +int gendb_search(struct ldb_context *ldb, + TALLOC_CTX *mem_ctx, + struct ldb_dn *basedn, + struct ldb_message ***res, + const char * const *attrs, + const char *format, ...) _PRINTF_ATTRIBUTE(6,7); +int gendb_search_dn(struct ldb_context *ldb, + TALLOC_CTX *mem_ctx, + struct ldb_dn *dn, + struct ldb_message ***res, + const char * const *attrs); +int gendb_add_ldif(struct ldb_context *ldb, const char *ldif_string); +char *wrap_casefold(void *context, void *mem_ctx, const char *s); + +#endif /* __LIB_UTIL_UTIL_LDB_H__ */ + diff --git a/source4/lib/util/wrap_xattr.h b/source4/lib/util/wrap_xattr.h new file mode 100644 index 0000000000..64b28d250c --- /dev/null +++ b/source4/lib/util/wrap_xattr.h @@ -0,0 +1,12 @@ +#ifndef __LIB_UTIL_WRAP_XATTR_H__ +#define __LIB_UTIL_WRAP_XATTR_H__ + +ssize_t wrap_fgetxattr(int fd, const char *name, void *value, size_t size); +ssize_t wrap_getxattr(const char *path, const char *name, void *value, size_t size); +int wrap_fsetxattr(int fd, const char *name, void *value, size_t size, int flags); +int wrap_setxattr(const char *path, const char *name, void *value, size_t size, int flags); +int wrap_fremovexattr(int fd, const char *name); +int wrap_removexattr(const char *path, const char *name); + +#endif /* __LIB_UTIL_WRAP_XATTR_H__ */ + -- cgit From 236fc02913adafd80921d4e30aa6ee1e414bef44 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 13:41:10 +0200 Subject: Reduce the number of installed headers. (This used to be commit 2243e24024f09ff9c9c7d0eb735c3b39c9d84424) --- source4/lib/basic.mk | 2 +- source4/lib/events/config.mk | 2 +- source4/lib/nss_wrapper/config.mk | 2 -- source4/lib/socket_wrapper/config.mk | 2 -- source4/lib/tdb/config.mk | 2 -- source4/lib/util/config.mk | 2 +- 6 files changed, 3 insertions(+), 9 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/basic.mk b/source4/lib/basic.mk index d059bdf49b..d6e90928b0 100644 --- a/source4/lib/basic.mk +++ b/source4/lib/basic.mk @@ -26,7 +26,7 @@ OBJ_FILES = gencache/gencache.o PRIVATE_DEPENDENCIES = TDB_WRAP -PUBLIC_HEADERS += lib/gencache/gencache.h +# PUBLIC_HEADERS += lib/gencache/gencache.h [SUBSYSTEM::LDB_WRAP] OBJ_FILES = ldb_wrap.o diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk index 225a23c634..8001699aee 100644 --- a/source4/lib/events/config.mk +++ b/source4/lib/events/config.mk @@ -36,7 +36,7 @@ PUBLIC_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL # End SUBSYSTEM LIBEVENTS ############################## -PUBLIC_HEADERS += $(addprefix lib/events/, events.h events_internal.h) +# PUBLIC_HEADERS += $(addprefix lib/events/, events.h events_internal.h) [PYTHON::swig_events] SWIG_FILE = events.i diff --git a/source4/lib/nss_wrapper/config.mk b/source4/lib/nss_wrapper/config.mk index 81b0ef36fd..03c10acc7a 100644 --- a/source4/lib/nss_wrapper/config.mk +++ b/source4/lib/nss_wrapper/config.mk @@ -4,5 +4,3 @@ OBJ_FILES = nss_wrapper.o # End SUBSYSTEM NSS_WRAPPER ############################## - -PUBLIC_HEADERS += lib/nss_wrapper/nss_wrapper.h diff --git a/source4/lib/socket_wrapper/config.mk b/source4/lib/socket_wrapper/config.mk index 2b9f30a7bb..902692d9be 100644 --- a/source4/lib/socket_wrapper/config.mk +++ b/source4/lib/socket_wrapper/config.mk @@ -5,5 +5,3 @@ OBJ_FILES = socket_wrapper.o PRIVATE_DEPENDENCIES = LIBREPLACE_NETWORK # End SUBSYSTEM SOCKET_WRAPPER ############################## - -PUBLIC_HEADERS += lib/socket_wrapper/socket_wrapper.h diff --git a/source4/lib/tdb/config.mk b/source4/lib/tdb/config.mk index c69804fa13..76342dc8fa 100644 --- a/source4/lib/tdb/config.mk +++ b/source4/lib/tdb/config.mk @@ -11,8 +11,6 @@ CFLAGS = -Ilib/tdb/include # End SUBSYSTEM ldb ################################################ -PUBLIC_HEADERS += $(tdbdir)/include/tdb.h - ################################################ # Start BINARY tdbtool [BINARY::tdbtool] diff --git a/source4/lib/util/config.mk b/source4/lib/util/config.mk index 483e835e00..0bf0692193 100644 --- a/source4/lib/util/config.mk +++ b/source4/lib/util/config.mk @@ -40,7 +40,7 @@ PUBLIC_HEADERS += $(addprefix lib/util/, util.h \ PRIVATE_PROTO_HEADER = asn1_proto.h OBJ_FILES = asn1.o -PUBLIC_HEADERS += lib/util/asn1.h +# PUBLIC_HEADERS += lib/util/asn1.h [SUBSYSTEM::UNIX_PRIVS] PRIVATE_PROTO_HEADER = unix_privs.h -- cgit From 5be50a222facee943edae868e39ff11f7dd68965 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 13:58:05 +0200 Subject: Merge patchfile.h into registry.h (This used to be commit 7b434df67aefc667993f0ebd955af9c1c258f153) --- source4/lib/registry/config.mk | 2 +- source4/lib/registry/patchfile.c | 1 - source4/lib/registry/patchfile.h | 55 --------------------------------- source4/lib/registry/patchfile_dotreg.c | 1 - source4/lib/registry/patchfile_preg.c | 1 - source4/lib/registry/registry.h | 31 +++++++++++++++++-- 6 files changed, 30 insertions(+), 61 deletions(-) delete mode 100644 source4/lib/registry/patchfile.h (limited to 'source4/lib') diff --git a/source4/lib/registry/config.mk b/source4/lib/registry/config.mk index 70ffce020a..1deac1dd46 100644 --- a/source4/lib/registry/config.mk +++ b/source4/lib/registry/config.mk @@ -39,7 +39,7 @@ PUBLIC_DEPENDENCIES = \ # End MODULE registry_ldb ################################################ -PUBLIC_HEADERS += $(addprefix lib/registry/, registry.h hive.h patchfile.h) +PUBLIC_HEADERS += $(addprefix lib/registry/, registry.h hive.h) [SUBSYSTEM::registry_common] PUBLIC_DEPENDENCIES = registry diff --git a/source4/lib/registry/patchfile.c b/source4/lib/registry/patchfile.c index 687fd4b91b..15e3a158f2 100644 --- a/source4/lib/registry/patchfile.c +++ b/source4/lib/registry/patchfile.c @@ -20,7 +20,6 @@ */ #include "includes.h" -#include "lib/registry/patchfile.h" #include "lib/registry/registry.h" #include "system/filesys.h" #include "param/param.h" diff --git a/source4/lib/registry/patchfile.h b/source4/lib/registry/patchfile.h deleted file mode 100644 index d586aa4c31..0000000000 --- a/source4/lib/registry/patchfile.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Patchfile interface - Copyright (C) Jelmer Vernooij 2006 - Copyright (C) Wilco Baan Hofman 2006 - - 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef _PATCHFILE_H -#define _PATCHFILE_H - -#include "lib/registry/registry.h" - -struct reg_diff_callbacks { - WERROR (*add_key) (void *callback_data, const char *key_name); - WERROR (*set_value) (void *callback_data, const char *key_name, - const char *value_name, uint32_t value_type, - DATA_BLOB value); - WERROR (*del_value) (void *callback_data, const char *key_name, - const char *value_name); - WERROR (*del_key) (void *callback_data, const char *key_name); - WERROR (*del_all_values) (void *callback_data, const char *key_name); - WERROR (*done) (void *callback_data); -}; - -WERROR reg_diff_apply(struct registry_context *ctx, const char *filename); - -WERROR reg_generate_diff(struct registry_context *ctx1, - struct registry_context *ctx2, - const struct reg_diff_callbacks *callbacks, - void *callback_data); -WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename, - struct smb_iconv_convenience *iconv_convenience, - struct reg_diff_callbacks **callbacks, - void **callback_data); -WERROR reg_generate_diff_key(struct registry_key *oldkey, - struct registry_key *newkey, - const char *path, - const struct reg_diff_callbacks *callbacks, - void *callback_data); - -#endif /* _PATCHFILE_H */ diff --git a/source4/lib/registry/patchfile_dotreg.c b/source4/lib/registry/patchfile_dotreg.c index 5150c90291..59f4044713 100644 --- a/source4/lib/registry/patchfile_dotreg.c +++ b/source4/lib/registry/patchfile_dotreg.c @@ -23,7 +23,6 @@ /* FIXME Newer .REG files, created by Windows XP and above use unicode UTF-16 */ #include "includes.h" -#include "lib/registry/patchfile.h" #include "lib/registry/registry.h" #include "system/filesys.h" #include "param/param.h" diff --git a/source4/lib/registry/patchfile_preg.c b/source4/lib/registry/patchfile_preg.c index 8f02a0b5e3..0fa367bfcb 100644 --- a/source4/lib/registry/patchfile_preg.c +++ b/source4/lib/registry/patchfile_preg.c @@ -21,7 +21,6 @@ #include "includes.h" #include "lib/registry/registry.h" -#include "lib/registry/patchfile.h" #include "system/filesys.h" #include "param/param.h" diff --git a/source4/lib/registry/registry.h b/source4/lib/registry/registry.h index 5e0b971a1d..b76f2c4bcc 100644 --- a/source4/lib/registry/registry.h +++ b/source4/lib/registry/registry.h @@ -66,8 +66,6 @@ struct registry_key struct registry_context *context; }; -#include "lib/registry/patchfile.h" - struct registry_value { const char *name; @@ -285,5 +283,34 @@ WERROR reg_get_security(TALLOC_CTX *mem_ctx, WERROR reg_set_security(struct registry_key *key, struct security_descriptor *security); +struct reg_diff_callbacks { + WERROR (*add_key) (void *callback_data, const char *key_name); + WERROR (*set_value) (void *callback_data, const char *key_name, + const char *value_name, uint32_t value_type, + DATA_BLOB value); + WERROR (*del_value) (void *callback_data, const char *key_name, + const char *value_name); + WERROR (*del_key) (void *callback_data, const char *key_name); + WERROR (*del_all_values) (void *callback_data, const char *key_name); + WERROR (*done) (void *callback_data); +}; + +WERROR reg_diff_apply(struct registry_context *ctx, const char *filename); + +WERROR reg_generate_diff(struct registry_context *ctx1, + struct registry_context *ctx2, + const struct reg_diff_callbacks *callbacks, + void *callback_data); +WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename, + struct smb_iconv_convenience *iconv_convenience, + struct reg_diff_callbacks **callbacks, + void **callback_data); +WERROR reg_generate_diff_key(struct registry_key *oldkey, + struct registry_key *newkey, + const char *path, + const struct reg_diff_callbacks *callbacks, + void *callback_data); + + #endif /* _REGISTRY_H */ -- cgit From ec7394e7d2f589905044cff3cb1899f0815991d6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 13:59:48 +0200 Subject: Merge hive.h into registry.h (This used to be commit 3ca14fdf74d2510049bbdbbd2a5be341412cda1b) --- source4/lib/registry/dir.c | 2 +- source4/lib/registry/hive.c | 2 +- source4/lib/registry/hive.h | 209 ----------------------------------- source4/lib/registry/regf.c | 2 +- source4/lib/registry/registry.h | 183 +++++++++++++++++++++++++++++- source4/lib/registry/registry.i | 1 - source4/lib/registry/registry_wrap.c | 2 +- 7 files changed, 186 insertions(+), 215 deletions(-) delete mode 100644 source4/lib/registry/hive.h (limited to 'source4/lib') diff --git a/source4/lib/registry/dir.c b/source4/lib/registry/dir.c index dc3717e886..449ee0f6ee 100644 --- a/source4/lib/registry/dir.c +++ b/source4/lib/registry/dir.c @@ -18,7 +18,7 @@ */ #include "includes.h" -#include "hive.h" +#include "registry.h" #include "system/dir.h" #include "system/filesys.h" diff --git a/source4/lib/registry/hive.c b/source4/lib/registry/hive.c index fc2d0fe869..2a9b1a59ce 100644 --- a/source4/lib/registry/hive.c +++ b/source4/lib/registry/hive.c @@ -20,7 +20,7 @@ */ #include "includes.h" -#include "hive.h" +#include "registry.h" #include "system/filesys.h" #include "param/param.h" diff --git a/source4/lib/registry/hive.h b/source4/lib/registry/hive.h deleted file mode 100644 index 2410885718..0000000000 --- a/source4/lib/registry/hive.h +++ /dev/null @@ -1,209 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Registry hive interface - Copyright (C) Jelmer Vernooij 2003-2007. - - 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef __REGISTRY_HIVE_H__ -#define __REGISTRY_HIVE_H__ - -#include -#include "libcli/util/werror.h" -#include "librpc/gen_ndr/security.h" -#include "libcli/util/ntstatus.h" - -/** - * This file contains the hive API. This API is generally used for - * reading a specific file that contains just one hive. - * - * Good examples are .DAT (NTUSER.DAT) files. - * - * This API does not have any notification support (that - * should be provided by the registry implementation), nor - * does it understand what predefined keys are. - */ - -struct hive_key { - const struct hive_operations *ops; -}; - -struct hive_operations { - const char *name; - - /** - * Open a specific subkey - */ - WERROR (*enum_key) (TALLOC_CTX *mem_ctx, - const struct hive_key *key, uint32_t idx, - const char **name, - const char **classname, - NTTIME *last_mod_time); - - /** - * Open a subkey by name - */ - WERROR (*get_key_by_name) (TALLOC_CTX *mem_ctx, - const struct hive_key *key, const char *name, - struct hive_key **subkey); - - /** - * Add a new key. - */ - WERROR (*add_key) (TALLOC_CTX *ctx, - const struct hive_key *parent_key, const char *name, - const char *classname, - struct security_descriptor *desc, - struct hive_key **key); - /** - * Remove an existing key. - */ - WERROR (*del_key) (const struct hive_key *key, const char *name); - - /** - * Force write of a key to disk. - */ - WERROR (*flush_key) (struct hive_key *key); - - /** - * Retrieve a registry value with a specific index. - */ - WERROR (*enum_value) (TALLOC_CTX *mem_ctx, - struct hive_key *key, int idx, - const char **name, uint32_t *type, - DATA_BLOB *data); - - /** - * Retrieve a registry value with the specified name - */ - WERROR (*get_value_by_name) (TALLOC_CTX *mem_ctx, - struct hive_key *key, const char *name, - uint32_t *type, DATA_BLOB *data); - - /** - * Set a value on the specified registry key. - */ - WERROR (*set_value) (struct hive_key *key, const char *name, - uint32_t type, const DATA_BLOB data); - - /** - * Remove a value. - */ - WERROR (*delete_value) (struct hive_key *key, const char *name); - - /* Security Descriptors */ - - /** - * Change the security descriptor on a registry key. - * - * This should return WERR_NOT_SUPPORTED if the underlying - * format does not have a mechanism for storing - * security descriptors. - */ - WERROR (*set_sec_desc) (struct hive_key *key, - const struct security_descriptor *desc); - - /** - * Retrieve the security descriptor on a registry key. - * - * This should return WERR_NOT_SUPPORTED if the underlying - * format does not have a mechanism for storing - * security descriptors. - */ - WERROR (*get_sec_desc) (TALLOC_CTX *ctx, - const struct hive_key *key, - struct security_descriptor **desc); - - /** - * Retrieve general information about a key. - */ - WERROR (*get_key_info) (TALLOC_CTX *mem_ctx, - const struct hive_key *key, - const char **classname, - uint32_t *num_subkeys, - uint32_t *num_values, - NTTIME *last_change_time, - uint32_t *max_subkeynamelen, - uint32_t *max_valnamelen, - uint32_t *max_valbufsize); -}; - -struct cli_credentials; -struct auth_session_info; - -WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location, - struct auth_session_info *session_info, - struct cli_credentials *credentials, - struct loadparm_context *lp_ctx, - struct hive_key **root); -WERROR hive_key_get_info(TALLOC_CTX *mem_ctx, const struct hive_key *key, - const char **classname, uint32_t *num_subkeys, - uint32_t *num_values, NTTIME *last_change_time, - uint32_t *max_subkeynamelen, - uint32_t *max_valnamelen, uint32_t *max_valbufsize); -WERROR hive_key_add_name(TALLOC_CTX *ctx, const struct hive_key *parent_key, - const char *name, const char *classname, - struct security_descriptor *desc, - struct hive_key **key); -WERROR hive_key_del(const struct hive_key *key, const char *name); -WERROR hive_get_key_by_name(TALLOC_CTX *mem_ctx, - const struct hive_key *key, const char *name, - struct hive_key **subkey); -WERROR hive_enum_key(TALLOC_CTX *mem_ctx, - const struct hive_key *key, uint32_t idx, - const char **name, - const char **classname, - NTTIME *last_mod_time); - -WERROR hive_key_set_value(struct hive_key *key, const char *name, - uint32_t type, const DATA_BLOB data); - -WERROR hive_get_value(TALLOC_CTX *mem_ctx, - struct hive_key *key, const char *name, - uint32_t *type, DATA_BLOB *data); -WERROR hive_get_value_by_index(TALLOC_CTX *mem_ctx, - struct hive_key *key, uint32_t idx, - const char **name, - uint32_t *type, DATA_BLOB *data); - -WERROR hive_key_del_value(struct hive_key *key, const char *name); - -WERROR hive_key_flush(struct hive_key *key); - - -/* Individual backends */ -WERROR reg_open_directory(TALLOC_CTX *parent_ctx, - const char *location, struct hive_key **key); -WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx, - const char *location, struct smb_iconv_convenience *iconv_convenience, - struct hive_key **key); -WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location, - struct auth_session_info *session_info, - struct cli_credentials *credentials, - struct loadparm_context *lp_ctx, - struct hive_key **k); - - -WERROR reg_create_directory(TALLOC_CTX *parent_ctx, - const char *location, struct hive_key **key); -WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, - struct smb_iconv_convenience *iconv_convenience, - const char *location, - int major_version, - struct hive_key **key); - - -#endif /* __REGISTRY_HIVE_H__ */ diff --git a/source4/lib/registry/regf.c b/source4/lib/registry/regf.c index a192f3be4d..46ccca922b 100644 --- a/source4/lib/registry/regf.c +++ b/source4/lib/registry/regf.c @@ -18,13 +18,13 @@ along with this program. If not, see . */ #include "includes.h" -#include "lib/registry/hive.h" #include "system/filesys.h" #include "system/time.h" #include "lib/registry/tdr_regf.h" #include "librpc/gen_ndr/ndr_security.h" #include "librpc/gen_ndr/winreg.h" #include "param/param.h" +#include "lib/registry/registry.h" static struct hive_operations reg_backend_regf; diff --git a/source4/lib/registry/registry.h b/source4/lib/registry/registry.h index b76f2c4bcc..ff03f71eb2 100644 --- a/source4/lib/registry/registry.h +++ b/source4/lib/registry/registry.h @@ -24,10 +24,191 @@ struct registry_context; #include +#include "libcli/util/werror.h" #include "librpc/gen_ndr/security.h" -#include "lib/registry/hive.h" #include "libcli/util/ntstatus.h" +/** + * The hive API. This API is generally used for + * reading a specific file that contains just one hive. + * + * Good examples are .DAT (NTUSER.DAT) files. + * + * This API does not have any notification support (that + * should be provided by the registry implementation), nor + * does it understand what predefined keys are. + */ + +struct hive_key { + const struct hive_operations *ops; +}; + +struct hive_operations { + const char *name; + + /** + * Open a specific subkey + */ + WERROR (*enum_key) (TALLOC_CTX *mem_ctx, + const struct hive_key *key, uint32_t idx, + const char **name, + const char **classname, + NTTIME *last_mod_time); + + /** + * Open a subkey by name + */ + WERROR (*get_key_by_name) (TALLOC_CTX *mem_ctx, + const struct hive_key *key, const char *name, + struct hive_key **subkey); + + /** + * Add a new key. + */ + WERROR (*add_key) (TALLOC_CTX *ctx, + const struct hive_key *parent_key, const char *name, + const char *classname, + struct security_descriptor *desc, + struct hive_key **key); + /** + * Remove an existing key. + */ + WERROR (*del_key) (const struct hive_key *key, const char *name); + + /** + * Force write of a key to disk. + */ + WERROR (*flush_key) (struct hive_key *key); + + /** + * Retrieve a registry value with a specific index. + */ + WERROR (*enum_value) (TALLOC_CTX *mem_ctx, + struct hive_key *key, int idx, + const char **name, uint32_t *type, + DATA_BLOB *data); + + /** + * Retrieve a registry value with the specified name + */ + WERROR (*get_value_by_name) (TALLOC_CTX *mem_ctx, + struct hive_key *key, const char *name, + uint32_t *type, DATA_BLOB *data); + + /** + * Set a value on the specified registry key. + */ + WERROR (*set_value) (struct hive_key *key, const char *name, + uint32_t type, const DATA_BLOB data); + + /** + * Remove a value. + */ + WERROR (*delete_value) (struct hive_key *key, const char *name); + + /* Security Descriptors */ + + /** + * Change the security descriptor on a registry key. + * + * This should return WERR_NOT_SUPPORTED if the underlying + * format does not have a mechanism for storing + * security descriptors. + */ + WERROR (*set_sec_desc) (struct hive_key *key, + const struct security_descriptor *desc); + + /** + * Retrieve the security descriptor on a registry key. + * + * This should return WERR_NOT_SUPPORTED if the underlying + * format does not have a mechanism for storing + * security descriptors. + */ + WERROR (*get_sec_desc) (TALLOC_CTX *ctx, + const struct hive_key *key, + struct security_descriptor **desc); + + /** + * Retrieve general information about a key. + */ + WERROR (*get_key_info) (TALLOC_CTX *mem_ctx, + const struct hive_key *key, + const char **classname, + uint32_t *num_subkeys, + uint32_t *num_values, + NTTIME *last_change_time, + uint32_t *max_subkeynamelen, + uint32_t *max_valnamelen, + uint32_t *max_valbufsize); +}; + +struct cli_credentials; +struct auth_session_info; + +WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location, + struct auth_session_info *session_info, + struct cli_credentials *credentials, + struct loadparm_context *lp_ctx, + struct hive_key **root); +WERROR hive_key_get_info(TALLOC_CTX *mem_ctx, const struct hive_key *key, + const char **classname, uint32_t *num_subkeys, + uint32_t *num_values, NTTIME *last_change_time, + uint32_t *max_subkeynamelen, + uint32_t *max_valnamelen, uint32_t *max_valbufsize); +WERROR hive_key_add_name(TALLOC_CTX *ctx, const struct hive_key *parent_key, + const char *name, const char *classname, + struct security_descriptor *desc, + struct hive_key **key); +WERROR hive_key_del(const struct hive_key *key, const char *name); +WERROR hive_get_key_by_name(TALLOC_CTX *mem_ctx, + const struct hive_key *key, const char *name, + struct hive_key **subkey); +WERROR hive_enum_key(TALLOC_CTX *mem_ctx, + const struct hive_key *key, uint32_t idx, + const char **name, + const char **classname, + NTTIME *last_mod_time); + +WERROR hive_key_set_value(struct hive_key *key, const char *name, + uint32_t type, const DATA_BLOB data); + +WERROR hive_get_value(TALLOC_CTX *mem_ctx, + struct hive_key *key, const char *name, + uint32_t *type, DATA_BLOB *data); +WERROR hive_get_value_by_index(TALLOC_CTX *mem_ctx, + struct hive_key *key, uint32_t idx, + const char **name, + uint32_t *type, DATA_BLOB *data); + +WERROR hive_key_del_value(struct hive_key *key, const char *name); + +WERROR hive_key_flush(struct hive_key *key); + + +/* Individual backends */ +WERROR reg_open_directory(TALLOC_CTX *parent_ctx, + const char *location, struct hive_key **key); +WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx, + const char *location, struct smb_iconv_convenience *iconv_convenience, + struct hive_key **key); +WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location, + struct auth_session_info *session_info, + struct cli_credentials *credentials, + struct loadparm_context *lp_ctx, + struct hive_key **k); + + +WERROR reg_create_directory(TALLOC_CTX *parent_ctx, + const char *location, struct hive_key **key); +WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, + struct smb_iconv_convenience *iconv_convenience, + const char *location, + int major_version, + struct hive_key **key); + + + /* Handles for the predefined keys */ #define HKEY_CLASSES_ROOT 0x80000000 #define HKEY_CURRENT_USER 0x80000001 diff --git a/source4/lib/registry/registry.i b/source4/lib/registry/registry.i index 20ae671c75..8ab402d57d 100644 --- a/source4/lib/registry/registry.i +++ b/source4/lib/registry/registry.i @@ -26,7 +26,6 @@ #include "includes.h" #include "registry.h" #include "param/param.h" -#include "hive.h" typedef struct registry_context reg; typedef struct hive_key hive_key; diff --git a/source4/lib/registry/registry_wrap.c b/source4/lib/registry/registry_wrap.c index 51c255e9f7..ded3acbbe6 100644 --- a/source4/lib/registry/registry_wrap.c +++ b/source4/lib/registry/registry_wrap.c @@ -2529,7 +2529,7 @@ static swig_module_info swig_module = {swig_types, 25, 0, 0, 0, 0}; #include "includes.h" #include "registry.h" #include "param/param.h" -#include "hive.h" +#include "registry.h" typedef struct registry_context reg; typedef struct hive_key hive_key; -- cgit From 4924446969b0f2a02b799fa9b2af14172310ebf0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 14:10:16 +0200 Subject: Trim down installed headers some more. (This used to be commit 71aa38842c270d52d39b805bf7ce29e25e062024) --- source4/lib/registry/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib') diff --git a/source4/lib/registry/config.mk b/source4/lib/registry/config.mk index 1deac1dd46..77b4ece552 100644 --- a/source4/lib/registry/config.mk +++ b/source4/lib/registry/config.mk @@ -39,7 +39,7 @@ PUBLIC_DEPENDENCIES = \ # End MODULE registry_ldb ################################################ -PUBLIC_HEADERS += $(addprefix lib/registry/, registry.h hive.h) +PUBLIC_HEADERS += lib/registry/registry.h [SUBSYSTEM::registry_common] PUBLIC_DEPENDENCIES = registry -- cgit From 1cf8130e110c63a3bfc04ef8e21ca4343a4ab35c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 14:18:31 +0200 Subject: Move handle utility functions to public header, remove more public headers. (This used to be commit 92e71c19f4e1d3ca123a083942ec578d21f7012c) --- source4/lib/registry/registry_wrap.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib') diff --git a/source4/lib/registry/registry_wrap.c b/source4/lib/registry/registry_wrap.c index ded3acbbe6..da09ecbe08 100644 --- a/source4/lib/registry/registry_wrap.c +++ b/source4/lib/registry/registry_wrap.c @@ -2529,7 +2529,6 @@ static swig_module_info swig_module = {swig_types, 25, 0, 0, 0, 0}; #include "includes.h" #include "registry.h" #include "param/param.h" -#include "registry.h" typedef struct registry_context reg; typedef struct hive_key hive_key; -- cgit From 4e5e7a7c688d8a065994cb16fb1da7581bab081a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 16:47:17 +0200 Subject: Reintroduce header previously autogenerated but ignored by git. Also fixed extra include in regpatch. (This used to be commit 0e371cf169e9a607fcbb3e65437ab9413935dd52) --- source4/lib/registry/tools/regpatch.c | 1 - source4/lib/util/util_ldb.h | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 71837d1807..98443e6456 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -23,7 +23,6 @@ #include "lib/registry/registry.h" #include "lib/cmdline/popt_common.h" #include "lib/registry/tools/common.h" -#include "lib/registry/patchfile.h" #include "param/param.h" int main(int argc, char **argv) diff --git a/source4/lib/util/util_ldb.h b/source4/lib/util/util_ldb.h index 864ce7e8c6..030ba7ebee 100644 --- a/source4/lib/util/util_ldb.h +++ b/source4/lib/util/util_ldb.h @@ -1,19 +1,21 @@ #ifndef __LIB_UTIL_UTIL_LDB_H__ #define __LIB_UTIL_UTIL_LDB_H__ +/* The following definitions come from lib/util/util_ldb.c */ + int gendb_search_v(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_dn *basedn, struct ldb_message ***msgs, const char * const *attrs, const char *format, - va_list ap) _PRINTF_ATTRIBUTE(6,0); + va_list ap) PRINTF_ATTRIBUTE(6,0); int gendb_search(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_dn *basedn, struct ldb_message ***res, const char * const *attrs, - const char *format, ...) _PRINTF_ATTRIBUTE(6,7); + const char *format, ...) PRINTF_ATTRIBUTE(6,7); int gendb_search_dn(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_dn *dn, @@ -23,4 +25,3 @@ int gendb_add_ldif(struct ldb_context *ldb, const char *ldif_string); char *wrap_casefold(void *context, void *mem_ctx, const char *s); #endif /* __LIB_UTIL_UTIL_LDB_H__ */ - -- cgit From 753824e9cfcbba51a2157eb75cc9ff9b287028fa Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 19:05:31 +0200 Subject: Re-add params file to git. (This used to be commit fc50e78e2631e8253571bc236302e2859e4d1559) --- source4/lib/util/params.c | 587 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 587 insertions(+) create mode 100644 source4/lib/util/params.c (limited to 'source4/lib') diff --git a/source4/lib/util/params.c b/source4/lib/util/params.c new file mode 100644 index 0000000000..3a9e2b9505 --- /dev/null +++ b/source4/lib/util/params.c @@ -0,0 +1,587 @@ +/* -------------------------------------------------------------------------- ** + * Microsoft Network Services for Unix, AKA., Andrew Tridgell's SAMBA. + * + * This module Copyright (C) 1990-1998 Karl Auer + * + * Rewritten almost completely by Christopher R. Hertel + * at the University of Minnesota, September, 1997. + * This module Copyright (C) 1997-1998 by the University of Minnesota + * -------------------------------------------------------------------------- ** + * + * 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 . + * + * -------------------------------------------------------------------------- ** + * + * Module name: params + * + * -------------------------------------------------------------------------- ** + * + * This module performs lexical analysis and initial parsing of a + * Windows-like parameter file. It recognizes and handles four token + * types: section-name, parameter-name, parameter-value, and + * end-of-file. Comments and line continuation are handled + * internally. + * + * The entry point to the module is function pm_process(). This + * function opens the source file, calls the Parse() function to parse + * the input, and then closes the file when either the EOF is reached + * or a fatal error is encountered. + * + * A sample parameter file might look like this: + * + * [section one] + * parameter one = value string + * parameter two = another value + * [section two] + * new parameter = some value or t'other + * + * The parameter file is divided into sections by section headers: + * section names enclosed in square brackets (eg. [section one]). + * Each section contains parameter lines, each of which consist of a + * parameter name and value delimited by an equal sign. Roughly, the + * syntax is: + * + * :== {
} EOF + * + *
:==
{ } + * + *
:== '[' NAME ']' + * + * :== NAME '=' VALUE '\n' + * + * Blank lines and comment lines are ignored. Comment lines are lines + * beginning with either a semicolon (';') or a pound sign ('#'). + * + * All whitespace in section names and parameter names is compressed + * to single spaces. Leading and trailing whitespace is stipped from + * both names and values. + * + * Only the first equals sign in a parameter line is significant. + * Parameter values may contain equals signs, square brackets and + * semicolons. Internal whitespace is retained in parameter values, + * with the exception of the '\r' character, which is stripped for + * historic reasons. Parameter names may not start with a left square + * bracket, an equal sign, a pound sign, or a semicolon, because these + * are used to identify other tokens. + * + * -------------------------------------------------------------------------- ** + */ + +#include "includes.h" +#include "system/locale.h" + +/* -------------------------------------------------------------------------- ** + * Constants... + */ + +#define BUFR_INC 1024 + + +/* we can't use FILE* due to the 256 fd limit - use this cheap hack + instead */ +typedef struct { + char *buf; + char *p; + size_t size; + char *bufr; + int bSize; +} myFILE; + +static int mygetc(myFILE *f) +{ + if (f->p >= f->buf+f->size) return EOF; + /* be sure to return chars >127 as positive values */ + return (int)( *(f->p++) & 0x00FF ); +} + +static void myfile_close(myFILE *f) +{ + talloc_free(f); +} + +/* -------------------------------------------------------------------------- ** + * Functions... + */ + +static int EatWhitespace( myFILE *InFile ) + /* ------------------------------------------------------------------------ ** + * Scan past whitespace (see ctype(3C)) and return the first non-whitespace + * character, or newline, or EOF. + * + * Input: InFile - Input source. + * + * Output: The next non-whitespace character in the input stream. + * + * Notes: Because the config files use a line-oriented grammar, we + * explicitly exclude the newline character from the list of + * whitespace characters. + * - Note that both EOF (-1) and the nul character ('\0') are + * considered end-of-file markers. + * + * ------------------------------------------------------------------------ ** + */ + { + int c; + + for( c = mygetc( InFile ); isspace( c ) && ('\n' != c); c = mygetc( InFile ) ) + ; + return( c ); + } /* EatWhitespace */ + +static int EatComment( myFILE *InFile ) + /* ------------------------------------------------------------------------ ** + * Scan to the end of a comment. + * + * Input: InFile - Input source. + * + * Output: The character that marks the end of the comment. Normally, + * this will be a newline, but it *might* be an EOF. + * + * Notes: Because the config files use a line-oriented grammar, we + * explicitly exclude the newline character from the list of + * whitespace characters. + * - Note that both EOF (-1) and the nul character ('\0') are + * considered end-of-file markers. + * + * ------------------------------------------------------------------------ ** + */ + { + int c; + + for( c = mygetc( InFile ); ('\n'!=c) && (EOF!=c) && (c>0); c = mygetc( InFile ) ) + ; + return( c ); + } /* EatComment */ + +/***************************************************************************** + * Scan backards within a string to discover if the last non-whitespace + * character is a line-continuation character ('\\'). + * + * Input: line - A pointer to a buffer containing the string to be + * scanned. + * pos - This is taken to be the offset of the end of the + * string. This position is *not* scanned. + * + * Output: The offset of the '\\' character if it was found, or -1 to + * indicate that it was not. + * + *****************************************************************************/ + +static int Continuation(char *line, int pos ) +{ + pos--; + while( (pos >= 0) && isspace((int)line[pos])) + pos--; + + return (((pos >= 0) && ('\\' == line[pos])) ? pos : -1 ); +} + + +static bool Section( myFILE *InFile, bool (*sfunc)(const char *, void *), void *userdata ) + /* ------------------------------------------------------------------------ ** + * Scan a section name, and pass the name to function sfunc(). + * + * Input: InFile - Input source. + * sfunc - Pointer to the function to be called if the section + * name is successfully read. + * + * Output: true if the section name was read and true was returned from + * . false if failed or if a lexical error was + * encountered. + * + * ------------------------------------------------------------------------ ** + */ + { + int c; + int i; + int end; + const char *func = "params.c:Section() -"; + + i = 0; /* is the offset of the next free byte in bufr[] and */ + end = 0; /* is the current "end of string" offset. In most */ + /* cases these will be the same, but if the last */ + /* character written to bufr[] is a space, then */ + /* will be one less than . */ + + c = EatWhitespace( InFile ); /* We've already got the '['. Scan */ + /* past initial white space. */ + + while( (EOF != c) && (c > 0) ) + { + + /* Check that the buffer is big enough for the next character. */ + if( i > (InFile->bSize - 2) ) + { + char *tb; + + tb = talloc_realloc(InFile, InFile->bufr, char, InFile->bSize + BUFR_INC); + if( NULL == tb ) + { + DEBUG(0, ("%s Memory re-allocation failure.", func) ); + return( false ); + } + InFile->bufr = tb; + InFile->bSize += BUFR_INC; + } + + /* Handle a single character. */ + switch( c ) + { + case ']': /* Found the closing bracket. */ + InFile->bufr[end] = '\0'; + if( 0 == end ) /* Don't allow an empty name. */ + { + DEBUG(0, ("%s Empty section name in configuration file.\n", func )); + return( false ); + } + if( !sfunc(InFile->bufr,userdata) ) /* Got a valid name. Deal with it. */ + return( false ); + (void)EatComment( InFile ); /* Finish off the line. */ + return( true ); + + case '\n': /* Got newline before closing ']'. */ + i = Continuation( InFile->bufr, i ); /* Check for line continuation. */ + if( i < 0 ) + { + InFile->bufr[end] = '\0'; + DEBUG(0, ("%s Badly formed line in configuration file: %s\n", + func, InFile->bufr )); + return( false ); + } + end = ( (i > 0) && (' ' == InFile->bufr[i - 1]) ) ? (i - 1) : (i); + c = mygetc( InFile ); /* Continue with next line. */ + break; + + default: /* All else are a valid name chars. */ + if( isspace( c ) ) /* One space per whitespace region. */ + { + InFile->bufr[end] = ' '; + i = end + 1; + c = EatWhitespace( InFile ); + } + else /* All others copy verbatim. */ + { + InFile->bufr[i++] = c; + end = i; + c = mygetc( InFile ); + } + } + } + + /* We arrive here if we've met the EOF before the closing bracket. */ + DEBUG(0, ("%s Unexpected EOF in the configuration file\n", func)); + return( false ); + } /* Section */ + +static bool Parameter( myFILE *InFile, bool (*pfunc)(const char *, const char *, void *), int c, void *userdata ) + /* ------------------------------------------------------------------------ ** + * Scan a parameter name and value, and pass these two fields to pfunc(). + * + * Input: InFile - The input source. + * pfunc - A pointer to the function that will be called to + * process the parameter, once it has been scanned. + * c - The first character of the parameter name, which + * would have been read by Parse(). Unlike a comment + * line or a section header, there is no lead-in + * character that can be discarded. + * + * Output: true if the parameter name and value were scanned and processed + * successfully, else false. + * + * Notes: This function is in two parts. The first loop scans the + * parameter name. Internal whitespace is compressed, and an + * equal sign (=) terminates the token. Leading and trailing + * whitespace is discarded. The second loop scans the parameter + * value. When both have been successfully identified, they are + * passed to pfunc() for processing. + * + * ------------------------------------------------------------------------ ** + */ + { + int i = 0; /* Position within bufr. */ + int end = 0; /* bufr[end] is current end-of-string. */ + int vstart = 0; /* Starting position of the parameter value. */ + const char *func = "params.c:Parameter() -"; + + /* Read the parameter name. */ + while( 0 == vstart ) /* Loop until we've found the start of the value. */ + { + + if( i > (InFile->bSize - 2) ) /* Ensure there's space for next char. */ + { + char *tb; + + tb = talloc_realloc(InFile, InFile->bufr, char, InFile->bSize + BUFR_INC ); + if( NULL == tb ) + { + DEBUG(0, ("%s Memory re-allocation failure.", func) ); + return( false ); + } + InFile->bufr = tb; + InFile->bSize += BUFR_INC; + } + + switch( c ) + { + case '=': /* Equal sign marks end of param name. */ + if( 0 == end ) /* Don't allow an empty name. */ + { + DEBUG(0, ("%s Invalid parameter name in config. file.\n", func )); + return( false ); + } + InFile->bufr[end++] = '\0'; /* Mark end of string & advance. */ + i = end; /* New string starts here. */ + vstart = end; /* New string is parameter value. */ + InFile->bufr[i] = '\0'; /* New string is nul, for now. */ + break; + + case '\n': /* Find continuation char, else error. */ + i = Continuation( InFile->bufr, i ); + if( i < 0 ) + { + InFile->bufr[end] = '\0'; + DEBUG(1,("%s Ignoring badly formed line in configuration file: %s\n", + func, InFile->bufr )); + return( true ); + } + end = ( (i > 0) && (' ' == InFile->bufr[i - 1]) ) ? (i - 1) : (i); + c = mygetc( InFile ); /* Read past eoln. */ + break; + + case '\0': /* Shouldn't have EOF within param name. */ + case EOF: + InFile->bufr[i] = '\0'; + DEBUG(1,("%s Unexpected end-of-file at: %s\n", func, InFile->bufr )); + return( true ); + + default: + if( isspace( c ) ) /* One ' ' per whitespace region. */ + { + InFile->bufr[end] = ' '; + i = end + 1; + c = EatWhitespace( InFile ); + } + else /* All others verbatim. */ + { + InFile->bufr[i++] = c; + end = i; + c = mygetc( InFile ); + } + } + } + + /* Now parse the value. */ + c = EatWhitespace( InFile ); /* Again, trim leading whitespace. */ + while( (EOF !=c) && (c > 0) ) + { + + if( i > (InFile->bSize - 2) ) /* Make sure there's enough room. */ + { + char *tb; + + tb = talloc_realloc(InFile, InFile->bufr, char, InFile->bSize + BUFR_INC ); + if( NULL == tb ) + { + DEBUG(0, ("%s Memory re-allocation failure.", func) ); + return( false ); + } + InFile->bufr = tb; + InFile->bSize += BUFR_INC; + } + + switch( c ) + { + case '\r': /* Explicitly remove '\r' because the older */ + c = mygetc( InFile ); /* version called fgets_slash() which also */ + break; /* removes them. */ + + case '\n': /* Marks end of value unless there's a '\'. */ + i = Continuation( InFile->bufr, i ); + if( i < 0 ) + c = 0; + else + { + for( end = i; (end >= 0) && isspace((int)InFile->bufr[end]); end-- ) + ; + c = mygetc( InFile ); + } + break; + + default: /* All others verbatim. Note that spaces do */ + InFile->bufr[i++] = c; /* not advance . This allows trimming */ + if( !isspace( c ) ) /* of whitespace at the end of the line. */ + end = i; + c = mygetc( InFile ); + break; + } + } + InFile->bufr[end] = '\0'; /* End of value. */ + + return( pfunc( InFile->bufr, &InFile->bufr[vstart], userdata ) ); /* Pass name & value to pfunc(). */ + } /* Parameter */ + +static bool Parse( myFILE *InFile, + bool (*sfunc)(const char *, void *), + bool (*pfunc)(const char *, const char *, void *), + void *userdata ) + /* ------------------------------------------------------------------------ ** + * Scan & parse the input. + * + * Input: InFile - Input source. + * sfunc - Function to be called when a section name is scanned. + * See Section(). + * pfunc - Function to be called when a parameter is scanned. + * See Parameter(). + * + * Output: true if the file was successfully scanned, else false. + * + * Notes: The input can be viewed in terms of 'lines'. There are four + * types of lines: + * Blank - May contain whitespace, otherwise empty. + * Comment - First non-whitespace character is a ';' or '#'. + * The remainder of the line is ignored. + * Section - First non-whitespace character is a '['. + * Parameter - The default case. + * + * ------------------------------------------------------------------------ ** + */ + { + int c; + + c = EatWhitespace( InFile ); + while( (EOF != c) && (c > 0) ) + { + switch( c ) + { + case '\n': /* Blank line. */ + c = EatWhitespace( InFile ); + break; + + case ';': /* Comment line. */ + case '#': + c = EatComment( InFile ); + break; + + case '[': /* Section Header. */ + if( !Section( InFile, sfunc, userdata ) ) + return( false ); + c = EatWhitespace( InFile ); + break; + + case '\\': /* Bogus backslash. */ + c = EatWhitespace( InFile ); + break; + + default: /* Parameter line. */ + if( !Parameter( InFile, pfunc, c, userdata ) ) + return( false ); + c = EatWhitespace( InFile ); + break; + } + } + return( true ); + } /* Parse */ + +static myFILE *OpenConfFile( const char *FileName ) + /* ------------------------------------------------------------------------ ** + * Open a configuration file. + * + * Input: FileName - The pathname of the config file to be opened. + * + * Output: A pointer of type (char **) to the lines of the file + * + * ------------------------------------------------------------------------ ** + */ + { + const char *func = "params.c:OpenConfFile() -"; + myFILE *ret; + + ret = talloc(talloc_autofree_context(), myFILE); + if (!ret) return NULL; + + ret->buf = file_load(FileName, &ret->size, ret); + if( NULL == ret->buf ) + { + DEBUG( 1, + ("%s Unable to open configuration file \"%s\":\n\t%s\n", + func, FileName, strerror(errno)) ); + talloc_free(ret); + return NULL; + } + + ret->p = ret->buf; + ret->bufr = NULL; + ret->bSize = 0; + return( ret ); + } /* OpenConfFile */ + +bool pm_process( const char *FileName, + bool (*sfunc)(const char *, void *), + bool (*pfunc)(const char *, const char *, void *), + void *userdata) + /* ------------------------------------------------------------------------ ** + * Process the named parameter file. + * + * Input: FileName - The pathname of the parameter file to be opened. + * sfunc - A pointer to a function that will be called when + * a section name is discovered. + * pfunc - A pointer to a function that will be called when + * a parameter name and value are discovered. + * + * Output: TRUE if the file was successfully parsed, else FALSE. + * + * ------------------------------------------------------------------------ ** + */ + { + int result; + myFILE *InFile; + const char *func = "params.c:pm_process() -"; + + InFile = OpenConfFile( FileName ); /* Open the config file. */ + if( NULL == InFile ) + return( false ); + + DEBUG( 3, ("%s Processing configuration file \"%s\"\n", func, FileName) ); + + if( NULL != InFile->bufr ) /* If we already have a buffer */ + result = Parse( InFile, sfunc, pfunc, userdata ); /* (recursive call), then just */ + /* use it. */ + + else /* If we don't have a buffer */ + { /* allocate one, then parse, */ + InFile->bSize = BUFR_INC; /* then free. */ + InFile->bufr = talloc_array(InFile, char, InFile->bSize ); + if( NULL == InFile->bufr ) + { + DEBUG(0,("%s memory allocation failure.\n", func)); + myfile_close(InFile); + return( false ); + } + result = Parse( InFile, sfunc, pfunc, userdata ); + InFile->bufr = NULL; + InFile->bSize = 0; + } + + myfile_close(InFile); + + if( !result ) /* Generic failure. */ + { + DEBUG(0,("%s Failed. Error returned from params.c:parse().\n", func)); + return( false ); + } + + return( true ); /* Generic success. */ + } /* pm_process */ + +/* -------------------------------------------------------------------------- */ -- cgit From 2d12b275f38fe2785c9ae389cc987269a232b5a8 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Fri, 21 Mar 2008 22:27:02 +0100 Subject: util: Add talloc_get_type_abort() call. (This used to be commit 38413ed4b6957e5f72e78a04f479c6a5d8b69ef5) --- source4/lib/util/util.c | 15 +++++++++++++++ source4/lib/util/util.h | 7 +++++++ 2 files changed, 22 insertions(+) (limited to 'source4/lib') diff --git a/source4/lib/util/util.c b/source4/lib/util/util.c index 7b6bfeeb7b..b5bb75358e 100644 --- a/source4/lib/util/util.c +++ b/source4/lib/util/util.c @@ -582,3 +582,18 @@ _PUBLIC_ void *realloc_array(void *ptr, size_t el_size, unsigned count) return realloc(ptr, el_size * count); } +_PUBLIC_ void *talloc_check_name_abort(const void *ptr, const char *name) +{ + void *result; + + result = talloc_check_name(ptr, name); + if (result != NULL) + return result; + + DEBUG(0, ("Talloc type mismatch, expected %s, got %s\n", + name, talloc_get_name(ptr))); + smb_panic("talloc type mismatch"); + /* Keep the compiler happy */ + return NULL; +} + diff --git a/source4/lib/util/util.h b/source4/lib/util/util.h index 60c8437634..3bf6b98d2f 100644 --- a/source4/lib/util/util.h +++ b/source4/lib/util/util.h @@ -803,4 +803,11 @@ bool pm_process( const char *fileName, bool (*pfunc)(const char *, const char *, void *), void *userdata); +/** + * Add-on to talloc_get_type + */ +_PUBLIC_ void *talloc_check_name_abort(const void *ptr, const char *name); +#define talloc_get_type_abort(ptr, type) \ + (type *)talloc_check_name_abort(ptr, #type) + #endif /* _SAMBA_UTIL_H_ */ -- cgit From 294c55faf6880251ad67f5a5c7fbefb5e066cef6 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Sat, 29 Mar 2008 00:31:37 +0100 Subject: IRPC: Add include guards for the header. (This used to be commit 0e66e443ad42f9644aafc1858ac8d01c7c699337) --- source4/lib/messaging/irpc.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib') diff --git a/source4/lib/messaging/irpc.h b/source4/lib/messaging/irpc.h index d596c6721e..f44c0af3ec 100644 --- a/source4/lib/messaging/irpc.h +++ b/source4/lib/messaging/irpc.h @@ -19,6 +19,9 @@ along with this program. If not, see . */ +#ifndef IRPC_H +#define IRPC_H + #include "librpc/gen_ndr/irpc.h" /* @@ -123,4 +126,5 @@ struct server_id *irpc_servers_byname(struct messaging_context *msg_ctx, TALLOC_ void irpc_remove_name(struct messaging_context *msg_ctx, const char *name); NTSTATUS irpc_send_reply(struct irpc_message *m, NTSTATUS status); +#endif -- cgit From 8495d17c1a97489a75b777d79e69f9680267fd28 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 3 Apr 2008 01:36:03 +0200 Subject: Fix installation of dcerpc_atsvc and registry as required by samba-gtk. (This used to be commit 64a6887ecddc1599bde5dcb06d0b74ffea1def0c) --- source4/lib/registry/registry.pc.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/registry/registry.pc.in b/source4/lib/registry/registry.pc.in index 98943a0736..d981a45b2c 100644 --- a/source4/lib/registry/registry.pc.in +++ b/source4/lib/registry/registry.pc.in @@ -5,8 +5,8 @@ includedir=@includedir@ Name: registry Description: Windows-style registry library -Requires: ldb -Requires.private: +Requires: talloc +Requires.private: ldb Version: 0.0.1 Libs: -L${libdir} -lregistry Cflags: -I${includedir} -DHAVE_IMMEDIATE_STRUCTURES=1 -- cgit From adc09857420c4a9306148e8d15ff5faf633ba7a5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 3 Apr 2008 02:28:31 +0200 Subject: Install libevents since it's required by samba-gtk. (This used to be commit 2073346828ffa1d9c35105eadd7afddd3a76a045) --- source4/lib/events/config.mk | 6 ++++-- source4/lib/registry/registry.h | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk index 8001699aee..1e402f80d6 100644 --- a/source4/lib/events/config.mk +++ b/source4/lib/events/config.mk @@ -30,13 +30,15 @@ INIT_FUNCTION = s4_events_standard_init ############################## # Start SUBSYSTEM LIBEVENTS -[SUBSYSTEM::LIBEVENTS] +[LIBRARY::LIBEVENTS] OBJ_FILES = events.o events_timed.o events_signal.o PUBLIC_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL +SO_VERSION = 0 +VERSION = 0.0.1 # End SUBSYSTEM LIBEVENTS ############################## -# PUBLIC_HEADERS += $(addprefix lib/events/, events.h events_internal.h) +PUBLIC_HEADERS += $(addprefix lib/events/, events.h events_internal.h) [PYTHON::swig_events] SWIG_FILE = events.i diff --git a/source4/lib/registry/registry.h b/source4/lib/registry/registry.h index ff03f71eb2..a86294bf46 100644 --- a/source4/lib/registry/registry.h +++ b/source4/lib/registry/registry.h @@ -22,11 +22,15 @@ #define _REGISTRY_H struct registry_context; +struct loadparm_context; +struct smb_iconv_convenience; #include #include "libcli/util/werror.h" #include "librpc/gen_ndr/security.h" #include "libcli/util/ntstatus.h" +#include "util/time.h" +#include "util/data_blob.h" /** * The hive API. This API is generally used for -- cgit