From 0a010f6581141f820f252abecc8dcc59c076b393 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Thu, 15 Dec 2022 14:21:22 +0100 Subject: [PATCH] provide users gid --- .../mods/user/UnixUserProcessorFactory.java | 15 --------------- .../src/de/hsadmin/pillar/JsonPillarServlet.java | 5 +++++ 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/user/UnixUserProcessorFactory.java b/hsarback/src/de/hsadmin/mods/user/UnixUserProcessorFactory.java index 7a75cb5..ced4297 100644 --- a/hsarback/src/de/hsadmin/mods/user/UnixUserProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/user/UnixUserProcessorFactory.java @@ -27,8 +27,6 @@ public class UnixUserProcessorFactory implements EntityProcessorFactory { + user.getUserId() + ":" + user.getPac().getName() + ":" + user.getComment() + ":" + user.getHomedir() + ":" + user.getShell() + "\n")); - appendSetHomeACLProcessor(aCP, user); - appendMakeMaildirProcessor(aCP, user); aCP.appendProcessor(new ShellProcessor("salt-call state.sls pacs >/dev/null 2>&1")); return aCP; } @@ -75,17 +73,4 @@ public class UnixUserProcessorFactory implements EntityProcessorFactory { return null; } - private void appendSetHomeACLProcessor(CompoundProcessor aCP, UnixUser user) { - aCP.appendProcessor(new ShellProcessor("chmod 700 " + user.getHomedir())); - } - - private void appendMakeMaildirProcessor(CompoundProcessor aCP, UnixUser user) { - aCP.appendProcessor( - new ShellProcessor( - "su -l " + user.getName() + " -s \"/bin/bash\" -c \"maildirmake " + - user.getHomedir() + "/Maildir" + - "\"" - )); - } - } diff --git a/hsarback/src/de/hsadmin/pillar/JsonPillarServlet.java b/hsarback/src/de/hsadmin/pillar/JsonPillarServlet.java index 25ec9c7..fd0f559 100644 --- a/hsarback/src/de/hsadmin/pillar/JsonPillarServlet.java +++ b/hsarback/src/de/hsadmin/pillar/JsonPillarServlet.java @@ -200,7 +200,11 @@ public class JsonPillarServlet extends HttpServlet { boolean firstLoopUsers = true; final Set users = pac.getUnixUser(); final TreeMap sortedUsersMap = new TreeMap<>(); + long pacGroupId = 0L; for (UnixUser user: users) { + if (pacName.equals(user.getName())) { + pacGroupId = user.getUserId(); + } sortedUsersMap.put(user.getName(), user); } for (String nextName: sortedUsersMap.keySet()) { @@ -222,6 +226,7 @@ public class JsonPillarServlet extends HttpServlet { writer.println(" \"user\": \"" + fullUsername + "\""); writer.println(" , \"dirname\": \"" + usernamePostfix + "\""); writer.println(" , \"uid\": " + user.getUserId()); + writer.println(" , \"gid\": " + pacGroupId); writer.println(" , \"comment\": \"" + quoteJSON(user.getComment()) + "\""); writer.println(" , \"shell\": \"" + user.getShell() + "\""); writer.println(" , \"homedir\": \"" + user.getHomedir() + "\"");