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/param/config.mk | 1 - source4/param/params.c | 587 ------------------------------------------------ 2 files changed, 588 deletions(-) delete mode 100644 source4/param/params.c (limited to 'source4/param') diff --git a/source4/param/config.mk b/source4/param/config.mk index f43c9d8a1b..59b3fd5f9a 100644 --- a/source4/param/config.mk +++ b/source4/param/config.mk @@ -1,6 +1,5 @@ [SUBSYSTEM::LIBSAMBA-CONFIG] OBJ_FILES = loadparm.o \ - params.o \ generic.o \ util.o \ ../lib/version.o 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 . - * - * -------------------------------------------------------------------------- ** - * - * 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 0ef6489eb171767401c2937f36e44c0b3c58f4f0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 1 Apr 2008 15:03:24 +0200 Subject: Add README file explaining param/. (This used to be commit 03226035aaa8d4fc68996b08bc6beb43feabbd3a) --- source4/param/README | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 source4/param/README (limited to 'source4/param') 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. -- 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/param/config.mk | 4 ++-- source4/param/samba-config.pc.in | 10 ---------- source4/param/samba-hostconfig.pc.in | 10 ++++++++++ 3 files changed, 12 insertions(+), 12 deletions(-) delete mode 100644 source4/param/samba-config.pc.in create mode 100644 source4/param/samba-hostconfig.pc.in (limited to 'source4/param') diff --git a/source4/param/config.mk b/source4/param/config.mk index 59b3fd5f9a..69e3d65434 100644 --- a/source4/param/config.mk +++ b/source4/param/config.mk @@ -1,4 +1,4 @@ -[SUBSYSTEM::LIBSAMBA-CONFIG] +[SUBSYSTEM::LIBSAMBA-HOSTCONFIG] OBJ_FILES = loadparm.o \ generic.o \ util.o \ @@ -46,4 +46,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/samba-config.pc.in b/source4/param/samba-config.pc.in deleted file mode 100644 index 801f6aeda4..0000000000 --- a/source4/param/samba-config.pc.in +++ /dev/null @@ -1,10 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: samba-config -Description: Reading Samba configuration files -Version: 0.0.1 -Libs: -L${libdir} -lsamba-config -Cflags: -I${includedir} -DHAVE_IMMEDIATE_STRUCTURES=1 diff --git a/source4/param/samba-hostconfig.pc.in b/source4/param/samba-hostconfig.pc.in new file mode 100644 index 0000000000..b8ba24096d --- /dev/null +++ b/source4/param/samba-hostconfig.pc.in @@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: samba-hostconfig +Description: Host-wide Samba configuration +Version: 0.0.1 +Libs: -L${libdir} -lsamba-hostconfig +Cflags: -I${includedir} -DHAVE_IMMEDIATE_STRUCTURES=1 -- cgit From 39b2fc37f2f8d914a6e5945b5b503ee4e7b9f5f3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 1 Apr 2008 15:26:00 +0200 Subject: Add context pointer to secrets functions. (This used to be commit 873941d8a8dca8e7ace83f9af9939e4264f78c96) --- source4/param/secrets.c | 33 ++++++++++----------------------- source4/param/secrets.h | 3 +-- 2 files changed, 11 insertions(+), 25 deletions(-) (limited to 'source4/param') 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); -- cgit From 696ab2662ef566f9dc517a5861036d41d841f869 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 1 Apr 2008 16:05:54 +0200 Subject: Install samba-hostconfig library. (This used to be commit 4d1fb503de31c5c81eb22cdd0a61eae5e4813b40) --- source4/param/config.mk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/param') diff --git a/source4/param/config.mk b/source4/param/config.mk index 69e3d65434..eee22cf1b8 100644 --- a/source4/param/config.mk +++ b/source4/param/config.mk @@ -1,8 +1,11 @@ -[SUBSYSTEM::LIBSAMBA-HOSTCONFIG] +[LIBRARY::LIBSAMBA-HOSTCONFIG] +VERSION = 0.0.1 +SO_VERSION = 1 OBJ_FILES = loadparm.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 -- 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/param/param.h | 361 +++++++++++++++++++++++++++++++++++++++++++++++++- source4/param/util.c | 22 +-- 2 files changed, 371 insertions(+), 12 deletions(-) (limited to 'source4/param') diff --git a/source4/param/param.h b/source4/param/param.h index 84f864edaa..0b276cdff2 100644 --- a/source4/param/param.h +++ b/source4/param/param.h @@ -61,8 +61,367 @@ struct loadparm_context; struct loadparm_service; struct smbcli_options; -#include "param/proto.h" +void reload_charcnv(struct loadparm_context *lp_ctx); extern struct loadparm_context *global_loadparm; +struct loadparm_service *lp_default_service(struct loadparm_context *lp_ctx); +struct parm_struct *lp_parm_table(void); +int lp_server_role(struct loadparm_context *); +const char **lp_smb_ports(struct loadparm_context *); +int lp_nbt_port(struct loadparm_context *); +int lp_dgram_port(struct loadparm_context *); +int lp_cldap_port(struct loadparm_context *); +int lp_krb5_port(struct loadparm_context *); +int lp_kpasswd_port(struct loadparm_context *); +int lp_web_port(struct loadparm_context *); +const char *lp_swat_directory(struct loadparm_context *); +bool lp_tls_enabled(struct loadparm_context *); +const char *lp_tls_keyfile(struct loadparm_context *); +const char *lp_tls_certfile(struct loadparm_context *); +const char *lp_tls_cafile(struct loadparm_context *); +const char *lp_tls_crlfile(struct loadparm_context *); +const char *lp_tls_dhpfile(struct loadparm_context *); +const char *lp_share_backend(struct loadparm_context *); +const char *lp_sam_url(struct loadparm_context *); +const char *lp_idmap_url(struct loadparm_context *); +const char *lp_secrets_url(struct loadparm_context *); +const char *lp_spoolss_url(struct loadparm_context *); +const char *lp_wins_config_url(struct loadparm_context *); +const char *lp_wins_url(struct loadparm_context *); +const char *lp_winbind_separator(struct loadparm_context *); +const char *lp_winbindd_socket_directory(struct loadparm_context *); +const char *lp_template_shell(struct loadparm_context *); +const char *lp_template_homedir(struct loadparm_context *); +bool lp_winbind_sealed_pipes(struct loadparm_context *); +bool lp_idmap_trusted_only(struct loadparm_context *); +const char *lp_private_dir(struct loadparm_context *); +const char *lp_serverstring(struct loadparm_context *); +const char *lp_lockdir(struct loadparm_context *); +const char *lp_modulesdir(struct loadparm_context *); +const char *lp_setupdir(struct loadparm_context *); +const char *lp_ncalrpc_dir(struct loadparm_context *); +const char *lp_dos_charset(struct loadparm_context *); +const char *lp_unix_charset(struct loadparm_context *); +const char *lp_display_charset(struct loadparm_context *); +const char *lp_piddir(struct loadparm_context *); +const char **lp_dcerpc_endpoint_servers(struct loadparm_context *); +const char **lp_server_services(struct loadparm_context *); +const char *lp_ntptr_providor(struct loadparm_context *); +const char *lp_auto_services(struct loadparm_context *); +const char *lp_passwd_chat(struct loadparm_context *); +const char **lp_passwordserver(struct loadparm_context *); +const char **lp_name_resolve_order(struct loadparm_context *); +const char *lp_realm(struct loadparm_context *); +const char *lp_socket_options(struct loadparm_context *); +const char *lp_workgroup(struct loadparm_context *); +const char *lp_netbios_name(struct loadparm_context *); +const char *lp_netbios_scope(struct loadparm_context *); +const char **lp_wins_server_list(struct loadparm_context *); +const char **lp_interfaces(struct loadparm_context *); +const char *lp_socket_address(struct loadparm_context *); +const char **lp_netbios_aliases(struct loadparm_context *); +bool lp_disable_netbios(struct loadparm_context *); +bool lp_wins_support(struct loadparm_context *); +bool lp_wins_dns_proxy(struct loadparm_context *); +const char *lp_wins_hook(struct loadparm_context *); +bool lp_local_master(struct loadparm_context *); +bool lp_readraw(struct loadparm_context *); +bool lp_large_readwrite(struct loadparm_context *); +bool lp_writeraw(struct loadparm_context *); +bool lp_null_passwords(struct loadparm_context *); +bool lp_obey_pam_restrictions(struct loadparm_context *); +bool lp_encrypted_passwords(struct loadparm_context *); +bool lp_time_server(struct loadparm_context *); +bool lp_bind_interfaces_only(struct loadparm_context *); +bool lp_unicode(struct loadparm_context *); +bool lp_nt_status_support(struct loadparm_context *); +bool lp_lanman_auth(struct loadparm_context *); +bool lp_ntlm_auth(struct loadparm_context *); +bool lp_client_plaintext_auth(struct loadparm_context *); +bool lp_client_lanman_auth(struct loadparm_context *); +bool lp_client_ntlmv2_auth(struct loadparm_context *); +bool lp_client_use_spnego_principal(struct loadparm_context *); +bool lp_host_msdfs(struct loadparm_context *); +bool lp_unix_extensions(struct loadparm_context *); +bool lp_use_spnego(struct loadparm_context *); +bool lp_rpc_big_endian(struct loadparm_context *); +int lp_max_wins_ttl(struct loadparm_context *); +int lp_min_wins_ttl(struct loadparm_context *); +int lp_maxmux(struct loadparm_context *); +int lp_max_xmit(struct loadparm_context *); +int lp_passwordlevel(struct loadparm_context *); +int lp_srv_maxprotocol(struct loadparm_context *); +int lp_srv_minprotocol(struct loadparm_context *); +int lp_cli_maxprotocol(struct loadparm_context *); +int lp_cli_minprotocol(struct loadparm_context *); +int lp_security(struct loadparm_context *); +bool lp_paranoid_server_security(struct loadparm_context *); +int lp_announce_as(struct loadparm_context *); +const char **lp_js_include(struct loadparm_context *); + +const char *lp_servicename(const struct loadparm_service *service); +const char *lp_pathname(struct loadparm_service *, struct loadparm_service *); +const char **lp_hostsallow(struct loadparm_service *, struct loadparm_service *); +const char **lp_hostsdeny(struct loadparm_service *, struct loadparm_service *); +const char *lp_comment(struct loadparm_service *, struct loadparm_service *); +const char *lp_fstype(struct loadparm_service *, struct loadparm_service *); +const char **lp_ntvfs_handler(struct loadparm_service *, struct loadparm_service *); +bool lp_msdfs_root(struct loadparm_service *, struct loadparm_service *); +bool lp_browseable(struct loadparm_service *, struct loadparm_service *); +bool lp_readonly(struct loadparm_service *, struct loadparm_service *); +bool lp_print_ok(struct loadparm_service *, struct loadparm_service *); +bool lp_map_hidden(struct loadparm_service *, struct loadparm_service *); +bool lp_map_archive(struct loadparm_service *, struct loadparm_service *); +bool lp_strict_locking(struct loadparm_service *, struct loadparm_service *); +bool lp_oplocks(struct loadparm_service *, struct loadparm_service *); +bool lp_strict_sync(struct loadparm_service *, struct loadparm_service *); +bool lp_ci_filesystem(struct loadparm_service *, struct loadparm_service *); +bool lp_map_system(struct loadparm_service *, struct loadparm_service *); +int lp_max_connections(struct loadparm_service *, struct loadparm_service *); +int lp_csc_policy(struct loadparm_service *, struct loadparm_service *); +int lp_create_mask(struct loadparm_service *, struct loadparm_service *); +int lp_force_create_mode(struct loadparm_service *, struct loadparm_service *); +int lp_dir_mask(struct loadparm_service *, struct loadparm_service *); +int lp_force_dir_mode(struct loadparm_service *, struct loadparm_service *); +int lp_server_signing(struct loadparm_context *); +int lp_client_signing(struct loadparm_context *); +const char *lp_get_parametric(struct loadparm_context *lp_ctx, + struct loadparm_service *service, + const char *type, const char *option); + +const char *lp_parm_string(struct loadparm_context *lp_ctx, + struct loadparm_service *service, const char *type, + const char *option); +const char **lp_parm_string_list(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx, + struct loadparm_service *service, + const char *type, + const char *option, const char *separator); +int lp_parm_int(struct loadparm_context *lp_ctx, + struct loadparm_service *service, const char *type, + const char *option, int default_v); +int lp_parm_bytes(struct loadparm_context *lp_ctx, + struct loadparm_service *service, const char *type, + const char *option, int default_v); +unsigned long lp_parm_ulong(struct loadparm_context *lp_ctx, + struct loadparm_service *service, const char *type, + const char *option, unsigned long default_v); +double lp_parm_double(struct loadparm_context *lp_ctx, + struct loadparm_service *service, const char *type, + const char *option, double default_v); +bool lp_parm_bool(struct loadparm_context *lp_ctx, + struct loadparm_service *service, const char *type, + const char *option, bool default_v); +struct loadparm_service *lp_add_service(struct loadparm_context *lp_ctx, + const struct loadparm_service *pservice, + const char *name); +bool lp_add_home(struct loadparm_context *lp_ctx, + const char *pszHomename, + struct loadparm_service *default_service, + const char *user, const char *pszHomedir); +bool lp_add_printer(struct loadparm_context *lp_ctx, + const char *pszPrintername, + struct loadparm_service *default_service); +struct parm_struct *lp_parm_struct(const char *name); +void *lp_parm_ptr(struct loadparm_context *lp_ctx, + struct loadparm_service *service, struct parm_struct *parm); +bool lp_file_list_changed(struct loadparm_context *lp_ctx); + +bool lp_do_global_parameter(struct loadparm_context *lp_ctx, + const char *pszParmName, const char *pszParmValue); +bool lp_do_service_parameter(struct loadparm_context *lp_ctx, + struct loadparm_service *service, + const char *pszParmName, const char *pszParmValue); + +/** + * Process a parameter. + */ +bool lp_do_global_parameter_var(struct loadparm_context *lp_ctx, + const char *pszParmName, const char *fmt, ...); +bool lp_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName, + const char *pszParmValue); +bool lp_set_option(struct loadparm_context *lp_ctx, const char *option); + +/** + * Display the contents of a single services record. + */ +bool lp_dump_a_parameter(struct loadparm_context *lp_ctx, + struct loadparm_service *service, + const char *parm_name, FILE * f); + +/** + * Return info about the next service in a service. snum==-1 gives the globals. + * Return NULL when out of parameters. + */ +struct parm_struct *lp_next_parameter(struct loadparm_context *lp_ctx, int snum, int *i, + int allparameters); + +/** + * Unload unused services. + */ +void lp_killunused(struct loadparm_context *lp_ctx, + struct smbsrv_connection *smb, + bool (*snumused) (struct smbsrv_connection *, int)); + +/** + * Initialise the global parameter structure. + */ +struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx); +const char *lp_configfile(struct loadparm_context *lp_ctx); +bool lp_load_default(struct loadparm_context *lp_ctx); + +/** + * Load the services array from the services file. + * + * Return True on success, False on failure. + */ +bool lp_load(struct loadparm_context *lp_ctx, const char *filename); + +/** + * Return the max number of services. + */ +int lp_numservices(struct loadparm_context *lp_ctx); + +/** + * Display the contents of the services array in human-readable form. + */ +void lp_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults, + int maxtoprint); + +/** + * Display the contents of one service in human-readable form. + */ +void lp_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service, struct loadparm_service *sDefault); +struct loadparm_service *lp_servicebynum(struct loadparm_context *lp_ctx, + int snum); +struct loadparm_service *lp_service(struct loadparm_context *lp_ctx, + const char *service_name); + +/** + * A useful volume label function. + */ +const char *volume_label(struct loadparm_service *service, struct loadparm_service *sDefault); + +/** + * If we are PDC then prefer us as DMB + */ +const char *lp_printername(struct loadparm_service *service, struct loadparm_service *sDefault); + +/** + * Return the max print jobs per queue. + */ +int lp_maxprintjobs(struct loadparm_service *service, struct loadparm_service *sDefault); +struct smb_iconv_convenience *lp_iconv_convenience(struct loadparm_context *lp_ctx); +void lp_smbcli_options(struct loadparm_context *lp_ctx, + struct smbcli_options *options); + +/* The following definitions come from param/generic.c */ + +struct param_section *param_get_section(struct param_context *ctx, const char *name); +struct param_opt *param_section_get(struct param_section *section, + const char *name); +struct param_opt *param_get (struct param_context *ctx, const char *name, const char *section_name); +struct param_section *param_add_section(struct param_context *ctx, const char *section_name); +struct param_opt *param_get_add(struct param_context *ctx, const char *name, const char *section_name); +const char *param_get_string(struct param_context *ctx, const char *param, const char *section); +int param_set_string(struct param_context *ctx, const char *param, const char *value, const char *section); +const char **param_get_string_list(struct param_context *ctx, const char *param, const char *separator, const char *section); +int param_set_string_list(struct param_context *ctx, const char *param, const char **list, const char *section); +int param_get_int(struct param_context *ctx, const char *param, int default_v, const char *section); +void param_set_int(struct param_context *ctx, const char *param, int value, const char *section); +unsigned long param_get_ulong(struct param_context *ctx, const char *param, unsigned long default_v, const char *section); +void param_set_ulong(struct param_context *ctx, const char *name, unsigned long value, const char *section); +struct param_context *param_init(TALLOC_CTX *mem_ctx); +int param_read(struct param_context *ctx, const char *fn); +int param_use(struct loadparm_context *lp_ctx, struct param_context *ctx); +int param_write(struct param_context *ctx, const char *fn); + +/* The following definitions come from param/util.c */ + + +/** + * @file + * @brief Misc utility functions + */ +bool lp_is_mydomain(struct loadparm_context *lp_ctx, + const char *domain); + +/** + see if a string matches either our primary or one of our secondary + netbios aliases. do a case insensitive match +*/ +bool lp_is_myname(struct loadparm_context *lp_ctx, const char *name); + +/** + A useful function for returning a path in the Samba lock directory. +**/ +char *lock_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, + const char *name); + +/** + * @brief Returns an absolute path to a file in the directory containing the current config file + * + * @param name File to find, relative to the config file directory. + * + * @retval Pointer to a talloc'ed string containing the full path. + **/ +char *config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, + const char *name); + +/** + * @brief Returns an absolute path to a file in the Samba private directory. + * + * @param name File to find, relative to PRIVATEDIR. + * if name is not relative, then use it as-is + * + * @retval Pointer to a talloc'ed string containing the full path. + **/ +char *private_path(TALLOC_CTX* mem_ctx, + struct loadparm_context *lp_ctx, + const char *name); + +/** + return a path in the smbd.tmp directory, where all temporary file + for smbd go. If NULL is passed for name then return the directory + path itself +*/ +char *smbd_tmp_path(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx, + const char *name); + +/** + * Obtain the init function from a shared library file + */ +init_module_fn load_module(TALLOC_CTX *mem_ctx, const char *path); + +/** + * Obtain list of init functions from the modules in the specified + * directory + */ +init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path); + +/** + * Run the specified init functions. + * + * @return true if all functions ran successfully, false otherwise + */ +bool run_init_functions(init_module_fn *fns); + +/** + * Load the initialization functions from DSO files for a specific subsystem. + * + * Will return an array of function pointers to initialization functions + */ +init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *subsystem); +const char *lp_messaging_path(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx); +struct smb_iconv_convenience *smb_iconv_convenience_init_lp(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx); + +/* The following definitions come from lib/version.c */ + +const char *samba_version_string(void); + + #endif /* _PARAM_H */ diff --git a/source4/param/util.c b/source4/param/util.c index 1cf05d4fa7..2baaefda8b 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -35,7 +35,7 @@ */ -_PUBLIC_ bool lp_is_mydomain(struct loadparm_context *lp_ctx, +bool lp_is_mydomain(struct loadparm_context *lp_ctx, const char *domain) { return strequal(lp_workgroup(lp_ctx), domain); @@ -45,7 +45,7 @@ _PUBLIC_ bool lp_is_mydomain(struct loadparm_context *lp_ctx, see if a string matches either our primary or one of our secondary netbios aliases. do a case insensitive match */ -_PUBLIC_ bool lp_is_myname(struct loadparm_context *lp_ctx, const char *name) +bool lp_is_myname(struct loadparm_context *lp_ctx, const char *name) { const char **aliases; int i; @@ -68,7 +68,7 @@ _PUBLIC_ bool lp_is_myname(struct loadparm_context *lp_ctx, const char *name) /** A useful function for returning a path in the Samba lock directory. **/ -_PUBLIC_ char *lock_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, +char *lock_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, const char *name) { char *fname, *dname; @@ -101,7 +101,7 @@ _PUBLIC_ char *lock_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, * @retval Pointer to a talloc'ed string containing the full path. **/ -_PUBLIC_ char *config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, +char *config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, const char *name) { char *fname, *config_dir, *p; @@ -127,7 +127,7 @@ _PUBLIC_ char *config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, * * @retval Pointer to a talloc'ed string containing the full path. **/ -_PUBLIC_ char *private_path(TALLOC_CTX* mem_ctx, +char *private_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, const char *name) { @@ -147,7 +147,7 @@ _PUBLIC_ char *private_path(TALLOC_CTX* mem_ctx, for smbd go. If NULL is passed for name then return the directory path itself */ -_PUBLIC_ char *smbd_tmp_path(TALLOC_CTX *mem_ctx, +char *smbd_tmp_path(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *name) { @@ -171,7 +171,7 @@ _PUBLIC_ char *smbd_tmp_path(TALLOC_CTX *mem_ctx, /** * Obtain the init function from a shared library file */ -_PUBLIC_ init_module_fn load_module(TALLOC_CTX *mem_ctx, const char *path) +init_module_fn load_module(TALLOC_CTX *mem_ctx, const char *path) { void *handle; void *init_fn; @@ -198,7 +198,7 @@ _PUBLIC_ init_module_fn load_module(TALLOC_CTX *mem_ctx, const char *path) * Obtain list of init functions from the modules in the specified * directory */ -_PUBLIC_ init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path) +init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path) { DIR *dir; struct dirent *entry; @@ -240,7 +240,7 @@ _PUBLIC_ init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path) * * @return true if all functions ran successfully, false otherwise */ -_PUBLIC_ bool run_init_functions(init_module_fn *fns) +bool run_init_functions(init_module_fn *fns) { int i; bool ret = true; @@ -268,7 +268,7 @@ static char *modules_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, * Will return an array of function pointers to initialization functions */ -_PUBLIC_ init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *subsystem) +init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *subsystem) { char *path = modules_path(mem_ctx, lp_ctx, subsystem); init_module_fn *ret; @@ -280,7 +280,7 @@ _PUBLIC_ init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, struct loadparm return ret; } -_PUBLIC_ const char *lp_messaging_path(TALLOC_CTX *mem_ctx, +const char *lp_messaging_path(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx) { return smbd_tmp_path(mem_ctx, lp_ctx, "messaging"); -- cgit