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:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

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

    r690 r745  
    1111   Copyright (C) Jim McDonough <[email protected]> 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
     56
    5557#include "printing.h"
     58
     59
     60
     61
     62
     63
     64
     65
     66
    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
    114127};
    115128
     
    185198        char *szAbortShutdownScript;
    186199        char *szUsernameMapScript;
     200
    187201        char *szCheckPasswordScript;
    188202        char *szWINSHook;
     
    208222        bool bWinbindRpcOnly;
    209223        bool bCreateKrb5Conf;
     224
    210225        char *szIdmapBackend;
    211         char *szIdmapAllocBackend;
     226        ;
    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_;
    258273        char **szWinbindNssInfo;
    259274        int iLockSpinTime;
     
    278293        bool clustering;
    279294        int ctdb_timeout;
     295
    280296        int ldap_passwd_sync;
    281297        int ldap_replication_sleep;
     
    330346        bool bClientUseSpnego;
    331347        bool client_use_spnego_principal;
     348
    332349        bool bDebugPrefixTimestamp;
    333350        bool bDebugHiresTimestamp;
     
    358375        int iIdmapNegativeCacheTime;
    359376        bool bResetOnZeroVC;
     377
    360378        int iKeepalive;
    361379        int iminreceivefile;
     
    364382        char *szSMBPerfcountModule;
    365383        bool bMapUntrustedToDomain;
     384
     385
     386
     387
     388
     389
     390
    366391};
    367392
     
    455480        bool bGuest_ok;
    456481        bool bPrint_ok;
     482
    457483        bool bMap_system;
    458484        bool bMap_hidden;
     
    599625        False,                  /* bGuest_ok */
    600626        False,                  /* bPrint_ok */
     627
    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);
     707
    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 );
     715
    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);
     725
    698726
    699727static const struct enum_list enum_protocol[] = {
     
    731759        {PRINT_LPRNT, "nt"},
    732760        {PRINT_LPROS2, "os2"},
    733 #ifdef DEVELOPER
     761#if
    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_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,
    11561169        },
    11571170        {
     
    12521265                .special        = NULL,
    12531266                .enum_list      = NULL,
    1254                 .flags          = FLAG_ADVANCED,
     1267                .flags          = FLAG_ADVANCED,
    12551268        },
    12561269
     
    13251338                .special        = NULL,
    13261339                .enum_list      = NULL,
    1327                 .flags          = FLAG_ADVANCED,
     1340                .flags          = FLAG_ADVANCED,
    13281341        },
    13291342        {
     
    14091422        },
    14101423        {
     1424
     1425
     1426
     1427
     1428
     1429
     1430
     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,
    14181440        },
    14191441        {
     
    20922114        },
    20932115        {
     2116
     2117
     2118
     2119
     2120
     2121
     2122
     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,
    22722303        },
    22732304        {
     
    25802611                .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
    25812612        },
     2613
     2614
     2615
     2616
     2617
     2618
     2619
     2620
     2621
     2622
     2623
     2624
     2625
     2626
     2627
     2628
     2629
     2630
     2631
     2632
     2633
     2634
     2635
     2636
     2637
     2638
     2639
     2640
     2641
     2642
     2643
     2644
     2645
     2646
     2647
     2648
     2649
     2650
     2651
     2652
     2653
     2654
     2655
     2656
     2657
    25822658
    25832659        {N_("Printing Options"), P_SEP, P_SEPARATOR},
     
    26452721                .enum_list      = NULL,
    26462722                .flags          = FLAG_ADVANCED | FLAG_PRINT,
     2723
     2724
     2725
     2726
     2727
     2728
     2729
     2730
     2731
    26472732        },
    26482733        {
     
    32543339        },
    32553340        {
     3341
     3342
     3343
     3344
     3345
     3346
     3347
     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,
    40604154        },
    40614155        {
     
    43574451        },
    43584452        {
     4453
     4454
     4455
     4456
     4457
     4458
     4459
     4460
     4461
     4462
     4463
     4464
     4465
     4466
     4467
     4468
     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,
    44844587        },
    44854588        {
     
    44994602                .special        = handle_idmap_gid,
    45004603                .enum_list      = NULL,
    4501                 .flags          = FLAG_ADVANCED,
     4604                .flags          = FLAG_ADVANCED,
    45024605        },
    45034606        {
     
    45564659        },
    45574660        {
     4661
     4662
     4663
     4664
     4665
     4666
     4667
     4668
     4669
    45584670                .label          = "winbind enum users",
    45594671                .type           = P_BOOL,
     
    46594771                .p_class        = P_GLOBAL,
    46604772                .ptr            = &Globals.bCreateKrb5Conf,
     4773
     4774
     4775
     4776
     4777
     4778
     4779
     4780
     4781
     4782
     4783
     4784
     4785
     4786
     4787
     4788
     4789
     4790
    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
     5085
     5086
     5087
     5088
     5089
     5090
     5091
     5092
     5093
     5094
     5095
     5096
     5097
     5098
     5099
     5100
     5101
     5102
     5103
     5104
     5105
     5106
     5107
     5108
     5109
     5110
     5111
     5112
     5113
     5114
     5115
     5116
     5117
     5118
     5119
     5120
     5121
     5122
     5123
     5124
     5125
     5126
     5127
     5128
     5129
     5130
     5131
     5132
     5133
     5134
     5135
     5136
     5137
     5138
     5139
     5140
     5141
     5142
     5143
     5144
     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 )
    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 ( && done_init) {
    49195159                /* ... then we have nothing more to do */
    49205160                return;
     
    49325172        }
    49335173
     5174
     5175
     5176
     5177
    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 = */
     5374        /* Note, that we will 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
    51455388        Globals.bCreateKrb5Conf = true;
     5389
    51465390
    51475391        /* hostname lookups can be very expensive and are broken on
     
    52085452        Globals.bAllowTrustedDomains = True;
    52095453        string_set(&Globals.szIdmapBackend, "tdb");
     5454
    52105455
    52115456        string_set(&Globals.szTemplateShell, "/bin/false");
     
    52205465        Globals.clustering = False;
    52215466        Globals.ctdb_timeout = 0;
     5467
    52225468
    52235469        Globals.winbind_cache_time = 300;       /* 5 minutes */
    52245470        Globals.winbind_reconnect_delay = 30;   /* 30 seconds */
     5471
    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(, "template", NULL);
    52325479        Globals.bWinbindRefreshTickets = False;
    52335480        Globals.bWinbindOfflineLogon = False;
     
    52745521
    52755522        Globals.bMapUntrustedToDomain = false;
     5523
     5524
     5525
     5526
     5527
     5528
     5529
     5530
     5531
     5532
     5533
    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)
     5742
    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)
     5762
     5763
     5764
     5765
     5766
     5767
     5768
     5769
     5770
     5771
     5772
     5773
     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)
     5810
     5811
    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)
     5866
    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)
     5968
    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)
     6016
    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)
     6041
     6042
    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)
     6087
    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
     6095
     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(, 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        (pservice->copymap);
    61176413
    61186414        free_param_opts(&pservice->param_opt);
     
    61396435        if (ServicePtrs[idx]->szService) {
    61406436                char *canon_name = canonicalize_servicename(
     6437
    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)
     6526const char *src)
    62336527{
    62346528        char *result;
     
    62396533        }
    62406534
    6241         result = talloc_strdup(talloc_tos(), src);
     6535        result = talloc_strdup(, src);
    62426536        SMB_ASSERT(result != NULL);
    62436537
     
    62666560                idx, name));
    62676561
    6268         canon_name = canonicalize_servicename( name );
     6562        canon_name = canonicalize_servicename( 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(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
     7116
     7117
     7118
     7119
     7120
    68207121                        string_free(&opt->value);
    68217122                        TALLOC_FREE(opt->list);
    68227123                        opt->value = SMB_STRDUP(opt_value);
     7124
    68237125                        not_added = false;
    68247126                        break;
     
    68317133            new_opt->value = SMB_STRDUP(opt_value);
    68327134            new_opt->list = NULL;
     7135
    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);
    69017204                data = data->next;
    69027205        }
     
    69517254static struct smbconf_ctx *lp_smbconf_ctx(void)
    69527255{
    6953         WERROR werr;
     7256        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 (!err)) {
    69597262                        DEBUG(1, ("error initializing registry configuration: "
    6960                                   "%s\n", win_errstr(werr)));
     7263                                  "%s\n", err)));
    69617264                        conf_ctx = NULL;
    69627265                }
     
    69987301bool process_registry_service(const char *service_name)
    69997302{
    7000         WERROR werr;
     7303        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 (!err)) {
    70237326                goto done;
    70247327        }
     
    70567359bool process_registry_shares(void)
    70577360{
    7058         WERROR werr;
     7361        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 (!err)) {
    70727375                goto done;
    70737376        }
     
    70927395        return ret;
    70937396}
     7397
     7398
     7399
     7400
     7401
     7402
     7403
     7404
     7405
     7406
     7407
     7408
     7409
     7410
     7411
     7412
     7413
     7414
     7415
     7416
     7417
     7418
     7419
     7420
     7421
     7422
     7423
     7424
     7425
    70947426
    70957427#define MAX_INCLUDE_DEPTH 100
     
    71317463                f->subfname = SMB_STRDUP(subfname);
    71327464                if (!f->subfname) {
     7465
    71337466                        SAFE_FREE(f);
    71347467                        return;
     
    71417474                        f->modtime = t;
    71427475        }
     7476
    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                        _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 =
     7586                current_user_info.domain,
     7587                pszParmValue);
    72547588
    72557589        ret = set_global_myname(netbios_name);
    7256         SAFE_FREE(netbios_name);
     7590        _FREE(netbios_name);
    72577591        string_set(&Globals.szNetbiosName,global_myname());
    72587592
     
    72727606}
    72737607
     7608
     7609
     7610
     7611
     7612
     7613
     7614
     7615
     7616
     7617
     7618
     7619
     7620
     7621
     7622
     7623
     7624
     7625
     7626
     7627
     7628
     7629
     7630
     7631
     7632
     7633
     7634
     7635
     7636
     7637
     7638
     7639
     7640
     7641
     7642
     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(, 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 = 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                _FREE(fname);
    73497720                return ret;
    73507721        }
    73517722
    73527723        DEBUG(2, ("Can't find include file %s\n", fname));
    7353         SAFE_FREE(fname);
     7724        _FREE(fname);
    73547725        return true;
    73557726}
     
    74457816}
    74467817
     7818
     7819
     7820
     7821
     7822
     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        (pservice->copymap);
     7954
     7955        pservice->copymap = bitmap_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);
    76558013
    76568014                return (True);
     8015
     8016
     8017
     8018
     8019
     8020
    76578021        }
    76588022
     
    77238087                        TALLOC_FREE(*((char ***)parm_ptr));
    77248088                        *(char ***)parm_ptr = str_list_make_v3(
    7725                                 talloc_autofree_context(), pszParmValue, NULL);
     8089                                , pszParmValue, NULL);
    77268090                        break;
    77278091
     
    77468110
    77478111/***************************************************************************
     8112
     8113
     8114
     8115
     8116
     8117
     8118
     8119
     8120
     8121
     8122
     8123
     8124
     8125
     8126
     8127
     8128
     8129
     8130
     8131
     8132
     8133
     8134
     8135
     8136
     8137
     8138
     8139
     8140
     8141
     8142
     8143
     8144
     8145
     8146
     8147
     8148
     8149
     8150
     8151
     8152
     8153
     8154
     8155
     8156
     8157
     8158
     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
     8368
     8369
    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
     8982
     8983
     8984
     8985
     8986
     8987
     8988
     8989
     8990
     8991
     8992
     8993
     8994
     8995
     8996
     8997
     8998
     8999
    86039000                }
    86049001        }
     
    87139110        char *sharepath = NULL;
    87149111        char *comment = NULL;
    8715         fstring service_name;
     9112        ;
    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 = ;
     9118        *psd = NULL;
    87229119        bool guest_ok = False;
     9120
     9121
     9122
    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                        _name ));
    87739174                ServicePtrs[iService]->usershare = USERSHARE_VALID;
    8774                 SAFE_FREE(fname);
    8775                 return iService;
     9175                ;
     9176                ;
    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, 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
    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(_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)
     9592bool 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
     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 = 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                _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(e);
    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
     9699
     9700
     9701
     9702
     9703
     9704
     9705
     9706
     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
     9725
     9726
    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,
     9757                          false,
     9758                          false,
     9759                          true,
     9760                          false,
     9761                          false);
    93519762}
    93529763
     
    93629773                          add_ipc,
    93639774                          initialize_globals,
    9364                           true,
    9365                           true);
     9775                          true,
     9776                          true);
    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;
    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 
    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(void)
     10062{
     10063        if (Globals.iDomainMaster
     10064                return ;
     10065
     10066        return ;
    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
     10401
     10402
     10403
     10404
     10405
     10406
     10407
     10408
     10409
     10410
     10411
     10412
     10413
     10414
     10415
Note: See TracChangeset for help on using the changeset viewer.