Skip to content

Commit b535cf3

Browse files
committed
feat: also check nixbld user groups
1 parent b3cd55a commit b535cf3

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

ansible-nix/files/permission_check.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,24 @@ def compare_results(username, query_result):
172172
print("Got:", query_result)
173173
sys.exit(1)
174174

175+
def check_nixbld_users():
176+
query = """
177+
SELECT u.username, g.groupname
178+
FROM users u
179+
JOIN user_groups ug ON u.uid = ug.uid
180+
JOIN groups g ON ug.gid = g.gid
181+
WHERE u.username LIKE 'nixbld%';
182+
"""
183+
query_result = run_osquery(query)
184+
parsed_result = parse_json(query_result)
185+
186+
for user in parsed_result:
187+
if user['groupname'] != 'nixbld':
188+
print(f"User '{user['username']}' is in group '{user['groupname']}' instead of 'nixbld'.")
189+
sys.exit(1)
190+
191+
print("All nixbld users are in the 'nixbld' group.")
192+
175193
# Define usernames for which you want to compare results
176194
usernames = ["postgres", "ubuntu", "root", "daemon", "bin", "sys", "sync", "games","man","lp","mail","news","uucp","proxy","www-data","backup","list","irc","gnats","nobody","systemd-network","systemd-resolve","systemd-timesync","messagebus","ec2-instance-connect","sshd","wal-g","pgbouncer","gotrue","envoy","kong","nginx","vector","adminapi","postgrest","tcpdump","systemd-coredump"]
177195

@@ -181,3 +199,6 @@ def compare_results(username, query_result):
181199
query_result = run_osquery(query)
182200
parsed_result = parse_json(query_result)
183201
compare_results(username, parsed_result)
202+
203+
# Check if all nixbld users are in the nixbld group
204+
check_nixbld_users()

common-nix.vars.pkr.hcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
postgres-version = "15.6.1.51-nix-staged"
1+
postgres-version = "15.6.1.52-nix-staged"

0 commit comments

Comments
 (0)