Changeset 745 for trunk/server/source3/param
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/param/loadparm.c
r690 r745 11 11 Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003 12 12 Copyright (C) Michael Adam 2008 13 13 14 14 This program is free software; you can redistribute it and/or modify 15 15 it under the terms of the GNU General Public License as published by 16 16 the Free Software Foundation; either version 3 of the License, or 17 17 (at your option) any later version. 18 18 19 19 This program is distributed in the hope that it will be useful, 20 20 but WITHOUT ANY WARRANTY; without even the implied warranty of 21 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 22 GNU General Public License for more details. 23 23 24 24 You should have received a copy of the GNU General Public License 25 25 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 53 53 54 54 #include "includes.h" 55 #include "system/filesys.h" 56 #include "util_tdb.h" 55 57 #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" 56 67 57 68 #ifdef HAVE_SYS_SYSCTL_H … … 89 100 static bool in_client = False; /* Not in the client by default */ 90 101 static struct smbconf_csn conf_last_csn; 102 91 103 #ifdef __OS2__ 92 104 static bool newLockDir = False; … … 112 124 char *value; 113 125 char **list; 126 unsigned flags; 114 127 }; 115 128 … … 185 198 char *szAbortShutdownScript; 186 199 char *szUsernameMapScript; 200 int iUsernameMapCacheTime; 187 201 char *szCheckPasswordScript; 188 202 char *szWINSHook; … … 208 222 bool bWinbindRpcOnly; 209 223 bool bCreateKrb5Conf; 224 int winbindMaxDomainConnections; 210 225 char *szIdmapBackend; 211 char *szIdmapAllocBackend;226 bool bIdmapReadOnly; 212 227 char *szAddShareCommand; 213 228 char *szChangeShareCommand; … … 255 270 int winbind_cache_time; 256 271 int winbind_reconnect_delay; 257 int winbind_max_ idle_children;272 int winbind_max_clients; 258 273 char **szWinbindNssInfo; 259 274 int iLockSpinTime; … … 278 293 bool clustering; 279 294 int ctdb_timeout; 295 int ctdb_locktime_warn_threshold; 280 296 int ldap_passwd_sync; 281 297 int ldap_replication_sleep; … … 330 346 bool bClientUseSpnego; 331 347 bool client_use_spnego_principal; 348 bool send_spnego_principal; 332 349 bool bDebugPrefixTimestamp; 333 350 bool bDebugHiresTimestamp; … … 358 375 int iIdmapNegativeCacheTime; 359 376 bool bResetOnZeroVC; 377 bool bLogWriteableFilesOnExit; 360 378 int iKeepalive; 361 379 int iminreceivefile; … … 364 382 char *szSMBPerfcountModule; 365 383 bool bMapUntrustedToDomain; 384 bool bAsyncSMBEchoHandler; 385 bool bMulticastDnsRegister; 386 int ismb2_max_read; 387 int ismb2_max_write; 388 int ismb2_max_trans; 389 int ismb2_max_credits; 390 char *ncalrpc_dir; 366 391 }; 367 392 … … 455 480 bool bGuest_ok; 456 481 bool bPrint_ok; 482 bool bPrintNotifyBackchannel; 457 483 bool bMap_system; 458 484 bool bMap_hidden; … … 599 625 False, /* bGuest_ok */ 600 626 False, /* bPrint_ok */ 627 True, /* bPrintNotifyBackchannel */ 601 628 False, /* bMap_system */ 602 629 False, /* bMap_hidden */ … … 670 697 static bool bInGlobalSection = True; 671 698 static bool bGlobalOnly = False; 672 static int server_role;673 699 static int default_server_announce; 674 700 … … 679 705 static bool handle_copy( int snum, const char *pszParmValue, char **ptr); 680 706 static bool handle_netbios_name( int snum, const char *pszParmValue, char **ptr); 707 static bool handle_idmap_backend(int snum, const char *pszParmValue, char **ptr); 681 708 static bool handle_idmap_uid( int snum, const char *pszParmValue, char **ptr); 682 709 static bool handle_idmap_gid( int snum, const char *pszParmValue, char **ptr); … … 686 713 static bool handle_netbios_scope( int snum, const char *pszParmValue, char **ptr ); 687 714 static bool handle_charset( int snum, const char *pszParmValue, char **ptr ); 715 static bool handle_dos_charset( int snum, const char *pszParmValue, char **ptr ); 688 716 static bool handle_printing( int snum, const char *pszParmValue, char **ptr); 689 717 static bool handle_ldap_debug_level( int snum, const char *pszParmValue, char **ptr); 690 718 691 static void set_server_role(void);692 719 static void set_default_server_announce_type(void); 693 720 static void set_allowed_client_auth(void); … … 696 723 697 724 static void add_to_file_list(const char *fname, const char *subfname); 725 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values); 698 726 699 727 static const struct enum_list enum_protocol[] = { … … 731 759 {PRINT_LPRNT, "nt"}, 732 760 {PRINT_LPROS2, "os2"}, 733 #if def DEVELOPER761 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS) 734 762 {PRINT_TEST, "test"}, 735 763 {PRINT_VLP, "vlp"}, … … 821 849 {-1, NULL} 822 850 }; 823 824 /* Client-side offline caching policy types */825 #define CSC_POLICY_MANUAL 0826 #define CSC_POLICY_DOCUMENTS 1827 #define CSC_POLICY_PROGRAMS 2828 #define CSC_POLICY_DISABLE 3829 851 830 852 static const struct enum_list enum_csc_policy[] = { … … 939 961 .p_class = P_GLOBAL, 940 962 .ptr = &Globals.dos_charset, 941 .special = handle_ charset,963 .special = handle_dos_charset, 942 964 .enum_list = NULL, 943 965 .flags = FLAG_ADVANCED … … 1102 1124 }, 1103 1125 { 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 {1113 1126 .label = "client schannel", 1114 1127 .type = P_ENUM, … … 1153 1166 .special = NULL, 1154 1167 .enum_list = NULL, 1155 .flags = FLAG_ADVANCED ,1168 .flags = FLAG_ADVANCED | FLAG_DEPRECATED, 1156 1169 }, 1157 1170 { … … 1252 1265 .special = NULL, 1253 1266 .enum_list = NULL, 1254 .flags = FLAG_ADVANCED ,1267 .flags = FLAG_ADVANCED | FLAG_DEPRECATED, 1255 1268 }, 1256 1269 … … 1325 1338 .special = NULL, 1326 1339 .enum_list = NULL, 1327 .flags = FLAG_ADVANCED ,1340 .flags = FLAG_ADVANCED | FLAG_DEPRECATED, 1328 1341 }, 1329 1342 { … … 1409 1422 }, 1410 1423 { 1424 .label = "send spnego principal", 1425 .type = P_BOOL, 1426 .p_class = P_GLOBAL, 1427 .ptr = &Globals.send_spnego_principal, 1428 .special = NULL, 1429 .enum_list = NULL, 1430 .flags = FLAG_ADVANCED, 1431 }, 1432 { 1411 1433 .label = "username", 1412 1434 .type = P_STRING, … … 1415 1437 .special = NULL, 1416 1438 .enum_list = NULL, 1417 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE ,1439 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE | FLAG_DEPRECATED, 1418 1440 }, 1419 1441 { … … 2092 2114 }, 2093 2115 { 2116 .label = "log writeable files on exit", 2117 .type = P_BOOL, 2118 .p_class = P_GLOBAL, 2119 .ptr = &Globals.bLogWriteableFilesOnExit, 2120 .special = NULL, 2121 .enum_list = NULL, 2122 .flags = FLAG_ADVANCED, 2123 }, 2124 { 2094 2125 .label = "acl compatibility", 2095 2126 .type = P_ENUM, … … 2269 2300 .special = NULL, 2270 2301 .enum_list = NULL, 2271 .flags = FLAG_ADVANCED ,2302 .flags = FLAG_ADVANCED | FLAG_DEPRECATED, 2272 2303 }, 2273 2304 { … … 2580 2611 .flags = FLAG_ADVANCED | FLAG_GLOBAL, 2581 2612 }, 2613 { 2614 .label = "ctdb locktime warn threshold", 2615 .type = P_INTEGER, 2616 .p_class = P_GLOBAL, 2617 .ptr = &Globals.ctdb_locktime_warn_threshold, 2618 .special = NULL, 2619 .enum_list = NULL, 2620 .flags = FLAG_ADVANCED | FLAG_GLOBAL, 2621 }, 2622 { 2623 .label = "smb2 max read", 2624 .type = P_INTEGER, 2625 .p_class = P_GLOBAL, 2626 .ptr = &Globals.ismb2_max_read, 2627 .special = NULL, 2628 .enum_list = NULL, 2629 .flags = FLAG_ADVANCED, 2630 }, 2631 { 2632 .label = "smb2 max write", 2633 .type = P_INTEGER, 2634 .p_class = P_GLOBAL, 2635 .ptr = &Globals.ismb2_max_write, 2636 .special = NULL, 2637 .enum_list = NULL, 2638 .flags = FLAG_ADVANCED, 2639 }, 2640 { 2641 .label = "smb2 max trans", 2642 .type = P_INTEGER, 2643 .p_class = P_GLOBAL, 2644 .ptr = &Globals.ismb2_max_trans, 2645 .special = NULL, 2646 .enum_list = NULL, 2647 .flags = FLAG_ADVANCED, 2648 }, 2649 { 2650 .label = "smb2 max credits", 2651 .type = P_INTEGER, 2652 .p_class = P_GLOBAL, 2653 .ptr = &Globals.ismb2_max_credits, 2654 .special = NULL, 2655 .enum_list = NULL, 2656 .flags = FLAG_ADVANCED, 2657 }, 2582 2658 2583 2659 {N_("Printing Options"), P_SEP, P_SEPARATOR}, … … 2645 2721 .enum_list = NULL, 2646 2722 .flags = FLAG_ADVANCED | FLAG_PRINT, 2723 }, 2724 { 2725 .label = "print notify backchannel", 2726 .type = P_BOOL, 2727 .p_class = P_LOCAL, 2728 .ptr = &sDefault.bPrintNotifyBackchannel, 2729 .special = NULL, 2730 .enum_list = NULL, 2731 .flags = FLAG_ADVANCED, 2647 2732 }, 2648 2733 { … … 3254 3339 }, 3255 3340 { 3341 .label = "username map cache time", 3342 .type = P_INTEGER, 3343 .p_class = P_GLOBAL, 3344 .ptr = &Globals.iUsernameMapCacheTime, 3345 .special = NULL, 3346 .enum_list = NULL, 3347 .flags = FLAG_ADVANCED, 3348 }, 3349 { 3256 3350 .label = "logon script", 3257 3351 .type = P_STRING, … … 4057 4151 .special = NULL, 4058 4152 .enum_list = NULL, 4059 .flags = FLAG_ADVANCED ,4153 .flags = FLAG_ADVANCED | FLAG_DEPRECATED, 4060 4154 }, 4061 4155 { … … 4357 4451 }, 4358 4452 { 4453 .label = "async smb echo handler", 4454 .type = P_BOOL, 4455 .p_class = P_GLOBAL, 4456 .ptr = &Globals.bAsyncSMBEchoHandler, 4457 .special = NULL, 4458 .enum_list = NULL, 4459 .flags = FLAG_ADVANCED | FLAG_GLOBAL, 4460 }, 4461 { 4462 .label = "multicast dns register", 4463 .type = P_BOOL, 4464 .p_class = P_GLOBAL, 4465 .ptr = &Globals.bMulticastDnsRegister, 4466 .special = NULL, 4467 .enum_list = NULL, 4468 .flags = FLAG_ADVANCED | FLAG_GLOBAL, 4469 }, 4470 { 4359 4471 .label = "panic action", 4360 4472 .type = P_STRING, … … 4443 4555 .p_class = P_GLOBAL, 4444 4556 .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, 4457 4560 }, 4458 4561 { … … 4481 4584 .special = handle_idmap_uid, 4482 4585 .enum_list = NULL, 4483 .flags = FLAG_ADVANCED ,4586 .flags = FLAG_ADVANCED | FLAG_DEPRECATED, 4484 4587 }, 4485 4588 { … … 4499 4602 .special = handle_idmap_gid, 4500 4603 .enum_list = NULL, 4501 .flags = FLAG_ADVANCED ,4604 .flags = FLAG_ADVANCED | FLAG_DEPRECATED, 4502 4605 }, 4503 4606 { … … 4556 4659 }, 4557 4660 { 4661 .label = "winbind max clients", 4662 .type = P_INTEGER, 4663 .p_class = P_GLOBAL, 4664 .ptr = &Globals.winbind_max_clients, 4665 .special = NULL, 4666 .enum_list = NULL, 4667 .flags = FLAG_ADVANCED, 4668 }, 4669 { 4558 4670 .label = "winbind enum users", 4559 4671 .type = P_BOOL, … … 4659 4771 .p_class = P_GLOBAL, 4660 4772 .ptr = &Globals.bCreateKrb5Conf, 4773 .special = NULL, 4774 .enum_list = NULL, 4775 .flags = FLAG_ADVANCED, 4776 }, 4777 { 4778 .label = "ncalrpc dir", 4779 .type = P_STRING, 4780 .p_class = P_GLOBAL, 4781 .ptr = &Globals.ncalrpc_dir, 4782 .special = NULL, 4783 .enum_list = NULL, 4784 .flags = FLAG_ADVANCED, 4785 }, 4786 { 4787 .label = "winbind max domain connections", 4788 .type = P_INTEGER, 4789 .p_class = P_GLOBAL, 4790 .ptr = &Globals.winbindMaxDomainConnections, 4661 4791 .special = NULL, 4662 4792 .enum_list = NULL, … … 4746 4876 break; 4747 4877 4748 #ifdef DEVELOPER 4878 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS) 4879 4749 4880 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 4758 4935 break; 4936 } 4759 4937 #endif /* DEVELOPER */ 4760 4938 … … 4792 4970 if(rl.rlim_cur == RLIM_INFINITY) 4793 4971 rlimit_max = MAX_OPEN_FILES; 4794 }4795 4972 #endif 4973 } 4796 4974 #endif 4797 4975 … … 4905 5083 } 4906 5084 5085 static int map_parameter(const char *pszParmName); 5086 5087 struct lp_stored_option { 5088 struct lp_stored_option *prev, *next; 5089 const char *label; 5090 const char *value; 5091 }; 5092 5093 static struct lp_stored_option *stored_options; 5094 5095 /* 5096 save options set by lp_set_cmdline() into a list. This list is 5097 re-applied when we do a globals reset, so that cmdline set options 5098 are sticky across reloads of smb.conf 5099 */ 5100 static bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue) 5101 { 5102 struct lp_stored_option *entry, *entry_next; 5103 for (entry = stored_options; entry != NULL; entry = entry_next) { 5104 entry_next = entry->next; 5105 if (strcmp(pszParmName, entry->label) == 0) { 5106 DLIST_REMOVE(stored_options, entry); 5107 talloc_free(entry); 5108 break; 5109 } 5110 } 5111 5112 entry = talloc(NULL, struct lp_stored_option); 5113 if (!entry) { 5114 return false; 5115 } 5116 5117 entry->label = talloc_strdup(entry, pszParmName); 5118 if (!entry->label) { 5119 talloc_free(entry); 5120 return false; 5121 } 5122 5123 entry->value = talloc_strdup(entry, pszParmValue); 5124 if (!entry->value) { 5125 talloc_free(entry); 5126 return false; 5127 } 5128 5129 DLIST_ADD_END(stored_options, entry, struct lp_stored_option); 5130 5131 return true; 5132 } 5133 5134 static bool apply_lp_set_cmdline(void) 5135 { 5136 struct lp_stored_option *entry = NULL; 5137 for (entry = stored_options; entry != NULL; entry = entry->next) { 5138 if (!lp_set_cmdline_helper(entry->label, entry->value, false)) { 5139 DEBUG(0, ("Failed to re-apply cmdline parameter %s = %s\n", 5140 entry->label, entry->value)); 5141 return false; 5142 } 5143 } 5144 return true; 5145 } 5146 4907 5147 /*************************************************************************** 4908 5148 Initialise the global parameter structure. 4909 5149 ***************************************************************************/ 4910 5150 4911 static void init_globals(bool first_time_only)5151 static void init_globals(bool reinit_globals) 4912 5152 { 4913 5153 static bool done_init = False; … … 4916 5156 4917 5157 /* If requested to initialize only once and we've already done it... */ 4918 if ( first_time_only&& done_init) {5158 if (!reinit_globals && done_init) { 4919 5159 /* ... then we have nothing more to do */ 4920 5160 return; … … 4932 5172 } 4933 5173 5174 /* This memset and the free_global_parameters() above will 5175 * wipe out smb.conf options set with lp_set_cmdline(). The 5176 * apply_lp_set_cmdline() call puts these values back in the 5177 * table once the defaults are set */ 4934 5178 memset((void *)&Globals, '\0', sizeof(Globals)); 4935 5179 … … 4960 5204 string_set(&Globals.szGuestaccount, GUEST_ACCOUNT); 4961 5205 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 4963 5210 /* search the system codepage and set OS2CodePageStr */ 4964 5211 unsigned long _System DosQueryCp (unsigned long ulLength, unsigned long *pCodePageList, unsigned long *pDataLength); … … 4970 5217 else 4971 5218 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 4977 5220 /* On OS/2, using UTF8 causes problems with display of foreign 4978 5221 characters - default to system codepage */ … … 4990 5233 string_set(&Globals.display_charset, OS2CodePageStr); 4991 5234 #endif 4992 4993 5235 #else 4994 5236 string_set(&Globals.display_charset, DEFAULT_DISPLAY_CHARSET); … … 5026 5268 /* 5027 5269 * By default support explicit binding to broadcast 5028 * addresses.5029 */5270 * addresses. 5271 */ 5030 5272 Globals.bNmbdBindExplicitBroadcast = true; 5031 5273 … … 5129 5371 Globals.bLanmanAuth = False; /* Do NOT use the LanMan hash, even if it is supplied */ 5130 5372 Globals.bNTLMAuth = True; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */ 5131 Globals.bClientNTLMv2Auth = False; /* Client should not use NTLMv2, as we can't tell that the server supports it.*/5132 /* Note, that we will use NTLM2 session security (which is different), if it is available */5373 Globals.bClientNTLMv2Auth = True; /* Client should always use use NTLMv2, as we can't tell that the server supports it, but most modern servers do */ 5374 /* Note, that we will also use NTLM2 session security (which is different), if it is available */ 5133 5375 5134 5376 Globals.map_to_guest = 0; /* By Default, "Never" */ … … 5143 5385 Globals.bUnixExtensions = True; 5144 5386 Globals.bResetOnZeroVC = False; 5387 Globals.bLogWriteableFilesOnExit = False; 5145 5388 Globals.bCreateKrb5Conf = true; 5389 Globals.winbindMaxDomainConnections = 1; 5146 5390 5147 5391 /* hostname lookups can be very expensive and are broken on … … 5208 5452 Globals.bAllowTrustedDomains = True; 5209 5453 string_set(&Globals.szIdmapBackend, "tdb"); 5454 Globals.bIdmapReadOnly = false; 5210 5455 5211 5456 string_set(&Globals.szTemplateShell, "/bin/false"); … … 5220 5465 Globals.clustering = False; 5221 5466 Globals.ctdb_timeout = 0; 5467 Globals.ctdb_locktime_warn_threshold = 0; 5222 5468 5223 5469 Globals.winbind_cache_time = 300; /* 5 minutes */ 5224 5470 Globals.winbind_reconnect_delay = 30; /* 30 seconds */ 5471 Globals.winbind_max_clients = 200; 5225 5472 Globals.bWinbindEnumUsers = False; 5226 5473 Globals.bWinbindEnumGroups = False; … … 5229 5476 Globals.bWinbindNestedGroups = True; 5230 5477 Globals.winbind_expand_groups = 1; 5231 Globals.szWinbindNssInfo = str_list_make_v3( talloc_autofree_context(), "template", NULL);5478 Globals.szWinbindNssInfo = str_list_make_v3(NULL, "template", NULL); 5232 5479 Globals.bWinbindRefreshTickets = False; 5233 5480 Globals.bWinbindOfflineLogon = False; … … 5274 5521 5275 5522 Globals.bMapUntrustedToDomain = false; 5523 Globals.bMulticastDnsRegister = true; 5524 5525 Globals.ismb2_max_read = DEFAULT_SMB2_MAX_READ; 5526 Globals.ismb2_max_write = DEFAULT_SMB2_MAX_WRITE; 5527 Globals.ismb2_max_trans = DEFAULT_SMB2_MAX_TRANSACT; 5528 Globals.ismb2_max_credits = DEFAULT_SMB2_MAX_CREDITS; 5529 5530 string_set(&Globals.ncalrpc_dir, get_dyn_NCALRPCDIR()); 5531 5532 /* Now put back the settings that were set with lp_set_cmdline() */ 5533 apply_lp_set_cmdline(); 5276 5534 } 5277 5535 … … 5348 5606 #define FN_LOCAL_PARM_INTEGER(fn_name,val) \ 5349 5607 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));}5352 5608 #define FN_LOCAL_CHAR(fn_name,val) \ 5353 5609 char fn_name(const struct share_params *p) {return(LP_SNUM_OK(p->service)? ServicePtrs[(p->service)]->val : sDefault.val);} … … 5484 5740 FN_GLOBAL_STRING(lp_abort_shutdown_script, &Globals.szAbortShutdownScript) 5485 5741 FN_GLOBAL_STRING(lp_username_map_script, &Globals.szUsernameMapScript) 5742 FN_GLOBAL_INTEGER(lp_username_map_cache_time, &Globals.iUsernameMapCacheTime) 5486 5743 5487 5744 FN_GLOBAL_STRING(lp_check_password_script, &Globals.szCheckPasswordScript) … … 5503 5760 FN_GLOBAL_BOOL(lp_winbind_rpc_only, &Globals.bWinbindRpcOnly) 5504 5761 FN_GLOBAL_BOOL(lp_create_krb5_conf, &Globals.bCreateKrb5Conf) 5762 static FN_GLOBAL_INTEGER(lp_winbind_max_domain_connections_int, 5763 &Globals.winbindMaxDomainConnections) 5764 5765 int lp_winbind_max_domain_connections(void) 5766 { 5767 if (lp_winbind_offline_logon() && 5768 lp_winbind_max_domain_connections_int() > 1) { 5769 DEBUG(1, ("offline logons active, restricting max domain " 5770 "connections to 1\n")); 5771 return 1; 5772 } 5773 return MAX(1, lp_winbind_max_domain_connections_int()); 5774 } 5505 5775 5506 5776 FN_GLOBAL_CONST_STRING(lp_idmap_backend, &Globals.szIdmapBackend) 5507 FN_GLOBAL_STRING(lp_idmap_alloc_backend, &Globals.szIdmapAllocBackend)5508 5777 FN_GLOBAL_INTEGER(lp_idmap_cache_time, &Globals.iIdmapCacheTime) 5509 5778 FN_GLOBAL_INTEGER(lp_idmap_negative_cache_time, &Globals.iIdmapNegativeCacheTime) … … 5539 5808 FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios) 5540 5809 FN_GLOBAL_BOOL(lp_reset_on_zero_vc, &Globals.bResetOnZeroVC) 5810 FN_GLOBAL_BOOL(lp_log_writeable_files_on_exit, 5811 &Globals.bLogWriteableFilesOnExit) 5541 5812 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard) 5542 5813 FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy) … … 5549 5820 FN_GLOBAL_INTEGER(lp_init_logon_delay, &Globals.InitLogonDelay) 5550 5821 FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters) 5551 FN_GLOBAL_BOOL( lp_readraw, &Globals.bReadRaw)5822 FN_GLOBAL_BOOL(_lp_readraw, &Globals.bReadRaw) 5552 5823 FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite) 5553 FN_GLOBAL_BOOL( lp_writeraw, &Globals.bWriteRaw)5824 FN_GLOBAL_BOOL(_lp_writeraw, &Globals.bWriteRaw) 5554 5825 FN_GLOBAL_BOOL(lp_null_passwords, &Globals.bNullPasswords) 5555 5826 FN_GLOBAL_BOOL(lp_obey_pam_restrictions, &Globals.bObeyPamRestrictions) 5556 5827 FN_GLOBAL_BOOL(lp_encrypted_passwords, &Globals.bEncryptPasswords) 5557 FN_GLOBAL_BOOL(lp_update_encrypted, &Globals.bUpdateEncrypt)5558 5828 FN_GLOBAL_INTEGER(lp_client_schannel, &Globals.clientSchannel) 5559 5829 FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel) … … 5594 5864 FN_GLOBAL_BOOL(lp_client_use_spnego, &Globals.bClientUseSpnego) 5595 5865 FN_GLOBAL_BOOL(lp_client_use_spnego_principal, &Globals.client_use_spnego_principal) 5866 FN_GLOBAL_BOOL(lp_send_spnego_principal, &Globals.send_spnego_principal) 5596 5867 FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups) 5597 5868 FN_LOCAL_PARM_BOOL(lp_change_notify, bChangeNotify) … … 5615 5886 FN_GLOBAL_INTEGER(lp_deadtime, &Globals.deadtime) 5616 5887 FN_GLOBAL_BOOL(lp_getwd_cache, &Globals.getwd_cache) 5617 FN_GLOBAL_INTEGER(lp_maxprotocol, &Globals.maxprotocol) 5888 static FN_GLOBAL_INTEGER(_lp_maxprotocol, &Globals.maxprotocol) 5889 int 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 } 5618 5900 FN_GLOBAL_INTEGER(lp_minprotocol, &Globals.minprotocol) 5619 5901 FN_GLOBAL_INTEGER(lp_security, &Globals.security) … … 5635 5917 FN_GLOBAL_CONST_STRING(lp_socket_options, &Globals.szSocketOptions) 5636 5918 FN_GLOBAL_INTEGER(lp_config_backend, &Globals.ConfigBackend) 5637 5919 FN_GLOBAL_INTEGER(lp_smb2_max_read, &Globals.ismb2_max_read) 5920 FN_GLOBAL_INTEGER(lp_smb2_max_write, &Globals.ismb2_max_write) 5921 FN_GLOBAL_INTEGER(lp_smb2_max_trans, &Globals.ismb2_max_trans) 5922 int 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 } 5638 5929 FN_LOCAL_STRING(lp_preexec, szPreExec) 5639 5930 FN_LOCAL_STRING(lp_postexec, szPostExec) … … 5675 5966 FN_GLOBAL_BOOL(lp_clustering, &Globals.clustering) 5676 5967 FN_GLOBAL_INTEGER(lp_ctdb_timeout, &Globals.ctdb_timeout) 5968 FN_GLOBAL_INTEGER(lp_ctdb_locktime_warn_threshold, &Globals.ctdb_locktime_warn_threshold) 5677 5969 FN_LOCAL_STRING(lp_printcommand, szPrintcommand) 5678 5970 FN_LOCAL_STRING(lp_lpqcommand, szLpqcommand) … … 5722 6014 FN_LOCAL_BOOL(lp_administrative_share, bAdministrative_share) 5723 6015 FN_LOCAL_BOOL(lp_print_ok, bPrint_ok) 6016 FN_LOCAL_BOOL(lp_print_notify_backchannel, bPrintNotifyBackchannel) 5724 6017 FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden) 5725 6018 FN_LOCAL_BOOL(lp_map_archive, bMap_archive) … … 5746 6039 FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution) 5747 6040 FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes) 6041 FN_GLOBAL_BOOL(lp_async_smb_echo_handler, &Globals.bAsyncSMBEchoHandler) 6042 FN_GLOBAL_BOOL(lp_multicast_dns_register, &Globals.bMulticastDnsRegister) 5748 6043 FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks) 5749 6044 FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms) … … 5790 6085 FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time) 5791 6086 FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, &Globals.winbind_reconnect_delay) 6087 FN_GLOBAL_INTEGER(lp_winbind_max_clients, &Globals.winbind_max_clients) 5792 6088 FN_GLOBAL_LIST(lp_winbind_nss_info, &Globals.szWinbindNssInfo) 5793 6089 FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase) … … 5797 6093 FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrapping) 5798 6094 6095 FN_GLOBAL_STRING(lp_ncalrpc_dir, &Globals.ncalrpc_dir) 6096 5799 6097 /* local prototypes */ 5800 6098 5801 static int map_parameter(const char *pszParmName);5802 6099 static int map_parameter_canonical(const char *pszParmName, bool *inverse); 5803 6100 static const char *get_boolean(bool bool_value); … … 5814 6111 static void free_service_byindex(int iService); 5815 6112 static void free_param_opts(struct param_opt_struct **popts); 5816 static char * canonicalize_servicename(const char *name);5817 6113 static void show_parameter(int parmIndex); 5818 6114 static bool is_synonym_of(int parm1, int parm2, bool *inverse); … … 5829 6125 char* param_key; 5830 6126 struct param_opt_struct *data; 5831 6127 5832 6128 if (snum >= iNumServices) return NULL; 5833 6129 5834 6130 if (snum < 0) { 5835 6131 data = Globals.param_opt; … … 5838 6134 data = ServicePtrs[snum]->param_opt; 5839 6135 } 5840 6136 5841 6137 if (asprintf(¶m_key, "%s:%s", type, option) == -1) { 5842 6138 DEBUG(0,("asprintf failed!\n")); … … 5866 6162 5867 6163 string_free(¶m_key); 5868 6164 5869 6165 return NULL; 5870 6166 } … … 5913 6209 return False; 5914 6210 } 5915 6211 5916 6212 if (!set_boolean(s, &ret)) { 5917 6213 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s)); … … 5933 6229 return (-1); 5934 6230 } 5935 6231 5936 6232 for (i=0; _enum[i].name; i++) { 5937 6233 if (strequal(_enum[i].name,s)) … … 5963 6259 { 5964 6260 struct param_opt_struct *data = get_parametrics(snum, type, option); 5965 6261 5966 6262 if (data == NULL||data->value==NULL) { 5967 6263 if (def) { … … 5980 6276 { 5981 6277 struct param_opt_struct *data = get_parametrics(snum, type, option); 5982 6278 5983 6279 if (data == NULL||data->value==NULL) 5984 6280 return def; 5985 6281 5986 6282 return data->value; 5987 6283 } … … 5996 6292 if (data == NULL||data->value==NULL) 5997 6293 return (const char **)def; 5998 6294 5999 6295 if (data->list==NULL) { 6000 data->list = str_list_make_v3( talloc_autofree_context(), data->value, NULL);6296 data->list = str_list_make_v3(NULL, data->value, NULL); 6001 6297 } 6002 6298 … … 6010 6306 { 6011 6307 struct param_opt_struct *data = get_parametrics(snum, type, option); 6012 6308 6013 6309 if (data && data->value && *data->value) 6014 6310 return lp_int(data->value); … … 6023 6319 { 6024 6320 struct param_opt_struct *data = get_parametrics(snum, type, option); 6025 6321 6026 6322 if (data && data->value && *data->value) 6027 6323 return lp_ulong(data->value); … … 6036 6332 { 6037 6333 struct param_opt_struct *data = get_parametrics(snum, type, option); 6038 6334 6039 6335 if (data && data->value && *data->value) 6040 6336 return lp_bool(data->value); … … 6050 6346 { 6051 6347 struct param_opt_struct *data = get_parametrics(snum, type, option); 6052 6348 6053 6349 if (data && data->value && *data->value && _enum) 6054 6350 return lp_enum(data->value, _enum); … … 6114 6410 6115 6411 string_free(&pservice->szService); 6116 bitmap_free(pservice->copymap);6412 TALLOC_FREE(pservice->copymap); 6117 6413 6118 6414 free_param_opts(&pservice->param_opt); … … 6139 6435 if (ServicePtrs[idx]->szService) { 6140 6436 char *canon_name = canonicalize_servicename( 6437 talloc_tos(), 6141 6438 ServicePtrs[idx]->szService ); 6142 6439 6143 6440 dbwrap_delete_bystring(ServiceHash, canon_name ); 6144 6441 TALLOC_FREE(canon_name); … … 6165 6462 i = getservicebyname(name, NULL); 6166 6463 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);6170 6464 return (i); 6171 6465 } … … 6182 6476 struct service **tsp; 6183 6477 int *tinvalid; 6184 6478 6185 6479 tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct service *, num_to_alloc); 6186 6480 if (tsp == NULL) { … … 6215 6509 if (name) 6216 6510 string_set(&ServicePtrs[i]->szService, name); 6217 6511 6218 6512 DEBUG(8,("add_a_service: Creating snum = %d for %s\n", 6219 6513 i, ServicePtrs[i]->szService)); … … 6222 6516 return (-1); 6223 6517 } 6224 6518 6225 6519 return (i); 6226 6520 } … … 6230 6524 ***************************************************************************/ 6231 6525 6232 static char *canonicalize_servicename(const char *src)6526 char *canonicalize_servicename(TALLOC_CTX *ctx, const char *src) 6233 6527 { 6234 6528 char *result; … … 6239 6533 } 6240 6534 6241 result = talloc_strdup( talloc_tos(), src);6535 result = talloc_strdup(ctx, src); 6242 6536 SMB_ASSERT(result != NULL); 6243 6537 … … 6266 6560 idx, name)); 6267 6561 6268 canon_name = canonicalize_servicename( name );6562 canon_name = canonicalize_servicename(talloc_tos(), name ); 6269 6563 6270 6564 dbwrap_store_bystring(ServiceHash, canon_name, … … 6405 6699 /* Printer services must be printable. */ 6406 6700 ServicePtrs[i]->bPrint_ok = True; 6407 6701 6408 6702 DEBUG(3, ("adding printer service %s\n", pszPrintername)); 6409 6703 … … 6773 7067 } 6774 7068 6775 canon_name = canonicalize_servicename( pszServiceName);7069 canon_name = canonicalize_servicename(talloc_tos(), pszServiceName); 6776 7070 6777 7071 data = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name); … … 6802 7096 static void set_param_opt(struct param_opt_struct **opt_list, 6803 7097 const char *opt_name, 6804 const char *opt_value) 7098 const char *opt_value, 7099 unsigned flags) 6805 7100 { 6806 7101 struct param_opt_struct *new_opt, *opt; … … 6818 7113 /* If we already have same option, override it */ 6819 7114 if (strwicmp(opt->key, opt_name) == 0) { 7115 if ((opt->flags & FLAG_CMDLINE) && 7116 !(flags & FLAG_CMDLINE)) { 7117 /* it's been marked as not to be 7118 overridden */ 7119 return; 7120 } 6820 7121 string_free(&opt->value); 6821 7122 TALLOC_FREE(opt->list); 6822 7123 opt->value = SMB_STRDUP(opt_value); 7124 opt->flags = flags; 6823 7125 not_added = false; 6824 7126 break; … … 6831 7133 new_opt->value = SMB_STRDUP(opt_value); 6832 7134 new_opt->list = NULL; 7135 new_opt->flags = flags; 6833 7136 DLIST_ADD(*opt_list, new_opt); 6834 7137 } … … 6895 7198 pserviceSource->copymap); 6896 7199 } 6897 7200 6898 7201 data = pserviceSource->param_opt; 6899 7202 while (data) { 6900 set_param_opt(&pserviceDest->param_opt, data->key, data->value );7203 set_param_opt(&pserviceDest->param_opt, data->key, data->value, data->flags); 6901 7204 data = data->next; 6902 7205 } … … 6951 7254 static struct smbconf_ctx *lp_smbconf_ctx(void) 6952 7255 { 6953 WERROR werr;7256 sbcErr err; 6954 7257 static struct smbconf_ctx *conf_ctx = NULL; 6955 7258 6956 7259 if (conf_ctx == NULL) { 6957 werr = smbconf_init(NULL, &conf_ctx, "registry:");6958 if (! W_ERROR_IS_OK(werr)) {7260 err = smbconf_init(NULL, &conf_ctx, "registry:"); 7261 if (!SBC_ERROR_IS_OK(err)) { 6959 7262 DEBUG(1, ("error initializing registry configuration: " 6960 "%s\n", win_errstr(werr)));7263 "%s\n", sbcErrorString(err))); 6961 7264 conf_ctx = NULL; 6962 7265 } … … 6998 7301 bool process_registry_service(const char *service_name) 6999 7302 { 7000 WERROR werr;7303 sbcErr err; 7001 7304 struct smbconf_service *service = NULL; 7002 7305 TALLOC_CTX *mem_ctx = talloc_stackframe(); … … 7019 7322 } 7020 7323 7021 werr = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);7022 if (! W_ERROR_IS_OK(werr)) {7324 err = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service); 7325 if (!SBC_ERROR_IS_OK(err)) { 7023 7326 goto done; 7024 7327 } … … 7056 7359 bool process_registry_shares(void) 7057 7360 { 7058 WERROR werr;7361 sbcErr err; 7059 7362 uint32_t count; 7060 7363 struct smbconf_service **service = NULL; … … 7068 7371 } 7069 7372 7070 werr = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service);7071 if (! W_ERROR_IS_OK(werr)) {7373 err = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &service); 7374 if (!SBC_ERROR_IS_OK(err)) { 7072 7375 goto done; 7073 7376 } … … 7092 7395 return ret; 7093 7396 } 7397 7398 /** 7399 * reload those shares from registry that are already 7400 * activated in the services array. 7401 */ 7402 static bool reload_registry_shares(void) 7403 { 7404 int i; 7405 bool ret = true; 7406 7407 for (i = 0; i < iNumServices; i++) { 7408 if (!VALID(i)) { 7409 continue; 7410 } 7411 7412 if (ServicePtrs[i]->usershare == USERSHARE_VALID) { 7413 continue; 7414 } 7415 7416 ret = process_registry_service(ServicePtrs[i]->szService); 7417 if (!ret) { 7418 goto done; 7419 } 7420 } 7421 7422 done: 7423 return ret; 7424 } 7425 7094 7426 7095 7427 #define MAX_INCLUDE_DEPTH 100 … … 7131 7463 f->subfname = SMB_STRDUP(subfname); 7132 7464 if (!f->subfname) { 7465 SAFE_FREE(f->name); 7133 7466 SAFE_FREE(f); 7134 7467 return; … … 7141 7474 f->modtime = t; 7142 7475 } 7476 return; 7143 7477 } 7144 7478 … … 7190 7524 7191 7525 while (f) { 7192 char *n2 = NULL;7193 7526 time_t mod_time; 7194 7527 … … 7206 7539 } 7207 7540 } 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); 7211 7546 if (!n2) { 7212 7547 return false; … … 7227 7562 f->modtime = mod_time; 7228 7563 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); 7232 7566 return true; 7233 7567 } 7234 SAFE_FREE(n2);7568 TALLOC_FREE(n2); 7235 7569 } 7236 7570 f = f->next; … … 7249 7583 { 7250 7584 bool ret; 7251 char *netbios_name = alloc_sub_basic(get_current_username(),7252 7253 7585 char *netbios_name = talloc_sub_basic( 7586 talloc_tos(), get_current_username(), current_user_info.domain, 7587 pszParmValue); 7254 7588 7255 7589 ret = set_global_myname(netbios_name); 7256 SAFE_FREE(netbios_name);7590 TALLOC_FREE(netbios_name); 7257 7591 string_set(&Globals.szNetbiosName,global_myname()); 7258 7592 … … 7272 7606 } 7273 7607 7608 static bool handle_dos_charset(int snum, const char *pszParmValue, char **ptr) 7609 { 7610 bool is_utf8 = false; 7611 size_t len = strlen(pszParmValue); 7612 7613 if (len == 4 || len == 5) { 7614 /* Don't use StrCaseCmp here as we don't want to 7615 initialize iconv. */ 7616 if ((toupper_m(pszParmValue[0]) == 'U') && 7617 (toupper_m(pszParmValue[1]) == 'T') && 7618 (toupper_m(pszParmValue[2]) == 'F')) { 7619 if (len == 4) { 7620 if (pszParmValue[3] == '8') { 7621 is_utf8 = true; 7622 } 7623 } else { 7624 if (pszParmValue[3] == '-' && 7625 pszParmValue[4] == '8') { 7626 is_utf8 = true; 7627 } 7628 } 7629 } 7630 } 7631 7632 if (strcmp(*ptr, pszParmValue) != 0) { 7633 if (is_utf8) { 7634 DEBUG(0,("ERROR: invalid DOS charset: 'dos charset' must not " 7635 "be UTF8, using (default value) %s instead.\n", 7636 DEFAULT_DOS_CHARSET)); 7637 pszParmValue = DEFAULT_DOS_CHARSET; 7638 } 7639 string_set(ptr, pszParmValue); 7640 init_iconv(); 7641 } 7642 return True; 7643 } 7644 7274 7645 7275 7646 … … 7277 7648 { 7278 7649 bool ret; 7279 7650 7280 7651 ret = set_global_myworkgroup(pszParmValue); 7281 7652 string_set(&Globals.szWorkgroup,lp_workgroup()); 7282 7653 7283 7654 return ret; 7284 7655 } … … 7287 7658 { 7288 7659 bool ret; 7289 7660 7290 7661 ret = set_global_scope(pszParmValue); 7291 7662 string_set(&Globals.szNetbiosScope,global_scope()); … … 7297 7668 { 7298 7669 TALLOC_FREE(Globals.szNetbiosAliases); 7299 Globals.szNetbiosAliases = str_list_make_v3( talloc_autofree_context(), pszParmValue, NULL);7670 Globals.szNetbiosAliases = str_list_make_v3(NULL, pszParmValue, NULL); 7300 7671 return set_netbios_aliases((const char **)Globals.szNetbiosAliases); 7301 7672 } … … 7333 7704 } 7334 7705 7335 fname = alloc_sub_basic(get_current_username(),7336 current_user_info.domain,7337 pszParmValue);7706 fname = talloc_sub_basic(talloc_tos(), get_current_username(), 7707 current_user_info.domain, 7708 pszParmValue); 7338 7709 7339 7710 add_to_file_list(pszParmValue, fname); … … 7346 7717 ret = pm_process(fname, do_section, do_parameter, NULL); 7347 7718 include_depth--; 7348 SAFE_FREE(fname);7719 TALLOC_FREE(fname); 7349 7720 return ret; 7350 7721 } 7351 7722 7352 7723 DEBUG(2, ("Can't find include file %s\n", fname)); 7353 SAFE_FREE(fname);7724 TALLOC_FREE(fname); 7354 7725 return true; 7355 7726 } … … 7445 7816 } 7446 7817 7818 static bool handle_idmap_backend(int snum, const char *pszParmValue, char **ptr) 7819 { 7820 lp_do_parameter(snum, "idmap config * : backend", pszParmValue); 7821 7822 return true; 7823 } 7824 7447 7825 /* Do some simple checks on "idmap [ug]id" parameter values */ 7448 7826 7449 7827 static bool handle_idmap_uid(int snum, const char *pszParmValue, char **ptr) 7450 7828 { 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); 7462 7830 7463 7831 return True; … … 7466 7834 static bool handle_idmap_gid(int snum, const char *pszParmValue, char **ptr) 7467 7835 { 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); 7479 7837 7480 7838 return True; … … 7592 7950 { 7593 7951 int i; 7594 if (pservice->copymap) { 7595 bitmap_free(pservice->copymap);7596 } 7597 pservice->copymap = bitmap_ allocate(NUMPARAMETERS);7952 7953 TALLOC_FREE(pservice->copymap); 7954 7955 pservice->copymap = bitmap_talloc(NULL, NUMPARAMETERS); 7598 7956 if (!pservice->copymap) 7599 7957 DEBUG(0, … … 7652 8010 opt_list = (snum < 0) 7653 8011 ? &Globals.param_opt : &ServicePtrs[snum]->param_opt; 7654 set_param_opt(opt_list, pszParmName, pszParmValue );8012 set_param_opt(opt_list, pszParmName, pszParmValue, 0); 7655 8013 7656 8014 return (True); 8015 } 8016 8017 /* if it's already been set by the command line, then we don't 8018 override here */ 8019 if (parm_table[parmnum].flags & FLAG_CMDLINE) { 8020 return true; 7657 8021 } 7658 8022 … … 7723 8087 TALLOC_FREE(*((char ***)parm_ptr)); 7724 8088 *(char ***)parm_ptr = str_list_make_v3( 7725 talloc_autofree_context(), pszParmValue, NULL);8089 NULL, pszParmValue, NULL); 7726 8090 break; 7727 8091 … … 7746 8110 7747 8111 /*************************************************************************** 8112 set a parameter, marking it with FLAG_CMDLINE. Parameters marked as 8113 FLAG_CMDLINE won't be overridden by loads from smb.conf. 8114 ***************************************************************************/ 8115 8116 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values) 8117 { 8118 int parmnum, i; 8119 parmnum = map_parameter(pszParmName); 8120 if (parmnum >= 0) { 8121 parm_table[parmnum].flags &= ~FLAG_CMDLINE; 8122 if (!lp_do_parameter(-1, pszParmName, pszParmValue)) { 8123 return false; 8124 } 8125 parm_table[parmnum].flags |= FLAG_CMDLINE; 8126 8127 /* we have to also set FLAG_CMDLINE on aliases. Aliases must 8128 * be grouped in the table, so we don't have to search the 8129 * whole table */ 8130 for (i=parmnum-1;i>=0 && parm_table[i].ptr == parm_table[parmnum].ptr;i--) { 8131 parm_table[i].flags |= FLAG_CMDLINE; 8132 } 8133 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].ptr == parm_table[parmnum].ptr;i++) { 8134 parm_table[i].flags |= FLAG_CMDLINE; 8135 } 8136 8137 if (store_values) { 8138 store_lp_set_cmdline(pszParmName, pszParmValue); 8139 } 8140 return true; 8141 } 8142 8143 /* it might be parametric */ 8144 if (strchr(pszParmName, ':') != NULL) { 8145 set_param_opt(&Globals.param_opt, pszParmName, pszParmValue, FLAG_CMDLINE); 8146 if (store_values) { 8147 store_lp_set_cmdline(pszParmName, pszParmValue); 8148 } 8149 return true; 8150 } 8151 8152 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName)); 8153 return true; 8154 } 8155 8156 bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue) 8157 { 8158 return lp_set_cmdline_helper(pszParmName, pszParmValue, true); 8159 } 8160 8161 /*************************************************************************** 7748 8162 Process a parameter. 7749 8163 ***************************************************************************/ … … 7761 8175 } 7762 8176 7763 /*************************************************************************** 8177 /* 8178 set a option from the commandline in 'a=b' format. Use to support --option 8179 */ 8180 bool 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 /************************************************************************** 7764 8209 Print a parameter of the specified type. 7765 8210 ***************************************************************************/ … … 7920 8365 return (False); 7921 8366 } 8367 /* Clean all parametric options for service */ 8368 /* They will be added during parsing again */ 8369 free_param_opts(&ServicePtrs[iServiceIndex]->param_opt); 7922 8370 } 7923 8371 … … 7968 8416 int i; 7969 8417 struct param_opt_struct *data; 7970 8418 7971 8419 fprintf(f, "[global]\n"); 7972 8420 … … 8013 8461 int i; 8014 8462 struct param_opt_struct *data; 8015 8463 8016 8464 if (pService != &sDefault) 8017 8465 fprintf(f, "[%s]\n", pService->szService); … … 8025 8473 (i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr))) 8026 8474 { 8027 8028 8475 int pdiff = PTR_DIFF(parm_table[i].ptr, &sDefault); 8029 8476 … … 8162 8609 parm_table[(*i) - 1].ptr)) 8163 8610 continue; 8164 8611 8165 8612 if (is_default(*i) && !allparameters) 8166 8613 continue; … … 8275 8722 ***************************************************************************/ 8276 8723 8277 void lp_add_one_printer(const char *name, const char *comment, void *pdata) 8724 void lp_add_one_printer(const char *name, const char *comment, 8725 const char *location, void *pdata) 8278 8726 { 8279 8727 int printers = lp_servicenumber(PRINTERS_NAME); … … 8387 8835 } 8388 8836 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 else8451 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 8462 8837 /*********************************************************** 8463 8838 If we should send plaintext/LANMAN passwords in the clinet … … 8535 8910 char **pp_sharepath, 8536 8911 char **pp_comment, 8537 SEC_DESC **ppsd, 8912 char **pp_cp_servicename, 8913 struct security_descriptor **ppsd, 8538 8914 bool *pallow_guest) 8539 8915 { … … 8601 8977 if (lines[4][9] == 'y') { 8602 8978 *pallow_guest = True; 8979 } 8980 8981 /* Backwards compatible extension to file version #2. */ 8982 if (numlines > 5) { 8983 if (strncmp(lines[5], "sharename=", 10) != 0) { 8984 return USERSHARE_MALFORMED_SHARENAME_DEF; 8985 } 8986 if (!strequal(&lines[5][10], servicename)) { 8987 return USERSHARE_BAD_SHARENAME; 8988 } 8989 *pp_cp_servicename = talloc_strdup(ctx, &lines[5][10]); 8990 if (!*pp_cp_servicename) { 8991 return USERSHARE_POSIX_ERR; 8992 } 8993 } 8994 } 8995 8996 if (*pp_cp_servicename == NULL) { 8997 *pp_cp_servicename = talloc_strdup(ctx, servicename); 8998 if (!*pp_cp_servicename) { 8999 return USERSHARE_POSIX_ERR; 8603 9000 } 8604 9001 } … … 8713 9110 char *sharepath = NULL; 8714 9111 char *comment = NULL; 8715 fstring service_name;9112 char *cp_service_name = NULL; 8716 9113 char **lines = NULL; 8717 9114 int numlines = 0; 8718 9115 int fd = -1; 8719 9116 int iService = -1; 8720 TALLOC_CTX *ctx = NULL;8721 SEC_DESC*psd = NULL;9117 TALLOC_CTX *ctx = talloc_stackframe(); 9118 struct security_descriptor *psd = NULL; 8722 9119 bool guest_ok = False; 9120 char *canon_name = NULL; 9121 bool added_service = false; 9122 int ret = -1; 8723 9123 8724 9124 /* Ensure share name doesn't contain invalid characters. */ … … 8727 9127 "invalid characters (any of %s)\n", 8728 9128 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; 8735 9140 } 8736 9141 … … 8741 9146 DEBUG(0,("process_usershare_file: stat of %s failed. %s\n", 8742 9147 fname, strerror(errno) )); 8743 SAFE_FREE(fname); 8744 return -1; 9148 goto out; 8745 9149 } 8746 9150 … … 8748 9152 other strange filetype. */ 8749 9153 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 { 8756 9158 TDB_DATA data = dbwrap_fetch_bystring( 8757 9159 ServiceHash, canon_name, canon_name); … … 8762 9164 iService = *(int *)data.dptr; 8763 9165 } 8764 TALLOC_FREE(canon_name);8765 9166 } 8766 9167 … … 8770 9171 /* Nothing changed - Mark valid and return. */ 8771 9172 DEBUG(10,("process_usershare_file: service %s not changed.\n", 8772 service_name ));9173 canon_name )); 8773 9174 ServicePtrs[iService]->usershare = USERSHARE_VALID; 8774 SAFE_FREE(fname);8775 return iService;9175 ret = iService; 9176 goto out; 8776 9177 } 8777 9178 … … 8786 9187 DEBUG(0,("process_usershare_file: unable to open %s. %s\n", 8787 9188 fname, strerror(errno) )); 8788 SAFE_FREE(fname); 8789 return -1; 9189 goto out; 8790 9190 } 8791 9191 … … 8795 9195 DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n", 8796 9196 fname, strerror(errno) )); 8797 SAFE_FREE(fname); 8798 return -1; 9197 goto out; 8799 9198 } 8800 9199 … … 8804 9203 DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. " 8805 9204 "Symlink spoofing going on ?\n", fname )); 8806 SAFE_FREE(fname); 8807 return -1; 9205 goto out; 8808 9206 } 8809 9207 … … 8811 9209 other strange filetype. */ 8812 9210 if (!check_usershare_stat(fname, &sbuf)) { 8813 SAFE_FREE(fname); 8814 return -1; 9211 goto out; 8815 9212 } 8816 9213 … … 8821 9218 DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n", 8822 9219 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, 8837 9224 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 } 8845 9229 8846 9230 /* Everything ok - add the service possibly using a template. */ … … 8851 9235 } 8852 9236 8853 if ((iService = add_a_service(sp, service_name)) < 0) {9237 if ((iService = add_a_service(sp, cp_service_name)) < 0) { 8854 9238 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; 8858 9241 } 9242 9243 added_service = true; 8859 9244 8860 9245 /* Read only is controlled by usershare ACL below. */ … … 8863 9248 8864 9249 /* Write the ACL of the new/modified share. */ 8865 if (!set_share_security( service_name, psd)) {9250 if (!set_share_security(canon_name, psd)) { 8866 9251 DEBUG(0, ("process_usershare_file: Failed to set share " 8867 9252 "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; 8872 9255 } 8873 9256 … … 8888 9271 string_set(&ServicePtrs[iService]->comment, comment); 8889 9272 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; 8893 9284 } 8894 9285 … … 9199 9590 ***************************************************************************/ 9200 9591 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)9592 static bool lp_load_ex(const char *pszFname, 9593 bool global_only, 9594 bool save_defaults, 9595 bool add_ipc, 9596 bool initialize_globals, 9597 bool allow_include_registry, 9598 bool allow_registry_shares) 9208 9599 { 9209 9600 char *n2 = NULL; … … 9218 9609 bAllowIncludeRegistry = allow_include_registry; 9219 9610 9220 init_globals(! initialize_globals); 9221 debug_init(); 9611 init_globals(initialize_globals); 9222 9612 9223 9613 free_file_list(); … … 9230 9620 free_param_opts(&Globals.param_opt); 9231 9621 9622 lp_do_parameter(-1, "idmap config * : backend", Globals.szIdmapBackend); 9623 9232 9624 /* We get sections first, so have to start 'behind' to make up */ 9233 9625 iServiceIndex = -1; 9234 9626 9235 9627 if (lp_config_backend_is_file()) { 9236 n2 = alloc_sub_basic(get_current_username(),9628 n2 = talloc_sub_basic(talloc_tos(), get_current_username(), 9237 9629 current_user_info.domain, 9238 9630 pszFname); … … 9244 9636 9245 9637 bRetval = pm_process(n2, do_section, do_parameter, NULL); 9246 SAFE_FREE(n2);9638 TALLOC_FREE(n2); 9247 9639 9248 9640 /* finish up the last section */ … … 9266 9658 DEBUG(1, ("lp_load_ex: changing to config backend " 9267 9659 "registry\n")); 9268 init_globals( false);9660 init_globals(true); 9269 9661 lp_kill_all_services(); 9270 9662 return lp_load_ex(pszFname, global_only, save_defaults, … … 9281 9673 } 9282 9674 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 } 9285 9681 } 9286 9682 … … 9300 9696 set_allowed_client_auth(); 9301 9697 9698 if (lp_security() == SEC_SHARE) { 9699 DEBUG(1, ("WARNING: The security=share option is deprecated\n")); 9700 } else if (lp_security() == SEC_SERVER) { 9701 DEBUG(1, ("WARNING: The security=server option is deprecated\n")); 9702 } 9703 9704 if (lp_security() == SEC_ADS && strchr(lp_passwordserver(), ':')) { 9705 DEBUG(1, ("WARNING: The optional ':port' in password server = %s is deprecated\n", 9706 lp_passwordserver())); 9707 } 9708 9302 9709 bLoaded = True; 9303 9710 … … 9307 9714 lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1"); 9308 9715 } 9716 9309 9717 #ifdef __OS2__ 9310 9718 if (lp_is_in_client() && newLockDir) { … … 9314 9722 } 9315 9723 lp_do_parameter(GLOBAL_SECTION_SNUM, "lock directory", s); 9724 // @todo what do these directories do 9725 lp_do_parameter(GLOBAL_SECTION_SNUM, "state directory", s); 9726 lp_do_parameter(GLOBAL_SECTION_SNUM, "cache directory", s); 9316 9727 SAFE_FREE(s); 9317 9728 newLockDir = False; 9318 9729 } 9319 9730 #endif 9320 9321 9731 init_iconv(); 9322 9732 … … 9337 9747 add_ipc, 9338 9748 initialize_globals, 9339 true, false); 9749 true, /* allow_include_registry */ 9750 false); /* allow_registry_shares*/ 9340 9751 } 9341 9752 … … 9343 9754 { 9344 9755 return lp_load_ex(pszFname, 9345 true, 9346 false, 9347 false, 9348 true, 9349 false, 9350 false); 9756 true, /* global only */ 9757 false, /* save_defaults */ 9758 false, /* add_ipc */ 9759 true, /* initialize_globals */ 9760 false, /* allow_include_registry */ 9761 false); /* allow_registry_shares*/ 9351 9762 } 9352 9763 … … 9362 9773 add_ipc, 9363 9774 initialize_globals, 9364 true, 9365 true); 9775 true, /* allow_include_registry */ 9776 true); /* allow_registry_shares*/ 9366 9777 } 9367 9778 … … 9420 9831 int iService; 9421 9832 fstring serviceName; 9422 9833 9423 9834 if (!pszServiceName) { 9424 9835 return GLOBAL_SECTION_SNUM; 9425 9836 } 9426 9837 9427 9838 for (iService = iNumServices - 1; iService >= 0; iService--) { 9428 9839 if (VALID(iService) && ServicePtrs[iService]->szService) { … … 9480 9891 { 9481 9892 struct share_params *result; 9482 char *sname ;9893 char *sname = NULL; 9483 9894 int snum; 9484 9895 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) { 9493 9898 return NULL; 9494 9899 } … … 9574 9979 label = lp_servicename(snum); 9575 9980 } 9576 9981 9577 9982 /* This returns a 33 byte guarenteed null terminated string. */ 9578 9983 ret = talloc_strndup(talloc_tos(), label, 32); … … 9639 10044 9640 10045 /*********************************************************** 9641 returns role of Samba server10046 If we are PDC then prefer us as DMB 9642 10047 ************************************************************/ 9643 10048 9644 int lp_server_role(void) 9645 { 9646 return server_role; 10049 bool lp_domain_master(void) 10050 { 10051 if (Globals.iDomainMaster == Auto) 10052 return (lp_server_role() == ROLE_DOMAIN_PDC); 10053 10054 return (bool)Globals.iDomainMaster; 9647 10055 } 9648 10056 … … 9651 10059 ************************************************************/ 9652 10060 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;10061 bool lp_domain_master_true_or_auto(void) 10062 { 10063 if (Globals.iDomainMaster) /* auto or yes */ 10064 return true; 10065 10066 return false; 9659 10067 } 9660 10068 … … 9947 10355 { 9948 10356 char *sock_addr = Globals.szSocketAddress; 9949 10357 9950 10358 if (sock_addr[0] == '\0'){ 9951 10359 string_set(&Globals.szSocketAddress, "0.0.0.0"); … … 9990 10398 return lp_widelinks_internal(snum); 9991 10399 } 10400 10401 bool lp_writeraw(void) 10402 { 10403 if (lp_async_smb_echo_handler()) { 10404 return false; 10405 } 10406 return _lp_writeraw(); 10407 } 10408 10409 bool lp_readraw(void) 10410 { 10411 if (lp_async_smb_echo_handler()) { 10412 return false; 10413 } 10414 return _lp_readraw(); 10415 } -
trunk/server/source3/param/test_lp_load.c
r414 r745 19 19 20 20 #include "includes.h" 21 22 extern bool AllowDebugChange; 21 #include "popt_common.h" 23 22 24 23 int main(int argc, const char **argv) … … 41 40 42 41 load_case_tables(); 43 DEBUGLEVEL_CLASS[DBGC_ALL] = 0;42 lp_set_cmdline("log level", "0"); 44 43 45 44 pc = poptGetContext(NULL, argc, argv, long_options, … … 49 48 while(poptGetNextOpt(pc) != -1); 50 49 51 setup_logging(poptGetArg(pc), True);50 setup_logging(poptGetArg(pc), DEBUG_STDERR); 52 51 53 52 if (poptPeekArg(pc)) { … … 60 59 count = atoi(count_str); 61 60 } 62 63 dbf = x_stderr;64 /* Don't let the debuglevel be changed by smb.conf. */65 AllowDebugChange = False;66 61 67 62 for (i=0; i < count; i++) {
Note:
See TracChangeset
for help on using the changeset viewer.