delete pac domains
This commit is contained in:
parent
4cd7489996
commit
8ae17912b7
@ -114,5 +114,33 @@ public class PacModuleImpl extends AbstractModuleImpl {
|
||||
throws HSAdminException {
|
||||
throw new AuthorisationException(getLoginUser(), "update", existingEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(AbstractEntity existingEntity) throws HSAdminException {
|
||||
EntityManager em = getTransaction().getEntityManager();
|
||||
Pac pac = (Pac) existingEntity;
|
||||
Date dateCancelled = pac.getCancelled();
|
||||
if (dateCancelled == null || dateCancelled.getTime() > System.currentTimeMillis()) {
|
||||
throw new AuthorisationException(getLoginUser(), "delete", existingEntity);
|
||||
}
|
||||
GenericModuleImpl helperModule = new GenericModuleImpl(getTransaction());
|
||||
|
||||
Query qDoms = em.createQuery("SELECT dom FROM Domains dom WHERE dom.user.pac.name = :pac");
|
||||
qDoms.setParameter("pac", pac.getName());
|
||||
List<?> domsList = qDoms.getResultList();
|
||||
for (Object o : domsList) {
|
||||
if (o instanceof Domain) {
|
||||
helperModule.delete((AbstractEntity) o);
|
||||
}
|
||||
}
|
||||
|
||||
UnixUser admin = pac.owningUser(em);
|
||||
for (UnixUser user : pac.getUnixUser()) {
|
||||
if (admin.getId() != user.getId()) {
|
||||
helperModule.delete(user);
|
||||
}
|
||||
}
|
||||
super.delete(existingEntity);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
|
||||
createNetworkInterfacesProc(hiveValues, pacValuesList),
|
||||
createSudouersProc(hiveValues, pacValuesList),
|
||||
createProftpdConfProc(hiveValues, pacValuesList),
|
||||
createMakePacDirectoryStructure(unixUser));
|
||||
createDelUserProc(unixUser.getName()));
|
||||
}
|
||||
|
||||
private TemplateProcessor createEtcHostsProc(
|
||||
@ -113,6 +113,10 @@ public class PacProcessorFactory implements EntityProcessorFactory {
|
||||
+ ":" + unixUser.getShell() + "\n");
|
||||
}
|
||||
|
||||
private ShellProcessor createDelUserProc(String pacName) {
|
||||
return new ShellProcessor("deluser --remove-all-files " + pacName);
|
||||
}
|
||||
|
||||
private ShellProcessor createMakePacDirectoryStructure(UnixUser unixUser) {
|
||||
return new ShellProcessor("chmod 711 " + unixUser.getHomedir() + " && " +
|
||||
"su -l " + unixUser.getName() + " -s \"/bin/bash\" -c \"mkdir -p " +
|
||||
|
Loading…
Reference in New Issue
Block a user