-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core/dracut/ignition-ostree: add ignition-ostree-sysusers service #774
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
overlay.d/05core/usr/lib/dracut/modules.d/40ignition-ostree/coreos-sysroot-bwrap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Needed to work around the initrd `rootfs` / filesystem not being a valid | ||
# mount to pivot out of. For reference, see: | ||
# - https://github.com/torvalds/linux/blob/26bc672134241a080a83b2ab9aa8abede8d30e1c/fs/namespace.c#L3605 | ||
# - https://gist.github.com/jlebon/fb6e7c6dcc3ce17d3e2a86f5938ec033 | ||
set -euo pipefail | ||
|
||
TMP_CHROOT_DIR="" | ||
|
||
main() { | ||
setup_chroot_tmpdir | ||
run_chrooted_bwrap "$@" | ||
} | ||
|
||
setup_chroot_tmpdir() { | ||
TMP_CHROOT_DIR=$(mktemp --directory --tmpdir=/mnt '.coreos-sysroot-bwrap.tmp.XXXXXXXXXX') | ||
mount --bind / "${TMP_CHROOT_DIR}" | ||
mount --make-private "${TMP_CHROOT_DIR}" | ||
mount --bind "${TMP_CHROOT_DIR}" "${TMP_CHROOT_DIR}" | ||
for mnt in proc sys dev; do | ||
mount --bind /$mnt "${TMP_CHROOT_DIR}"/$mnt | ||
done | ||
touch "${TMP_CHROOT_DIR}"/run/ostree-booted | ||
mount --bind /sysroot "${TMP_CHROOT_DIR}"/sysroot | ||
} | ||
|
||
run_chrooted_bwrap() { | ||
chroot "${TMP_CHROOT_DIR}" \ | ||
/usr/bin/env --chdir /sysroot \ | ||
bwrap \ | ||
--unshare-pid --unshare-uts --unshare-ipc --unshare-net \ | ||
--unshare-cgroup-try --dev /dev --proc /proc --chdir / \ | ||
--ro-bind usr /usr --bind etc /etc --dir /tmp --tmpfs /var/tmp \ | ||
--tmpfs /run --ro-bind /run/ostree-booted /run/ostree-booted \ | ||
--symlink usr/lib /lib \ | ||
--symlink usr/lib64 /lib64 \ | ||
--symlink usr/bin /bin \ | ||
--symlink usr/sbin /sbin -- "$@" | ||
} | ||
|
||
cleanup() { | ||
if test -z "${TMP_CHROOT_DIR}"; then | ||
return | ||
fi | ||
|
||
umount --lazy --recursive "${TMP_CHROOT_DIR}" | ||
umount --recursive "${TMP_CHROOT_DIR}" | ||
lucab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rmdir "${TMP_CHROOT_DIR}" | ||
} | ||
|
||
trap cleanup EXIT | ||
main "$@" |
19 changes: 19 additions & 0 deletions
19
overlay.d/05core/usr/lib/dracut/modules.d/40ignition-ostree/ignition-ostree-sysusers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
# Run systemd-sysusers for the target OSTree sysroot. | ||
|
||
set -euo pipefail | ||
|
||
main() { | ||
coreos-sysroot-bwrap systemd-sysusers | ||
travier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
coreos-relabel \ | ||
/etc/group \ | ||
/etc/group- \ | ||
/etc/gshadow \ | ||
/etc/gshadow- \ | ||
/etc/passwd \ | ||
/etc/passwd- \ | ||
/etc/shadow \ | ||
/etc/shadow- | ||
} | ||
|
||
main "$@" |
17 changes: 17 additions & 0 deletions
17
overlay.d/05core/usr/lib/dracut/modules.d/40ignition-ostree/ignition-ostree-sysusers.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[Unit] | ||
Description=Populate OSTree sysusers | ||
DefaultDependencies=false | ||
ConditionKernelCommandLine=|ostree | ||
|
||
# Need to do this with all mount points active | ||
After=ignition-mount.service | ||
|
||
# But *before* we start dumping files in there | ||
Before=ignition-files.service | ||
Before=ignition-ostree-populate-var.service | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
MountFlags=slave | ||
ExecStart=/usr/sbin/ignition-ostree-sysusers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
variant: fcos | ||
version: 1.0.0 | ||
storage: | ||
files: | ||
- path: /etc/zincati/config.d/00-dummy-placeholder.toml | ||
mode: 0644 | ||
user: | ||
name: "zincati" | ||
contents: | ||
inline: | | ||
# Dummy placeholder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
ok() { | ||
echo "ok" "$@" | ||
} | ||
|
||
fatal() { | ||
echo "$@" >&2 | ||
exit 1 | ||
} | ||
|
||
TARGET="/etc/zincati/config.d/00-dummy-placeholder.toml" | ||
OWNER=$(stat -c '%U' "${TARGET}") | ||
|
||
# make sure the placeholder file is owned by the proper system user. | ||
if test "${OWNER}" != 'zincati' ; then | ||
fatal "unexpected owner of ${TARGET}: ${OWNER}" | ||
fi | ||
ok "placeholder file correctly owned by zincati user" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would probably be a good thing to live in rdcore (and in theory in the future it could be a crate shared between rdcore and rpm-ostree).
Not a blocker though.