fix(homebrew): own trust store files to user (root-created files blocked brew writes)
This commit is contained in:
parent
0671e65289
commit
f306c2d01c
1 changed files with 11 additions and 0 deletions
|
|
@ -77,8 +77,12 @@ in
|
||||||
${pkgs.python3}/bin/python3 - <<'PY'
|
${pkgs.python3}/bin/python3 - <<'PY'
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import pwd
|
||||||
|
|
||||||
home = "${userHome}"
|
home = "${userHome}"
|
||||||
|
user = "${user}"
|
||||||
|
uid = pwd.getpwnam(user).pw_uid
|
||||||
|
gid = pwd.getpwnam(user).pw_gid
|
||||||
rel_paths = [
|
rel_paths = [
|
||||||
os.path.join(".homebrew", "trust.json"),
|
os.path.join(".homebrew", "trust.json"),
|
||||||
os.path.join(".config", "homebrew", "trust.json"),
|
os.path.join(".config", "homebrew", "trust.json"),
|
||||||
|
|
@ -100,6 +104,13 @@ in
|
||||||
with open(path, "w") as fh:
|
with open(path, "w") as fh:
|
||||||
json.dump(data, fh, indent=2)
|
json.dump(data, fh, indent=2)
|
||||||
fh.write("\n")
|
fh.write("\n")
|
||||||
|
try:
|
||||||
|
os.chmod(path, 0o600)
|
||||||
|
os.chown(path, uid, gid)
|
||||||
|
except OSError:
|
||||||
|
# Not running as root (e.g. standalone activation); brew will
|
||||||
|
# still read the file, it just may not be able to rewrite it.
|
||||||
|
pass
|
||||||
PY
|
PY
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue