Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

Location:
vendor/current/source3/param
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/param/loadparm.c

    r597 r740  
    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
     
    109120        char *value;
    110121        char **list;
     122        unsigned flags;
    111123};
    112124
     
    182194        char *szAbortShutdownScript;
    183195        char *szUsernameMapScript;
     196        int iUsernameMapCacheTime;
    184197        char *szCheckPasswordScript;
    185198        char *szWINSHook;
     
    205218        bool bWinbindRpcOnly;
    206219        bool bCreateKrb5Conf;
     220        int winbindMaxDomainConnections;
    207221        char *szIdmapBackend;
    208         char *szIdmapAllocBackend;
     222        bool bIdmapReadOnly;
    209223        char *szAddShareCommand;
    210224        char *szChangeShareCommand;
     
    252266        int winbind_cache_time;
    253267        int winbind_reconnect_delay;
    254         int winbind_max_idle_children;
     268        int winbind_max_clients;
    255269        char **szWinbindNssInfo;
    256270        int iLockSpinTime;
     
    275289        bool clustering;
    276290        int ctdb_timeout;
     291        int ctdb_locktime_warn_threshold;
    277292        int ldap_passwd_sync;
    278293        int ldap_replication_sleep;
     
    327342        bool bClientUseSpnego;
    328343        bool client_use_spnego_principal;
     344        bool send_spnego_principal;
    329345        bool bDebugPrefixTimestamp;
    330346        bool bDebugHiresTimestamp;
     
    355371        int iIdmapNegativeCacheTime;
    356372        bool bResetOnZeroVC;
     373        bool bLogWriteableFilesOnExit;
    357374        int iKeepalive;
    358375        int iminreceivefile;
     
    361378        char *szSMBPerfcountModule;
    362379        bool bMapUntrustedToDomain;
     380        bool bAsyncSMBEchoHandler;
     381        bool bMulticastDnsRegister;
     382        int ismb2_max_read;
     383        int ismb2_max_write;
     384        int ismb2_max_trans;
     385        int ismb2_max_credits;
     386        char *ncalrpc_dir;
    363387};
    364388
     
    452476        bool bGuest_ok;
    453477        bool bPrint_ok;
     478        bool bPrintNotifyBackchannel;
    454479        bool bMap_system;
    455480        bool bMap_hidden;
     
    596621        False,                  /* bGuest_ok */
    597622        False,                  /* bPrint_ok */
     623        True,                   /* bPrintNotifyBackchannel */
    598624        False,                  /* bMap_system */
    599625        False,                  /* bMap_hidden */
     
    667693static bool bInGlobalSection = True;
    668694static bool bGlobalOnly = False;
    669 static int server_role;
    670695static int default_server_announce;
    671696
     
    676701static bool handle_copy( int snum, const char *pszParmValue, char **ptr);
    677702static bool handle_netbios_name( int snum, const char *pszParmValue, char **ptr);
     703static bool handle_idmap_backend(int snum, const char *pszParmValue, char **ptr);
    678704static bool handle_idmap_uid( int snum, const char *pszParmValue, char **ptr);
    679705static bool handle_idmap_gid( int snum, const char *pszParmValue, char **ptr);
     
    683709static bool handle_netbios_scope( int snum, const char *pszParmValue, char **ptr );
    684710static bool handle_charset( int snum, const char *pszParmValue, char **ptr );
     711static bool handle_dos_charset( int snum, const char *pszParmValue, char **ptr );
    685712static bool handle_printing( int snum, const char *pszParmValue, char **ptr);
    686713static bool handle_ldap_debug_level( int snum, const char *pszParmValue, char **ptr);
    687714
    688 static void set_server_role(void);
    689715static void set_default_server_announce_type(void);
    690716static void set_allowed_client_auth(void);
     
    693719
    694720static void add_to_file_list(const char *fname, const char *subfname);
     721static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values);
    695722
    696723static const struct enum_list enum_protocol[] = {
     
    728755        {PRINT_LPRNT, "nt"},
    729756        {PRINT_LPROS2, "os2"},
    730 #ifdef DEVELOPER
     757#if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
    731758        {PRINT_TEST, "test"},
    732759        {PRINT_VLP, "vlp"},
     
    818845        {-1, NULL}
    819846};
    820 
    821 /* Client-side offline caching policy types */
    822 #define CSC_POLICY_MANUAL 0
    823 #define CSC_POLICY_DOCUMENTS 1
    824 #define CSC_POLICY_PROGRAMS 2
    825 #define CSC_POLICY_DISABLE 3
    826847
    827848static const struct enum_list enum_csc_policy[] = {
     
    936957                .p_class        = P_GLOBAL,
    937958                .ptr            = &Globals.dos_charset,
    938                 .special        = handle_charset,
     959                .special        = handle_dos_charset,
    939960                .enum_list      = NULL,
    940961                .flags          = FLAG_ADVANCED
     
    10991120        },
    11001121        {
    1101                 .label          = "update encrypted",
    1102                 .type           = P_BOOL,
    1103                 .p_class        = P_GLOBAL,
    1104                 .ptr            = &Globals.bUpdateEncrypt,
    1105                 .special        = NULL,
    1106                 .enum_list      = NULL,
    1107                 .flags          = FLAG_ADVANCED,
    1108         },
    1109         {
    11101122                .label          = "client schannel",
    11111123                .type           = P_ENUM,
     
    11501162                .special        = NULL,
    11511163                .enum_list      = NULL,
    1152                 .flags          = FLAG_ADVANCED,
     1164                .flags          = FLAG_ADVANCED | FLAG_DEPRECATED,
    11531165        },
    11541166        {
     
    12491261                .special        = NULL,
    12501262                .enum_list      = NULL,
    1251                 .flags          = FLAG_ADVANCED,
     1263                .flags          = FLAG_ADVANCED | FLAG_DEPRECATED,
    12521264        },
    12531265
     
    13221334                .special        = NULL,
    13231335                .enum_list      = NULL,
    1324                 .flags          = FLAG_ADVANCED,
     1336                .flags          = FLAG_ADVANCED | FLAG_DEPRECATED,
    13251337        },
    13261338        {
     
    14061418        },
    14071419        {
     1420                .label          = "send spnego principal",
     1421                .type           = P_BOOL,
     1422                .p_class        = P_GLOBAL,
     1423                .ptr            = &Globals.send_spnego_principal,
     1424                .special        = NULL,
     1425                .enum_list      = NULL,
     1426                .flags          = FLAG_ADVANCED,
     1427        },
     1428        {
    14081429                .label          = "username",
    14091430                .type           = P_STRING,
     
    14121433                .special        = NULL,
    14131434                .enum_list      = NULL,
    1414                 .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
     1435                .flags          = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE | FLAG_DEPRECATED,
    14151436        },
    14161437        {
     
    20892110        },
    20902111        {
     2112                .label          = "log writeable files on exit",
     2113                .type           = P_BOOL,
     2114                .p_class        = P_GLOBAL,
     2115                .ptr            = &Globals.bLogWriteableFilesOnExit,
     2116                .special        = NULL,
     2117                .enum_list      = NULL,
     2118                .flags          = FLAG_ADVANCED,
     2119        },
     2120        {
    20912121                .label          = "acl compatibility",
    20922122                .type           = P_ENUM,
     
    22662296                .special        = NULL,
    22672297                .enum_list      = NULL,
    2268                 .flags          = FLAG_ADVANCED,
     2298                .flags          = FLAG_ADVANCED | FLAG_DEPRECATED,
    22692299        },
    22702300        {
     
    25772607                .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
    25782608        },
     2609        {
     2610                .label          = "ctdb locktime warn threshold",
     2611                .type           = P_INTEGER,
     2612                .p_class        = P_GLOBAL,
     2613                .ptr            = &Globals.ctdb_locktime_warn_threshold,
     2614                .special        = NULL,
     2615                .enum_list      = NULL,
     2616                .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
     2617        },
     2618        {
     2619                .label          = "smb2 max read",
     2620                .type           = P_INTEGER,
     2621                .p_class        = P_GLOBAL,
     2622                .ptr            = &Globals.ismb2_max_read,
     2623                .special        = NULL,
     2624                .enum_list      = NULL,
     2625                .flags          = FLAG_ADVANCED,
     2626        },
     2627        {
     2628                .label          = "smb2 max write",
     2629                .type           = P_INTEGER,
     2630                .p_class        = P_GLOBAL,
     2631                .ptr            = &Globals.ismb2_max_write,
     2632                .special        = NULL,
     2633                .enum_list      = NULL,
     2634                .flags          = FLAG_ADVANCED,
     2635        },
     2636        {
     2637                .label          = "smb2 max trans",
     2638                .type           = P_INTEGER,
     2639                .p_class        = P_GLOBAL,
     2640                .ptr            = &Globals.ismb2_max_trans,
     2641                .special        = NULL,
     2642                .enum_list      = NULL,
     2643                .flags          = FLAG_ADVANCED,
     2644        },
     2645        {
     2646                .label          = "smb2 max credits",
     2647                .type           = P_INTEGER,
     2648                .p_class        = P_GLOBAL,
     2649                .ptr            = &Globals.ismb2_max_credits,
     2650                .special        = NULL,
     2651                .enum_list      = NULL,
     2652                .flags          = FLAG_ADVANCED,
     2653        },
    25792654
    25802655        {N_("Printing Options"), P_SEP, P_SEPARATOR},
     
    26422717                .enum_list      = NULL,
    26432718                .flags          = FLAG_ADVANCED | FLAG_PRINT,
     2719        },
     2720        {
     2721                .label          = "print notify backchannel",
     2722                .type           = P_BOOL,
     2723                .p_class        = P_LOCAL,
     2724                .ptr            = &sDefault.bPrintNotifyBackchannel,
     2725                .special        = NULL,
     2726                .enum_list      = NULL,
     2727                .flags          = FLAG_ADVANCED,
    26442728        },
    26452729        {
     
    32513335        },
    32523336        {
     3337                .label          = "username map cache time",
     3338                .type           = P_INTEGER,
     3339                .p_class        = P_GLOBAL,
     3340                .ptr            = &Globals.iUsernameMapCacheTime,
     3341                .special        = NULL,
     3342                .enum_list      = NULL,
     3343                .flags          = FLAG_ADVANCED,
     3344        },
     3345        {
    32533346                .label          = "logon script",
    32543347                .type           = P_STRING,
     
    40544147                .special        = NULL,
    40554148                .enum_list      = NULL,
    4056                 .flags          = FLAG_ADVANCED,
     4149                .flags          = FLAG_ADVANCED | FLAG_DEPRECATED,
    40574150        },
    40584151        {
     
    43544447        },
    43554448        {
     4449                .label          = "async smb echo handler",
     4450                .type           = P_BOOL,
     4451                .p_class        = P_GLOBAL,
     4452                .ptr            = &Globals.bAsyncSMBEchoHandler,
     4453                .special        = NULL,
     4454                .enum_list      = NULL,
     4455                .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
     4456        },
     4457        {
     4458                .label          = "multicast dns register",
     4459                .type           = P_BOOL,
     4460                .p_class        = P_GLOBAL,
     4461                .ptr            = &Globals.bMulticastDnsRegister,
     4462                .special        = NULL,
     4463                .enum_list      = NULL,
     4464                .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
     4465        },
     4466        {
    43564467                .label          = "panic action",
    43574468                .type           = P_STRING,
     
    44404551                .p_class        = P_GLOBAL,
    44414552                .ptr            = &Globals.szIdmapBackend,
    4442                 .special        = NULL,
    4443                 .enum_list      = NULL,
    4444                 .flags          = FLAG_ADVANCED,
    4445         },
    4446         {
    4447                 .label          = "idmap alloc backend",
    4448                 .type           = P_STRING,
    4449                 .p_class        = P_GLOBAL,
    4450                 .ptr            = &Globals.szIdmapAllocBackend,
    4451                 .special        = NULL,
    4452                 .enum_list      = NULL,
    4453                 .flags          = FLAG_ADVANCED,
     4553                .special        = handle_idmap_backend,
     4554                .enum_list      = NULL,
     4555                .flags          = FLAG_ADVANCED | FLAG_DEPRECATED,
    44544556        },
    44554557        {
     
    44784580                .special        = handle_idmap_uid,
    44794581                .enum_list      = NULL,
    4480                 .flags          = FLAG_ADVANCED,
     4582                .flags          = FLAG_ADVANCED | FLAG_DEPRECATED,
    44814583        },
    44824584        {
     
    44964598                .special        = handle_idmap_gid,
    44974599                .enum_list      = NULL,
    4498                 .flags          = FLAG_ADVANCED,
     4600                .flags          = FLAG_ADVANCED | FLAG_DEPRECATED,
    44994601        },
    45004602        {
     
    45534655        },
    45544656        {
     4657                .label          = "winbind max clients",
     4658                .type           = P_INTEGER,
     4659                .p_class        = P_GLOBAL,
     4660                .ptr            = &Globals.winbind_max_clients,
     4661                .special        = NULL,
     4662                .enum_list      = NULL,
     4663                .flags          = FLAG_ADVANCED,
     4664        },
     4665        {
    45554666                .label          = "winbind enum users",
    45564667                .type           = P_BOOL,
     
    46564767                .p_class        = P_GLOBAL,
    46574768                .ptr            = &Globals.bCreateKrb5Conf,
     4769                .special        = NULL,
     4770                .enum_list      = NULL,
     4771                .flags          = FLAG_ADVANCED,
     4772        },
     4773        {
     4774                .label          = "ncalrpc dir",
     4775                .type           = P_STRING,
     4776                .p_class        = P_GLOBAL,
     4777                .ptr            = &Globals.ncalrpc_dir,
     4778                .special        = NULL,
     4779                .enum_list      = NULL,
     4780                .flags          = FLAG_ADVANCED,
     4781        },
     4782        {
     4783                .label          = "winbind max domain connections",
     4784                .type           = P_INTEGER,
     4785                .p_class        = P_GLOBAL,
     4786                .ptr            = &Globals.winbindMaxDomainConnections,
    46584787                .special        = NULL,
    46594788                .enum_list      = NULL,
     
    47344863                        break;
    47354864
    4736 #ifdef DEVELOPER
     4865#if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
     4866
    47374867        case PRINT_TEST:
    4738         case PRINT_VLP:
    4739                 string_set(&pService->szPrintcommand, "vlp print %p %s");
    4740                 string_set(&pService->szLpqcommand, "vlp lpq %p");
    4741                 string_set(&pService->szLprmcommand, "vlp lprm %p %j");
    4742                 string_set(&pService->szLppausecommand, "vlp lppause %p %j");
    4743                 string_set(&pService->szLpresumecommand, "vlp lpresume %p %j");
    4744                 string_set(&pService->szQueuepausecommand, "vlp queuepause %p");
    4745                 string_set(&pService->szQueueresumecommand, "vlp queueresume %p");
     4868        case PRINT_VLP: {
     4869                const char *tdbfile;
     4870                char *tmp;
     4871
     4872                tdbfile = talloc_asprintf(
     4873                        talloc_tos(), "tdbfile=%s",
     4874                        lp_parm_const_string(-1, "vlp", "tdbfile",
     4875                                             "/tmp/vlp.tdb"));
     4876                if (tdbfile == NULL) {
     4877                        tdbfile="tdbfile=/tmp/vlp.tdb";
     4878                }
     4879
     4880                tmp = talloc_asprintf(talloc_tos(), "vlp %s print %%p %%s",
     4881                                      tdbfile);
     4882                string_set(&pService->szPrintcommand,
     4883                           tmp ? tmp : "vlp print %p %s");
     4884                TALLOC_FREE(tmp);
     4885
     4886                tmp = talloc_asprintf(talloc_tos(), "vlp %s lpq %%p",
     4887                                      tdbfile);
     4888                string_set(&pService->szLpqcommand,
     4889                           tmp ? tmp : "vlp lpq %p");
     4890                TALLOC_FREE(tmp);
     4891
     4892                tmp = talloc_asprintf(talloc_tos(), "vlp %s lprm %%p %%j",
     4893                                      tdbfile);
     4894                string_set(&pService->szLprmcommand,
     4895                           tmp ? tmp : "vlp lprm %p %j");
     4896                TALLOC_FREE(tmp);
     4897
     4898                tmp = talloc_asprintf(talloc_tos(), "vlp %s lppause %%p %%j",
     4899                                      tdbfile);
     4900                string_set(&pService->szLppausecommand,
     4901                           tmp ? tmp : "vlp lppause %p %j");
     4902                TALLOC_FREE(tmp);
     4903
     4904                tmp = talloc_asprintf(talloc_tos(), "vlp %s lpresume %%p %%j",
     4905                                      tdbfile);
     4906                string_set(&pService->szLpresumecommand,
     4907                           tmp ? tmp : "vlp lpresume %p %j");
     4908                TALLOC_FREE(tmp);
     4909
     4910                tmp = talloc_asprintf(talloc_tos(), "vlp %s queuepause %%p",
     4911                                      tdbfile);
     4912                string_set(&pService->szQueuepausecommand,
     4913                           tmp ? tmp : "vlp queuepause %p");
     4914                TALLOC_FREE(tmp);
     4915
     4916                tmp = talloc_asprintf(talloc_tos(), "vlp %s queueresume %%p",
     4917                                      tdbfile);
     4918                string_set(&pService->szQueueresumecommand,
     4919                           tmp ? tmp : "vlp queueresume %p");
     4920                TALLOC_FREE(tmp);
     4921
    47464922                break;
     4923        }
    47474924#endif /* DEVELOPER */
    47484925
     
    47804957                if(rl.rlim_cur == RLIM_INFINITY)
    47814958                        rlimit_max = MAX_OPEN_FILES;
    4782         }
    47834959#endif
     4960        }
    47844961#endif
    47854962
     
    48935070}
    48945071
     5072static int map_parameter(const char *pszParmName);
     5073
     5074struct lp_stored_option {
     5075        struct lp_stored_option *prev, *next;
     5076        const char *label;
     5077        const char *value;
     5078};
     5079
     5080static struct lp_stored_option *stored_options;
     5081
     5082/*
     5083  save options set by lp_set_cmdline() into a list. This list is
     5084  re-applied when we do a globals reset, so that cmdline set options
     5085  are sticky across reloads of smb.conf
     5086 */
     5087static bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
     5088{
     5089        struct lp_stored_option *entry, *entry_next;
     5090        for (entry = stored_options; entry != NULL; entry = entry_next) {
     5091                entry_next = entry->next;
     5092                if (strcmp(pszParmName, entry->label) == 0) {
     5093                        DLIST_REMOVE(stored_options, entry);
     5094                        talloc_free(entry);
     5095                        break;
     5096                }
     5097        }
     5098
     5099        entry = talloc(NULL, struct lp_stored_option);
     5100        if (!entry) {
     5101                return false;
     5102        }
     5103
     5104        entry->label = talloc_strdup(entry, pszParmName);
     5105        if (!entry->label) {
     5106                talloc_free(entry);
     5107                return false;
     5108        }
     5109
     5110        entry->value = talloc_strdup(entry, pszParmValue);
     5111        if (!entry->value) {
     5112                talloc_free(entry);
     5113                return false;
     5114        }
     5115
     5116        DLIST_ADD_END(stored_options, entry, struct lp_stored_option);
     5117
     5118        return true;
     5119}
     5120
     5121static bool apply_lp_set_cmdline(void)
     5122{
     5123        struct lp_stored_option *entry = NULL;
     5124        for (entry = stored_options; entry != NULL; entry = entry->next) {
     5125                if (!lp_set_cmdline_helper(entry->label, entry->value, false)) {
     5126                        DEBUG(0, ("Failed to re-apply cmdline parameter %s = %s\n",
     5127                                  entry->label, entry->value));
     5128                        return false;
     5129                }
     5130        }
     5131        return true;
     5132}
     5133
    48955134/***************************************************************************
    48965135 Initialise the global parameter structure.
    48975136***************************************************************************/
    48985137
    4899 static void init_globals(bool first_time_only)
     5138static void init_globals(bool reinit_globals)
    49005139{
    49015140        static bool done_init = False;
     
    49045143
    49055144        /* If requested to initialize only once and we've already done it... */
    4906         if (first_time_only && done_init) {
     5145        if (!reinit_globals && done_init) {
    49075146                /* ... then we have nothing more to do */
    49085147                return;
     
    49205159        }
    49215160
     5161        /* This memset and the free_global_parameters() above will
     5162         * wipe out smb.conf options set with lp_set_cmdline().  The
     5163         * apply_lp_set_cmdline() call puts these values back in the
     5164         * table once the defaults are set */
    49225165        memset((void *)&Globals, '\0', sizeof(Globals));
    49235166
     
    49815224        /*
    49825225         * By default support explicit binding to broadcast
    4983          * addresses.
    4984          */
     5226         * addresses.
     5227         */
    49855228        Globals.bNmbdBindExplicitBroadcast = true;
    49865229
     
    50845327        Globals.bLanmanAuth = False;    /* Do NOT use the LanMan hash, even if it is supplied */
    50855328        Globals.bNTLMAuth = True;       /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */
    5086         Globals.bClientNTLMv2Auth = False; /* Client should not use NTLMv2, as we can't tell that the server supports it. */
    5087         /* Note, that we will use NTLM2 session security (which is different), if it is available */
     5329        Globals.bClientNTLMv2Auth = True; /* Client should always use use NTLMv2, as we can't tell that the server supports it, but most modern servers do */
     5330        /* Note, that we will also use NTLM2 session security (which is different), if it is available */
    50885331
    50895332        Globals.map_to_guest = 0;       /* By Default, "Never" */
     
    50985341        Globals.bUnixExtensions = True;
    50995342        Globals.bResetOnZeroVC = False;
     5343        Globals.bLogWriteableFilesOnExit = False;
    51005344        Globals.bCreateKrb5Conf = true;
     5345        Globals.winbindMaxDomainConnections = 1;
    51015346
    51025347        /* hostname lookups can be very expensive and are broken on
     
    51635408        Globals.bAllowTrustedDomains = True;
    51645409        string_set(&Globals.szIdmapBackend, "tdb");
     5410        Globals.bIdmapReadOnly = false;
    51655411
    51665412        string_set(&Globals.szTemplateShell, "/bin/false");
     
    51755421        Globals.clustering = False;
    51765422        Globals.ctdb_timeout = 0;
     5423        Globals.ctdb_locktime_warn_threshold = 0;
    51775424
    51785425        Globals.winbind_cache_time = 300;       /* 5 minutes */
    51795426        Globals.winbind_reconnect_delay = 30;   /* 30 seconds */
     5427        Globals.winbind_max_clients = 200;
    51805428        Globals.bWinbindEnumUsers = False;
    51815429        Globals.bWinbindEnumGroups = False;
     
    51845432        Globals.bWinbindNestedGroups = True;
    51855433        Globals.winbind_expand_groups = 1;
    5186         Globals.szWinbindNssInfo = str_list_make_v3(talloc_autofree_context(), "template", NULL);
     5434        Globals.szWinbindNssInfo = str_list_make_v3(NULL, "template", NULL);
    51875435        Globals.bWinbindRefreshTickets = False;
    51885436        Globals.bWinbindOfflineLogon = False;
     
    52295477
    52305478        Globals.bMapUntrustedToDomain = false;
     5479        Globals.bMulticastDnsRegister = true;
     5480
     5481        Globals.ismb2_max_read = DEFAULT_SMB2_MAX_READ;
     5482        Globals.ismb2_max_write = DEFAULT_SMB2_MAX_WRITE;
     5483        Globals.ismb2_max_trans = DEFAULT_SMB2_MAX_TRANSACT;
     5484        Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
     5485
     5486        string_set(&Globals.ncalrpc_dir, get_dyn_NCALRPCDIR());
     5487
     5488        /* Now put back the settings that were set with lp_set_cmdline() */
     5489        apply_lp_set_cmdline();
    52315490}
    52325491
     
    53035562#define FN_LOCAL_PARM_INTEGER(fn_name,val) \
    53045563 int fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
    5305 #define FN_LOCAL_PARM_STRING(fn_name,val) \
    5306  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));}
    53075564#define FN_LOCAL_CHAR(fn_name,val) \
    53085565 char fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);}
     
    54395696FN_GLOBAL_STRING(lp_abort_shutdown_script, &Globals.szAbortShutdownScript)
    54405697FN_GLOBAL_STRING(lp_username_map_script, &Globals.szUsernameMapScript)
     5698FN_GLOBAL_INTEGER(lp_username_map_cache_time, &Globals.iUsernameMapCacheTime)
    54415699
    54425700FN_GLOBAL_STRING(lp_check_password_script, &Globals.szCheckPasswordScript)
     
    54585716FN_GLOBAL_BOOL(lp_winbind_rpc_only, &Globals.bWinbindRpcOnly)
    54595717FN_GLOBAL_BOOL(lp_create_krb5_conf, &Globals.bCreateKrb5Conf)
     5718static FN_GLOBAL_INTEGER(lp_winbind_max_domain_connections_int,
     5719                  &Globals.winbindMaxDomainConnections)
     5720
     5721int lp_winbind_max_domain_connections(void)
     5722{
     5723        if (lp_winbind_offline_logon() &&
     5724            lp_winbind_max_domain_connections_int() > 1) {
     5725                DEBUG(1, ("offline logons active, restricting max domain "
     5726                          "connections to 1\n"));
     5727                return 1;
     5728        }
     5729        return MAX(1, lp_winbind_max_domain_connections_int());
     5730}
    54605731
    54615732FN_GLOBAL_CONST_STRING(lp_idmap_backend, &Globals.szIdmapBackend)
    5462 FN_GLOBAL_STRING(lp_idmap_alloc_backend, &Globals.szIdmapAllocBackend)
    54635733FN_GLOBAL_INTEGER(lp_idmap_cache_time, &Globals.iIdmapCacheTime)
    54645734FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, &Globals.iIdmapNegativeCacheTime)
     
    54945764FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
    54955765FN_GLOBAL_BOOL(lp_reset_on_zero_vc, &Globals.bResetOnZeroVC)
     5766FN_GLOBAL_BOOL(lp_log_writeable_files_on_exit,
     5767               &Globals.bLogWriteableFilesOnExit)
    54965768FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
    54975769FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
     
    55045776FN_GLOBAL_INTEGER(lp_init_logon_delay, &Globals.InitLogonDelay)
    55055777FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
    5506 FN_GLOBAL_BOOL(lp_readraw, &Globals.bReadRaw)
     5778FN_GLOBAL_BOOL(_lp_readraw, &Globals.bReadRaw)
    55075779FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
    5508 FN_GLOBAL_BOOL(lp_writeraw, &Globals.bWriteRaw)
     5780FN_GLOBAL_BOOL(_lp_writeraw, &Globals.bWriteRaw)
    55095781FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords)
    55105782FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions)
    55115783FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords)
    5512 FN_GLOBAL_BOOL(lp_update_encrypted, &Globals.bUpdateEncrypt)
    55135784FN_GLOBAL_INTEGER(lp_client_schannel, &Globals.clientSchannel)
    55145785FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel)
     
    55495820FN_GLOBAL_BOOL(lp_client_use_spnego, &Globals.bClientUseSpnego)
    55505821FN_GLOBAL_BOOL(lp_client_use_spnego_principal, &Globals.client_use_spnego_principal)
     5822FN_GLOBAL_BOOL(lp_send_spnego_principal, &Globals.send_spnego_principal)
    55515823FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups)
    55525824FN_LOCAL_PARM_BOOL(lp_change_notify, bChangeNotify)
     
    55705842FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime)
    55715843FN_GLOBAL_BOOL(lp_getwd_cache, &Globals.getwd_cache)
    5572 FN_GLOBAL_INTEGER(lp_maxprotocol, &Globals.maxprotocol)
     5844static FN_GLOBAL_INTEGER(_lp_maxprotocol, &Globals.maxprotocol)
     5845int lp_maxprotocol(void)
     5846{
     5847        int ret = _lp_maxprotocol();
     5848        if ((ret == PROTOCOL_SMB2) && (lp_security() == SEC_SHARE)) {
     5849                DEBUG(2,("WARNING!!: \"security = share\" is incompatible "
     5850                        "with the SMB2 protocol. Resetting to SMB1.\n" ));
     5851                        lp_do_parameter(-1, "max protocol", "NT1");
     5852                return PROTOCOL_NT1;
     5853        }
     5854        return ret;
     5855}
    55735856FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol)
    55745857FN_GLOBAL_INTEGER(lp_security, &Globals.security)
     
    55905873FN_GLOBAL_CONST_STRING(lp_socket_options, &Globals.szSocketOptions)
    55915874FN_GLOBAL_INTEGER(lp_config_backend, &Globals.ConfigBackend)
    5592 
     5875FN_GLOBAL_INTEGER(lp_smb2_max_read, &Globals.ismb2_max_read)
     5876FN_GLOBAL_INTEGER(lp_smb2_max_write, &Globals.ismb2_max_write)
     5877FN_GLOBAL_INTEGER(lp_smb2_max_trans, &Globals.ismb2_max_trans)
     5878int lp_smb2_max_credits(void)
     5879{
     5880        if (Globals.ismb2_max_credits == 0) {
     5881                Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS;
     5882        }
     5883        return Globals.ismb2_max_credits;
     5884}
    55935885FN_LOCAL_STRING(lp_preexec, szPreExec)
    55945886FN_LOCAL_STRING(lp_postexec, szPostExec)
     
    56305922FN_GLOBAL_BOOL(lp_clustering, &Globals.clustering)
    56315923FN_GLOBAL_INTEGER(lp_ctdb_timeout, &Globals.ctdb_timeout)
     5924FN_GLOBAL_INTEGER(lp_ctdb_locktime_warn_threshold, &Globals.ctdb_locktime_warn_threshold)
    56325925FN_LOCAL_STRING(lp_printcommand, szPrintcommand)
    56335926FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand)
     
    56775970FN_LOCAL_BOOL(lp_administrative_share, bAdministrative_share)
    56785971FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
     5972FN_LOCAL_BOOL(lp_print_notify_backchannel, bPrintNotifyBackchannel)
    56795973FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
    56805974FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
     
    57015995FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
    57025996FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes)
     5997FN_GLOBAL_BOOL(lp_async_smb_echo_handler, &Globals.bAsyncSMBEchoHandler)
     5998FN_GLOBAL_BOOL(lp_multicast_dns_register, &Globals.bMulticastDnsRegister)
    57035999FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
    57046000FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
     
    57456041FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
    57466042FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, &Globals.winbind_reconnect_delay)
     6043FN_GLOBAL_INTEGER(lp_winbind_max_clients, &Globals.winbind_max_clients)
    57476044FN_GLOBAL_LIST(lp_winbind_nss_info, &Globals.szWinbindNssInfo)
    57486045FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase)
     
    57526049FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrapping)
    57536050
     6051FN_GLOBAL_STRING(lp_ncalrpc_dir, &Globals.ncalrpc_dir)
     6052
    57546053/* local prototypes */
    57556054
    5756 static int map_parameter(const char *pszParmName);
    57576055static int map_parameter_canonical(const char *pszParmName, bool *inverse);
    57586056static const char *get_boolean(bool bool_value);
     
    57696067static void free_service_byindex(int iService);
    57706068static void free_param_opts(struct param_opt_struct **popts);
    5771 static char * canonicalize_servicename(const char *name);
    57726069static void show_parameter(int parmIndex);
    57736070static bool is_synonym_of(int parm1, int parm2, bool *inverse);
     
    57846081        char* param_key;
    57856082        struct param_opt_struct *data;
    5786        
     6083
    57876084        if (snum >= iNumServices) return NULL;
    5788        
     6085
    57896086        if (snum < 0) {
    57906087                data = Globals.param_opt;
     
    57936090                data = ServicePtrs[snum]->param_opt;
    57946091        }
    5795    
     6092
    57966093        if (asprintf(&param_key, "%s:%s", type, option) == -1) {
    57976094                DEBUG(0,("asprintf failed!\n"));
     
    58216118
    58226119        string_free(&param_key);
    5823        
     6120
    58246121        return NULL;
    58256122}
     
    58686165                return False;
    58696166        }
    5870        
     6167
    58716168        if (!set_boolean(s, &ret)) {
    58726169                DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
     
    58886185                return (-1);
    58896186        }
    5890        
     6187
    58916188        for (i=0; _enum[i].name; i++) {
    58926189                if (strequal(_enum[i].name,s))
     
    59186215{
    59196216        struct param_opt_struct *data = get_parametrics(snum, type, option);
    5920        
     6217
    59216218        if (data == NULL||data->value==NULL) {
    59226219                if (def) {
     
    59356232{
    59366233        struct param_opt_struct *data = get_parametrics(snum, type, option);
    5937        
     6234
    59386235        if (data == NULL||data->value==NULL)
    59396236                return def;
    5940                
     6237
    59416238        return data->value;
    59426239}
     
    59516248        if (data == NULL||data->value==NULL)
    59526249                return (const char **)def;
    5953                
     6250
    59546251        if (data->list==NULL) {
    5955                 data->list = str_list_make_v3(talloc_autofree_context(), data->value, NULL);
     6252                data->list = str_list_make_v3(NULL, data->value, NULL);
    59566253        }
    59576254
     
    59656262{
    59666263        struct param_opt_struct *data = get_parametrics(snum, type, option);
    5967        
     6264
    59686265        if (data && data->value && *data->value)
    59696266                return lp_int(data->value);
     
    59786275{
    59796276        struct param_opt_struct *data = get_parametrics(snum, type, option);
    5980        
     6277
    59816278        if (data && data->value && *data->value)
    59826279                return lp_ulong(data->value);
     
    59916288{
    59926289        struct param_opt_struct *data = get_parametrics(snum, type, option);
    5993        
     6290
    59946291        if (data && data->value && *data->value)
    59956292                return lp_bool(data->value);
     
    60056302{
    60066303        struct param_opt_struct *data = get_parametrics(snum, type, option);
    6007        
     6304
    60086305        if (data && data->value && *data->value && _enum)
    60096306                return lp_enum(data->value, _enum);
     
    60696366
    60706367        string_free(&pservice->szService);
    6071         bitmap_free(pservice->copymap);
     6368        TALLOC_FREE(pservice->copymap);
    60726369
    60736370        free_param_opts(&pservice->param_opt);
     
    60946391        if (ServicePtrs[idx]->szService) {
    60956392                char *canon_name = canonicalize_servicename(
     6393                        talloc_tos(),
    60966394                        ServicePtrs[idx]->szService );
    6097                
     6395
    60986396                dbwrap_delete_bystring(ServiceHash, canon_name );
    60996397                TALLOC_FREE(canon_name);
     
    61206418                i = getservicebyname(name, NULL);
    61216419                if (i >= 0) {
    6122                         /* Clean all parametric options for service */
    6123                         /* They will be added during parsing again */
    6124                         free_param_opts(&ServicePtrs[i]->param_opt);
    61256420                        return (i);
    61266421                }
     
    61376432                struct service **tsp;
    61386433                int *tinvalid;
    6139                
     6434
    61406435                tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct service *, num_to_alloc);
    61416436                if (tsp == NULL) {
     
    61706465        if (name)
    61716466                string_set(&ServicePtrs[i]->szService, name);
    6172                
     6467
    61736468        DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
    61746469                i, ServicePtrs[i]->szService));
     
    61776472                return (-1);
    61786473        }
    6179                
     6474
    61806475        return (i);
    61816476}
     
    61856480***************************************************************************/
    61866481
    6187 static char *canonicalize_servicename(const char *src)
     6482char *canonicalize_servicename(TALLOC_CTX *ctx, const char *src)
    61886483{
    61896484        char *result;
     
    61946489        }
    61956490
    6196         result = talloc_strdup(talloc_tos(), src);
     6491        result = talloc_strdup(ctx, src);
    61976492        SMB_ASSERT(result != NULL);
    61986493
     
    62216516                idx, name));
    62226517
    6223         canon_name = canonicalize_servicename( name );
     6518        canon_name = canonicalize_servicename(talloc_tos(), name );
    62246519
    62256520        dbwrap_store_bystring(ServiceHash, canon_name,
     
    63606655        /* Printer services must be printable. */
    63616656        ServicePtrs[i]->bPrint_ok = True;
    6362        
     6657
    63636658        DEBUG(3, ("adding printer service %s\n", pszPrintername));
    63646659
     
    67287023        }
    67297024
    6730         canon_name = canonicalize_servicename(pszServiceName);
     7025        canon_name = canonicalize_servicename(talloc_tos(), pszServiceName);
    67317026
    67327027        data = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name);
     
    67577052static void set_param_opt(struct param_opt_struct **opt_list,
    67587053                          const char *opt_name,
    6759                           const char *opt_value)
     7054                          const char *opt_value,
     7055                          unsigned flags)
    67607056{
    67617057        struct param_opt_struct *new_opt, *opt;
     
    67737069                /* If we already have same option, override it */
    67747070                if (strwicmp(opt->key, opt_name) == 0) {
     7071                        if ((opt->flags & FLAG_CMDLINE) &&
     7072                            !(flags & FLAG_CMDLINE)) {
     7073                                /* it's been marked as not to be
     7074                                   overridden */
     7075                                return;
     7076                        }
    67757077                        string_free(&opt->value);
    67767078                        TALLOC_FREE(opt->list);
    67777079                        opt->value = SMB_STRDUP(opt_value);
     7080                        opt->flags = flags;
    67787081                        not_added = false;
    67797082                        break;
     
    67867089            new_opt->value = SMB_STRDUP(opt_value);
    67877090            new_opt->list = NULL;
     7091            new_opt->flags = flags;
    67887092            DLIST_ADD(*opt_list, new_opt);
    67897093        }
     
    68507154                                    pserviceSource->copymap);
    68517155        }
    6852        
     7156
    68537157        data = pserviceSource->param_opt;
    68547158        while (data) {
    6855                 set_param_opt(&pserviceDest->param_opt, data->key, data->value);
     7159                set_param_opt(&pserviceDest->param_opt, data->key, data->value, data->flags);
    68567160                data = data->next;
    68577161        }
     
    69067210static struct smbconf_ctx *lp_smbconf_ctx(void)
    69077211{
    6908         WERROR werr;
     7212        sbcErr err;
    69097213        static struct smbconf_ctx *conf_ctx = NULL;
    69107214
    69117215        if (conf_ctx == NULL) {
    6912                 werr = smbconf_init(NULL, &conf_ctx, "registry:");
    6913                 if (!W_ERROR_IS_OK(werr)) {
     7216                err = smbconf_init(NULL, &conf_ctx, "registry:");
     7217                if (!SBC_ERROR_IS_OK(err)) {
    69147218                        DEBUG(1, ("error initializing registry configuration: "
    6915                                   "%s\n", win_errstr(werr)));
     7219                                  "%s\n", sbcErrorString(err)));
    69167220                        conf_ctx = NULL;
    69177221                }
     
    69537257bool process_registry_service(const char *service_name)
    69547258{
    6955         WERROR werr;
     7259        sbcErr err;
    69567260        struct smbconf_service *service = NULL;
    69577261        TALLOC_CTX *mem_ctx = talloc_stackframe();
     
    69747278        }
    69757279
    6976         werr = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
    6977         if (!W_ERROR_IS_OK(werr)) {
     7280        err = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
     7281        if (!SBC_ERROR_IS_OK(err)) {
    69787282                goto done;
    69797283        }
     
    70117315bool process_registry_shares(void)
    70127316{
    7013         WERROR werr;
     7317        sbcErr err;
    70147318        uint32_t count;
    70157319        struct smbconf_service **service = NULL;
     
    70237327        }
    70247328
    7025         werr = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
    7026         if (!W_ERROR_IS_OK(werr)) {
     7329        err = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);
     7330        if (!SBC_ERROR_IS_OK(err)) {
    70277331                goto done;
    70287332        }
     
    70477351        return ret;
    70487352}
     7353
     7354/**
     7355 * reload those shares from registry that are already
     7356 * activated in the services array.
     7357 */
     7358static bool reload_registry_shares(void)
     7359{
     7360        int i;
     7361        bool ret = true;
     7362
     7363        for (i = 0; i < iNumServices; i++) {
     7364                if (!VALID(i)) {
     7365                        continue;
     7366                }
     7367
     7368                if (ServicePtrs[i]->usershare == USERSHARE_VALID) {
     7369                        continue;
     7370                }
     7371
     7372                ret = process_registry_service(ServicePtrs[i]->szService);
     7373                if (!ret) {
     7374                        goto done;
     7375                }
     7376        }
     7377
     7378done:
     7379        return ret;
     7380}
     7381
    70497382
    70507383#define MAX_INCLUDE_DEPTH 100
     
    70867419                f->subfname = SMB_STRDUP(subfname);
    70877420                if (!f->subfname) {
     7421                        SAFE_FREE(f->name);
    70887422                        SAFE_FREE(f);
    70897423                        return;
     
    70967430                        f->modtime = t;
    70977431        }
     7432        return;
    70987433}
    70997434
     
    71457480
    71467481        while (f) {
    7147                 char *n2 = NULL;
    71487482                time_t mod_time;
    71497483
     
    71617495                        }
    71627496                } else {
    7163                         n2 = alloc_sub_basic(get_current_username(),
    7164                                             current_user_info.domain,
    7165                                             f->name);
     7497                        char *n2 = NULL;
     7498                        n2 = talloc_sub_basic(talloc_tos(),
     7499                                              get_current_username(),
     7500                                              current_user_info.domain,
     7501                                              f->name);
    71667502                        if (!n2) {
    71677503                                return false;
     
    71827518                                f->modtime = mod_time;
    71837519                                SAFE_FREE(f->subfname);
    7184                                 f->subfname = n2; /* Passing ownership of
    7185                                                      return from alloc_sub_basic
    7186                                                      above. */
     7520                                f->subfname = SMB_STRDUP(n2);
     7521                                TALLOC_FREE(n2);
    71877522                                return true;
    71887523                        }
    7189                         SAFE_FREE(n2);
     7524                        TALLOC_FREE(n2);
    71907525                }
    71917526                f = f->next;
     
    72047539{
    72057540        bool ret;
    7206         char *netbios_name = alloc_sub_basic(get_current_username(),
    7207                                         current_user_info.domain,
    7208                                         pszParmValue);
     7541        char *netbios_name = talloc_sub_basic(
     7542                talloc_tos(), get_current_username(), current_user_info.domain,
     7543                pszParmValue);
    72097544
    72107545        ret = set_global_myname(netbios_name);
    7211         SAFE_FREE(netbios_name);
     7546        TALLOC_FREE(netbios_name);
    72127547        string_set(&Globals.szNetbiosName,global_myname());
    72137548
     
    72277562}
    72287563
     7564static bool handle_dos_charset(int snum, const char *pszParmValue, char **ptr)
     7565{
     7566        bool is_utf8 = false;
     7567        size_t len = strlen(pszParmValue);
     7568
     7569        if (len == 4 || len == 5) {
     7570                /* Don't use StrCaseCmp here as we don't want to
     7571                   initialize iconv. */
     7572                if ((toupper_m(pszParmValue[0]) == 'U') &&
     7573                    (toupper_m(pszParmValue[1]) == 'T') &&
     7574                    (toupper_m(pszParmValue[2]) == 'F')) {
     7575                        if (len == 4) {
     7576                                if (pszParmValue[3] == '8') {
     7577                                        is_utf8 = true;
     7578                                }
     7579                        } else {
     7580                                if (pszParmValue[3] == '-' &&
     7581                                    pszParmValue[4] == '8') {
     7582                                        is_utf8 = true;
     7583                                }
     7584                        }
     7585                }
     7586        }
     7587
     7588        if (strcmp(*ptr, pszParmValue) != 0) {
     7589                if (is_utf8) {
     7590                        DEBUG(0,("ERROR: invalid DOS charset: 'dos charset' must not "
     7591                                "be UTF8, using (default value) %s instead.\n",
     7592                                DEFAULT_DOS_CHARSET));
     7593                        pszParmValue = DEFAULT_DOS_CHARSET;
     7594                }
     7595                string_set(ptr, pszParmValue);
     7596                init_iconv();
     7597        }
     7598        return True;
     7599}
     7600
    72297601
    72307602
     
    72327604{
    72337605        bool ret;
    7234        
     7606
    72357607        ret = set_global_myworkgroup(pszParmValue);
    72367608        string_set(&Globals.szWorkgroup,lp_workgroup());
    7237        
     7609
    72387610        return ret;
    72397611}
     
    72427614{
    72437615        bool ret;
    7244        
     7616
    72457617        ret = set_global_scope(pszParmValue);
    72467618        string_set(&Globals.szNetbiosScope,global_scope());
     
    72527624{
    72537625        TALLOC_FREE(Globals.szNetbiosAliases);
    7254         Globals.szNetbiosAliases = str_list_make_v3(talloc_autofree_context(), pszParmValue, NULL);
     7626        Globals.szNetbiosAliases = str_list_make_v3(NULL, pszParmValue, NULL);
    72557627        return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
    72567628}
     
    72887660        }
    72897661
    7290         fname = alloc_sub_basic(get_current_username(),
    7291                                 current_user_info.domain,
    7292                                 pszParmValue);
     7662        fname = talloc_sub_basic(talloc_tos(), get_current_username(),
     7663                                 current_user_info.domain,
     7664                                 pszParmValue);
    72937665
    72947666        add_to_file_list(pszParmValue, fname);
     
    73017673                ret = pm_process(fname, do_section, do_parameter, NULL);
    73027674                include_depth--;
    7303                 SAFE_FREE(fname);
     7675                TALLOC_FREE(fname);
    73047676                return ret;
    73057677        }
    73067678
    73077679        DEBUG(2, ("Can't find include file %s\n", fname));
    7308         SAFE_FREE(fname);
     7680        TALLOC_FREE(fname);
    73097681        return true;
    73107682}
     
    74007772}
    74017773
     7774static bool handle_idmap_backend(int snum, const char *pszParmValue, char **ptr)
     7775{
     7776        lp_do_parameter(snum, "idmap config * : backend", pszParmValue);
     7777
     7778        return true;
     7779}
     7780
    74027781/* Do some simple checks on "idmap [ug]id" parameter values */
    74037782
    74047783static bool handle_idmap_uid(int snum, const char *pszParmValue, char **ptr)
    74057784{
    7406         uint32 low, high;
    7407 
    7408         if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
    7409                 return False;
    7410 
    7411         /* Parse OK */
    7412 
    7413         string_set(ptr, pszParmValue);
    7414 
    7415         idmap_uid_low = low;
    7416         idmap_uid_high = high;
     7785        lp_do_parameter(snum, "idmap config * : range", pszParmValue);
    74177786
    74187787        return True;
     
    74217790static bool handle_idmap_gid(int snum, const char *pszParmValue, char **ptr)
    74227791{
    7423         uint32 low, high;
    7424 
    7425         if (sscanf(pszParmValue, "%u - %u", &low, &high) != 2 || high < low)
    7426                 return False;
    7427 
    7428         /* Parse OK */
    7429 
    7430         string_set(ptr, pszParmValue);
    7431 
    7432         idmap_gid_low = low;
    7433         idmap_gid_high = high;
     7792        lp_do_parameter(snum, "idmap config * : range", pszParmValue);
    74347793
    74357794        return True;
     
    75477906{
    75487907        int i;
    7549         if (pservice->copymap) {
    7550                 bitmap_free(pservice->copymap);
    7551         }
    7552         pservice->copymap = bitmap_allocate(NUMPARAMETERS);
     7908
     7909        TALLOC_FREE(pservice->copymap);
     7910
     7911        pservice->copymap = bitmap_talloc(NULL, NUMPARAMETERS);
    75537912        if (!pservice->copymap)
    75547913                DEBUG(0,
     
    76077966                opt_list = (snum < 0)
    76087967                        ? &Globals.param_opt : &ServicePtrs[snum]->param_opt;
    7609                 set_param_opt(opt_list, pszParmName, pszParmValue);
     7968                set_param_opt(opt_list, pszParmName, pszParmValue, 0);
    76107969
    76117970                return (True);
     7971        }
     7972
     7973        /* if it's already been set by the command line, then we don't
     7974           override here */
     7975        if (parm_table[parmnum].flags & FLAG_CMDLINE) {
     7976                return true;
    76127977        }
    76137978
     
    76788043                        TALLOC_FREE(*((char ***)parm_ptr));
    76798044                        *(char ***)parm_ptr = str_list_make_v3(
    7680                                 talloc_autofree_context(), pszParmValue, NULL);
     8045                                NULL, pszParmValue, NULL);
    76818046                        break;
    76828047
     
    77018066
    77028067/***************************************************************************
     8068set a parameter, marking it with FLAG_CMDLINE. Parameters marked as
     8069FLAG_CMDLINE won't be overridden by loads from smb.conf.
     8070***************************************************************************/
     8071
     8072static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values)
     8073{
     8074        int parmnum, i;
     8075        parmnum = map_parameter(pszParmName);
     8076        if (parmnum >= 0) {
     8077                parm_table[parmnum].flags &= ~FLAG_CMDLINE;
     8078                if (!lp_do_parameter(-1, pszParmName, pszParmValue)) {
     8079                        return false;
     8080                }
     8081                parm_table[parmnum].flags |= FLAG_CMDLINE;
     8082
     8083                /* we have to also set FLAG_CMDLINE on aliases.  Aliases must
     8084                 * be grouped in the table, so we don't have to search the
     8085                 * whole table */
     8086                for (i=parmnum-1;i>=0 && parm_table[i].ptr == parm_table[parmnum].ptr;i--) {
     8087                        parm_table[i].flags |= FLAG_CMDLINE;
     8088                }
     8089                for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].ptr == parm_table[parmnum].ptr;i++) {
     8090                        parm_table[i].flags |= FLAG_CMDLINE;
     8091                }
     8092
     8093                if (store_values) {
     8094                        store_lp_set_cmdline(pszParmName, pszParmValue);
     8095                }
     8096                return true;
     8097        }
     8098
     8099        /* it might be parametric */
     8100        if (strchr(pszParmName, ':') != NULL) {
     8101                set_param_opt(&Globals.param_opt, pszParmName, pszParmValue, FLAG_CMDLINE);
     8102                if (store_values) {
     8103                        store_lp_set_cmdline(pszParmName, pszParmValue);
     8104                }
     8105                return true;
     8106        }
     8107
     8108        DEBUG(0, ("Ignoring unknown parameter \"%s\"\n",  pszParmName));
     8109        return true;
     8110}
     8111
     8112bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue)
     8113{
     8114        return lp_set_cmdline_helper(pszParmName, pszParmValue, true);
     8115}
     8116
     8117/***************************************************************************
    77038118 Process a parameter.
    77048119***************************************************************************/
     
    77168131}
    77178132
    7718 /***************************************************************************
     8133/*
     8134  set a option from the commandline in 'a=b' format. Use to support --option
     8135*/
     8136bool lp_set_option(const char *option)
     8137{
     8138        char *p, *s;
     8139        bool ret;
     8140
     8141        s = talloc_strdup(NULL, option);
     8142        if (!s) {
     8143                return false;
     8144        }
     8145
     8146        p = strchr(s, '=');
     8147        if (!p) {
     8148                talloc_free(s);
     8149                return false;
     8150        }
     8151
     8152        *p = 0;
     8153
     8154        /* skip white spaces after the = sign */
     8155        do {
     8156                p++;
     8157        } while (*p == ' ');
     8158
     8159        ret = lp_set_cmdline(s, p);
     8160        talloc_free(s);
     8161        return ret;
     8162}
     8163
     8164/**************************************************************************
    77198165 Print a parameter of the specified type.
    77208166***************************************************************************/
     
    78758321                        return (False);
    78768322                }
     8323                /* Clean all parametric options for service */
     8324                /* They will be added during parsing again */
     8325                free_param_opts(&ServicePtrs[iServiceIndex]->param_opt);
    78778326        }
    78788327
     
    79238372        int i;
    79248373        struct param_opt_struct *data;
    7925        
     8374
    79268375        fprintf(f, "[global]\n");
    79278376
     
    79688417        int i;
    79698418        struct param_opt_struct *data;
    7970        
     8419
    79718420        if (pService != &sDefault)
    79728421                fprintf(f, "[%s]\n", pService->szService);
     
    79808429                    (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
    79818430                {
    7982                
    79838431                        int pdiff = PTR_DIFF(parm_table[i].ptr, &sDefault);
    79848432
     
    81178565                                parm_table[(*i) - 1].ptr))
    81188566                                continue;
    8119                        
     8567
    81208568                        if (is_default(*i) && !allparameters)
    81218569                                continue;
     
    82308678***************************************************************************/
    82318679
    8232 void lp_add_one_printer(const char *name, const char *comment, void *pdata)
     8680void lp_add_one_printer(const char *name, const char *comment,
     8681                        const char *location, void *pdata)
    82338682{
    82348683        int printers = lp_servicenumber(PRINTERS_NAME);
     
    83428791}
    83438792
    8344 /*******************************************************************
    8345  Set the server type we will announce as via nmbd.
    8346 ********************************************************************/
    8347 
    8348 static const struct srv_role_tab {
    8349         uint32 role;
    8350         const char *role_str;
    8351 } srv_role_tab [] = {
    8352         { ROLE_STANDALONE, "ROLE_STANDALONE" },
    8353         { ROLE_DOMAIN_MEMBER, "ROLE_DOMAIN_MEMBER" },
    8354         { ROLE_DOMAIN_BDC, "ROLE_DOMAIN_BDC" },
    8355         { ROLE_DOMAIN_PDC, "ROLE_DOMAIN_PDC" },
    8356         { 0, NULL }
    8357 };
    8358 
    8359 const char* server_role_str(uint32 role)
    8360 {
    8361         int i = 0;
    8362         for (i=0; srv_role_tab[i].role_str; i++) {
    8363                 if (role == srv_role_tab[i].role) {
    8364                         return srv_role_tab[i].role_str;
    8365                 }
    8366         }
    8367         return NULL;
    8368 }
    8369 
    8370 static void set_server_role(void)
    8371 {
    8372         server_role = ROLE_STANDALONE;
    8373 
    8374         switch (lp_security()) {
    8375                 case SEC_SHARE:
    8376                         if (lp_domain_logons())
    8377                                 DEBUG(0, ("Server's Role (logon server) conflicts with share-level security\n"));
    8378                         break;
    8379                 case SEC_SERVER:
    8380                         if (lp_domain_logons())
    8381                                 DEBUG(0, ("Server's Role (logon server) conflicts with server-level security\n"));
    8382                         /* this used to be considered ROLE_DOMAIN_MEMBER but that's just wrong */
    8383                         server_role = ROLE_STANDALONE;
    8384                         break;
    8385                 case SEC_DOMAIN:
    8386                         if (lp_domain_logons()) {
    8387                                 DEBUG(1, ("Server's Role (logon server) NOT ADVISED with domain-level security\n"));
    8388                                 server_role = ROLE_DOMAIN_BDC;
    8389                                 break;
    8390                         }
    8391                         server_role = ROLE_DOMAIN_MEMBER;
    8392                         break;
    8393                 case SEC_ADS:
    8394                         if (lp_domain_logons()) {
    8395                                 server_role = ROLE_DOMAIN_PDC;
    8396                                 break;
    8397                         }
    8398                         server_role = ROLE_DOMAIN_MEMBER;
    8399                         break;
    8400                 case SEC_USER:
    8401                         if (lp_domain_logons()) {
    8402 
    8403                                 if (Globals.iDomainMaster) /* auto or yes */
    8404                                         server_role = ROLE_DOMAIN_PDC;
    8405                                 else
    8406                                         server_role = ROLE_DOMAIN_BDC;
    8407                         }
    8408                         break;
    8409                 default:
    8410                         DEBUG(0, ("Server's Role undefined due to unknown security mode\n"));
    8411                         break;
    8412         }
    8413 
    8414         DEBUG(10, ("set_server_role: role = %s\n", server_role_str(server_role)));
    8415 }
    8416 
    84178793/***********************************************************
    84188794 If we should send plaintext/LANMAN passwords in the clinet
     
    84908866                        char **pp_sharepath,
    84918867                        char **pp_comment,
    8492                         SEC_DESC **ppsd,
     8868                        char **pp_cp_servicename,
     8869                        struct security_descriptor **ppsd,
    84938870                        bool *pallow_guest)
    84948871{
     
    85568933                if (lines[4][9] == 'y') {
    85578934                        *pallow_guest = True;
     8935                }
     8936
     8937                /* Backwards compatible extension to file version #2. */
     8938                if (numlines > 5) {
     8939                        if (strncmp(lines[5], "sharename=", 10) != 0) {
     8940                                return USERSHARE_MALFORMED_SHARENAME_DEF;
     8941                        }
     8942                        if (!strequal(&lines[5][10], servicename)) {
     8943                                return USERSHARE_BAD_SHARENAME;
     8944                        }
     8945                        *pp_cp_servicename = talloc_strdup(ctx, &lines[5][10]);
     8946                        if (!*pp_cp_servicename) {
     8947                                return USERSHARE_POSIX_ERR;
     8948                        }
     8949                }
     8950        }
     8951
     8952        if (*pp_cp_servicename == NULL) {
     8953                *pp_cp_servicename = talloc_strdup(ctx, servicename);
     8954                if (!*pp_cp_servicename) {
     8955                        return USERSHARE_POSIX_ERR;
    85588956                }
    85598957        }
     
    86689066        char *sharepath = NULL;
    86699067        char *comment = NULL;
    8670         fstring service_name;
     9068        char *cp_service_name = NULL;
    86719069        char **lines = NULL;
    86729070        int numlines = 0;
    86739071        int fd = -1;
    86749072        int iService = -1;
    8675         TALLOC_CTX *ctx = NULL;
    8676         SEC_DESC *psd = NULL;
     9073        TALLOC_CTX *ctx = talloc_stackframe();
     9074        struct security_descriptor *psd = NULL;
    86779075        bool guest_ok = False;
     9076        char *canon_name = NULL;
     9077        bool added_service = false;
     9078        int ret = -1;
    86789079
    86799080        /* Ensure share name doesn't contain invalid characters. */
     
    86829083                        "invalid characters (any of %s)\n",
    86839084                        file_name, INVALID_SHARENAME_CHARS ));
    8684                 return -1;
    8685         }
    8686 
    8687         fstrcpy(service_name, file_name);
    8688 
    8689         if (asprintf(&fname, "%s/%s", dir_name, file_name) < 0) {
     9085                goto out;
     9086        }
     9087
     9088        canon_name = canonicalize_servicename(ctx, file_name);
     9089        if (!canon_name) {
     9090                goto out;
     9091        }
     9092
     9093        fname = talloc_asprintf(ctx, "%s/%s", dir_name, file_name);
     9094        if (!fname) {
     9095                goto out;
    86909096        }
    86919097
     
    86969102                DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
    86979103                        fname, strerror(errno) ));
    8698                 SAFE_FREE(fname);
    8699                 return -1;
     9104                goto out;
    87009105        }
    87019106
     
    87039108           other strange filetype. */
    87049109        if (!check_usershare_stat(fname, &lsbuf)) {
    8705                 SAFE_FREE(fname);
    8706                 return -1;
    8707         }
    8708 
    8709         {
    8710                 char *canon_name = canonicalize_servicename(service_name);
     9110                goto out;
     9111        }
     9112
     9113        {
    87119114                TDB_DATA data = dbwrap_fetch_bystring(
    87129115                        ServiceHash, canon_name, canon_name);
     
    87179120                        iService = *(int *)data.dptr;
    87189121                }
    8719                 TALLOC_FREE(canon_name);
    87209122        }
    87219123
     
    87259127                /* Nothing changed - Mark valid and return. */
    87269128                DEBUG(10,("process_usershare_file: service %s not changed.\n",
    8727                         service_name ));
     9129                        canon_name ));
    87289130                ServicePtrs[iService]->usershare = USERSHARE_VALID;
    8729                 SAFE_FREE(fname);
    8730                 return iService;
     9131                ret = iService;
     9132                goto out;
    87319133        }
    87329134
     
    87419143                DEBUG(0,("process_usershare_file: unable to open %s. %s\n",
    87429144                        fname, strerror(errno) ));
    8743                 SAFE_FREE(fname);
    8744                 return -1;
     9145                goto out;
    87459146        }
    87469147
     
    87509151                DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
    87519152                        fname, strerror(errno) ));
    8752                 SAFE_FREE(fname);
    8753                 return -1;
     9153                goto out;
    87549154        }
    87559155
     
    87599159                DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
    87609160                        "Symlink spoofing going on ?\n", fname ));
    8761                 SAFE_FREE(fname);
    8762                 return -1;
     9161                goto out;
    87639162        }
    87649163
     
    87669165           other strange filetype. */
    87679166        if (!check_usershare_stat(fname, &sbuf)) {
    8768                 SAFE_FREE(fname);
    8769                 return -1;
     9167                goto out;
    87709168        }
    87719169
     
    87769174                DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
    87779175                        fname, (unsigned int)sbuf.st_ex_uid ));
    8778                 SAFE_FREE(fname);
    8779                 return -1;
    8780         }
    8781 
    8782         SAFE_FREE(fname);
    8783 
    8784         /* Should we allow printers to be shared... ? */
    8785         ctx = talloc_init("usershare_sd_xctx");
    8786         if (!ctx) {
    8787                 TALLOC_FREE(lines);
    8788                 return 1;
    8789         }
    8790 
    8791         if (parse_usershare_file(ctx, &sbuf, service_name,
     9176                goto out;
     9177        }
     9178
     9179        if (parse_usershare_file(ctx, &sbuf, file_name,
    87929180                        iService, lines, numlines, &sharepath,
    8793                         &comment, &psd, &guest_ok) != USERSHARE_OK) {
    8794                 talloc_destroy(ctx);
    8795                 TALLOC_FREE(lines);
    8796                 return -1;
    8797         }
    8798 
    8799         TALLOC_FREE(lines);
     9181                        &comment, &cp_service_name,
     9182                        &psd, &guest_ok) != USERSHARE_OK) {
     9183                goto out;
     9184        }
    88009185
    88019186        /* Everything ok - add the service possibly using a template. */
     
    88069191                }
    88079192
    8808                 if ((iService = add_a_service(sp, service_name)) < 0) {
     9193                if ((iService = add_a_service(sp, cp_service_name)) < 0) {
    88099194                        DEBUG(0, ("process_usershare_file: Failed to add "
    8810                                 "new service %s\n", service_name));
    8811                         talloc_destroy(ctx);
    8812                         return -1;
     9195                                "new service %s\n", cp_service_name));
     9196                        goto out;
    88139197                }
     9198
     9199                added_service = true;
    88149200
    88159201                /* Read only is controlled by usershare ACL below. */
     
    88189204
    88199205        /* Write the ACL of the new/modified share. */
    8820         if (!set_share_security(service_name, psd)) {
     9206        if (!set_share_security(canon_name, psd)) {
    88219207                 DEBUG(0, ("process_usershare_file: Failed to set share "
    88229208                        "security for user share %s\n",
    8823                         service_name ));
    8824                 lp_remove_service(iService);
    8825                 talloc_destroy(ctx);
    8826                 return -1;
     9209                        canon_name ));
     9210                goto out;
    88279211        }
    88289212
     
    88439227        string_set(&ServicePtrs[iService]->comment, comment);
    88449228
    8845         talloc_destroy(ctx);
    8846 
    8847         return iService;
     9229        ret = iService;
     9230
     9231  out:
     9232
     9233        if (ret == -1 && iService != -1 && added_service) {
     9234                lp_remove_service(iService);
     9235        }
     9236
     9237        TALLOC_FREE(lines);
     9238        TALLOC_FREE(ctx);
     9239        return ret;
    88489240}
    88499241
     
    91549546***************************************************************************/
    91559547
    9156 bool lp_load_ex(const char *pszFname,
    9157                 bool global_only,
    9158                 bool save_defaults,
    9159                 bool add_ipc,
    9160                 bool initialize_globals,
    9161                 bool allow_include_registry,
    9162                 bool allow_registry_shares)
     9548static bool lp_load_ex(const char *pszFname,
     9549                       bool global_only,
     9550                       bool save_defaults,
     9551                       bool add_ipc,
     9552                       bool initialize_globals,
     9553                       bool allow_include_registry,
     9554                       bool allow_registry_shares)
    91639555{
    91649556        char *n2 = NULL;
     
    91739565        bAllowIncludeRegistry = allow_include_registry;
    91749566
    9175         init_globals(! initialize_globals);
    9176         debug_init();
     9567        init_globals(initialize_globals);
    91779568
    91789569        free_file_list();
     
    91859576        free_param_opts(&Globals.param_opt);
    91869577
     9578        lp_do_parameter(-1, "idmap config * : backend", Globals.szIdmapBackend);
     9579
    91879580        /* We get sections first, so have to start 'behind' to make up */
    91889581        iServiceIndex = -1;
    91899582
    91909583        if (lp_config_backend_is_file()) {
    9191                 n2 = alloc_sub_basic(get_current_username(),
     9584                n2 = talloc_sub_basic(talloc_tos(), get_current_username(),
    91929585                                        current_user_info.domain,
    91939586                                        pszFname);
     
    91999592
    92009593                bRetval = pm_process(n2, do_section, do_parameter, NULL);
    9201                 SAFE_FREE(n2);
     9594                TALLOC_FREE(n2);
    92029595
    92039596                /* finish up the last section */
     
    92219614                        DEBUG(1, ("lp_load_ex: changing to config backend "
    92229615                                  "registry\n"));
    9223                         init_globals(false);
     9616                        init_globals(true);
    92249617                        lp_kill_all_services();
    92259618                        return lp_load_ex(pszFname, global_only, save_defaults,
     
    92369629        }
    92379630
    9238         if (bRetval && lp_registry_shares() && allow_registry_shares) {
    9239                 bRetval = process_registry_shares();
     9631        if (bRetval && lp_registry_shares()) {
     9632                if (allow_registry_shares) {
     9633                        bRetval = process_registry_shares();
     9634                } else {
     9635                        bRetval = reload_registry_shares();
     9636                }
    92409637        }
    92419638
     
    92559652        set_allowed_client_auth();
    92569653
     9654        if (lp_security() == SEC_SHARE) {
     9655                DEBUG(1, ("WARNING: The security=share option is deprecated\n"));
     9656        } else if (lp_security() == SEC_SERVER) {
     9657                DEBUG(1, ("WARNING: The security=server option is deprecated\n"));
     9658        }
     9659
     9660        if (lp_security() == SEC_ADS && strchr(lp_passwordserver(), ':')) {
     9661                DEBUG(1, ("WARNING: The optional ':port' in password server = %s is deprecated\n",
     9662                          lp_passwordserver()));
     9663        }
     9664
    92579665        bLoaded = True;
    92589666
     
    92819689                          add_ipc,
    92829690                          initialize_globals,
    9283                           true, false);
     9691                          true,   /* allow_include_registry */
     9692                          false); /* allow_registry_shares*/
    92849693}
    92859694
     
    92879696{
    92889697        return lp_load_ex(pszFname,
    9289                           true,
    9290                           false,
    9291                           false,
    9292                           true,
    9293                           false,
    9294                           false);
     9698                          true,   /* global only */
     9699                          false,  /* save_defaults */
     9700                          false,  /* add_ipc */
     9701                          true,   /* initialize_globals */
     9702                          false,  /* allow_include_registry */
     9703                          false); /* allow_registry_shares*/
    92959704}
    92969705
     
    93069715                          add_ipc,
    93079716                          initialize_globals,
    9308                           true,
    9309                           true);
     9717                          true,  /* allow_include_registry */
     9718                          true); /* allow_registry_shares*/
    93109719}
    93119720
     
    93649773        int iService;
    93659774        fstring serviceName;
    9366        
     9775
    93679776        if (!pszServiceName) {
    93689777                return GLOBAL_SECTION_SNUM;
    93699778        }
    9370        
     9779
    93719780        for (iService = iNumServices - 1; iService >= 0; iService--) {
    93729781                if (VALID(iService) && ServicePtrs[iService]->szService) {
     
    94249833{
    94259834        struct share_params *result;
    9426         char *sname;
     9835        char *sname = NULL;
    94279836        int snum;
    94289837
    9429         if (!(sname = SMB_STRDUP(sharename))) {
    9430                 return NULL;
    9431         }
    9432 
    9433         snum = find_service(sname);
    9434         SAFE_FREE(sname);
    9435 
    9436         if (snum < 0) {
     9838        snum = find_service(mem_ctx, sharename, &sname);
     9839        if (snum < 0 || sname == NULL) {
    94379840                return NULL;
    94389841        }
     
    95189921                label = lp_servicename(snum);
    95199922        }
    9520                
     9923
    95219924        /* This returns a 33 byte guarenteed null terminated string. */
    95229925        ret = talloc_strndup(talloc_tos(), label, 32);
     
    95839986
    95849987/***********************************************************
    9585  returns role of Samba server
     9988 If we are PDC then prefer us as DMB
    95869989************************************************************/
    95879990
    9588 int lp_server_role(void)
    9589 {
    9590         return server_role;
     9991bool lp_domain_master(void)
     9992{
     9993        if (Globals.iDomainMaster == Auto)
     9994                return (lp_server_role() == ROLE_DOMAIN_PDC);
     9995
     9996        return (bool)Globals.iDomainMaster;
    95919997}
    95929998
     
    959510001************************************************************/
    959610002
    9597 bool lp_domain_master(void)
    9598 {
    9599         if (Globals.iDomainMaster == Auto)
    9600                 return (lp_server_role() == ROLE_DOMAIN_PDC);
    9601 
    9602         return (bool)Globals.iDomainMaster;
     10003bool lp_domain_master_true_or_auto(void)
     10004{
     10005        if (Globals.iDomainMaster) /* auto or yes */
     10006                return true;
     10007
     10008        return false;
    960310009}
    960410010
     
    989110297{
    989210298        char *sock_addr = Globals.szSocketAddress;
    9893        
     10299
    989410300        if (sock_addr[0] == '\0'){
    989510301                string_set(&Globals.szSocketAddress, "0.0.0.0");
     
    993410340        return lp_widelinks_internal(snum);
    993510341}
     10342
     10343bool lp_writeraw(void)
     10344{
     10345        if (lp_async_smb_echo_handler()) {
     10346                return false;
     10347        }
     10348        return _lp_writeraw();
     10349}
     10350
     10351bool lp_readraw(void)
     10352{
     10353        if (lp_async_smb_echo_handler()) {
     10354                return false;
     10355        }
     10356        return _lp_readraw();
     10357}
  • vendor/current/source3/param/test_lp_load.c

    r414 r740  
    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.