⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loadparm.c

📁 samba最新软件
💻 C
📖 第 1 页 / 共 5 页
字号:
/*    Unix SMB/CIFS implementation.   Parameter loading functions   Copyright (C) Karl Auer 1993-1998   Largely re-written by Andrew Tridgell, September 1994   Copyright (C) Simo Sorce 2001   Copyright (C) Alexander Bokovoy 2002   Copyright (C) Stefan (metze) Metzmacher 2002   Copyright (C) Jim McDonough (jmcd@us.ibm.com)  2003.   Copyright (C) James Myers 2003 <myersjj@samba.org>   Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007   This program is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 3 of the License, or   (at your option) any later version.   This program is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with this program.  If not, see <http://www.gnu.org/licenses/>.*//* *  Load parameters. * *  This module provides suitable callback functions for the params *  module. It builds the internal table of service details which is *  then used by the rest of the server. * * To add a parameter: * * 1) add it to the global or service structure definition * 2) add it to the parm_table * 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING()) * 4) If it's a global then initialise it in init_globals. If a local *    (ie. service) parameter then initialise it in the sDefault structure * * * Notes: *   The configuration file is processed sequentially for speed. It is NOT *   accessed randomly as happens in 'real' Windows. For this reason, there *   is a fair bit of sequence-dependent code here - ie., code which assumes *   that certain things happen before others. In particular, the code which *   happens at the boundary between sections is delicately poised, so be *   careful! * */#include "includes.h"#include "version.h"#include "dynconfig/dynconfig.h"#include "system/time.h"#include "system/locale.h"#include "system/network.h" /* needed for TCP_NODELAY */#include "smb_server/smb_server.h"#include "libcli/raw/signing.h"#include "lib/util/dlinklist.h"#include "param/param.h"#include "param/loadparm.h"#include "libcli/raw/libcliraw.h"#define standard_sub_basic talloc_strdupstatic bool do_parameter(const char *, const char *, void *);static bool defaults_saved = false;/** * This structure describes global (ie., server-wide) parameters. */struct loadparm_global{	enum server_role server_role;	const char **smb_ports;	char *ncalrpc_dir;	char *dos_charset;	char *unix_charset;	char *display_charset;	char *szLockDir;	char *szModulesDir;	char *szPidDir;	char *szSetupDir;	char *szServerString;	char *szAutoServices;	char *szPasswdChat;	char *szShareBackend;	char *szSAM_URL;	char *szIDMAP_URL;	char *szSECRETS_URL;	char *szSPOOLSS_URL;	char *szWINS_CONFIG_URL;	char *szWINS_URL;	char *szPrivateDir;	const char **jsInclude;	char *jsonrpcServicesDir;	const char **szPasswordServers;	char *szSocketOptions;	char *szRealm;	const char **szWINSservers;	const char **szInterfaces;	char *szSocketAddress;	char *szAnnounceVersion;	/* This is initialised in init_globals */	char *szWorkgroup;	char *szNetbiosName;	const char **szNetbiosAliases;	char *szNetbiosScope;	char *szDomainOtherSIDs;	const char **szNameResolveOrder;	const char **dcerpc_ep_servers;	const char **server_services;	char *ntptr_providor;	char *szWinbindSeparator;	char *szWinbinddSocketDirectory;	char *szTemplateShell;	char *szTemplateHomedir;	int bWinbindSealedPipes;	int bIdmapTrustedOnly;	char *swat_directory;	int tls_enabled;	char *tls_keyfile;	char *tls_certfile;	char *tls_cafile;	char *tls_crlfile;	char *tls_dhpfile;	char *logfile;	char *panic_action;	int max_mux;	int debuglevel;	int max_xmit;	int pwordlevel;	int srv_maxprotocol;	int srv_minprotocol;	int cli_maxprotocol;	int cli_minprotocol;	int security;	int paranoid_server_security;	int max_wins_ttl;	int min_wins_ttl;	int announce_as;	/* This is initialised in init_globals */	int nbt_port;	int dgram_port;	int cldap_port;	int krb5_port;	int kpasswd_port;	int web_port;	char *socket_options;	int bWINSsupport;	int bWINSdnsProxy;	char *szWINSHook;	int bLocalMaster;	int bPreferredMaster;	int bEncryptPasswords;	int bNullPasswords;	int bObeyPamRestrictions;	int bLargeReadwrite;	int bReadRaw;	int bWriteRaw;	int bTimeServer;	int bBindInterfacesOnly;	int bNTSmbSupport;	int bNTStatusSupport;	int bLanmanAuth;	int bNTLMAuth;	int bUseSpnego;	int server_signing;	int client_signing;	int bClientPlaintextAuth;	int bClientLanManAuth;	int bClientNTLMv2Auth;	int client_use_spnego_principal;	int bHostMSDfs;	int bUnicode;	int bUnixExtensions;	int bDisableNetbios;	int bRpcBigEndian;	char *szNTPSignDSocketDirectory;	struct param_opt *param_opt;};/** * This structure describes a single service. */struct loadparm_service{	char *szService;	char *szPath;	char *szCopy;	char *szInclude;	char *szPrintername;	char **szHostsallow;	char **szHostsdeny;	char *comment;	char *volume;	char *fstype;	char **ntvfs_handler;	int iMaxPrintJobs;	int iMaxConnections;	int iCSCPolicy;	int bAvailable;	int bBrowseable;	int bRead_only;	int bPrint_ok;	int bMap_system;	int bMap_hidden;	int bMap_archive;	int bStrictLocking;	int bOplocks;	int iCreate_mask;	int iCreate_force_mode;	int iDir_mask;	int iDir_force_mode;	int *copymap;	int bMSDfsRoot;	int bStrictSync;	int bCIFileSystem;	struct param_opt *param_opt;	char dummy[3];		/* for alignment */};struct loadparm_context *global_loadparm = NULL;#define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))/* prototypes for the special type handlers */static bool handle_include(struct loadparm_context *lp_ctx,			   const char *pszParmValue, char **ptr);static bool handle_copy(struct loadparm_context *lp_ctx,			const char *pszParmValue, char **ptr);static bool handle_debuglevel(struct loadparm_context *lp_ctx,			      const char *pszParmValue, char **ptr);static bool handle_logfile(struct loadparm_context *lp_ctx,			   const char *pszParmValue, char **ptr);static const struct enum_list enum_protocol[] = {	{PROTOCOL_SMB2, "SMB2"},	{PROTOCOL_NT1, "NT1"},	{PROTOCOL_LANMAN2, "LANMAN2"},	{PROTOCOL_LANMAN1, "LANMAN1"},	{PROTOCOL_CORE, "CORE"},	{PROTOCOL_COREPLUS, "COREPLUS"},	{PROTOCOL_COREPLUS, "CORE+"},	{-1, NULL}};static const struct enum_list enum_security[] = {	{SEC_SHARE, "SHARE"},	{SEC_USER, "USER"},	{-1, NULL}};static const struct enum_list enum_announce_as[] = {	{ANNOUNCE_AS_NT_SERVER, "NT"},	{ANNOUNCE_AS_NT_SERVER, "NT Server"},	{ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},	{ANNOUNCE_AS_WIN95, "win95"},	{ANNOUNCE_AS_WFW, "WfW"},	{-1, NULL}};static const struct enum_list enum_bool_auto[] = {	{false, "No"},	{false, "False"},	{false, "0"},	{true, "Yes"},	{true, "True"},	{true, "1"},	{Auto, "Auto"},	{-1, NULL}};/* Client-side offline caching policy types */enum csc_policy {	CSC_POLICY_MANUAL=0,	CSC_POLICY_DOCUMENTS=1,	CSC_POLICY_PROGRAMS=2,	CSC_POLICY_DISABLE=3};static const struct enum_list enum_csc_policy[] = {	{CSC_POLICY_MANUAL, "manual"},	{CSC_POLICY_DOCUMENTS, "documents"},	{CSC_POLICY_PROGRAMS, "programs"},	{CSC_POLICY_DISABLE, "disable"},	{-1, NULL}};/* SMB signing types. */static const struct enum_list enum_smb_signing_vals[] = {	{SMB_SIGNING_OFF, "No"},	{SMB_SIGNING_OFF, "False"},	{SMB_SIGNING_OFF, "0"},	{SMB_SIGNING_OFF, "Off"},	{SMB_SIGNING_OFF, "disabled"},	{SMB_SIGNING_SUPPORTED, "Yes"},	{SMB_SIGNING_SUPPORTED, "True"},	{SMB_SIGNING_SUPPORTED, "1"},	{SMB_SIGNING_SUPPORTED, "On"},	{SMB_SIGNING_SUPPORTED, "enabled"},	{SMB_SIGNING_REQUIRED, "required"},	{SMB_SIGNING_REQUIRED, "mandatory"},	{SMB_SIGNING_REQUIRED, "force"},	{SMB_SIGNING_REQUIRED, "forced"},	{SMB_SIGNING_REQUIRED, "enforced"},	{SMB_SIGNING_AUTO, "auto"},	{-1, NULL}};static const struct enum_list enum_server_role[] = {	{ROLE_STANDALONE, "standalone"},	{ROLE_DOMAIN_MEMBER, "member server"},	{ROLE_DOMAIN_MEMBER, "member"},	{ROLE_DOMAIN_CONTROLLER, "domain controller"},	{ROLE_DOMAIN_CONTROLLER, "dc"},	{-1, NULL}};#define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)#define LOCAL_VAR(name) offsetof(struct loadparm_service, name)static struct parm_struct parm_table[] = {	{"server role", P_ENUM, P_GLOBAL, GLOBAL_VAR(server_role), NULL, enum_server_role},	{"dos charset", P_STRING, P_GLOBAL, GLOBAL_VAR(dos_charset), NULL, NULL},	{"unix charset", P_STRING, P_GLOBAL, GLOBAL_VAR(unix_charset), NULL, NULL},	{"ncalrpc dir", P_STRING, P_GLOBAL, GLOBAL_VAR(ncalrpc_dir), NULL, NULL},	{"display charset", P_STRING, P_GLOBAL, GLOBAL_VAR(display_charset), NULL, NULL},	{"comment", P_STRING, P_LOCAL, LOCAL_VAR(comment), NULL, NULL},	{"path", P_STRING, P_LOCAL, LOCAL_VAR(szPath), NULL, NULL},	{"directory", P_STRING, P_LOCAL, LOCAL_VAR(szPath), NULL, NULL},	{"workgroup", P_USTRING, P_GLOBAL, GLOBAL_VAR(szWorkgroup), NULL, NULL},	{"realm", P_STRING, P_GLOBAL, GLOBAL_VAR(szRealm), NULL, NULL},	{"netbios name", P_USTRING, P_GLOBAL, GLOBAL_VAR(szNetbiosName), NULL, NULL},	{"netbios aliases", P_LIST, P_GLOBAL, GLOBAL_VAR(szNetbiosAliases), NULL, NULL},	{"netbios scope", P_USTRING, P_GLOBAL, GLOBAL_VAR(szNetbiosScope), NULL, NULL},	{"server string", P_STRING, P_GLOBAL, GLOBAL_VAR(szServerString), NULL, NULL},	{"interfaces", P_LIST, P_GLOBAL, GLOBAL_VAR(szInterfaces), NULL, NULL},	{"bind interfaces only", P_BOOL, P_GLOBAL, GLOBAL_VAR(bBindInterfacesOnly), NULL, NULL},	{"ntvfs handler", P_LIST, P_LOCAL, LOCAL_VAR(ntvfs_handler), NULL, NULL},	{"ntptr providor", P_STRING, P_GLOBAL, GLOBAL_VAR(ntptr_providor), NULL, NULL},	{"dcerpc endpoint servers", P_LIST, P_GLOBAL, GLOBAL_VAR(dcerpc_ep_servers), NULL, NULL},	{"server services", P_LIST, P_GLOBAL, GLOBAL_VAR(server_services), NULL, NULL},	{"security", P_ENUM, P_GLOBAL, GLOBAL_VAR(security), NULL, enum_security},	{"encrypt passwords", P_BOOL, P_GLOBAL, GLOBAL_VAR(bEncryptPasswords), NULL, NULL},	{"null passwords", P_BOOL, P_GLOBAL, GLOBAL_VAR(bNullPasswords), NULL, NULL},	{"obey pam restrictions", P_BOOL, P_GLOBAL, GLOBAL_VAR(bObeyPamRestrictions), NULL, NULL},	{"password server", P_LIST, P_GLOBAL, GLOBAL_VAR(szPasswordServers), NULL, NULL},	{"sam database", P_STRING, P_GLOBAL, GLOBAL_VAR(szSAM_URL), NULL, NULL},	{"idmap database", P_STRING, P_GLOBAL, GLOBAL_VAR(szIDMAP_URL), NULL, NULL},	{"secrets database", P_STRING, P_GLOBAL, GLOBAL_VAR(szSECRETS_URL), NULL, NULL},	{"spoolss database", P_STRING, P_GLOBAL, GLOBAL_VAR(szSPOOLSS_URL), NULL, NULL},	{"wins config database", P_STRING, P_GLOBAL, GLOBAL_VAR(szWINS_CONFIG_URL), NULL, NULL},	{"wins database", P_STRING, P_GLOBAL, GLOBAL_VAR(szWINS_URL), NULL, NULL},	{"private dir", P_STRING, P_GLOBAL, GLOBAL_VAR(szPrivateDir), NULL, NULL},	{"passwd chat", P_STRING, P_GLOBAL, GLOBAL_VAR(szPasswdChat), NULL, NULL},	{"password level", P_INTEGER, P_GLOBAL, GLOBAL_VAR(pwordlevel), NULL, NULL},	{"lanman auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bLanmanAuth), NULL, NULL},	{"ntlm auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bNTLMAuth), NULL, NULL},	{"client NTLMv2 auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bClientNTLMv2Auth), NULL, NULL},	{"client lanman auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bClientLanManAuth), NULL, NULL},	{"client plaintext auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bClientPlaintextAuth), NULL, NULL},	{"client use spnego principal", P_BOOL, P_GLOBAL, GLOBAL_VAR(client_use_spnego_principal), NULL, NULL},	{"read only", P_BOOL, P_LOCAL, LOCAL_VAR(bRead_only), NULL, NULL},	{"create mask", P_OCTAL, P_LOCAL, LOCAL_VAR(iCreate_mask), NULL, NULL},	{"force create mode", P_OCTAL, P_LOCAL, LOCAL_VAR(iCreate_force_mode), NULL, NULL}, 	{"directory mask", P_OCTAL, P_LOCAL, LOCAL_VAR(iDir_mask), NULL, NULL},	{"force directory mode", P_OCTAL, P_LOCAL, LOCAL_VAR(iDir_force_mode), NULL, NULL}, 	{"hosts allow", P_LIST, P_LOCAL, LOCAL_VAR(szHostsallow), NULL, NULL},	{"hosts deny", P_LIST, P_LOCAL, LOCAL_VAR(szHostsdeny), NULL, NULL},	{"log level", P_INTEGER, P_GLOBAL, GLOBAL_VAR(debuglevel), handle_debuglevel, NULL},	{"debuglevel", P_INTEGER, P_GLOBAL, GLOBAL_VAR(debuglevel), handle_debuglevel, NULL},	{"log file", P_STRING, P_GLOBAL, GLOBAL_VAR(logfile), handle_logfile, NULL},	{"smb ports", P_LIST, P_GLOBAL, GLOBAL_VAR(smb_ports), NULL, NULL},	{"nbt port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(nbt_port), NULL, NULL},	{"dgram port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(dgram_port), NULL, NULL},	{"cldap port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(cldap_port), NULL, NULL},	{"krb5 port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(krb5_port), NULL, NULL},	{"kpasswd port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(kpasswd_port), NULL, NULL},	{"web port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(web_port), NULL, NULL},	{"tls enabled", P_BOOL, P_GLOBAL, GLOBAL_VAR(tls_enabled), NULL, NULL},	{"tls keyfile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_keyfile), NULL, NULL},	{"tls certfile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_certfile), NULL, NULL},	{"tls cafile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_cafile), NULL, NULL},	{"tls crlfile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_crlfile), NULL, NULL},	{"tls dh params file", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_dhpfile), NULL, NULL},	{"swat directory", P_STRING, P_GLOBAL, GLOBAL_VAR(swat_directory), NULL, NULL},	{"large readwrite", P_BOOL, P_GLOBAL, GLOBAL_VAR(bLargeReadwrite), NULL, NULL},	{"server max protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(srv_maxprotocol), NULL, enum_protocol},	{"server min protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(srv_minprotocol), NULL, enum_protocol},	{"client max protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(cli_maxprotocol), NULL, enum_protocol},	{"client min protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(cli_minprotocol), NULL, enum_protocol},	{"unicode", P_BOOL, P_GLOBAL, GLOBAL_VAR(bUnicode), NULL, NULL},	{"read raw", P_BOOL, P_GLOBAL, GLOBAL_VAR(bReadRaw), NULL, NULL},	{"write raw", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWriteRaw), NULL, NULL},	{"disable netbios", P_BOOL, P_GLOBAL, GLOBAL_VAR(bDisableNetbios), NULL, NULL},	{"nt status support", P_BOOL, P_GLOBAL, GLOBAL_VAR(bNTStatusSupport), NULL, NULL},	{"announce version", P_STRING, P_GLOBAL, GLOBAL_VAR(szAnnounceVersion), NULL, NULL},	{"announce as", P_ENUM, P_GLOBAL, GLOBAL_VAR(announce_as), NULL, enum_announce_as},	{"max mux", P_INTEGER, P_GLOBAL, GLOBAL_VAR(max_mux), NULL, NULL},	{"max xmit", P_BYTES, P_GLOBAL, GLOBAL_VAR(max_xmit), NULL, NULL},	{"name resolve order", P_LIST, P_GLOBAL, GLOBAL_VAR(szNameResolveOrder), NULL, NULL},	{"max wins ttl", P_INTEGER, P_GLOBAL, GLOBAL_VAR(max_wins_ttl), NULL, NULL},	{"min wins ttl", P_INTEGER, P_GLOBAL, GLOBAL_VAR(min_wins_ttl), NULL, NULL},	{"time server", P_BOOL, P_GLOBAL, GLOBAL_VAR(bTimeServer), NULL, NULL},	{"unix extensions", P_BOOL, P_GLOBAL, GLOBAL_VAR(bUnixExtensions), NULL, NULL},	{"use spnego", P_BOOL, P_GLOBAL, GLOBAL_VAR(bUseSpnego), NULL, NULL},	{"server signing", P_ENUM, P_GLOBAL, GLOBAL_VAR(server_signing), NULL, enum_smb_signing_vals}, 	{"client signing", P_ENUM, P_GLOBAL, GLOBAL_VAR(client_signing), NULL, enum_smb_signing_vals}, 	{"rpc big endian", P_BOOL, P_GLOBAL, GLOBAL_VAR(bRpcBigEndian), NULL, NULL},	{"max connections", P_INTEGER, P_LOCAL, LOCAL_VAR(iMaxConnections), NULL, NULL},	{"paranoid server security", P_BOOL, P_GLOBAL, GLOBAL_VAR(paranoid_server_security), NULL, NULL},	{"socket options", P_STRING, P_GLOBAL, GLOBAL_VAR(socket_options), NULL, NULL},

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -