summaryrefslogtreecommitdiff
path: root/src/firstboot
Commit message (Collapse)AuthorAgeFilesLines
* dissect-image: port mount_image_privately_interactively() to use ↵Lennart Poettering2023-05-161-3/+3
| | | | | | | | | | /run/systemd/mount-rootfs/ too Let's use the same common directory as the unit logic uses. This means we have less to clean up, and opens the door to eventually allow unprivileged operation of the mount_image_privately_interactively() logic.
* image-policy: introduce parse_image_policy_argument() helperYu Watanabe2023-04-131-13/+8
| | | | | | | | | Addresses https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1060130312, https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1067927293, and https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1067926416. Follow-up for 84be0c710d9d562f6d2cf986cc2a8ff4c98a138b.
* Merge pull request #25608 from poettering/dissect-moarLennart Poettering2023-04-121-1/+18
|\ | | | | dissect: add dissection policies
| * tree-wide: hook up image dissection policy logic everywhereLennart Poettering2023-04-051-1/+18
| |
* | firstboot: Use root directory file descriptor for everythingDaan De Meyer2023-04-111-39/+57
|/ | | | | | There were a few remaining cases where we used arg_root instead of the root directory file descriptor. Let's port those over to use the root directory file descriptor as well.
* firstboot: Add --reset optionDaan De Meyer2023-04-011-0/+54
| | | | | | This can be used to prepare an image for firstboot by removing all files that systemd knows about that contain machine specific information.
* firstboot: Do not dereference symlinksDaan De Meyer2023-04-011-4/+4
| | | | | | | | Let's always operate on paths without resolving the final component. If the path is a symlink, it could point to a vendor default in /usr, in which case we definitely do not want to modify the vendor defaults. To avoid this from happening, we replace the symlink with our own file instead of modifying the file the symlink points at.
* firstboot: Refactor should_configure()Daan De Meyer2023-03-291-6/+7
|
* firstboot: Check for errors returned by dir_fd_is_root()Daan De Meyer2023-03-291-5/+21
|
* user-util: Rename ETC_PASSWD_LOCK_NAME to ETC_PASSWD_LOCK_FILENAMEDaan De Meyer2023-03-291-1/+1
|
* firstboot: Modernize path handlingDaan De Meyer2023-03-291-146/+227
| | | | | | | Let's open a file descriptor to the root directory and perform all path operations using that file descriptor. On top of that, let's make sure we pin the directory containing the file we want to work on and use atomic copies and writes everywhere we can..
* chase-symlinks: Rename chase_symlinks() to chase()Daan De Meyer2023-03-241-2/+2
| | | | | | | | | Chasing symlinks is a core function that's used in a lot of places so it deservers a less verbose names so let's rename it to chase() and chaseat(). We also slightly change the pattern used for the chaseat() helpers so we get chase_and_openat() and similar.
* copy: Move chattr arguments to full function signaturesDaan De Meyer2023-03-211-2/+2
| | | | | These are almost never used, so let's move them to the _full() functions signatures.
* dissect-image: Return mount point fd if requestedDaan De Meyer2023-02-171-0/+1
|
* basic/user-util: create /etc from take_etc_passwd_lockZbigniew Jędrzejewski-Szmek2023-02-011-2/+0
| | | | | | | | This allows sysusers to operate with --root that is an empty directory. It may be useful to, for example, populate the user database before installing anything else. firstboot was already doing this, so drop the duplicated call there.
* tree-wide: unify how we pick OS pretty name to displayLennart Poettering2023-01-241-2/+3
|
* tree-wide: use -EBADF moreYu Watanabe2022-12-211-1/+1
|
* basic: move version() to build.h+cZbigniew Jędrzejewski-Szmek2022-11-081-0/+1
|
* firstboot: fix segfault when --locale-messages= is passed without --locale=Luca Boccassi2022-11-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | \#0 __strcmp_evex () at ../sysdeps/x86_64/multiarch/strcmp-evex.S:295 No locals. \#1 0x0000557444eb172b in process_locale () at ../src/firstboot/firstboot.c:342 etc_localeconf = 0x7ffd40217b80 "/root/root/etc/locale.conf" locales = {0x0, 0x0, 0x0} i = 0 r = <optimized out> __PRETTY_FUNCTION__ = "process_locale" __func__ = "process_locale" \#2 0x0000557444eaff93 in run (argv=0x7ffd40217d98, argc=3) at ../src/firstboot/firstboot.c:1401 loop_device = 0x0 unlink_dir = 0x0 r = <optimized out> loop_device = <optimized out> unlink_dir = <optimized out> r = <optimized out> __func__ = <optimized out> __PRETTY_FUNCTION__ = <optimized out> enabled = <optimized out> _error = <optimized out> _level = <optimized out> _e = <optimized out> _level = <optimized out> _e = <optimized out> \#3 main (argc=3, argv=0x7ffd40217d98) at ../src/firstboot/firstboot.c:1432 r = <optimized out> __PRETTY_FUNCTION__ = "main" Fixes https://github.com/systemd/systemd/issues/25249
* firstboot: add debug loggingZbigniew Jędrzejewski-Szmek2022-09-301-20/+61
| | | | | | | | | | | | | $ SYSTEMD_LOG_LEVEL=debug build/systemd-firstboot --prompt-root-password Found container virtualization systemd-nspawn. Found /etc/locale.conf, assuming locale information has been configured. Failed to read credential firstboot.keymap, ignoring: No such device or address Prompting for keymap was not requested. Found /etc/localtime, assuming timezone has been configured. Prompting for hostname was not requested. Found /etc/machine-id, assuming machine-id has been configured. Found /etc/passwd and /etc/shadow, assuming root account has been initialized. Creation of /etc/kernel/cmdline was not requested, skipping.
* tree-wide: drop unused reference to DecryptedImageYu Watanabe2022-09-181-3/+1
|
* tree-wide: Fix field width specifier warningsJan Janssen2022-08-301-1/+1
| | | | | The casting here isn't pretty, but at least it makes it obvious what is happening instead of implicit and it allows enabling -Wformat-signedness.
* various: try to use DEFAULT_USER_SHELL for root tooZbigniew Jędrzejewski-Szmek2022-08-241-1/+1
| | | | | | | | | | | | | | | | | | | /bin/sh as a shell is punishing. There is no good reason to make the occasional root login unpleasant. Since /bin/sh is usually /bin/bash in compat mode, i.e. if one is available, the other will be too, /bin/bash is almost as good as a default. But to avoid a regression in the situation where /bin/bash (or DEFAULT_USER_SHELL) is not installed, we check with access() and fall back to /bin/sh. This should make this change in behaviour less risky. (FWIW, e.g. Fedora/RHEL use /bin/bash as default for root.) This is a follow-up of sorts for 53350c7bbade8c5f357aa3d1029ef9b2208ea675, which added the default-user-shell option, but most likely with the idea of using /bin/bash less ;) Fixes #24369.
* firstboot: fix can't overwrite timezonebin4567892022-08-151-4/+6
|
* creds: refactor reading user passwordLudwig Nussel2022-08-111-14/+1
| | | | Share code between firstboot and sysusers
* firstboot: Don't skip passwd/shadow logic if only one of the files existsDaan De Meyer2022-07-051-4/+2
| | | | | | If one of the files exists but not the other one, we want to make sure we create the other file to make sure the passwd database is in a valid state.
* firstboot: make --help output fit in 80 columnsZbigniew Jędrzejewski-Szmek2022-04-051-31/+31
| | | | | | A long name of one parameter was making the whole thing very wide. I think that it's obvious from the context what the argument is, so a shorter name should be just as good.
* basic: spit out chase_symlinks() from fs-util.[ch] → chase-symlinks.[ch]Lennart Poettering2021-10-051-0/+1
|
* basic: split out glyph/emoji related calls from locale-util.[ch] into ↵Lennart Poettering2021-10-051-0/+1
| | | | | | | | glyph-util.[ch] These functions are used pretty much independently of locale, i.e. the only info relevant is whether th locale is UTF-8 or not. Hence let's give this its own pair of .c/.h files.
* smack: move helper function to smack-util.cZbigniew Jędrzejewski-Szmek2021-09-211-0/+1
| | | | | | | The function was in basic/fileio.c, but it's more appropriate to keep it out of src/basic. Fixes compilation with -Dsmack-run-label= set.
* tree-wide: port everything over to new sd-id128 compund literal blissLennart Poettering2021-08-201-2/+1
|
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-1/+1
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
* Merge pull request #19391 from poettering/dissect-growZbigniew Jędrzejewski-Szmek2021-05-071-1/+2
|\ | | | | optionally, grow file systems to partition size when mounting them via GPT auto-discovery
| * tree-wide: enable automatic growing of file systems in images in various ↵Lennart Poettering2021-04-231-1/+2
| | | | | | | | | | | | | | | | | | | | tools that deal with OS images Let's enable this in all tools that intend to write to the OS images. It's not conditionalized for now, as there already is conditionalization in the existance or absence of the flag in the GPT partition table (and it's opt-in), hence it should be OK to just enable this by default for now if the flag is set.
* | user-util: add generic definition for special password hash values in ↵Lennart Poettering2021-05-061-4/+4
|/ | | | | | | | | | | | | | /etc/passwd + /etc/shadow Let's add three defines for the 3 special cases of passwords. Some of our tools used different values for the "locked"/"invalid" case, let's settle on using "!*" which means the password is both locked *and* invalid. Other tools like to use "!!" for this case, which however is less than ideal I think, since the this could also be a considered an entry with an empty password, that can be enabled again by unlocking it twice.
* Merge pull request #18971 from poettering/sysusers-credsLennart Poettering2021-03-311-2/+64
|\ | | | | let's read LoadCredentials=/SetCredentials= style cred in sysusers/firstboot and when asking for passwords
| * firstboot: allow provisioning of firstboot params via creds tooLennart Poettering2021-03-261-1/+63
| |
| * firstboot: slightly reorder variable declarationLennart Poettering2021-03-261-1/+1
| | | | | | | | | | Let's put the locale fields which we process together next to each other.
* | dissect-image: split DISSECT_IMAGE_REQUIRE_ROOT in twoLennart Poettering2021-03-161-1/+5
|/ | | | | | | | | | | | Previously, the flag did two things at once: enable support for using generic partitions as root fs if there were only one/allow use of partition-table-less images as root fs. And secondly, insist that there was a rootfs, and fail if not. Let's split these two in two separate options so that they can be used independently of each other. There are cases where one wants to use one without the other (i.e. when inspecting things with systemd-dissect tool it should be OK to do so even if image has no root fs), and it's cleaner anyway.
* Merge pull request #18852 from yuwata/tree-wide-use-UINT64_MAXZbigniew Jędrzejewski-Szmek2021-03-051-1/+1
|\ | | | | tree-wide: use UINT64_MAX or friends
| * tree-wide: use UINT64_MAX or friendsYu Watanabe2021-03-051-1/+1
| |
* | copy: move sync_rights() to copy.c and rename copy_rights()Lennart Poettering2021-03-041-2/+2
|/ | | | | | | It's so similar to copy_access(), hence let's move it over and rename it in similar style to the rest of the functions. No change in behaviour, just moving things over.
* basic/os-util: make the sentinel implicitZbigniew Jędrzejewski-Szmek2021-02-221-2/+1
|
* Move and rename parse_path_argument() functionZbigniew Jędrzejewski-Szmek2021-02-151-2/+3
| | | | | This fits better in shared/, and the new parse-argument.c file is a good home for it.
* tree-wide: use free_and_strdup_warn()Yu Watanabe2021-02-121-4/+1
|
* tree-wide: propagate error in xxx_from-string()Yu Watanabe2021-02-121-3/+3
|
* tree-wide: enable colorized logging for daemons when run in consoleYu Watanabe2021-02-011-1/+1
| | | | It may be useful when debugging daemons.
* tree-wide: Drop custom formatting for print() help messagesDaan De Meyer2021-01-311-4/+3
| | | | | | | | | | | | I think this formatting was originally used because it simplified adding new options to the help messages. However, these days, most tools their help message end with "\nSee the %s for details.\n" so the final line almost never has to be edited which eliminates the benefit of the custom formatting used for printf() help messages. Let's make things more consistent and use the same formatting for printf() help messages that we use everywhere else. Prompted by https://github.com/systemd/systemd/pull/18355#discussion_r567241580
* firstboot: clean-up the copied hostname, not argv[] directly, as that's uglyLennart Poettering2020-12-151-1/+1
|
* hostname-util: flagsify hostname_is_valid(), drop machine_name_is_valid()Lennart Poettering2020-12-151-2/+2
| | | | | | | | | | | | Let's clean up hostname_is_valid() a bit: let's turn the second boolean argument into a more explanatory flags field, and add a flag that accepts the special name ".host" as valid. This is useful for the container logic, where the special hostname ".host" refers to the "root container", i.e. the host system itself, and can be specified at various places. let's also get rid of machine_name_is_valid(). It was just an alias, which is confusing and even more so now that we have the flags param.