]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/configuration/sgconfig/parser.cpp
Added ability to list authorizers for user.
[stg.git] / projects / stargazer / plugins / configuration / sgconfig / parser.cpp
index 1f7757d22a99e68e013cba489092061cb9b43e55..b6c491721f78c53a3c01d5edad0b163cc5ef57f3 100644 (file)
@@ -286,6 +286,13 @@ answerList->push_back(s);
 strprintf(&s, "<CreditExpire value=\"%ld\" />", u->GetProperty().creditExpire.Get());
 answerList->push_back(s);
 
+s = "<AuthorizedBy>";
+std::vector<std::string> list(u->GetAuthorizers());
+for (std::vector<std::string>::const_iterator it = list.begin(); it != list.end(); ++it)
+    s += "<Auth name=\"" + *it + "\">";
+s += "</AuthorizedBy>";
+answerList->push_back(s);
+
 strprintf(&s, "</user>");
 answerList->push_back(s);
 }
@@ -1025,9 +1032,23 @@ if (check && alwaysOnline && !onlyOneIP)
     {
     printfd(__FILE__, "Requested change leads to a forbidden state: AlwaysOnline with multiple IP's\n");
     GetStgLogger()("%s Requested change leads to a forbidden state: AlwaysOnline with multiple IP's", currAdmin->GetLogStr().c_str());
+    res = -1;
     return -1;
     }
 
+for (size_t i = 0; i < ucr->ips.const_data().Count(); ++i)
+    {
+    CONST_USER_PTR user;
+    uint32_t ip = ucr->ips.const_data().operator[](i).ip;
+    if (users->IsIPInUse(ip, login, &user))
+        {
+        printfd(__FILE__, "Trying to assign an IP %s to '%s' that is already in use by '%s'\n", inet_ntostring(ip).c_str(), login.c_str(), user->GetLogin().c_str());
+        GetStgLogger()("%s trying to assign an IP %s to '%s' that is currently in use by '%s'", currAdmin->GetLogStr().c_str(), inet_ntostring(ip).c_str(), login.c_str(), user->GetLogin().c_str());
+        res = -1;
+        return -1;
+        }
+    }
+
 if (!ucr->ips.res_empty())
     if (!u->GetProperty().ips.Set(ucr->ips.const_data(), currAdmin, login, store))
         res = -1;