Skip to content

Commit 2ceea80

Browse files
committed
CLOUDSTACK-4862:Admin cannot delete shared network scoped to user
account.
1 parent 1d982a5 commit 2ceea80

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎server/src/com/cloud/network/element/VirtualRouterElement.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
import com.cloud.offering.NetworkOffering;
7676
import com.cloud.offerings.NetworkOfferingVO;
7777
import com.cloud.offerings.dao.NetworkOfferingDao;
78+
import com.cloud.user.Account;
7879
import com.cloud.user.AccountManager;
7980
import com.cloud.uservm.UserVm;
8081
import com.cloud.utils.Pair;
@@ -663,8 +664,11 @@ public boolean destroy(Network config, ReservationContext context) throws Concur
663664
return true;
664665
}
665666
boolean result = true;
667+
// NOTE that we need to pass caller account to destroyRouter, otherwise it will fail permission check there. Context passed in from deleteNetwork is the network account,
668+
// not caller account
669+
Account callerAccount = _accountMgr.getAccount(context.getCaller().getAccountId());
666670
for (DomainRouterVO router : routers) {
667-
result = result && (_routerMgr.destroyRouter(router.getId(), context.getAccount(), context.getCaller().getId()) != null);
671+
result = result && (_routerMgr.destroyRouter(router.getId(), callerAccount, context.getCaller().getId()) != null);
668672
}
669673
return result;
670674
}

0 commit comments

Comments
 (0)