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

📄 pdb_xml.c

📁 samba-3.0.22.tar.gz 编译smb服务器的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
		cur = cur->next;	}	if (!cur)		return NULL;	if ((strcmp(cur->name, "users")) || (cur->ns != data->ns)) {		DEBUG(0, ("document of the wrong type, was '%s', users expected",				  cur->name));		DEBUG(0, ("xmlDocDump follows\n"));		xmlDocDump(stderr, data->doc);		DEBUG(0, ("xmlDocDump finished\n"));		xmlFreeDoc(data->doc);		return NULL;	}	data->users = cur;	cur = cur->xmlChildrenNode;	return cur;}static NTSTATUS xmlsam_setsampwent(struct pdb_methods *methods, BOOL update, uint16 acb_mask){	pdb_xml *data;	if (!methods) {		DEBUG(0, ("Invalid methods\n"));		return NT_STATUS_INVALID_PARAMETER;	}	data = (pdb_xml *) methods->private_data;	if (!data) {		DEBUG(0, ("Invalid pdb_xml_data\n"));		return NT_STATUS_INVALID_PARAMETER;	}	data->pwent = parseSambaXMLFile(data);	if (!data->pwent)		return NT_STATUS_UNSUCCESSFUL;		return NT_STATUS_OK;}/***************************************************************  End enumeration of the passwd list. ****************************************************************/static void xmlsam_endsampwent(struct pdb_methods *methods){	pdb_xml *data;	if (!methods) {		DEBUG(0, ("Invalid methods\n"));		return;	}	data = (pdb_xml *) methods->private_data;	if (!data) {		DEBUG(0, ("Invalid pdb_xml_data\n"));		return;	}	xmlFreeDoc(data->doc);	data->doc = NULL;	data->pwent = NULL;}/*****************************************************************  Get one SAM_ACCOUNT from the list (next in line) *****************************************************************/static NTSTATUS xmlsam_getsampwent(struct pdb_methods *methods, SAM_ACCOUNT * user){	pdb_xml *data;	if (!methods) {		DEBUG(0, ("Invalid methods\n"));		return NT_STATUS_INVALID_PARAMETER;	}	data = (pdb_xml *) methods->private_data;	if (!data) {		DEBUG(0, ("Invalid pdb_xml_data\n"));		return NT_STATUS_INVALID_PARAMETER;	}	while (data->pwent) {		if ((!strcmp(data->pwent->name, "user")) &&			(data->pwent->ns == data->ns)) {			parseUser(data->doc, data->ns, data->pwent, user);			data->pwent = data->pwent->next;			return NT_STATUS_OK;		}		data->pwent = data->pwent->next;	}	return NT_STATUS_UNSUCCESSFUL;}/***************************************************************************  Adds an existing SAM_ACCOUNT ****************************************************************************/static NTSTATUS xmlsam_add_sam_account(struct pdb_methods *methods, SAM_ACCOUNT * u){	pstring temp;	fstring sid_str;	xmlNodePtr cur, user, pass, root;	pdb_xml *data;	DEBUG(10, ("xmlsam_add_sam_account called!\n"));	if (!methods) {		DEBUG(0, ("Invalid methods\n"));		return NT_STATUS_INVALID_PARAMETER;	}	data = (pdb_xml *) methods->private_data;	if (!data) {		DEBUG(0, ("Invalid pdb_xml_data\n"));		return NT_STATUS_INVALID_PARAMETER;	}	/* Create a new document if we can't open the current one */	if (!parseSambaXMLFile(data)) {		DEBUG(0, ("Can't load current XML file, creating a new one\n"));		data->doc = xmlNewDoc(XML_DEFAULT_VERSION);		root = xmlNewDocNode(data->doc, NULL, "samba", NULL);		cur = xmlDocSetRootElement(data->doc, root);		data->ns = xmlNewNs(root, XML_URL, "samba");		data->users = smbXmlNewChild(root, data->ns, "users", NULL);	}	user = smbXmlNewChild(data->users, data->ns, "user", NULL);	xmlNewProp(user, "sid",			   sid_to_string(sid_str, pdb_get_user_sid(u)));	if (pdb_get_username(u) && strcmp(pdb_get_username(u), ""))		xmlNewProp(user, "name", pdb_get_username(u));	cur = smbXmlNewChild(user, data->ns, "group", NULL);		xmlNewProp(cur, "sid",			   sid_to_string(sid_str, pdb_get_group_sid(u)));	if (pdb_get_init_flags(u, PDB_LOGONTIME) != PDB_DEFAULT)		smbXmlNewChild(user, data->ns, "logon_time",					iota(pdb_get_logon_time(u)));	if (pdb_get_init_flags(u, PDB_LOGOFFTIME) != PDB_DEFAULT)		smbXmlNewChild(user, data->ns, "logoff_time",					iota(pdb_get_logoff_time(u)));	if (pdb_get_init_flags(u, PDB_KICKOFFTIME) != PDB_DEFAULT)		smbXmlNewChild(user, data->ns, "kickoff_time",					iota(pdb_get_kickoff_time(u)));	if (pdb_get_domain(u) && strcmp(pdb_get_domain(u), ""))		smbXmlNewChild(user, data->ns, "domain", pdb_get_domain(u));	if (pdb_get_nt_username(u) && strcmp(pdb_get_nt_username(u), ""))		smbXmlNewChild(user, data->ns, "nt_username", pdb_get_nt_username(u));	if (pdb_get_fullname(u) && strcmp(pdb_get_fullname(u), ""))		smbXmlNewChild(user, data->ns, "fullname", pdb_get_fullname(u));	if (pdb_get_homedir(u) && strcmp(pdb_get_homedir(u), ""))		smbXmlNewChild(user, data->ns, "homedir", pdb_get_homedir(u));	if (pdb_get_dir_drive(u) && strcmp(pdb_get_dir_drive(u), ""))		smbXmlNewChild(user, data->ns, "dir_drive", pdb_get_dir_drive(u));	if (pdb_get_logon_script(u) && strcmp(pdb_get_logon_script(u), ""))		smbXmlNewChild(user, data->ns, "logon_script",					pdb_get_logon_script(u));	if (pdb_get_profile_path(u) && strcmp(pdb_get_profile_path(u), ""))		smbXmlNewChild(user, data->ns, "profile_path",					pdb_get_profile_path(u));	if (pdb_get_acct_desc(u) && strcmp(pdb_get_acct_desc(u), ""))		smbXmlNewChild(user, data->ns, "acct_desc", pdb_get_acct_desc(u));	if (pdb_get_workstations(u) && strcmp(pdb_get_workstations(u), ""))		smbXmlNewChild(user, data->ns, "workstations",					pdb_get_workstations(u));	if (pdb_get_unknown_str(u) && strcmp(pdb_get_unknown_str(u), ""))		smbXmlNewChild(user, data->ns, "unknown_str", pdb_get_unknown_str(u));	if (pdb_get_munged_dial(u) && strcmp(pdb_get_munged_dial(u), ""))		smbXmlNewChild(user, data->ns, "munged_dial", pdb_get_munged_dial(u));	/* Password stuff */	pass = smbXmlNewChild(user, data->ns, "password", NULL);	if (pdb_get_pass_last_set_time(u))		xmlNewProp(pass, "last_set", iota(pdb_get_pass_last_set_time(u)));	if (pdb_get_init_flags(u, PDB_CANCHANGETIME) != PDB_DEFAULT)		xmlNewProp(pass, "can_change",				   iota(pdb_get_pass_can_change_time(u)));	if (pdb_get_init_flags(u, PDB_MUSTCHANGETIME) != PDB_DEFAULT)		xmlNewProp(pass, "must_change",				   iota(pdb_get_pass_must_change_time(u)));	if (pdb_get_lanman_passwd(u)) {		pdb_sethexpwd(temp, pdb_get_lanman_passwd(u),					  pdb_get_acct_ctrl(u));		cur = smbXmlNewChild(pass, data->ns, "crypt", temp);		xmlNewProp(cur, "type", "lanman");	}	if (pdb_get_nt_passwd(u)) {		pdb_sethexpwd(temp, pdb_get_nt_passwd(u), pdb_get_acct_ctrl(u));		cur = smbXmlNewChild(pass, data->ns, "crypt", temp);		xmlNewProp(cur, "type", "nt");	}	smbXmlNewChild(user, data->ns, "acct_ctrl", iota(pdb_get_acct_ctrl(u)));	if (pdb_get_logon_divs(u))		smbXmlNewChild(user, data->ns, "logon_divs",					iota(pdb_get_logon_divs(u)));	if (pdb_get_hours_len(u))		smbXmlNewChild(user, data->ns, "hours_len",					iota(pdb_get_hours_len(u)));	smbXmlNewChild(user, data->ns, "bad_password_count", iota(pdb_get_bad_password_count(u)));	smbXmlNewChild(user, data->ns, "logon_count", iota(pdb_get_logon_count(u)));	smbXmlNewChild(user, data->ns, "unknown_6", iota(pdb_get_unknown_6(u)));	xmlSaveFile(data->location, data->doc);	return NT_STATUS_OK;}static NTSTATUS xmlsam_init(PDB_CONTEXT * pdb_context, PDB_METHODS ** pdb_method,		 const char *location){	NTSTATUS nt_status;	pdb_xml *data;	xmlsam_debug_level = debug_add_class("xmlsam");	if (xmlsam_debug_level == -1) {		xmlsam_debug_level = DBGC_ALL;		DEBUG(0, ("xmlsam: Couldn't register custom debugging class!\n"));	}	if (!pdb_context) {		DEBUG(0, ("invalid pdb_methods specified\n"));		return NT_STATUS_UNSUCCESSFUL;	}	if (!NT_STATUS_IS_OK		(nt_status = make_pdb_methods(pdb_context->mem_ctx, pdb_method))) {		return nt_status;	}	(*pdb_method)->name = "xmlsam";	(*pdb_method)->setsampwent = xmlsam_setsampwent;	(*pdb_method)->endsampwent = xmlsam_endsampwent;	(*pdb_method)->getsampwent = xmlsam_getsampwent;	(*pdb_method)->add_sam_account = xmlsam_add_sam_account;	(*pdb_method)->getsampwnam = NULL;	(*pdb_method)->getsampwsid = NULL;	(*pdb_method)->update_sam_account = NULL;	(*pdb_method)->delete_sam_account = NULL;	(*pdb_method)->getgrsid = NULL;	(*pdb_method)->getgrgid = NULL;	(*pdb_method)->getgrnam = NULL;	(*pdb_method)->add_group_mapping_entry = NULL;	(*pdb_method)->update_group_mapping_entry = NULL;	(*pdb_method)->delete_group_mapping_entry = NULL;	(*pdb_method)->enum_group_mapping = NULL;	data = _talloc(pdb_context->mem_ctx, sizeof(pdb_xml));	data->location = talloc_strdup(pdb_context->mem_ctx, (location ? location : "passdb.xml"));	data->pwent = NULL;	data->written = 0;	(*pdb_method)->private_data = data;	LIBXML_TEST_VERSION xmlKeepBlanksDefault(0);	return NT_STATUS_OK;}NTSTATUS pdb_xml_init(void) {	return smb_register_passdb(PASSDB_INTERFACE_VERSION, "xml", xmlsam_init);}

⌨️ 快捷键说明

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