carbon-config

config submodule of carbon-core-system
git clone https://ccx.te2000.cz/git/carbon-config
Log | Files | Refs

commit c05aa6d49ceac69d801baf63afa1f76b9d470387
parent cd5b847eb870da8769e54ec08d4260a039523eff
Author: Jan Pobrislo <ccx@webprojekty.cz>
Date:   Wed, 27 Jul 2022 01:51:41 +0200

Add user ccx

Diffstat:
Mpostinstall.aat | 5+++++
Mpostinstall.fileset | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpostinstall.rsfilter | 2++
3 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/postinstall.aat b/postinstall.aat @@ -94,11 +94,16 @@ CN # Managed by /usr/src/core-system /etc + /etc/group + |line_append_file("sshd:x", ":22:", "", "^[^:]*:[^:]*") +|line_append_file("ccx:x", ":1000:", "", "^[^:]*:[^:]*") /etc/passwd f + ?i grep -q '^root:.*:{<root_shell>}$' !f sed -Ee 's|^(root:.*:)[^:]*$|\1{<root_shell>}|' + |passwd_user("sshd:x:22:22:server privilege separation,,,:/home/sshd:/sbin/nologin") |shadow_user("sshd:!:10000::::::") +|passwd_user("ccx:x:1000:1000:Jan Pobrislo:/home/ccx:/bin/zsh") +|shadow_user("ccx:!:10000::::::") + |} diff --git a/postinstall.fileset b/postinstall.fileset @@ -43,10 +43,17 @@ CN # Managed by /usr/src/core-system else printf '%s\n' 'sshd:x:22:' >> "$fname" fi +? grep -qEe '^ccx:x:1000:$' "$fname" +! if grep -qEe '^[^:]*:[^:]*:1000:' "$fname"; then + sed -ire 's|^[^:]*:[^:]*:1000:|ccx:x:1000:|' "$fname" + else + printf '%s\n' 'ccx:x:1000:' >> "$fname" + fi /etc/passwd f + ?i grep -q '^root:.*:/bin/zsh$' !f sed -Ee 's|^(root:.*:)[^:]*$|\1/bin/zsh|' + /etc/passwd f + !f awk 'BEGIN { FS=OFS=":"; seen=0; line="sshd:x:22:22:server privilege separation,,,:/home/sshd:/sbin/nologin"; split(line, a) } { uids[$3] = $0 } @@ -93,3 +100,49 @@ CN # Managed by /usr/src/core-system } }' +/etc/passwd f + +!f awk 'BEGIN { FS=OFS=":"; seen=0; line="ccx:x:1000:1000:Jan Pobrislo:/home/ccx:/bin/zsh"; split(line, a) } + { uids[$3] = $0 } + $1 == a[1] { + for(n in a) { + if(a[n] != $n) { + print "error: differing present and requested lines" >>"/dev/stderr" + print "requested: " line >>"/dev/stderr" + print "present: " $0 >>"/dev/stderr" + exit 1 + } + } + seen = 1 + } + { print $0 } + END { + if(seen == 0) { + if(a[3] in uids) { + print "error: user record with requested UID already present" >>"/dev/stderr" + print "requested: " line >>"/dev/stderr" + print "present: " uids[a[3]] >>"/dev/stderr" + exit 1 + } + print line + } + }' +/etc/shadow f + +!f awk 'BEGIN { FS=OFS=":"; seen=0; line="ccx:!:10000::::::"; split(line, a) } + $1 == a[1] { + for(n in a) { + if(a[n] != $n) { + print "error: differing present and requested lines" >>"/dev/stderr" + print "requested: " line >>"/dev/stderr" + print "present: " $0 >>"/dev/stderr" + exit 1 + } + } + seen = 1 + } + { print $0 } + END { + if(seen == 0) { + print line + } + }' + diff --git a/postinstall.rsfilter b/postinstall.rsfilter @@ -10,3 +10,5 @@ + /etc/passwd + /etc/passwd + /etc/shadow ++ /etc/passwd ++ /etc/shadow