provide users gid

This commit is contained in:
Peter Hormanns 2022-12-15 14:21:22 +01:00
parent 41a9490170
commit 0a010f6581
2 changed files with 5 additions and 15 deletions

View File

@ -27,8 +27,6 @@ public class UnixUserProcessorFactory implements EntityProcessorFactory {
+ user.getUserId() + ":" + user.getPac().getName() + user.getUserId() + ":" + user.getPac().getName()
+ ":" + user.getComment() + ":" + user.getHomedir() + ":" + user.getComment() + ":" + user.getHomedir()
+ ":" + user.getShell() + "\n")); + ":" + user.getShell() + "\n"));
appendSetHomeACLProcessor(aCP, user);
appendMakeMaildirProcessor(aCP, user);
aCP.appendProcessor(new ShellProcessor("salt-call state.sls pacs >/dev/null 2>&1")); aCP.appendProcessor(new ShellProcessor("salt-call state.sls pacs >/dev/null 2>&1"));
return aCP; return aCP;
} }
@ -75,17 +73,4 @@ public class UnixUserProcessorFactory implements EntityProcessorFactory {
return null; 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" +
"\""
));
}
} }

View File

@ -200,7 +200,11 @@ public class JsonPillarServlet extends HttpServlet {
boolean firstLoopUsers = true; boolean firstLoopUsers = true;
final Set<UnixUser> users = pac.getUnixUser(); final Set<UnixUser> users = pac.getUnixUser();
final TreeMap<String, UnixUser> sortedUsersMap = new TreeMap<>(); final TreeMap<String, UnixUser> sortedUsersMap = new TreeMap<>();
long pacGroupId = 0L;
for (UnixUser user: users) { for (UnixUser user: users) {
if (pacName.equals(user.getName())) {
pacGroupId = user.getUserId();
}
sortedUsersMap.put(user.getName(), user); sortedUsersMap.put(user.getName(), user);
} }
for (String nextName: sortedUsersMap.keySet()) { for (String nextName: sortedUsersMap.keySet()) {
@ -222,6 +226,7 @@ public class JsonPillarServlet extends HttpServlet {
writer.println(" \"user\": \"" + fullUsername + "\""); writer.println(" \"user\": \"" + fullUsername + "\"");
writer.println(" , \"dirname\": \"" + usernamePostfix + "\""); writer.println(" , \"dirname\": \"" + usernamePostfix + "\"");
writer.println(" , \"uid\": " + user.getUserId()); writer.println(" , \"uid\": " + user.getUserId());
writer.println(" , \"gid\": " + pacGroupId);
writer.println(" , \"comment\": \"" + quoteJSON(user.getComment()) + "\""); writer.println(" , \"comment\": \"" + quoteJSON(user.getComment()) + "\"");
writer.println(" , \"shell\": \"" + user.getShell() + "\""); writer.println(" , \"shell\": \"" + user.getShell() + "\"");
writer.println(" , \"homedir\": \"" + user.getHomedir() + "\""); writer.println(" , \"homedir\": \"" + user.getHomedir() + "\"");