[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[myserver-commit] [2859] Added possibility to redefine permissions mask
From: |
Giuseppe Scrivano |
Subject: |
[myserver-commit] [2859] Added possibility to redefine permissions mask in the security file through the `PERMISSION ' command. |
Date: |
Thu, 02 Oct 2008 19:20:28 +0000 |
Revision: 2859
http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=2859
Author: gscrivano
Date: 2008-10-02 19:20:25 +0000 (Thu, 02 Oct 2008)
Log Message:
-----------
Added possibility to redefine permissions mask in the security file through the
`PERMISSION' command.
Modified Paths:
--------------
branches/myserver_sec_new/include/conf/security/security_manager.h
branches/myserver_sec_new/include/conf/security/xml_validator.h
branches/myserver_sec_new/src/conf/security/xml_validator.cpp
Modified: branches/myserver_sec_new/include/conf/security/security_manager.h
===================================================================
--- branches/myserver_sec_new/include/conf/security/security_manager.h
2008-10-01 19:43:35 UTC (rev 2858)
+++ branches/myserver_sec_new/include/conf/security/security_manager.h
2008-10-02 19:20:25 UTC (rev 2859)
@@ -87,8 +87,13 @@
*where the password is not sent in clear on the network.
*/
string neededPassword;
-
+
/*!
+ *The provided password is correct.
+ */
+ bool authenticated;
+
+ /*!
*The obtained mask if password were correct.
*/
int providedMask;
Modified: branches/myserver_sec_new/include/conf/security/xml_validator.h
===================================================================
--- branches/myserver_sec_new/include/conf/security/xml_validator.h
2008-10-01 19:43:35 UTC (rev 2858)
+++ branches/myserver_sec_new/include/conf/security/xml_validator.h
2008-10-02 19:20:25 UTC (rev 2859)
@@ -58,11 +58,17 @@
SecurityToken *st,
HashMap<string, SecurityDomain*> *hashedDomains);
+ void doPermission (xmlNodePtr node,
+ SecurityToken *st,
+ HashMap<string, SecurityDomain*> *hashedDomains);
+
int computeXmlNode (xmlNodePtr node,
SecurityToken *st,
int *cmd,
HashMap<string, SecurityDomain*> *hashedDomains);
+ int getPermissions (xmlAttr* attrs, xmlChar** user = NULL, xmlChar**
password = NULL);
+
SecurityCache *getCache(Server*);
SecurityCache *secCache;
Mutex cacheMutex;
Modified: branches/myserver_sec_new/src/conf/security/xml_validator.cpp
===================================================================
--- branches/myserver_sec_new/src/conf/security/xml_validator.cpp
2008-10-01 19:43:35 UTC (rev 2858)
+++ branches/myserver_sec_new/src/conf/security/xml_validator.cpp
2008-10-02 19:20:25 UTC (rev 2859)
@@ -105,20 +105,56 @@
xmlAttr *attrs = cur->properties;
- const xmlChar* name;
- const xmlChar* password;
+ xmlChar* name = NULL;
+ xmlChar* password = NULL;
+ int permissions = getPermissions (attrs, &name, &password);
+
+ if (!name || !password)
+ continue;
+
+ if (xmlStrcmp (name, (const xmlChar *)st->user.c_str ()))
+ continue;
+
+ st->providedMask = permissions;
+
+ if (xmlStrcmp (password, (const xmlChar *)st->password.c_str ()))
+ {
+ st->authenticated = false;
+ st->mask = 0;
+ }
+ else
+ {
+ st->authenticated = true;
+ st->mask = permissions;
+ }
+
+ return st->mask;
+ }
+
+ return 0;
+}
+
+/*!
+ *Get a permission mask from the attributes.
+ *\param attrs Attributes list.
+ *\param user The found user name.
+ *\param password The found password.
+ *\return the permissions mask.
+ */
+int XmlValidator::getPermissions (xmlAttr* attrs, xmlChar** user, xmlChar**
password )
+{
int permissions = 0;
while (attrs)
{
- if (!xmlStrcmp (attrs->name, (const xmlChar *)"name") &&
+ if (user && !xmlStrcmp (attrs->name, (const xmlChar *)"name") &&
attrs->children && attrs->children->content)
- name = attrs->children->content;
+ *user = attrs->children->content;
- if (!xmlStrcmp (attrs->name, (const xmlChar *)"password") &&
+ if (password && !xmlStrcmp (attrs->name, (const xmlChar *)"password") &&
attrs->children && attrs->children->content)
- password = attrs->children->content;
+ *password = attrs->children->content;
if (!xmlStrcmp (attrs->name, (const xmlChar *)"read") &&
attrs->children && attrs->children->content &&
@@ -143,20 +179,7 @@
attrs = attrs->next;
}
- if (xmlStrcmp (name, (const xmlChar *)st->user.c_str ()))
- continue;
-
- st->providedMask = permissions;
-
- if (xmlStrcmp (password, (const xmlChar *)st->password.c_str ()))
- st->mask = 0;
- else
- st->mask = permissions;
-
- return st->mask;
- }
-
- return 0;
+ return permissions;
}
@@ -215,6 +238,10 @@
{
doDefine (cur, st, hashedDomains);
}
+ else if (!xmlStrcmp (cur->name, (const xmlChar *) "PERMISSION"))
+ {
+ doPermission (cur, st, hashedDomains);
+ }
}
return 0;
@@ -261,6 +288,23 @@
}
/*!
+ *Handle a PERMISSION.
+ */
+void XmlValidator::doPermission (xmlNodePtr node, SecurityToken *st,
HashMap<string, SecurityDomain*> *hashedDomains)
+{
+ string name;
+ const xmlChar *isNot = (const xmlChar*)"";
+ const xmlChar *value = (const xmlChar*)"";
+ xmlAttr *attrs = node->properties;
+
+ st->providedMask = getPermissions (attrs);
+
+ if (st->authenticated)
+ st->mask = st->providedMask;
+}
+
+
+/*!
*Handle a DEFINE.
*/
void XmlValidator::doDefine (xmlNodePtr node, SecurityToken *st,
HashMap<string, SecurityDomain*> *hashedDomains)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [myserver-commit] [2859] Added possibility to redefine permissions mask in the security file through the `PERMISSION ' command.,
Giuseppe Scrivano <=