diff options
33 files changed, 78 insertions, 668 deletions
diff --git a/source4/client/config.mk b/source4/client/config.mk index 9f785004a0..2085faf61e 100644 --- a/source4/client/config.mk +++ b/source4/client/config.mk @@ -7,7 +7,7 @@ INSTALLDIR = BINDIR OBJ_FILES = \ client.o PRIVATE_DEPENDENCIES = \ - LIBSAMBA-CONFIG \ + LIBSAMBA-HOSTCONFIG \ SMBREADLINE \ LIBSAMBA-UTIL \ LIBCLI_SMB \ @@ -28,7 +28,7 @@ OBJ_FILES = \ cifsdd.o \ cifsddio.o PRIVATE_DEPENDENCIES = \ - LIBSAMBA-CONFIG \ + LIBSAMBA-HOSTCONFIG \ LIBCLI_SMB \ LIBPOPT \ POPT_SAMBA \ diff --git a/source4/configure.ac b/source4/configure.ac index 41f1bcf054..0e264d3474 100644 --- a/source4/configure.ac +++ b/source4/configure.ac @@ -32,7 +32,7 @@ AC_CONFIG_FILES(librpc/dcerpc.pc) AC_CONFIG_FILES(librpc/ndr.pc) AC_CONFIG_FILES(torture/torture.pc) AC_CONFIG_FILES(auth/gensec/gensec.pc) -AC_CONFIG_FILES(param/samba-config.pc) +AC_CONFIG_FILES(param/samba-hostconfig.pc) AC_CONFIG_FILES(librpc/dcerpc_samr.pc) SMB_EXT_LIB_FROM_PKGCONFIG(LIBTALLOC, talloc >= 1.2.0, diff --git a/source4/heimdal_build/config.mk b/source4/heimdal_build/config.mk index 65b49b73db..24d50acb05 100644 --- a/source4/heimdal_build/config.mk +++ b/source4/heimdal_build/config.mk @@ -452,7 +452,7 @@ PUBLIC_DEPENDENCIES = \ [SUBSYSTEM::HEIMDAL_GLUE] CFLAGS = -Iheimdal_build -Iheimdal/lib/krb5 -Iheimdal/lib/asn1 -Iheimdal/lib/com_err OBJ_FILES = glue.o -PUBLIC_DEPENDENCIES = LIBNETIF LIBSAMBA-CONFIG +PUBLIC_DEPENDENCIES = LIBNETIF LIBSAMBA-HOSTCONFIG # End SUBSYSTEM HEIMDAL_GLUE ####################### diff --git a/source4/ldap_server/config.mk b/source4/ldap_server/config.mk index 9892376821..5f8c530db9 100644 --- a/source4/ldap_server/config.mk +++ b/source4/ldap_server/config.mk @@ -15,6 +15,6 @@ PRIVATE_DEPENDENCIES = CREDENTIALS \ LIBCLI_LDAP SAMDB \ process_model \ gensec \ - LIBSAMBA-CONFIG + LIBSAMBA-HOSTCONFIG # End SUBSYSTEM SMB ####################### 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 ################################################ 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/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 550b60c625..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. @@ -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_ */ diff --git a/source4/libcli/auth/config.mk b/source4/libcli/auth/config.mk index 61d3fe8c94..f786c71469 100644 --- a/source4/libcli/auth/config.mk +++ b/source4/libcli/auth/config.mk @@ -8,7 +8,7 @@ OBJ_FILES = credentials.o \ smbdes.o PUBLIC_DEPENDENCIES = \ MSRPC_PARSE \ - LIBSAMBA-CONFIG + LIBSAMBA-HOSTCONFIG # End SUBSYSTEM LIBCLI_AUTH ################################# diff --git a/source4/libcli/config.mk b/source4/libcli/config.mk index d3a3beaaa9..0aa67f35db 100644 --- a/source4/libcli/config.mk +++ b/source4/libcli/config.mk @@ -53,11 +53,11 @@ PUBLIC_DEPENDENCIES = LIBNDR NDR_NBT LIBCLI_COMPOSITE LIBEVENTS \ [PYTHON::python_libcli_nbt] SWIG_FILE = swig/libcli_nbt.i -PUBLIC_DEPENDENCIES = LIBCLI_NBT DYNCONFIG LIBSAMBA-CONFIG +PUBLIC_DEPENDENCIES = LIBCLI_NBT DYNCONFIG LIBSAMBA-HOSTCONFIG [PYTHON::python_libcli_smb] SWIG_FILE = swig/libcli_smb.i -PUBLIC_DEPENDENCIES = LIBCLI_SMB DYNCONFIG LIBSAMBA-CONFIG +PUBLIC_DEPENDENCIES = LIBCLI_SMB DYNCONFIG LIBSAMBA-HOSTCONFIG [SUBSYSTEM::LIBCLI_DGRAM] OBJ_FILES = \ @@ -96,7 +96,7 @@ OBJ_FILES = \ resolve/wins.o \ resolve/host.o \ resolve/resolve_lp.o -PRIVATE_DEPENDENCIES = LIBCLI_NBT LIBSAMBA-CONFIG LIBNETIF +PRIVATE_DEPENDENCIES = LIBCLI_NBT LIBSAMBA-HOSTCONFIG LIBNETIF [SUBSYSTEM::LIBCLI_FINDDCS] PRIVATE_PROTO_HEADER = finddcs.h diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk index a316e059b3..4bbce62482 100644 --- a/source4/librpc/config.mk +++ b/source4/librpc/config.mk @@ -11,7 +11,7 @@ OBJ_FILES = \ ndr/ndr_string.o \ ndr/uuid.o PUBLIC_DEPENDENCIES = LIBSAMBA-ERRORS LIBTALLOC LIBSAMBA-UTIL CHARSET \ - LIBSAMBA-CONFIG + LIBSAMBA-HOSTCONFIG # End SUBSYSTEM LIBNDR ################################################ @@ -24,7 +24,7 @@ INSTALLDIR = BINDIR OBJ_FILES = \ tools/ndrdump.o PRIVATE_DEPENDENCIES = \ - LIBSAMBA-CONFIG \ + LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ LIBPOPT \ POPT_SAMBA \ @@ -606,7 +606,7 @@ PRIVATE_DEPENDENCIES = dcerpc NDR_IRPC EJSRPC [PYTHON::swig_dcerpc] SWIG_FILE = rpc/dcerpc.i -PUBLIC_DEPENDENCIES = LIBCLI_SMB NDR_MISC LIBSAMBA-UTIL LIBSAMBA-CONFIG dcerpc_samr RPC_NDR_LSA DYNCONFIG +PUBLIC_DEPENDENCIES = LIBCLI_SMB NDR_MISC LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG dcerpc_samr RPC_NDR_LSA DYNCONFIG [PYTHON::python_echo] OBJ_FILES = gen_ndr/py_echo.o diff --git a/source4/librpc/ndr.pc.in b/source4/librpc/ndr.pc.in index ed4c459214..2f4d95006f 100644 --- a/source4/librpc/ndr.pc.in +++ b/source4/librpc/ndr.pc.in @@ -5,7 +5,7 @@ includedir=@includedir@ Name: ndr Description: Network Data Representation Core Library -Requires: samba-config talloc +Requires: samba-hostconfig talloc Version: 0.0.1 Libs: -L${libdir} -lndr Cflags: -I${includedir} -DHAVE_IMMEDIATE_STRUCTURES=1 diff --git a/source4/nbt_server/config.mk b/source4/nbt_server/config.mk index 9285044768..b510a6e2d6 100644 --- a/source4/nbt_server/config.mk +++ b/source4/nbt_server/config.mk @@ -21,7 +21,7 @@ INIT_FUNCTION = &ldb_wins_ldb_module_ops OBJ_FILES = \ wins/wins_ldb.o PRIVATE_DEPENDENCIES = \ - LIBNETIF LIBSAMBA-CONFIG LIBSAMBA-UTIL + LIBNETIF LIBSAMBA-HOSTCONFIG LIBSAMBA-UTIL # End MODULE ldb_wins_ldb ####################### diff --git a/source4/nsswitch/config.mk b/source4/nsswitch/config.mk index e53e064272..c7c70c141e 100644 --- a/source4/nsswitch/config.mk +++ b/source4/nsswitch/config.mk @@ -11,7 +11,7 @@ OBJ_FILES = \ PRIVATE_DEPENDENCIES = \ LIBSAMBA-UTIL \ LIBREPLACE_EXT \ - LIBSAMBA-CONFIG + LIBSAMBA-HOSTCONFIG # End BINARY nsstest ################################# diff --git a/source4/param/README b/source4/param/README new file mode 100644 index 0000000000..403a217588 --- /dev/null +++ b/source4/param/README @@ -0,0 +1,4 @@ +This directory contains "libsamba-hostconfig". + +The libsamba-hostconfig library provides access to all host-wide configuration +such as the configured shares, default parameter values and host secret keys. diff --git a/source4/param/config.mk b/source4/param/config.mk index f43c9d8a1b..eee22cf1b8 100644 --- a/source4/param/config.mk +++ b/source4/param/config.mk @@ -1,9 +1,11 @@ -[SUBSYSTEM::LIBSAMBA-CONFIG] +[LIBRARY::LIBSAMBA-HOSTCONFIG] +VERSION = 0.0.1 +SO_VERSION = 1 OBJ_FILES = loadparm.o \ - params.o \ generic.o \ util.o \ ../lib/version.o +PC_FILE = samba-hostconfig.pc PUBLIC_DEPENDENCIES = LIBSAMBA-UTIL PRIVATE_DEPENDENCIES = DYNCONFIG LIBREPLACE_EXT CHARSET PRIVATE_PROTO_HEADER = proto.h @@ -47,4 +49,4 @@ PRIVATE_DEPENDENCIES = LIBLDB TDB_WRAP UTIL_TDB NDR_SECURITY [PYTHON::param] SWIG_FILE = param.i -PRIVATE_DEPENDENCIES = LIBSAMBA-CONFIG +PRIVATE_DEPENDENCIES = LIBSAMBA-HOSTCONFIG diff --git a/source4/param/params.c b/source4/param/params.c deleted file mode 100644 index 3a9e2b9505..0000000000 --- a/source4/param/params.c +++ /dev/null @@ -1,587 +0,0 @@ -/* -------------------------------------------------------------------------- ** - * 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 <http://www.gnu.org/licenses/>. - * - * -------------------------------------------------------------------------- ** - * - * 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: - * - * <file> :== { <section> } EOF - * - * <section> :== <section header> { <parameter line> } - * - * <section header> :== '[' NAME ']' - * - * <parameter line> :== 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 - * <sfunc>. false if <sfunc> failed or if a lexical error was - * encountered. - * - * ------------------------------------------------------------------------ ** - */ - { - int c; - int i; - int end; - const char *func = "params.c:Section() -"; - - i = 0; /* <i> is the offset of the next free byte in bufr[] and */ - end = 0; /* <end> 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 <end> */ - /* will be one less than <i>. */ - - 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 <end>. 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 */ - -/* -------------------------------------------------------------------------- */ diff --git a/source4/param/samba-config.pc.in b/source4/param/samba-hostconfig.pc.in index 801f6aeda4..b8ba24096d 100644 --- a/source4/param/samba-config.pc.in +++ b/source4/param/samba-hostconfig.pc.in @@ -3,8 +3,8 @@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ -Name: samba-config -Description: Reading Samba configuration files +Name: samba-hostconfig +Description: Host-wide Samba configuration Version: 0.0.1 -Libs: -L${libdir} -lsamba-config +Libs: -L${libdir} -lsamba-hostconfig Cflags: -I${includedir} -DHAVE_IMMEDIATE_STRUCTURES=1 diff --git a/source4/param/secrets.c b/source4/param/secrets.c index bc4327188a..06dc850c8e 100644 --- a/source4/param/secrets.c +++ b/source4/param/secrets.c @@ -32,8 +32,6 @@ #include "lib/util/util_ldb.h" #include "librpc/gen_ndr/ndr_security.h" -static struct tdb_wrap *tdb; - /** * Use a TDB to store an incrementing random seed. * @@ -42,42 +40,31 @@ static struct tdb_wrap *tdb; * * @note Not called by systems with a working /dev/urandom. */ -static void get_rand_seed(int *new_seed) +static void get_rand_seed(struct tdb_wrap *secretsdb, int *new_seed) { *new_seed = getpid(); - if (tdb != NULL) { - tdb_change_int32_atomic(tdb->tdb, "INFO/random_seed", new_seed, 1); + if (secretsdb != NULL) { + tdb_change_int32_atomic(secretsdb->tdb, "INFO/random_seed", new_seed, 1); } } /** - * close the secrets database - */ -void secrets_shutdown(void) -{ - talloc_free(tdb); -} - -/** * open up the secrets database */ -bool secrets_init(struct loadparm_context *lp_ctx) +struct tdb_wrap *secrets_init(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx) { char *fname; uint8_t dummy; + struct tdb_wrap *tdb; - if (tdb != NULL) - return true; + fname = private_path(mem_ctx, lp_ctx, "secrets.tdb"); - fname = private_path(NULL, lp_ctx, "secrets.tdb"); - - tdb = tdb_wrap_open(talloc_autofree_context(), fname, 0, TDB_DEFAULT, - O_RDWR|O_CREAT, 0600); + tdb = tdb_wrap_open(mem_ctx, fname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600); if (!tdb) { DEBUG(0,("Failed to open %s\n", fname)); talloc_free(fname); - return false; + return NULL; } talloc_free(fname); @@ -87,12 +74,12 @@ bool secrets_init(struct loadparm_context *lp_ctx) * This avoids a problem where systems without /dev/urandom * could send the same challenge to multiple clients */ - set_rand_reseed_callback(get_rand_seed); + set_rand_reseed_callback((void (*) (void *, int *))get_rand_seed, tdb); /* Ensure that the reseed is done now, while we are root, etc */ generate_random_buffer(&dummy, sizeof(dummy)); - return true; + return tdb; } /** diff --git a/source4/param/secrets.h b/source4/param/secrets.h index 4a9eb25e7e..bd6ff4a401 100644 --- a/source4/param/secrets.h +++ b/source4/param/secrets.h @@ -43,8 +43,7 @@ struct machine_acct_pass { * @note Not called by systems with a working /dev/urandom. */ struct loadparm_context; -void secrets_shutdown(void); -bool secrets_init(struct loadparm_context *lp_ctx); +struct tdb_wrap *secrets_init(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx); struct ldb_context *secrets_db_connect(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx); struct dom_sid *secrets_get_domain_sid(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *domain); diff --git a/source4/pidl/config.mk b/source4/pidl/config.mk index 3793008319..c469afa1f5 100644 --- a/source4/pidl/config.mk +++ b/source4/pidl/config.mk @@ -5,10 +5,7 @@ pidl-testcov: pidl/Makefile cd pidl && cover -test installpidl:: pidl/Makefile - $(MAKE) -C pidl install - -uninstallpidl:: pidl/Makefile - $(MAKE) -C pidl uninstall + $(MAKE) -C pidl install_vendor PREFIX=$(prefix) idl_full:: pidl/lib/Parse/Pidl/IDL.pm pidl/lib/Parse/Pidl/Expr.pm @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh FULL diff --git a/source4/pidl/pidl b/source4/pidl/pidl index 220d62cd71..b7a22f0499 100755 --- a/source4/pidl/pidl +++ b/source4/pidl/pidl @@ -403,8 +403,8 @@ pidl README by Andrew Tridgell. use strict; use FindBin qw($RealBin $Script); -use lib "$RealBin"; use lib "$RealBin/lib"; +use lib "$RealBin/../share/perl5"; use Getopt::Long; use File::Basename; use Parse::Pidl qw ( $VERSION ); diff --git a/source4/scripting/ejs/config.mk b/source4/scripting/ejs/config.mk index c1f07367fb..33a4ac915f 100644 --- a/source4/scripting/ejs/config.mk +++ b/source4/scripting/ejs/config.mk @@ -93,6 +93,6 @@ PRIVATE_DEPENDENCIES = \ INSTALLDIR = BINDIR OBJ_FILES = \ smbscript.o -PRIVATE_DEPENDENCIES = EJS LIBSAMBA-UTIL smbcalls LIBSAMBA-CONFIG +PRIVATE_DEPENDENCIES = EJS LIBSAMBA-UTIL smbcalls LIBSAMBA-HOSTCONFIG # End BINARY SMBSCRIPT ####################### diff --git a/source4/smbd/config.mk b/source4/smbd/config.mk index 2482780756..6cbfa16045 100644 --- a/source4/smbd/config.mk +++ b/source4/smbd/config.mk @@ -32,7 +32,7 @@ OBJ_FILES = \ PRIVATE_DEPENDENCIES = \ process_model \ service \ - LIBSAMBA-CONFIG \ + LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ POPT_SAMBA \ PIDFILE \ diff --git a/source4/smbd/process_model.mk b/source4/smbd/process_model.mk index 5201a2e46e..d559ce1577 100644 --- a/source4/smbd/process_model.mk +++ b/source4/smbd/process_model.mk @@ -46,4 +46,4 @@ OBJ_FILES = \ PRIVATE_PROTO_HEADER = process_model_proto.h OBJ_FILES = \ process_model.o -PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBSAMBA-CONFIG +PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c index deb44c0a68..820859400e 100644 --- a/source4/smbd/process_standard.c +++ b/source4/smbd/process_standard.c @@ -204,9 +204,6 @@ _NORETURN_ static void standard_terminate(struct event_context *ev, const char * which makes leak checking easier */ reload_charcnv(global_loadparm); - /* the secrets db should really hang off the connection structure */ - secrets_shutdown(); - talloc_free(ev); /* terminate this process */ diff --git a/source4/smbd/server.c b/source4/smbd/server.c index fe38a4e5ab..d6e2fb19e4 100644 --- a/source4/smbd/server.c +++ b/source4/smbd/server.c @@ -278,7 +278,7 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ /* Do *not* remove this, until you have removed * passdb/secrets.c, and proved that Samba still builds... */ /* Setup the SECRETS subsystem */ - if (!secrets_init(cmdline_lp_ctx)) { + if (secrets_init(talloc_autofree_context(), cmdline_lp_ctx) == NULL) { exit(1); } diff --git a/source4/torture/config.mk b/source4/torture/config.mk index e35a26e49f..1d09d74f99 100644 --- a/source4/torture/config.mk +++ b/source4/torture/config.mk @@ -8,7 +8,7 @@ OBJ_FILES = \ torture.o \ ui.o PUBLIC_DEPENDENCIES = \ - LIBSAMBA-CONFIG \ + LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ LIBTALLOC \ LIBPOPT @@ -327,7 +327,7 @@ INSTALLDIR = BINDIR OBJ_FILES = \ gentest.o PRIVATE_DEPENDENCIES = \ - LIBSAMBA-CONFIG \ + LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ LIBPOPT \ POPT_SAMBA \ @@ -346,7 +346,7 @@ INSTALLDIR = BINDIR OBJ_FILES = \ masktest.o PRIVATE_DEPENDENCIES = \ - LIBSAMBA-CONFIG \ + LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ LIBPOPT \ POPT_SAMBA \ @@ -369,7 +369,7 @@ PRIVATE_DEPENDENCIES = \ POPT_CREDENTIALS \ LIBSAMBA-UTIL \ LIBCLI_SMB \ - LIBSAMBA-CONFIG + LIBSAMBA-HOSTCONFIG # End BINARY locktest ################################# diff --git a/source4/utils/config.mk b/source4/utils/config.mk index 9ebfbbb7e3..9dea2c5af3 100644 --- a/source4/utils/config.mk +++ b/source4/utils/config.mk @@ -7,7 +7,7 @@ INSTALLDIR = BINDIR OBJ_FILES = \ ntlm_auth.o PRIVATE_DEPENDENCIES = \ - LIBSAMBA-CONFIG \ + LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ LIBPOPT \ POPT_SAMBA \ @@ -29,7 +29,7 @@ INSTALLDIR = BINDIR OBJ_FILES = \ getntacl.o PRIVATE_DEPENDENCIES = \ - LIBSAMBA-CONFIG \ + LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ NDR_XATTR \ WRAP_XATTR \ @@ -67,7 +67,7 @@ INSTALLDIR = BINDIR OBJ_FILES = \ nmblookup.o PRIVATE_DEPENDENCIES = \ - LIBSAMBA-CONFIG \ + LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ LIBCLI_NBT \ LIBPOPT \ @@ -84,7 +84,7 @@ INSTALLDIR = BINDIR OBJ_FILES = \ testparm.o PRIVATE_DEPENDENCIES = \ - LIBSAMBA-CONFIG \ + LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ LIBPOPT \ samba-socket \ diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index c07d6a67cb..ced0710ae0 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -13,7 +13,7 @@ OBJ_FILES = \ net_vampire.o \ net_user.o PRIVATE_DEPENDENCIES = \ - LIBSAMBA-CONFIG \ + LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ LIBSAMBA-NET \ LIBPOPT \ |