Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/param/loadparm.c

    r690 r745  
    1111   Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
    1212   Copyright (C) Michael Adam 2008
    13    
     13
    1414   This program is free software; you can redistribute it and/or modify
    1515   it under the terms of the GNU General Public License as published by
    1616   the Free Software Foundation; either version 3 of the License, or
    1717   (at your option) any later version.
    18    
     18
    1919   This program is distributed in the hope that it will be useful,
    2020   but WITHOUT ANY WARRANTY; without even the implied warranty of
    2121   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2222   GNU General Public License for more details.
    23    
     23
    2424   You should have received a copy of the GNU General Public License
    2525   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    5353
    5454#include "includes.h"
     55#include "system/filesys.h"
     56#include "util_tdb.h"
    5557#include "printing.h"
     58#include "lib/smbconf/smbconf.h"
     59#include "lib/smbconf/smbconf_init.h"
     60
     61#include "ads.h"
     62#include "../librpc/gen_ndr/svcctl.h"
     63#include "intl.h"
     64#include "smb_signing.h"
     65#include "dbwrap.h"
     66#include "smbldap.h"
    5667
    5768#ifdef HAVE_SYS_SYSCTL_H
     
    89100static bool in_client = False;          /* Not in the client by default */
    90101static struct smbconf_csn conf_last_csn;
     102
    91103#ifdef __OS2__
    92104static bool newLockDir = False;
     
    112124        char *value;
    113125        char **list;
     126        unsigned flags;
    114127};
    115128
     
    185198        char *szAbortShutdownScript;
    186199        char *szUsernameMapScript;
     200        int iUsernameMapCacheTime;
    187201        char *szCheckPasswordScript;
    188202        char *szWINSHook;
     
    208222        bool bWinbindRpcOnly;
    209223        bool bCreateKrb5Conf;
     224        int winbindMaxDomainConnections;
    210225        char *szIdmapBackend;
    211         char *szIdmapAllocBackend;
     226        bool bIdmapReadOnly;
    212227        char *szAddShareCommand;
    213228        char *szChangeShareCommand;
     
    255270        int winbind_cache_time;
    256271        int winbind_reconnect_delay;
    257         int winbind_max_idle_children;
     272        int winbind_max_clients;
    258273        char **szWinbindNssInfo;
    259274        int iLockSpinTime;
     
    278293        bool clustering;
    279294        int ctdb_timeout;
     295        int ctdb_locktime_warn_threshold;
    280296        int ldap_passwd_sync;
    281297        int ldap_replication_sleep;
     
    330346        bool bClientUseSpnego;
    331347        bool client_use_spnego_principal;
     348        bool send_spnego_principal;
    332349        bool bDebugPrefixTimestamp;
    333350        bool bDebugHiresTimestamp;
     
    358375        int iIdmapNegativeCacheTime;
    359376        bool bResetOnZeroVC;
     377        bool bLogWriteableFilesOnExit;
    360378        int iKeepalive;
    361379        int iminreceivefile;
     
    364382        char *szSMBPerfcountModule;
    365383        bool bMapUntrustedToDomain;
     384        bool bAsyncSMBEchoHandler;
     385        bool bMulticastDnsRegister;
     386        int ismb2_max_read;
     387        int ismb2_max_write;
     388        int ismb2_max_trans;
     389        int ismb2_max_credits;
     390        char *ncalrpc_dir;
    366391};
    367392
     
    455480        bool bGuest_ok;
    456481        bool bPrint_ok;
     482        bool bPrintNotifyBackchannel;
    457483        bool bMap_system;
    458484        bool bMap_hidden;
     
    599625        False,                  /* bGuest_ok */
    600626        False,                  /* bPrint_ok */
     627        True,                   /* bPrintNotifyBackchannel */
    601628        False,                  /* bMap_system */
    602629        False,                  /* bMap_hidden */
     
    670697static bool bInGlobalSection = True;
    671698static bool bGlobalOnly = False;
    672 static int server_role;
    673699static int default_server_announce;
    674700
     
    679705static bool handle_copy( int snum, const char *pszParmValue, char **ptr);
    680706static bool handle_netbios_name( int snum, const char *pszParmValue, char **ptr);
     707static bool handle_idmap_backend(int snum, const char *pszParmValue, char **ptr);
    681708static bool handle_idmap_uid( int snum, const char *pszParmValue, char **ptr);
    682709static bool handle_idmap_gid( int snum, const char *pszParmValue, char **ptr);
     
    686713static bool handle_netbios_scope( int snum, const char *pszParmValue, char **ptr );
    687714static bool handle_charset( int snum, const char *pszParmValue, char **ptr );
     715static bool handle_dos_charset( int snum, const char *pszParmValue, char **ptr );
    688716static bool handle_printing( int snum, const char *pszParmValue, char **ptr);
    689717static bool handle_ldap_debug_level( int snum, const char *pszParmValue, char **ptr);
    690718
    691 static void set_server_role(void);
    692719static void set_default_server_announce_type(void);
    693720static void set_allowed_client_auth(void);
     
    696723
    697724static void add_to_file_list(const char *fname, const char *subfname);
     725static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values);
    698726
    699727static const struct enum_list enum_protocol[] = {
     
    731759        {PRINT_LPRNT, "nt"},
    732760        {PRINT_LPROS2, "os2"},
    733 #ifdef DEVELOPER
     761#if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
    734762        {PRINT_TEST, "test"},
    735763        {PRINT_VLP, "vlp"},
     
    821849        {-1, NULL}
    822850};
    823 
    824 /* Client-side offline caching policy types */
    825 #define CSC_POLICY_MANUAL 0
    826 #define CSC_POLICY_DOCUMENTS 1
    827 #define CSC_POLICY_PROGRAMS 2
    828 #define CSC_POLICY_DISABLE 3
    829851
    830852static const struct enum_list enum_csc_policy[] = {
     
    939961                .p_class        = P_GLOBAL,
    940962                .ptr            = &Globals.dos_charset,
    941                 .special        = handle_charset,
     963                .special        = handle_dos_charset,
    942964                .enum_list      = NULL,
    943965                .flags          = FLAG_ADVANCED
     
    11021124        },
    11031125        {
    1104                 .label          = "update encrypted",
    1105                 .type           = P_BOOL,
    1106                 .p_class        = P_GLOBAL,
    1107                 .ptr            = &Globals.bUpdateEncrypt,
    1108                 .special        = NULL,
    1109                 .enum_list      = NULL,
    1110                 .flags          = FLAG_ADVANCED,
    1111         },
    1112         {
    11131126                .label          = "client schannel",
    11141127                .type           = P_ENUM,
     
    11531166                .special        = NULL,
    11541167                .enum_list      = NULL,
    1155                 .flags          = FLAG_ADVANCED,
     1168                .flags          = FLAG_ADVANCED | FLAG_DEPRECATED,
    11561169        },
    11571170        {
     
    12521265                .special        = NULL,
    12531266                .enum_list      = NULL,
    1254                 .flags          = FLAG_ADVANCED,
     1267                .flags          = FLAG_ADVANCED | FLAG_DEPRECATED,
    12551268        },
    12561269
     
    13251338                .special        = NULL,
    13261339                .enum_list      = NULL,
    1327                 .flags          = FLAG_ADVANCED,
     1340                .flags          = FLAG_ADVANCED | FLAG_DEPRECATED,
    13281341        },
    13291342        {
     
    14091422        },
    14101423        {
     1424                .label          = "send spnego principal",
     1425                .type           = P_BOOL,
     1426                .p_class        = P_GLOBAL,
     1427                .ptr            = &Globals.send_spnego_principal,
     1428                .special        = NULL,
     1429                .enum_list      = NULL,
     1430                .flags          = FLAG_ADVANCED,
     1431        },
     1432        {
    14111433                .label          = "username",
    14121434                .type           = P_STRING,
     
    14151437                .special        = NULL,
    14161438                .enum_list      = NULL,
    1417                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
     1439                .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE | FLAG_DEPRECATED,
    14181440        },
    14191441        {
     
    20922114        },
    20932115        {
     2116                .label          = "log writeable files on exit",
     2117                .type           = P_BOOL,
     2118                .p_class        = P_GLOBAL,
     2119                .ptr            = &Globals.bLogWriteableFilesOnExit,
     2120                .special        = NULL,
     2121                .enum_list      = NULL,
     2122                .flags          = FLAG_ADVANCED,
     2123        },
     2124        {
    20942125                .label          = "acl compatibility",
    20952126                .type           = P_ENUM,
     
    22692300                .special        = NULL,
    22702301                .enum_list      = NULL,
    2271                 .flags          = FLAG_ADVANCED,
     2302                .flags          = FLAG_ADVANCED | FLAG_DEPRECATED,
    22722303        },
    22732304        {
     
    25802611                .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
    25812612        },
     2613        {
     2614                .label          = "ctdb locktime warn threshold",
     2615                .type           = P_INTEGER,
     2616                .p_class        = P_GLOBAL,
     2617                .ptr            = &Globals.ctdb_locktime_warn_threshold,
     2618                .special        = NULL,
     2619                .enum_list      = NULL,
     2620                .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
     2621        },
     2622        {
     2623                .label          = "smb2 max read",
     2624                .type           = P_INTEGER,
     2625                .p_class        = P_GLOBAL,
     2626                .ptr            = &Globals.ismb2_max_read,
     2627                .special        = NULL,
     2628                .enum_list      = NULL,
     2629                .flags          = FLAG_ADVANCED,
     2630        },
     2631        {
     2632                .label          = "smb2 max write",
     2633                .type           = P_INTEGER,
     2634                .p_class        = P_GLOBAL,
     2635                .ptr            = &Globals.ismb2_max_write,
     2636                .special        = NULL,
     2637                .enum_list      = NULL,
     2638                .flags          = FLAG_ADVANCED,
     2639        },
     2640        {
     2641                .label          = "smb2 max trans",
     2642                .type           = P_INTEGER,
     2643                .p_class        = P_GLOBAL,
     2644                .ptr            = &Globals.ismb2_max_trans,
     2645                .special        = NULL,
     2646                .enum_list      = NULL,
     2647                .flags          = FLAG_ADVANCED,
     2648        },
     2649        {
     2650                .label          = "smb2 max credits",
     2651                .type           = P_INTEGER,
     2652                .p_class        = P_GLOBAL,
     2653                .ptr            = &Globals.ismb2_max_credits,
     2654                .special        = NULL,
     2655                .enum_list      = NULL,
     2656                .flags          = FLAG_ADVANCED,
     2657        },
    25822658
    25832659        {N_("Printing Options"), P_SEP, P_SEPARATOR},
     
    26452721                .enum_list      = NULL,
    26462722                .flags          = FLAG_ADVANCED | FLAG_PRINT,
     2723        },
     2724        {
     2725                .label          = "print notify backchannel",
     2726                .type           = P_BOOL,
     2727                .p_class        = P_LOCAL,
     2728                .ptr            = &sDefault.bPrintNotifyBackchannel,
     2729                .special        = NULL,
     2730                .enum_list      = NULL,
     2731                .flags          = FLAG_ADVANCED,
    26472732        },
    26482733        {
     
    32543339        },
    32553340        {
     3341                .label          = "username map cache time",
     3342                .type           = P_INTEGER,
     3343                .p_class        = P_GLOBAL,
     3344                .ptr            = &Globals.iUsernameMapCacheTime,
     3345                .special        = NULL,
     3346                .enum_list      = NULL,
     3347                .flags          = FLAG_ADVANCED,
     3348        },
     3349        {
    32563350                .label          = "logon script",
    32573351                .type           = P_STRING,
     
    40574151                .special        = NULL,
    40584152                .enum_list      = NULL,
    4059                 .flags          = FLAG_ADVANCED,
     4153                .flags          = FLAG_ADVANCED | FLAG_DEPRECATED,
    40604154        },
    40614155        {
     
    43574451        },
    43584452        {
     4453                .label          = "async smb echo handler",
     4454                .type           = P_BOOL,
     4455                .p_class        = P_GLOBAL,
     4456                .ptr            = &Globals.bAsyncSMBEchoHandler,
     4457                .special        = NULL,
     4458                .enum_list      = NULL,
     4459                .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
     4460        },
     4461        {
     4462                .label          = "multicast dns register",
     4463                .type           = P_BOOL,
     4464                .p_class        = P_GLOBAL,
     4465                .ptr            = &Globals.bMulticastDnsRegister,
     4466                .special        = NULL,
     4467                .enum_list      = NULL,
     4468                .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
     4469        },
     4470        {
    43594471                .label          = "panic action",
    43604472                .type           = P_STRING,
     
    44434555                .p_class        = P_GLOBAL,
    44444556                .ptr            = &Globals.szIdmapBackend,
    4445                 .special        = NULL,
    4446                 .enum_list      = NULL,
    4447                 .flags          = FLAG_ADVANCED,
    4448         },
    4449         {
    4450                 .label          = "idmap alloc backend",
    4451                 .type           = P_STRING,
    4452                 .p_class        = P_GLOBAL,
    4453                 .ptr            = &Globals.szIdmapAllocBackend,
    4454                 .special        = NULL,
    4455                 .enum_list      = NULL,
    4456                 .flags          = FLAG_ADVANCED,
     4557                .special        = handle_idmap_backend,
     4558                .enum_list      = NULL,
     4559                .flags          = FLAG_ADVANCED | FLAG_DEPRECATED,
    44574560        },
    44584561        {
     
    44814584                .special        = handle_idmap_uid,
    44824585                .enum_list      = NULL,
    4483                 .flags          = FLAG_ADVANCED,
     4586                .flags          = FLAG_ADVANCED | FLAG_DEPRECATED,
    44844587        },
    44854588        {
     
    44994602                .special        = handle_idmap_gid,
    45004603                .enum_list      = NULL,
    4501                 .flags          = FLAG_ADVANCED,
     4604                .flags          = FLAG_ADVANCED | FLAG_DEPRECATED,
    45024605        },
    45034606        {
     
    45564659        },
    45574660        {
     4661                .label          = "winbind max clients",
     4662                .type           = P_INTEGER,
     4663                .p_class        = P_GLOBAL,
     4664                .ptr            = &Globals.winbind_max_clients,
     4665                .special        = NULL,
     4666                .enum_list      = NULL,
     4667                .flags          = FLAG_ADVANCED,
     4668        },
     4669        {
    45584670                .label          = "winbind enum users",
    45594671                .type           = P_BOOL,
     
    46594771                .p_class        = P_GLOBAL,
    46604772                .ptr            = &Globals.bCreateKrb5Conf,
     4773                .special        = NULL,
     4774                .enum_list      = NULL,
     4775                .flags          = FLAG_ADVANCED,
     4776        },
     4777        {
     4778                .label          = "ncalrpc dir",
     4779                .type           = P_STRING,
     4780                .p_class        = P_GLOBAL,
     4781                .ptr            = &Globals.ncalrpc_dir,
     4782                .special        = NULL,
     4783                .enum_list      = NULL,
     4784                .flags          = FLAG_ADVANCED,
     4785        },
     4786        {
     4787                .label          = "winbind max domain connections",
     4788                .type           = P_INTEGER,
     4789                .p_class        = P_GLOBAL,
     4790                .ptr            = &Globals.winbindMaxDomainConnections,
    46614791                .special        = NULL,
    46624792                .enum_list      = NULL,
     
    47464876                        break;
    47474877
    4748 #ifdef DEVELOPER
     4878#if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
     4879
    47494880        case PRINT_TEST:
    4750         case PRINT_VLP:
    4751                 string_set(&pService->szPrintcommand, "vlp print %p %s");
    4752                 string_set(&pService->szLpqcommand, "vlp lpq %p");
    4753                 string_set(&pService->szLprmcommand, "vlp lprm %p %j");
    4754                 string_set(&pService->szLppausecommand, "vlp lppause %p %j");
    4755                 string_set(&pService->szLpresumecommand, "vlp lpresume %p %j");
    4756                 string_set(&pService->szQueuepausecommand, "vlp queuepause %p");
    4757                 string_set(&pService->szQueueresumecommand, "vlp queueresume %p");
     4881        case PRINT_VLP: {
     4882                const char *tdbfile;
     4883                char *tmp;
     4884
     4885                tdbfile = talloc_asprintf(
     4886                        talloc_tos(), "tdbfile=%s",
     4887                        lp_parm_const_string(-1, "vlp", "tdbfile",
     4888                                             "/tmp/vlp.tdb"));
     4889                if (tdbfile == NULL) {
     4890                        tdbfile="tdbfile=/tmp/vlp.tdb";
     4891                }
     4892
     4893                tmp = talloc_asprintf(talloc_tos(), "vlp %s print %%p %%s",
     4894                                      tdbfile);
     4895                string_set(&pService->szPrintcommand,
     4896                           tmp ? tmp : "vlp print %p %s");
     4897                TALLOC_FREE(tmp);
     4898
     4899                tmp = talloc_asprintf(talloc_tos(), "vlp %s lpq %%p",
     4900                                      tdbfile);
     4901                string_set(&pService->szLpqcommand,
     4902                           tmp ? tmp : "vlp lpq %p");
     4903                TALLOC_FREE(tmp);
     4904
     4905                tmp = talloc_asprintf(talloc_tos(), "vlp %s lprm %%p %%j",
     4906                                      tdbfile);
     4907                string_set(&pService->szLprmcommand,
     4908                           tmp ? tmp : "vlp lprm %p %j");
     4909                TALLOC_FREE(tmp);
     4910
     4911                tmp = talloc_asprintf(talloc_tos(), "vlp %s lppause %%p %%j",
     4912                                      tdbfile);
     4913                string_set(&pService->szLppausecommand,
     4914                           tmp ? tmp : "vlp lppause %p %j");
     4915                TALLOC_FREE(tmp);
     4916
     4917                tmp = talloc_asprintf(talloc_tos(), "vlp %s lpresume %%p %%j",
     4918                                      tdbfile);
     4919                string_set(&pService->szLpresumecommand,
     4920                           tmp ? tmp : "vlp lpresume %p %j");
     4921                TALLOC_FREE(tmp);
     4922
     4923                tmp = talloc_asprintf(talloc_tos(), "vlp %s queuepause %%p",
     4924                                      tdbfile);
     4925                string_set(&pService->szQueuepausecommand,
     4926                           tmp ? tmp : "vlp queuepause %p");
     4927                TALLOC_FREE(tmp);
     4928
     4929                tmp = talloc_asprintf(talloc_tos(), "vlp %s queueresume %%p",
     4930                                      tdbfile);
     4931                string_set(&pService->szQueueresumecommand,
     4932                           tmp ? tmp : "vlp queueresume %p");
     4933                TALLOC_FREE(tmp);
     4934
    47584935                break;
     4936        }
    47594937#endif /* DEVELOPER */
    47604938
     
    47924970                if(rl.rlim_cur == RLIM_INFINITY)
    47934971                        rlimit_max = MAX_OPEN_FILES;
    4794         }
    47954972#endif
     4973        }
    47964974#endif
    47974975
     
    49055083}
    49065084
     5085static int map_parameter(const char *pszParmName);
     5086
     5087struct lp_stored_option {
     5088        struct lp_stored_option *prev, *next;
     5089        const char *label;
     5090        const char *value;
     5091};
     5092
     5093static struct lp_stored_option *stored_options;
     5094
     5095/*
     5096  save options set by lp_set_cmdline() into a list. This list is
     5097  re-applied when we do a globals reset, so that cmdline set options
     5098  are sticky across reloads of smb.conf
     5099 */
     5100static bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
     5101{
     5102        struct lp_stored_option *entry, *entry_next;
     5103        for (entry = stored_options; entry != NULL; entry = entry_next) {
     5104                entry_next = entry->next;
     5105                if (strcmp(pszParmName, entry->label) == 0) {
     5106                        DLIST_REMOVE(stored_options, entry);
     5107                        talloc_free(entry);
     5108                        break;
     5109                }
     5110        }
     5111
     5112        entry = talloc(NULL, struct lp_stored_option);
     5113        if (!entry) {
     5114                return false;
     5115        }
     5116
     5117        entry->label = talloc_strdup(entry, pszParmName);
     5118        if (!entry->label) {
     5119                talloc_free(entry);
     5120                return false;
     5121        }
     5122
     5123        entry->value = talloc_strdup(entry, pszParmValue);
     5124        if (!entry->value) {
     5125                talloc_free(entry);
     5126                return false;
     5127        }
     5128
     5129        DLIST_ADD_END(stored_options, entry, struct lp_stored_option);
     5130
     5131        return true;
     5132}
     5133
     5134static bool apply_lp_set_cmdline(void)
     5135{
     5136        struct lp_stored_option *entry = NULL;
     5137        for (entry = stored_options; entry != NULL; entry = entry->next) {
     5138                if (!lp_set_cmdline_helper(entry->label, entry->value, false)) {
     5139                        DEBUG(0, ("Failed to re-apply cmdline parameter %s = %s\n",
     5140                                  entry->label, entry->value));
     5141                        return false;
     5142                }
     5143        }
     5144        return true;
     5145}
     5146
    49075147/***************************************************************************
    49085148 Initialise the global parameter structure.
    49095149***************************************************************************/
    49105150
    4911 static void init_globals(bool first_time_only)
     5151static void init_globals(bool reinit_globals)
    49125152{
    49135153        static bool done_init = False;
     
    49165156
    49175157        /* If requested to initialize only once and we've already done it... */
    4918         if (first_time_only && done_init) {
     5158        if (!reinit_globals && done_init) {
    49195159                /* ... then we have nothing more to do */
    49205160                return;
     
    49325172        }
    49335173
     5174        /* This memset and the free_global_parameters() above will
     5175         * wipe out smb.conf options set with lp_set_cmdline().  The
     5176         * apply_lp_set_cmdline() call puts these values back in the
     5177         * table once the defaults are set */
    49345178        memset((void *)&Globals, '\0', sizeof(Globals));
    49355179
     
    49605204        string_set(&Globals.szGuestaccount, GUEST_ACCOUNT);
    49615205
    4962 #ifdef __OS2__
     5206#ifndef __OS2__
     5207        /* using UTF8 by default allows us to support all chars */
     5208        string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
     5209#else
    49635210        /* search the system codepage and set OS2CodePageStr */
    49645211        unsigned long _System DosQueryCp (unsigned long ulLength, unsigned long *pCodePageList, unsigned long *pDataLength);
     
    49705217          else
    49715218           asprintf(&OS2CodePageStr, "IBM-%u", OS2CodePage[0]);
    4972 #endif
    4973 #ifndef __OS2__
    4974         /* using UTF8 by default allows us to support all chars */
    4975         string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET);
    4976 #else
     5219
    49775220        /* On OS/2, using UTF8 causes problems with display of foreign
    49785221           characters - default to system codepage */
     
    49905233        string_set(&Globals.display_charset, OS2CodePageStr);
    49915234#endif
    4992 
    49935235#else
    49945236        string_set(&Globals.display_charset, DEFAULT_DISPLAY_CHARSET);
     
    50265268        /*
    50275269         * By default support explicit binding to broadcast
    5028          * addresses.
    5029          */
     5270         * addresses.
     5271         */
    50305272        Globals.bNmbdBindExplicitBroadcast = true;
    50315273
     
    51295371        Globals.bLanmanAuth = False;    /* Do NOT use the LanMan hash, even if it is supplied */
    51305372        Globals.bNTLMAuth = True;       /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
    5131         Globals.bClientNTLMv2Auth = False; /* Client should not use NTLMv2, as we can't tell that the server supports it. */
    5132         /* Note, that we will use NTLM2 session security (which is different), if it is available */
     5373        Globals.bClientNTLMv2Auth = True; /* Client should always use use NTLMv2, as we can't tell that the server supports it, but most modern servers do */
     5374        /* Note, that we will also use NTLM2 session security (which is different), if it is available */
    51335375
    51345376        Globals.map_to_guest = 0;       /* By Default, "Never" */
     
    51435385        Globals.bUnixExtensions = True;
    51445386        Globals.bResetOnZeroVC = False;
     5387        Globals.bLogWriteableFilesOnExit = False;
    51455388        Globals.bCreateKrb5Conf = true;
     5389        Globals.winbindMaxDomainConnections = 1;
    51465390
    51475391        /* hostname lookups can be very expensive and are broken on
     
    52085452        Globals.bAllowTrustedDomains = True;
    52095453        string_set(&Globals.szIdmapBackend, "tdb");
     5454        Globals.bIdmapReadOnly = false;
    52105455
    52115456        string_set(&Globals.szTemplateShell, "/bin/false");
     
    52205465        Globals.clustering = False;
    52215466        Globals.ctdb_timeout = 0;
     5467        Globals.ctdb_locktime_warn_threshold = 0;
    52225468
    52235469        Globals.winbind_cache_time = 300;       /* 5 minutes */
    52245470        Globals.winbind_reconnect_delay = 30;   /* 30 seconds */
     5471        Globals.winbind_max_clients = 200;
    52255472        Globals.bWinbindEnumUsers = False;
    52265473        Globals.bWinbindEnumGroups = False;
     
    52295476        Globals.bWinbindNestedGroups = True;
    52305477        Globals.winbind_expand_groups = 1;
    5231         Globals.szWinbindNssInfo = str_list_make_v3(talloc_autofree_context(), "template", NULL);
     5478        Globals.szWinbindNssInfo = str_list_make_v3(NULL, "template", NULL);
    52325479        Globals.bWinbindRefreshTickets = False;
    52335480        Globals.bWinbindOfflineLogon = False;
     
    52745521
    52755522        Globals.bMapUntrustedToDomain = false;
     5523        Globals.bMulticastDnsRegister = true;
     5524
     5525        Globals.ismb2_max_read = DEFAULT_SMB2_MAX_READ;
     5526        Globals.ismb2_max_write = DEFAULT_SMB2_MAX_WRITE;
     5527        Globals.ismb2_max_trans = DEFAULT_SMB2_MAX_TRANSACT;
     5528        Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
     5529
     5530        string_set(&Globals.ncalrpc_dir, get_dyn_NCALRPCDIR());
     5531
     5532        /* Now put back the settings that were set with lp_set_cmdline() */
     5533        apply_lp_set_cmdline();
    52765534}
    52775535
     
    53485606#define FN_LOCAL_PARM_INTEGER(fn_name,val) \
    53495607 int fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
    5350 #define FN_LOCAL_PARM_STRING(fn_name,val) \
    5351  char *fn_name(const struct share_params *p) {return(lp_string((LP_SNUM_OK(p->service) && ServicePtrs[(p->service)]->val) ? ServicePtrs[(p->service)]->val : sDefault.val));}
    53525608#define FN_LOCAL_CHAR(fn_name,val) \
    53535609 char fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
     
    54845740FN_GLOBAL_STRING(lp_abort_shutdown_script, &Globals.szAbortShutdownScript)
    54855741FN_GLOBAL_STRING(lp_username_map_script, &Globals.szUsernameMapScript)
     5742FN_GLOBAL_INTEGER(lp_username_map_cache_time, &Globals.iUsernameMapCacheTime)
    54865743
    54875744FN_GLOBAL_STRING(lp_check_password_script, &Globals.szCheckPasswordScript)
     
    55035760FN_GLOBAL_BOOL(lp_winbind_rpc_only, &Globals.bWinbindRpcOnly)
    55045761FN_GLOBAL_BOOL(lp_create_krb5_conf, &Globals.bCreateKrb5Conf)
     5762static FN_GLOBAL_INTEGER(lp_winbind_max_domain_connections_int,
     5763                  &Globals.winbindMaxDomainConnections)
     5764
     5765int lp_winbind_max_domain_connections(void)
     5766{
     5767        if (lp_winbind_offline_logon() &&
     5768            lp_winbind_max_domain_connections_int() > 1) {
     5769                DEBUG(1, ("offline logons active, restricting max domain "
     5770                          "connections to 1\n"));
     5771                return 1;
     5772        }
     5773        return MAX(1, lp_winbind_max_domain_connections_int());
     5774}
    55055775
    55065776FN_GLOBAL_CONST_STRING(lp_idmap_backend, &Globals.szIdmapBackend)
    5507 FN_GLOBAL_STRING(lp_idmap_alloc_backend, &Globals.szIdmapAllocBackend)
    55085777FN_GLOBAL_INTEGER(lp_idmap_cache_time, &Globals.iIdmapCacheTime)
    55095778FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, &Globals.iIdmapNegativeCacheTime)
     
    55395808FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
    55405809FN_GLOBAL_BOOL(lp_reset_on_zero_vc, &Globals.bResetOnZeroVC)
     5810FN_GLOBAL_BOOL(lp_log_writeable_files_on_exit,
     5811               &Globals.bLogWriteableFilesOnExit)
    55415812FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
    55425813FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
     
    55495820FN_GLOBAL_INTEGER(lp_init_logon_delay, &Globals.InitLogonDelay)
    55505821FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
    5551 FN_GLOBAL_BOOL(lp_readraw, &Globals.bReadRaw)
     5822FN_GLOBAL_BOOL(_lp_readraw, &Globals.bReadRaw)
    55525823FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
    5553 FN_GLOBAL_BOOL(lp_writeraw, &Globals.bWriteRaw)
     5824FN_GLOBAL_BOOL(_lp_writeraw, &Globals.bWriteRaw)
    55545825FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
    55555826FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
    55565827FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
    5557 FN_GLOBAL_BOOL(lp_update_encrypted, &Globals.bUpdateEncrypt)
    55585828FN_GLOBAL_INTEGER(lp_client_schannel, &Globals.clientSchannel)
    55595829FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel)
     
    55945864FN_GLOBAL_BOOL(lp_client_use_spnego, &Globals.bClientUseSpnego)
    55955865FN_GLOBAL_BOOL(lp_client_use_spnego_principal, &Globals.client_use_spnego_principal)
     5866FN_GLOBAL_BOOL(lp_send_spnego_principal, &Globals.send_spnego_principal)
    55965867FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups)
    55975868FN_LOCAL_PARM_BOOL(lp_change_notify, bChangeNotify)
     
    56155886FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime)
    56165887FN_GLOBAL_BOOL(lp_getwd_cache, &Globals.getwd_cache)
    5617 FN_GLOBAL_INTEGER(lp_maxprotocol, &Globals.maxprotocol)
     5888static FN_GLOBAL_INTEGER(_lp_maxprotocol, &Globals.maxprotocol)
     5889int lp_maxprotocol(void)
     5890{
     5891        int ret = _lp_maxprotocol();
     5892        if ((ret == PROTOCOL_SMB2) && (lp_security() == SEC_SHARE)) {
     5893                DEBUG(2,("WARNING!!: \"security = share\" is incompatible "
     5894                        "with the SMB2 protocol. Resetting to SMB1.\n" ));
     5895                        lp_do_parameter(-1, "max protocol", "NT1");
     5896                return PROTOCOL_NT1;
     5897        }
     5898        return ret;
     5899}
    56185900FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol)
    56195901FN_GLOBAL_INTEGER(lp_security, &Globals.security)
     
    56355917FN_GLOBAL_CONST_STRING(lp_socket_options, &Globals.szSocketOptions)
    56365918FN_GLOBAL_INTEGER(lp_config_backend, &Globals.ConfigBackend)
    5637 
     5919FN_GLOBAL_INTEGER(lp_smb2_max_read, &Globals.ismb2_max_read)
     5920FN_GLOBAL_INTEGER(lp_smb2_max_write, &Globals.ismb2_max_write)
     5921FN_GLOBAL_INTEGER(lp_smb2_max_trans, &Globals.ismb2_max_trans)
     5922int lp_smb2_max_credits(void)
     5923{
     5924        if (Globals.ismb2_max_credits == 0) {
     5925                Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
     5926        }
     5927        return Globals.ismb2_max_credits;
     5928}
    56385929FN_LOCAL_STRING(lp_preexec, szPreExec)
    56395930FN_LOCAL_STRING(lp_postexec, szPostExec)
     
    56755966FN_GLOBAL_BOOL(lp_clustering, &Globals.clustering)
    56765967FN_GLOBAL_INTEGER(lp_ctdb_timeout, &Globals.ctdb_timeout)
     5968FN_GLOBAL_INTEGER(lp_ctdb_locktime_warn_threshold, &Globals.ctdb_locktime_warn_threshold)
    56775969FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
    56785970FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
     
    57226014FN_LOCAL_BOOL(lp_administrative_share, bAdministrative_share)
    57236015FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
     6016FN_LOCAL_BOOL(lp_print_notify_backchannel, bPrintNotifyBackchannel)
    57246017FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
    57256018FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
     
    57466039FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
    57476040FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes)
     6041FN_GLOBAL_BOOL(lp_async_smb_echo_handler, &Globals.bAsyncSMBEchoHandler)
     6042FN_GLOBAL_BOOL(lp_multicast_dns_register, &Globals.bMulticastDnsRegister)
    57486043FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
    57496044FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
     
    57906085FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
    57916086FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, &Globals.winbind_reconnect_delay)
     6087FN_GLOBAL_INTEGER(lp_winbind_max_clients, &Globals.winbind_max_clients)
    57926088FN_GLOBAL_LIST(lp_winbind_nss_info, &Globals.szWinbindNssInfo)
    57936089FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase)
     
    57976093FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrapping)
    57986094
     6095FN_GLOBAL_STRING(lp_ncalrpc_dir, &Globals.ncalrpc_dir)
     6096
    57996097/* local prototypes */
    58006098
    5801 static int map_parameter(const char *pszParmName);
    58026099static int map_parameter_canonical(const char *pszParmName, bool *inverse);
    58036100static const char *get_boolean(bool bool_value);
     
    58146111static void free_service_byindex(int iService);
    58156112static void free_param_opts(struct param_opt_struct **popts);
    5816 static char * canonicalize_servicename(const char *name);
    58176113static void show_parameter(int parmIndex);
    58186114static bool is_synonym_of(int parm1, int parm2, bool *inverse);
     
    58296125        char* param_key;
    58306126        struct param_opt_struct *data;
    5831        
     6127
    58326128        if (snum >= iNumServices) return NULL;
    5833        
     6129
    58346130        if (snum < 0) {
    58356131                data = Globals.param_opt;
     
    58386134                data = ServicePtrs[snum]->param_opt;
    58396135        }
    5840    
     6136
    58416137        if (asprintf(&param_key, "%s:%s", type, option) == -1) {
    58426138                DEBUG(0,("asprintf failed!\n"));
     
    58666162
    58676163        string_free(&param_key);
    5868        
     6164
    58696165        return NULL;
    58706166}
     
    59136209                return False;
    59146210        }
    5915        
     6211
    59166212        if (!set_boolean(s, &ret)) {
    59176213                DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
     
    59336229                return (-1);
    59346230        }
    5935        
     6231
    59366232        for (i=0; _enum[i].name; i++) {
    59376233                if (strequal(_enum[i].name,s))
     
    59636259{
    59646260        struct param_opt_struct *data = get_parametrics(snum, type, option);
    5965        
     6261
    59666262        if (data == NULL||data->value==NULL) {
    59676263                if (def) {
     
    59806276{
    59816277        struct param_opt_struct *data = get_parametrics(snum, type, option);
    5982        
     6278
    59836279        if (data == NULL||data->value==NULL)
    59846280                return def;
    5985                
     6281
    59866282        return data->value;
    59876283}
     
    59966292        if (data == NULL||data->value==NULL)
    59976293                return (const char **)def;
    5998                
     6294
    59996295        if (data->list==NULL) {
    6000                 data->list = str_list_make_v3(talloc_autofree_context(), data->value, NULL);
     6296                data->list = str_list_make_v3(NULL, data->value, NULL);
    60016297        }
    60026298
     
    60106306{
    60116307        struct param_opt_struct *data = get_parametrics(snum, type, option);
    6012        
     6308
    60136309        if (data && data->value && *data->value)
    60146310                return lp_int(data->value);
     
    60236319{
    60246320        struct param_opt_struct *data = get_parametrics(snum, type, option);
    6025        
     6321
    60266322        if (data && data->value && *data->value)
    60276323                return lp_ulong(data->value);
     
    60366332{
    60376333        struct param_opt_struct *data = get_parametrics(snum, type, option);
    6038        
     6334
    60396335        if (data && data->value && *data->value)
    60406336                return lp_bool(data->value);
     
    60506346{
    60516347        struct param_opt_struct *data = get_parametrics(snum, type, option);
    6052        
     6348
    60536349        if (data && data->value && *data->value && _enum)
    60546350                return lp_enum(data->value, _enum);
     
    61146410
    61156411        string_free(&pservice->szService);
    6116         bitmap_free(pservice->copymap);
     6412        TALLOC_FREE(pservice->copymap);
    61176413
    61186414        free_param_opts(&pservice->param_opt);
     
    61396435        if (ServicePtrs[idx]->szService) {
    61406436                char *canon_name = canonicalize_servicename(
     6437                        talloc_tos(),
    61416438                        ServicePtrs[idx]->szService );
    6142                
     6439
    61436440                dbwrap_delete_bystring(ServiceHash, canon_name );
    61446441                TALLOC_FREE(canon_name);
     
    61656462                i = getservicebyname(name, NULL);
    61666463                if (i >= 0) {
    6167                         /* Clean all parametric options for service */
    6168                         /* They will be added during parsing again */
    6169                         free_param_opts(&ServicePtrs[i]->param_opt);
    61706464                        return (i);
    61716465                }
     
    61826476                struct service **tsp;
    61836477                int *tinvalid;
    6184                
     6478
    61856479                tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct service *, num_to_alloc);
    61866480                if (tsp == NULL) {
     
    62156509        if (name)
    62166510                string_set(&ServicePtrs[i]->szService, name);
    6217                
     6511
    62186512        DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
    62196513                i, ServicePtrs[i]->szService));
     
    62226516                return (-1);
    62236517        }
    6224                
     6518
    62256519        return (i);
    62266520}
     
    62306524***************************************************************************/
    62316525
    6232 static char *canonicalize_servicename(const char *src)
     6526char *canonicalize_servicename(TALLOC_CTX *ctx, const char *src)
    62336527{
    62346528        char *result;
     
    62396533        }
    62406534
    6241         result = talloc_strdup(talloc_tos(), src);
     6535        result = talloc_strdup(ctx, src);
    62426536        SMB_ASSERT(result != NULL);
    62436537
     
    62666560                idx, name));
    62676561
    6268         canon_name = canonicalize_servicename( name );
     6562        canon_name = canonicalize_servicename(talloc_tos(), name );
    62696563
    62706564        dbwrap_store_bystring(ServiceHash, canon_name,
     
    64056699        /* Printer services must be printable. */
    64066700        ServicePtrs[i]->bPrint_ok = True;
    6407        
     6701
    64086702        DEBUG(3, ("adding printer service %s\n", pszPrintername));
    64096703
     
    67737067        }
    67747068
    6775         canon_name = canonicalize_servicename(pszServiceName);
     7069        canon_name = canonicalize_servicename(talloc_tos(), pszServiceName);
    67767070
    67777071        data = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name);
     
    68027096static void set_param_opt(struct param_opt_struct **opt_list,
    68037097                          const char *opt_name,
    6804                           const char *opt_value)
     7098                          const char *opt_value,
     7099                          unsigned flags)
    68057100{
    68067101        struct param_opt_struct *new_opt, *opt;
     
    68187113                /* If we already have same option, override it */
    68197114                if (strwicmp(opt->key, opt_name) == 0) {
     7115                        if ((opt->flags & FLAG_CMDLINE) &&
     7116                            !(flags & FLAG_CMDLINE)) {
     7117                                /* it's been marked as not to be
     7118                                   overridden */
     7119                                return;
     7120                        }
    68207121                        string_free(&opt->value);
    68217122                        TALLOC_FREE(opt->list);
    68227123                        opt->value = SMB_STRDUP(opt_value);
     7124                        opt->flags = flags;
    68237125                        not_added = false;
    68247126                        break;
     
    68317133            new_opt->value = SMB_STRDUP(opt_value);
    68327134            new_opt->list = NULL;
     7135            new_opt->flags = flags;
    68337136            DLIST_ADD(*opt_list, new_opt);
    68347137        }
     
    68957198                                    pserviceSource->copymap);
    68967199        }
    6897        
     7200
    68987201        data = pserviceSource->param_opt;
    68997202        while (data) {
    6900                 set_param_opt(&pserviceDest->param_opt, data->key, data->value);
     7203                set_param_opt(&pserviceDest->param_opt, data->key, data->value, data->flags);
    69017204                data = data->next;
    69027205        }
     
    69517254static struct smbconf_ctx *lp_smbconf_ctx(void)
    69527255{
    6953         WERROR werr;
     7256        sbcErr err;
    69547257        static struct smbconf_ctx *conf_ctx = NULL;
    69557258
    69567259        if (conf_ctx == NULL) {
    6957                 werr = smbconf_init(NULL, &conf_ctx, "registry:");
    6958                 if (!W_ERROR_IS_OK(werr)) {
     7260                err = smbconf_init(NULL, &conf_ctx, "registry:");
     7261                if (!SBC_ERROR_IS_OK(err)) {
    69597262                        DEBUG(1, ("error initializing registry configuration: "
    6960                                   "%s\n", win_errstr(werr)));
     7263                                  "%s\n", sbcErrorString(err)));
    69617264                        conf_ctx = NULL;
    69627265                }
     
    69987301bool process_registry_service(const char *service_name)
    69997302{
    7000         WERROR werr;
     7303        sbcErr err;
    70017304        struct smbconf_service *service = NULL;
    70027305        TALLOC_CTX *mem_ctx = talloc_stackframe();
     
    70197322        }
    70207323
    7021         werr = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
    7022         if (!W_ERROR_IS_OK(werr)) {
     7324        err = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
     7325        if (!SBC_ERROR_IS_OK(err)) {
    70237326                goto done;
    70247327        }
     
    70567359bool process_registry_shares(void)
    70577360{
    7058         WERROR werr;
     7361        sbcErr err;
    70597362        uint32_t count;
    70607363        struct smbconf_service **service = NULL;
     
    70687371        }
    70697372
    7070         werr = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
    7071         if (!W_ERROR_IS_OK(werr)) {
     7373        err = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
     7374        if (!SBC_ERROR_IS_OK(err)) {
    70727375                goto done;
    70737376        }
     
    70927395        return ret;
    70937396}
     7397
     7398/**
     7399 * reload those shares from registry that are already
     7400 * activated in the services array.
     7401 */
     7402static bool reload_registry_shares(void)
     7403{
     7404        int i;
     7405        bool ret = true;
     7406
     7407        for (i = 0; i < iNumServices; i++) {
     7408                if (!VALID(i)) {
     7409                        continue;
     7410                }
     7411
     7412                if (ServicePtrs[i]->usershare == USERSHARE_VALID) {
     7413                        continue;
     7414                }
     7415
     7416                ret = process_registry_service(ServicePtrs[i]->szService);
     7417                if (!ret) {
     7418                        goto done;
     7419                }
     7420        }
     7421
     7422done:
     7423        return ret;
     7424}
     7425
    70947426
    70957427#define MAX_INCLUDE_DEPTH 100
     
    71317463                f->subfname = SMB_STRDUP(subfname);
    71327464                if (!f->subfname) {
     7465                        SAFE_FREE(f->name);
    71337466                        SAFE_FREE(f);
    71347467                        return;
     
    71417474                        f->modtime = t;
    71427475        }
     7476        return;
    71437477}
    71447478
     
    71907524
    71917525        while (f) {
    7192                 char *n2 = NULL;
    71937526                time_t mod_time;
    71947527
     
    72067539                        }
    72077540                } else {
    7208                         n2 = alloc_sub_basic(get_current_username(),
    7209                                             current_user_info.domain,
    7210                                             f->name);
     7541                        char *n2 = NULL;
     7542                        n2 = talloc_sub_basic(talloc_tos(),
     7543                                              get_current_username(),
     7544                                              current_user_info.domain,
     7545                                              f->name);
    72117546                        if (!n2) {
    72127547                                return false;
     
    72277562                                f->modtime = mod_time;
    72287563                                SAFE_FREE(f->subfname);
    7229                                 f->subfname = n2; /* Passing ownership of
    7230                                                      return from alloc_sub_basic
    7231                                                      above. */
     7564                                f->subfname = SMB_STRDUP(n2);
     7565                                TALLOC_FREE(n2);
    72327566                                return true;
    72337567                        }
    7234                         SAFE_FREE(n2);
     7568                        TALLOC_FREE(n2);
    72357569                }
    72367570                f = f->next;
     
    72497583{
    72507584        bool ret;
    7251         char *netbios_name = alloc_sub_basic(get_current_username(),
    7252                                         current_user_info.domain,
    7253                                         pszParmValue);
     7585        char *netbios_name = talloc_sub_basic(
     7586                talloc_tos(), get_current_username(), current_user_info.domain,
     7587                pszParmValue);
    72547588
    72557589        ret = set_global_myname(netbios_name);
    7256         SAFE_FREE(netbios_name);
     7590        TALLOC_FREE(netbios_name);
    72577591        string_set(&Globals.szNetbiosName,global_myname());
    72587592
     
    72727606}
    72737607
     7608static bool handle_dos_charset(int snum, const char *pszParmValue, char **ptr)
     7609{
     7610        bool is_utf8 = false;
     7611        size_t len = strlen(pszParmValue);
     7612
     7613        if (len == 4 || len == 5) {
     7614                /* Don't use StrCaseCmp here as we don't want to
     7615                   initialize iconv. */
     7616                if ((toupper_m(pszParmValue[0]) == 'U') &&
     7617                    (toupper_m(pszParmValue[1]) == 'T') &&
     7618                    (toupper_m(pszParmValue[2]) == 'F')) {
     7619                        if (len == 4) {
     7620                                if (pszParmValue[3] == '8') {
     7621                                        is_utf8 = true;
     7622                                }
     7623                        } else {
     7624                                if (pszParmValue[3] == '-' &&
     7625                                    pszParmValue[4] == '8') {
     7626                                        is_utf8 = true;
     7627                                }
     7628                        }
     7629                }
     7630        }
     7631
     7632        if (strcmp(*ptr, pszParmValue) != 0) {
     7633                if (is_utf8) {
     7634                        DEBUG(0,("ERROR: invalid DOS charset: 'dos charset' must not "
     7635                                "be UTF8, using (default value) %s instead.\n",
     7636                                DEFAULT_DOS_CHARSET));
     7637                        pszParmValue = DEFAULT_DOS_CHARSET;
     7638                }
     7639                string_set(ptr, pszParmValue);
     7640                init_iconv();
     7641        }
     7642        return True;
     7643}
     7644
    72747645
    72757646
     
    72777648{
    72787649        bool ret;
    7279        
     7650
    72807651        ret = set_global_myworkgroup(pszParmValue);
    72817652        string_set(&Globals.szWorkgroup,lp_workgroup());
    7282        
     7653
    72837654        return ret;
    72847655}
     
    72877658{
    72887659        bool ret;
    7289        
     7660
    72907661        ret = set_global_scope(pszParmValue);
    72917662        string_set(&Globals.szNetbiosScope,global_scope());
     
    72977668{
    72987669        TALLOC_FREE(Globals.szNetbiosAliases);
    7299         Globals.szNetbiosAliases = str_list_make_v3(talloc_autofree_context(), pszParmValue, NULL);
     7670        Globals.szNetbiosAliases = str_list_make_v3(NULL, pszParmValue, NULL);
    73007671        return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
    73017672}
     
    73337704        }
    73347705
    7335         fname = alloc_sub_basic(get_current_username(),
    7336                                 current_user_info.domain,
    7337                                 pszParmValue);
     7706        fname = talloc_sub_basic(talloc_tos(), get_current_username(),
     7707                                 current_user_info.domain,
     7708                                 pszParmValue);
    73387709
    73397710        add_to_file_list(pszParmValue, fname);
     
    73467717                ret = pm_process(fname, do_section, do_parameter, NULL);
    73477718                include_depth--;
    7348                 SAFE_FREE(fname);
     7719                TALLOC_FREE(fname);
    73497720                return ret;
    73507721        }
    73517722
    73527723        DEBUG(2, ("Can't find include file %s\n", fname));
    7353         SAFE_FREE(fname);
     7724        TALLOC_FREE(fname);
    73547725        return true;
    73557726}
     
    74457816}
    74467817
     7818static bool handle_idmap_backend(int snum, const char *pszParmValue, char **ptr)
     7819{
     7820        lp_do_parameter(snum, "idmap config * : backend", pszParmValue);
     7821
     7822        return true;
     7823}
     7824
    74477825/* Do some simple checks on "idmap [ug]id" parameter values */
    74487826
    74497827static bool handle_idmap_uid(int snum, const char *pszParmValue, char **ptr)
    74507828{
    7451         uint32 low, high;
    7452 
    7453         if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
    7454                 return False;
    7455 
    7456         /* Parse OK */
    7457 
    7458         string_set(ptr, pszParmValue);
    7459 
    7460         idmap_uid_low = low;
    7461         idmap_uid_high = high;
     7829        lp_do_parameter(snum, "idmap config * : range", pszParmValue);
    74627830
    74637831        return True;
     
    74667834static bool handle_idmap_gid(int snum, const char *pszParmValue, char **ptr)
    74677835{
    7468         uint32 low, high;
    7469 
    7470         if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
    7471                 return False;
    7472 
    7473         /* Parse OK */
    7474 
    7475         string_set(ptr, pszParmValue);
    7476 
    7477         idmap_gid_low = low;
    7478         idmap_gid_high = high;
     7836        lp_do_parameter(snum, "idmap config * : range", pszParmValue);
    74797837
    74807838        return True;
     
    75927950{
    75937951        int i;
    7594         if (pservice->copymap) {
    7595                 bitmap_free(pservice->copymap);
    7596         }
    7597         pservice->copymap = bitmap_allocate(NUMPARAMETERS);
     7952
     7953        TALLOC_FREE(pservice->copymap);
     7954
     7955        pservice->copymap = bitmap_talloc(NULL, NUMPARAMETERS);
    75987956        if (!pservice->copymap)
    75997957                DEBUG(0,
     
    76528010                opt_list = (snum < 0)
    76538011                        ? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
    7654                 set_param_opt(opt_list, pszParmName, pszParmValue);
     8012                set_param_opt(opt_list, pszParmName, pszParmValue, 0);
    76558013
    76568014                return (True);
     8015        }
     8016
     8017        /* if it's already been set by the command line, then we don't
     8018           override here */
     8019        if (parm_table[parmnum].flags & FLAG_CMDLINE) {
     8020                return true;
    76578021        }
    76588022
     
    77238087                        TALLOC_FREE(*((char ***)parm_ptr));
    77248088                        *(char ***)parm_ptr = str_list_make_v3(
    7725                                 talloc_autofree_context(), pszParmValue, NULL);
     8089                                NULL, pszParmValue, NULL);
    77268090                        break;
    77278091
     
    77468110
    77478111/***************************************************************************
     8112set a parameter, marking it with FLAG_CMDLINE. Parameters marked as
     8113FLAG_CMDLINE won't be overridden by loads from smb.conf.
     8114***************************************************************************/
     8115
     8116static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values)
     8117{
     8118        int parmnum, i;
     8119        parmnum = map_parameter(pszParmName);
     8120        if (parmnum >= 0) {
     8121                parm_table[parmnum].flags &= ~FLAG_CMDLINE;
     8122                if (!lp_do_parameter(-1, pszParmName, pszParmValue)) {
     8123                        return false;
     8124                }
     8125                parm_table[parmnum].flags |= FLAG_CMDLINE;
     8126
     8127                /* we have to also set FLAG_CMDLINE on aliases.  Aliases must
     8128                 * be grouped in the table, so we don't have to search the
     8129                 * whole table */
     8130                for (i=parmnum-1;i>=0 && parm_table[i].ptr == parm_table[parmnum].ptr;i--) {
     8131                        parm_table[i].flags |= FLAG_CMDLINE;
     8132                }
     8133                for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].ptr == parm_table[parmnum].ptr;i++) {
     8134                        parm_table[i].flags |= FLAG_CMDLINE;
     8135                }
     8136
     8137                if (store_values) {
     8138                        store_lp_set_cmdline(pszParmName, pszParmValue);
     8139                }
     8140                return true;
     8141        }
     8142
     8143        /* it might be parametric */
     8144        if (strchr(pszParmName, ':') != NULL) {
     8145                set_param_opt(&Globals.param_opt, pszParmName, pszParmValue, FLAG_CMDLINE);
     8146                if (store_values) {
     8147                        store_lp_set_cmdline(pszParmName, pszParmValue);
     8148                }
     8149                return true;
     8150        }
     8151
     8152        DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",  pszParmName));
     8153        return true;
     8154}
     8155
     8156bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
     8157{
     8158        return lp_set_cmdline_helper(pszParmName, pszParmValue, true);
     8159}
     8160
     8161/***************************************************************************
    77488162 Process a parameter.
    77498163***************************************************************************/
     
    77618175}
    77628176
    7763 /***************************************************************************
     8177/*
     8178  set a option from the commandline in 'a=b' format. Use to support --option
     8179*/
     8180bool lp_set_option(const char *option)
     8181{
     8182        char *p, *s;
     8183        bool ret;
     8184
     8185        s = talloc_strdup(NULL, option);
     8186        if (!s) {
     8187                return false;
     8188        }
     8189
     8190        p = strchr(s, '=');
     8191        if (!p) {
     8192                talloc_free(s);
     8193                return false;
     8194        }
     8195
     8196        *p = 0;
     8197
     8198        /* skip white spaces after the = sign */
     8199        do {
     8200                p++;
     8201        } while (*p == ' ');
     8202
     8203        ret = lp_set_cmdline(s, p);
     8204        talloc_free(s);
     8205        return ret;
     8206}
     8207
     8208/**************************************************************************
    77648209 Print a parameter of the specified type.
    77658210***************************************************************************/
     
    79208365                        return (False);
    79218366                }
     8367                /* Clean all parametric options for service */
     8368                /* They will be added during parsing again */
     8369                free_param_opts(&ServicePtrs[iServiceIndex]->param_opt);
    79228370        }
    79238371
     
    79688416        int i;
    79698417        struct param_opt_struct *data;
    7970        
     8418
    79718419        fprintf(f, "[global]\n");
    79728420
     
    80138461        int i;
    80148462        struct param_opt_struct *data;
    8015        
     8463
    80168464        if (pService != &sDefault)
    80178465                fprintf(f, "[%s]\n", pService->szService);
     
    80258473                    (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
    80268474                {
    8027                
    80288475                        int pdiff = PTR_DIFF(parm_table[i].ptr, &sDefault);
    80298476
     
    81628609                                parm_table[(*i) - 1].ptr))
    81638610                                continue;
    8164                        
     8611
    81658612                        if (is_default(*i) && !allparameters)
    81668613                                continue;
     
    82758722***************************************************************************/
    82768723
    8277 void lp_add_one_printer(const char *name, const char *comment, void *pdata)
     8724void lp_add_one_printer(const char *name, const char *comment,
     8725                        const char *location, void *pdata)
    82788726{
    82798727        int printers = lp_servicenumber(PRINTERS_NAME);
     
    83878835}
    83888836
    8389 /*******************************************************************
    8390  Set the server type we will announce as via nmbd.
    8391 ********************************************************************/
    8392 
    8393 static const struct srv_role_tab {
    8394         uint32 role;
    8395         const char *role_str;
    8396 } srv_role_tab [] = {
    8397         { ROLE_STANDALONE, "ROLE_STANDALONE" },
    8398         { ROLE_DOMAIN_MEMBER, "ROLE_DOMAIN_MEMBER" },
    8399         { ROLE_DOMAIN_BDC, "ROLE_DOMAIN_BDC" },
    8400         { ROLE_DOMAIN_PDC, "ROLE_DOMAIN_PDC" },
    8401         { 0, NULL }
    8402 };
    8403 
    8404 const char* server_role_str(uint32 role)
    8405 {
    8406         int i = 0;
    8407         for (i=0; srv_role_tab[i].role_str; i++) {
    8408                 if (role == srv_role_tab[i].role) {
    8409                         return srv_role_tab[i].role_str;
    8410                 }
    8411         }
    8412         return NULL;
    8413 }
    8414 
    8415 static void set_server_role(void)
    8416 {
    8417         server_role = ROLE_STANDALONE;
    8418 
    8419         switch (lp_security()) {
    8420                 case SEC_SHARE:
    8421                         if (lp_domain_logons())
    8422                                 DEBUG(0, ("Server's Role (logon server) conflicts with share-level security\n"));
    8423                         break;
    8424                 case SEC_SERVER:
    8425                         if (lp_domain_logons())
    8426                                 DEBUG(0, ("Server's Role (logon server) conflicts with server-level security\n"));
    8427                         /* this used to be considered ROLE_DOMAIN_MEMBER but that's just wrong */
    8428                         server_role = ROLE_STANDALONE;
    8429                         break;
    8430                 case SEC_DOMAIN:
    8431                         if (lp_domain_logons()) {
    8432                                 DEBUG(1, ("Server's Role (logon server) NOT ADVISED with domain-level security\n"));
    8433                                 server_role = ROLE_DOMAIN_BDC;
    8434                                 break;
    8435                         }
    8436                         server_role = ROLE_DOMAIN_MEMBER;
    8437                         break;
    8438                 case SEC_ADS:
    8439                         if (lp_domain_logons()) {
    8440                                 server_role = ROLE_DOMAIN_PDC;
    8441                                 break;
    8442                         }
    8443                         server_role = ROLE_DOMAIN_MEMBER;
    8444                         break;
    8445                 case SEC_USER:
    8446                         if (lp_domain_logons()) {
    8447 
    8448                                 if (Globals.iDomainMaster) /* auto or yes */
    8449                                         server_role = ROLE_DOMAIN_PDC;
    8450                                 else
    8451                                         server_role = ROLE_DOMAIN_BDC;
    8452                         }
    8453                         break;
    8454                 default:
    8455                         DEBUG(0, ("Server's Role undefined due to unknown security mode\n"));
    8456                         break;
    8457         }
    8458 
    8459         DEBUG(10, ("set_server_role: role = %s\n", server_role_str(server_role)));
    8460 }
    8461 
    84628837/***********************************************************
    84638838 If we should send plaintext/LANMAN passwords in the clinet
     
    85358910                        char **pp_sharepath,
    85368911                        char **pp_comment,
    8537                         SEC_DESC **ppsd,
     8912                        char **pp_cp_servicename,
     8913                        struct security_descriptor **ppsd,
    85388914                        bool *pallow_guest)
    85398915{
     
    86018977                if (lines[4][9] == 'y') {
    86028978                        *pallow_guest = True;
     8979                }
     8980
     8981                /* Backwards compatible extension to file version #2. */
     8982                if (numlines > 5) {
     8983                        if (strncmp(lines[5], "sharename=", 10) != 0) {
     8984                                return USERSHARE_MALFORMED_SHARENAME_DEF;
     8985                        }
     8986                        if (!strequal(&lines[5][10], servicename)) {
     8987                                return USERSHARE_BAD_SHARENAME;
     8988                        }
     8989                        *pp_cp_servicename = talloc_strdup(ctx, &lines[5][10]);
     8990                        if (!*pp_cp_servicename) {
     8991                                return USERSHARE_POSIX_ERR;
     8992                        }
     8993                }
     8994        }
     8995
     8996        if (*pp_cp_servicename == NULL) {
     8997                *pp_cp_servicename = talloc_strdup(ctx, servicename);
     8998                if (!*pp_cp_servicename) {
     8999                        return USERSHARE_POSIX_ERR;
    86039000                }
    86049001        }
     
    87139110        char *sharepath = NULL;
    87149111        char *comment = NULL;
    8715         fstring service_name;
     9112        char *cp_service_name = NULL;
    87169113        char **lines = NULL;
    87179114        int numlines = 0;
    87189115        int fd = -1;
    87199116        int iService = -1;
    8720         TALLOC_CTX *ctx = NULL;
    8721         SEC_DESC *psd = NULL;
     9117        TALLOC_CTX *ctx = talloc_stackframe();
     9118        struct security_descriptor *psd = NULL;
    87229119        bool guest_ok = False;
     9120        char *canon_name = NULL;
     9121        bool added_service = false;
     9122        int ret = -1;
    87239123
    87249124        /* Ensure share name doesn't contain invalid characters. */
     
    87279127                        "invalid characters (any of %s)\n",
    87289128                        file_name, INVALID_SHARENAME_CHARS ));
    8729                 return -1;
    8730         }
    8731 
    8732         fstrcpy(service_name, file_name);
    8733 
    8734         if (asprintf(&fname, "%s/%s", dir_name, file_name) < 0) {
     9129                goto out;
     9130        }
     9131
     9132        canon_name = canonicalize_servicename(ctx, file_name);
     9133        if (!canon_name) {
     9134                goto out;
     9135        }
     9136
     9137        fname = talloc_asprintf(ctx, "%s/%s", dir_name, file_name);
     9138        if (!fname) {
     9139                goto out;
    87359140        }
    87369141
     
    87419146                DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
    87429147                        fname, strerror(errno) ));
    8743                 SAFE_FREE(fname);
    8744                 return -1;
     9148                goto out;
    87459149        }
    87469150
     
    87489152           other strange filetype. */
    87499153        if (!check_usershare_stat(fname, &lsbuf)) {
    8750                 SAFE_FREE(fname);
    8751                 return -1;
    8752         }
    8753 
    8754         {
    8755                 char *canon_name = canonicalize_servicename(service_name);
     9154                goto out;
     9155        }
     9156
     9157        {
    87569158                TDB_DATA data = dbwrap_fetch_bystring(
    87579159                        ServiceHash, canon_name, canon_name);
     
    87629164                        iService = *(int *)data.dptr;
    87639165                }
    8764                 TALLOC_FREE(canon_name);
    87659166        }
    87669167
     
    87709171                /* Nothing changed - Mark valid and return. */
    87719172                DEBUG(10,("process_usershare_file: service %s not changed.\n",
    8772                         service_name ));
     9173                        canon_name ));
    87739174                ServicePtrs[iService]->usershare = USERSHARE_VALID;
    8774                 SAFE_FREE(fname);
    8775                 return iService;
     9175                ret = iService;
     9176                goto out;
    87769177        }
    87779178
     
    87869187                DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
    87879188                        fname, strerror(errno) ));
    8788                 SAFE_FREE(fname);
    8789                 return -1;
     9189                goto out;
    87909190        }
    87919191
     
    87959195                DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
    87969196                        fname, strerror(errno) ));
    8797                 SAFE_FREE(fname);
    8798                 return -1;
     9197                goto out;
    87999198        }
    88009199
     
    88049203                DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
    88059204                        "Symlink spoofing going on ?\n", fname ));
    8806                 SAFE_FREE(fname);
    8807                 return -1;
     9205                goto out;
    88089206        }
    88099207
     
    88119209           other strange filetype. */
    88129210        if (!check_usershare_stat(fname, &sbuf)) {
    8813                 SAFE_FREE(fname);
    8814                 return -1;
     9211                goto out;
    88159212        }
    88169213
     
    88219218                DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
    88229219                        fname, (unsigned int)sbuf.st_ex_uid ));
    8823                 SAFE_FREE(fname);
    8824                 return -1;
    8825         }
    8826 
    8827         SAFE_FREE(fname);
    8828 
    8829         /* Should we allow printers to be shared... ? */
    8830         ctx = talloc_init("usershare_sd_xctx");
    8831         if (!ctx) {
    8832                 TALLOC_FREE(lines);
    8833                 return 1;
    8834         }
    8835 
    8836         if (parse_usershare_file(ctx, &sbuf, service_name,
     9220                goto out;
     9221        }
     9222
     9223        if (parse_usershare_file(ctx, &sbuf, file_name,
    88379224                        iService, lines, numlines, &sharepath,
    8838                         &comment, &psd, &guest_ok) != USERSHARE_OK) {
    8839                 talloc_destroy(ctx);
    8840                 TALLOC_FREE(lines);
    8841                 return -1;
    8842         }
    8843 
    8844         TALLOC_FREE(lines);
     9225                        &comment, &cp_service_name,
     9226                        &psd, &guest_ok) != USERSHARE_OK) {
     9227                goto out;
     9228        }
    88459229
    88469230        /* Everything ok - add the service possibly using a template. */
     
    88519235                }
    88529236
    8853                 if ((iService = add_a_service(sp, service_name)) < 0) {
     9237                if ((iService = add_a_service(sp, cp_service_name)) < 0) {
    88549238                        DEBUG(0, ("process_usershare_file: Failed to add "
    8855                                 "new service %s\n", service_name));
    8856                         talloc_destroy(ctx);
    8857                         return -1;
     9239                                "new service %s\n", cp_service_name));
     9240                        goto out;
    88589241                }
     9242
     9243                added_service = true;
    88599244
    88609245                /* Read only is controlled by usershare ACL below. */
     
    88639248
    88649249        /* Write the ACL of the new/modified share. */
    8865         if (!set_share_security(service_name, psd)) {
     9250        if (!set_share_security(canon_name, psd)) {
    88669251                 DEBUG(0, ("process_usershare_file: Failed to set share "
    88679252                        "security for user share %s\n",
    8868                         service_name ));
    8869                 lp_remove_service(iService);
    8870                 talloc_destroy(ctx);
    8871                 return -1;
     9253                        canon_name ));
     9254                goto out;
    88729255        }
    88739256
     
    88889271        string_set(&ServicePtrs[iService]->comment, comment);
    88899272
    8890         talloc_destroy(ctx);
    8891 
    8892         return iService;
     9273        ret = iService;
     9274
     9275  out:
     9276
     9277        if (ret == -1 && iService != -1 && added_service) {
     9278                lp_remove_service(iService);
     9279        }
     9280
     9281        TALLOC_FREE(lines);
     9282        TALLOC_FREE(ctx);
     9283        return ret;
    88939284}
    88949285
     
    91999590***************************************************************************/
    92009591
    9201 bool lp_load_ex(const char *pszFname,
    9202                 bool global_only,
    9203                 bool save_defaults,
    9204                 bool add_ipc,
    9205                 bool initialize_globals,
    9206                 bool allow_include_registry,
    9207                 bool allow_registry_shares)
     9592static bool lp_load_ex(const char *pszFname,
     9593                       bool global_only,
     9594                       bool save_defaults,
     9595                       bool add_ipc,
     9596                       bool initialize_globals,
     9597                       bool allow_include_registry,
     9598                       bool allow_registry_shares)
    92089599{
    92099600        char *n2 = NULL;
     
    92189609        bAllowIncludeRegistry = allow_include_registry;
    92199610
    9220         init_globals(! initialize_globals);
    9221         debug_init();
     9611        init_globals(initialize_globals);
    92229612
    92239613        free_file_list();
     
    92309620        free_param_opts(&Globals.param_opt);
    92319621
     9622        lp_do_parameter(-1, "idmap config * : backend", Globals.szIdmapBackend);
     9623
    92329624        /* We get sections first, so have to start 'behind' to make up */
    92339625        iServiceIndex = -1;
    92349626
    92359627        if (lp_config_backend_is_file()) {
    9236                 n2 = alloc_sub_basic(get_current_username(),
     9628                n2 = talloc_sub_basic(talloc_tos(), get_current_username(),
    92379629                                        current_user_info.domain,
    92389630                                        pszFname);
     
    92449636
    92459637                bRetval = pm_process(n2, do_section, do_parameter, NULL);
    9246                 SAFE_FREE(n2);
     9638                TALLOC_FREE(n2);
    92479639
    92489640                /* finish up the last section */
     
    92669658                        DEBUG(1, ("lp_load_ex: changing to config backend "
    92679659                                  "registry\n"));
    9268                         init_globals(false);
     9660                        init_globals(true);
    92699661                        lp_kill_all_services();
    92709662                        return lp_load_ex(pszFname, global_only, save_defaults,
     
    92819673        }
    92829674
    9283         if (bRetval && lp_registry_shares() && allow_registry_shares) {
    9284                 bRetval = process_registry_shares();
     9675        if (bRetval && lp_registry_shares()) {
     9676                if (allow_registry_shares) {
     9677                        bRetval = process_registry_shares();
     9678                } else {
     9679                        bRetval = reload_registry_shares();
     9680                }
    92859681        }
    92869682
     
    93009696        set_allowed_client_auth();
    93019697
     9698        if (lp_security() == SEC_SHARE) {
     9699                DEBUG(1, ("WARNING: The security=share option is deprecated\n"));
     9700        } else if (lp_security() == SEC_SERVER) {
     9701                DEBUG(1, ("WARNING: The security=server option is deprecated\n"));
     9702        }
     9703
     9704        if (lp_security() == SEC_ADS && strchr(lp_passwordserver(), ':')) {
     9705                DEBUG(1, ("WARNING: The optional ':port' in password server = %s is deprecated\n",
     9706                          lp_passwordserver()));
     9707        }
     9708
    93029709        bLoaded = True;
    93039710
     
    93079714                lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1");
    93089715        }
     9716
    93099717#ifdef __OS2__
    93109718        if (lp_is_in_client() && newLockDir) {
     
    93149722           }
    93159723           lp_do_parameter(GLOBAL_SECTION_SNUM, "lock directory", s);
     9724// @todo what do these directories do
     9725           lp_do_parameter(GLOBAL_SECTION_SNUM, "state directory", s);
     9726           lp_do_parameter(GLOBAL_SECTION_SNUM, "cache directory", s);
    93169727           SAFE_FREE(s);
    93179728           newLockDir = False;
    93189729        }
    93199730#endif
    9320 
    93219731        init_iconv();
    93229732
     
    93379747                          add_ipc,
    93389748                          initialize_globals,
    9339                           true, false);
     9749                          true,   /* allow_include_registry */
     9750                          false); /* allow_registry_shares*/
    93409751}
    93419752
     
    93439754{
    93449755        return lp_load_ex(pszFname,
    9345                           true,
    9346                           false,
    9347                           false,
    9348                           true,
    9349                           false,
    9350                           false);
     9756                          true,   /* global only */
     9757                          false,  /* save_defaults */
     9758                          false,  /* add_ipc */
     9759                          true,   /* initialize_globals */
     9760                          false,  /* allow_include_registry */
     9761                          false); /* allow_registry_shares*/
    93519762}
    93529763
     
    93629773                          add_ipc,
    93639774                          initialize_globals,
    9364                           true,
    9365                           true);
     9775                          true,  /* allow_include_registry */
     9776                          true); /* allow_registry_shares*/
    93669777}
    93679778
     
    94209831        int iService;
    94219832        fstring serviceName;
    9422        
     9833
    94239834        if (!pszServiceName) {
    94249835                return GLOBAL_SECTION_SNUM;
    94259836        }
    9426        
     9837
    94279838        for (iService = iNumServices - 1; iService >= 0; iService--) {
    94289839                if (VALID(iService) && ServicePtrs[iService]->szService) {
     
    94809891{
    94819892        struct share_params *result;
    9482         char *sname;
     9893        char *sname = NULL;
    94839894        int snum;
    94849895
    9485         if (!(sname = SMB_STRDUP(sharename))) {
    9486                 return NULL;
    9487         }
    9488 
    9489         snum = find_service(sname);
    9490         SAFE_FREE(sname);
    9491 
    9492         if (snum < 0) {
     9896        snum = find_service(mem_ctx, sharename, &sname);
     9897        if (snum < 0 || sname == NULL) {
    94939898                return NULL;
    94949899        }
     
    95749979                label = lp_servicename(snum);
    95759980        }
    9576                
     9981
    95779982        /* This returns a 33 byte guarenteed null terminated string. */
    95789983        ret = talloc_strndup(talloc_tos(), label, 32);
     
    963910044
    964010045/***********************************************************
    9641  returns role of Samba server
     10046 If we are PDC then prefer us as DMB
    964210047************************************************************/
    964310048
    9644 int lp_server_role(void)
    9645 {
    9646         return server_role;
     10049bool lp_domain_master(void)
     10050{
     10051        if (Globals.iDomainMaster == Auto)
     10052                return (lp_server_role() == ROLE_DOMAIN_PDC);
     10053
     10054        return (bool)Globals.iDomainMaster;
    964710055}
    964810056
     
    965110059************************************************************/
    965210060
    9653 bool lp_domain_master(void)
    9654 {
    9655         if (Globals.iDomainMaster == Auto)
    9656                 return (lp_server_role() == ROLE_DOMAIN_PDC);
    9657 
    9658         return (bool)Globals.iDomainMaster;
     10061bool lp_domain_master_true_or_auto(void)
     10062{
     10063        if (Globals.iDomainMaster) /* auto or yes */
     10064                return true;
     10065
     10066        return false;
    965910067}
    966010068
     
    994710355{
    994810356        char *sock_addr = Globals.szSocketAddress;
    9949        
     10357
    995010358        if (sock_addr[0] == '\0'){
    995110359                string_set(&Globals.szSocketAddress, "0.0.0.0");
     
    999010398        return lp_widelinks_internal(snum);
    999110399}
     10400
     10401bool lp_writeraw(void)
     10402{
     10403        if (lp_async_smb_echo_handler()) {
     10404                return false;
     10405        }
     10406        return _lp_writeraw();
     10407}
     10408
     10409bool lp_readraw(void)
     10410{
     10411        if (lp_async_smb_echo_handler()) {
     10412                return false;
     10413        }
     10414        return _lp_readraw();
     10415}
  • trunk/server/source3/param/test_lp_load.c

    r414 r745  
    1919
    2020#include "includes.h"
    21 
    22 extern bool AllowDebugChange;
     21#include "popt_common.h"
    2322
    2423int main(int argc, const char **argv)
     
    4140
    4241        load_case_tables();
    43         DEBUGLEVEL_CLASS[DBGC_ALL] = 0;
     42        lp_set_cmdline("log level", "0");
    4443
    4544        pc = poptGetContext(NULL, argc, argv, long_options,
     
    4948        while(poptGetNextOpt(pc) != -1);
    5049
    51         setup_logging(poptGetArg(pc), True);
     50        setup_logging(poptGetArg(pc), DEBUG_STDERR);
    5251
    5352        if (poptPeekArg(pc)) {
     
    6059                count = atoi(count_str);
    6160        }
    62 
    63         dbf = x_stderr;
    64         /* Don't let the debuglevel be changed by smb.conf. */
    65         AllowDebugChange = False;
    6661
    6762        for (i=0; i < count; i++) {
Note: See TracChangeset for help on using the changeset viewer.