You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 29e6dae
Browse filesBrowse the repository at this point in the historyBrowse files
Alena Prokharchyk
committed
CLOUDSTACK-287: don't allow API call against system account (adding users to system account is prohibited; can't delete/update System account)
if (account == null || account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
835
835
thrownewInvalidParameterValueException("Unable to find account " + accountName + " in domain id=" + domainId + " to create user");
836
836
}
837
+
838
+
if (account.getId() == Account.ACCOUNT_ID_SYSTEM) {
839
+
thrownewPermissionDeniedException("Account id : " + account.getId() + " is a system account, can't add a user to it");
840
+
}
837
841
838
842
if (!_userAccountDao.validateUsernameInDomain(userName, domainId)) {
839
843
thrownewCloudRuntimeException("The user " + userName + " already exists in domain " + domainId);
@@ -1155,9 +1159,8 @@ public AccountVO enableAccount(String accountName, Long domainId, Long accountId
1155
1159
thrownewInvalidParameterValueException("Unable to find account by accountId: " + accountId + " OR by name: " + accountName + " in domain " + domainId);
1156
1160
}
1157
1161
1158
-
// Don't allow to modify system account
1159
1162
if (account.getId() == Account.ACCOUNT_ID_SYSTEM) {
1160
-
thrownewInvalidParameterValueException("Can not modify system account");
1163
+
thrownewPermissionDeniedException("Account id : " + accountId + " is a system account, enable is not allowed");
1161
1164
}
1162
1165
1163
1166
// Check if user performing the action is allowed to modify this account
@@ -1187,14 +1190,13 @@ public AccountVO lockAccount(String accountName, Long domainId, Long accountId)
1187
1190
if (account == null || account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
1188
1191
thrownewInvalidParameterValueException("Unable to find active account by accountId: " + accountId + " OR by name: " + accountName + " in domain " + domainId);
1189
1192
}
1190
-
1191
-
checkAccess(caller, null, true, account);
1192
-
1193
-
// don't allow modify system account
1193
+
1194
1194
if (account.getId() == Account.ACCOUNT_ID_SYSTEM) {
1195
-
thrownewInvalidParameterValueException("can not lock system account");
1195
+
thrownewPermissionDeniedException("Account id : " + accountId + " is a system account, lock is not allowed");
1196
1196
}
1197
1197
1198
+
checkAccess(caller, null, true, account);
1199
+
1198
1200
if (lockAccount(account.getId())) {
1199
1201
return_accountDao.findById(account.getId());
1200
1202
} else {
@@ -1217,6 +1219,10 @@ public AccountVO disableAccount(String accountName, Long domainId, Long accountI
1217
1219
if (account == null || account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
1218
1220
thrownewInvalidParameterValueException("Unable to find account by accountId: " + accountId + " OR by name: " + accountName + " in domain " + domainId);
1219
1221
}
1222
+
1223
+
if (account.getId() == Account.ACCOUNT_ID_SYSTEM) {
1224
+
thrownewPermissionDeniedException("Account id : " + accountId + " is a system account, disable is not allowed");
0 commit comments