summaryrefslogtreecommitdiff
path: root/src/cryptsetup
Commit message (Collapse)AuthorAgeFilesLines
* cryptsetup: bump minimum libcryptsetup version to v2.0.1Jay Strict2019-10-011-31/+3
| | | | | | | | | | libcryptsetup v2.0.1 introduced new API calls, supporting 64 bit wide integers for `keyfile_offset`. This change invokes the new function call, gets rid of the warning that was added in #7689, and removes redundant #ifdefery and constant definitions. See https://gitlab.com/cryptsetup/cryptsetup/issues/359. Fixes #7677.
* cryptsetup: don't assert on variable which is optionalZbigniew Jędrzejewski-Szmek2019-08-011-2/+6
| | | | | | | https://github.com/systemd/systemd/commit/50d2eba27b9bfc77ef6b40e5721713846815418b#commitcomment-34519739 In add_crypttab_devices() split_keyspec is called on the keyfile argument, which may be NULL.
* cryptsetup: use unabbrieviated variable namesZbigniew Jędrzejewski-Szmek2019-08-011-9/+9
| | | | | Now that "ret_" has been added to the output variables, we can name the internal variables without artificial abbrevs.
* cryptsetup-generator: fix coverity issueLennart Poettering2019-07-311-8/+8
| | | | Fixes coverity issue 1403772
* cryptsetup: add keyfile-timeout to allow a keydev timeout and allow to ↵shinygold2019-07-172-35/+89
| | | | fallback to a password if it fails.
* cryptsetup: no need to zero-initialize zero-initialized structuresLennart Poettering2019-07-161-3/+0
|
* tree-wide: get rid of strappend()Lennart Poettering2019-07-121-2/+2
| | | | | It's a special case of strjoin(), so no need to keep both. In particular as typing strjoin() is even shoert than strappend().
* cryptsetup: enable libcryptsetup debug logging if we want itIvan Shapovalov2019-07-081-0/+4
| | | | | Even if we set a log callback that would accept debug messages, libcryptsetup needs debug logging enabled explicitly for it to happen.
* cryptsetup: set libcryptsetup global log callback tooIvan Shapovalov2019-07-061-0/+1
|
* cryptsetup-generator: fix luks-* entry parsing from crypttabLubomir Rintel2019-06-281-1/+3
| | | | | | | | | This reverts a part of commit 49fe5c099639 ('tree-wide: port various places over to STARTSWITH_SET()') that replaced a pair of startswith() calls with STARTSWITH_SET(). They were in fact for a different strings (device vs. name), botching the crypttap parsing.
* cryptsetup: comment: crypt_setup → crypt_formatMichael Stapelberg2019-06-271-1/+1
|
* path-util: get rid of prefix_root()Lennart Poettering2019-06-211-1/+1
| | | | | | | | | | | | | | | | | | | prefix_root() is equivalent to path_join() in almost all ways, hence let's remove it. There are subtle differences though: prefix_root() will try shorten multiple "/" before and after the prefix. path_join() doesn't do that. This means prefix_root() might return a string shorter than both its inputs combined, while path_join() never does that. I like the path_join() semantics better, hence I think dropping prefix_root() is totally OK. In the end the strings generated by both functon should always be identical in terms of path_equal() if not streq(). This leaves prefix_roota() in place. Ideally we'd have path_joina(), but I don't think we can reasonably implement that as a macro. or maybe we can? (if so, sounds like something for a later PR) Also add in a few missing OOM checks
* Merge pull request #12636 from mbroz/masterZbigniew Jędrzejewski-Szmek2019-05-301-14/+27
|\ | | | | Cryptsetup: call crypt_load() once for LUKS and support LUKS2 tokens
| * cryptsetup: Add LUKS2 token support.Milan Broz2019-05-281-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | LUKS2 supports so-called tokens. The libcryptsetup internally support keyring token (it tries to open device using specified keyring entry). Only if all token fails (or are not available), it uses a passphrase. This patch aligns the functionality with the cryptsetup utility (cryptsetup luksOpen tries tokens first) but does not replace the systemd native ask-password function (can be used the same in combination with this patch).
| * cryptsetup: call crypt_load() for LUKS only onceMilan Broz2019-05-281-14/+12
| | | | | | | | | | | | | | | | | | The crypt_load() for LUKS2 can read a quite big area of disk (metadata area size is configurable and can increase up to megabytes). This initialization is not needed to be repeated, just use the existing context. (This patch is also required for the following change.)
| * cryptsetup: Do not fallback to PLAIN mapping if LUKS data device set fails.Milan Broz2019-05-281-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | If crypt_load() for LUKS succeeds, we know that it is a LUKS device. Failure of data device setting should fail in this case; remapping as a PLAIN device late could mean data corruption. (If a user wants to map PLAIN device over a device with LUKS header, it should be said explicitly with "plain" argument type.) Also, if there is no explicit PLAIN type requested and crypt device is already initialized (crypt_data_type() is set), do not run the initialization again.
* | cryptsetup: Add dependency for detached headerRoberto Santalla2019-05-301-24/+56
|/ | | | | | | | | | | | | Fixes #12650 cryptsetup: Extract dependency check to a separate function cryptsetup: style improvements, error checking Return early on failure/nothing to do Removed braces from single-line ifs Check return value of fstab_filter_options cryptsetup: code style
* Add fopen_unlocked() wrapperZbigniew Jędrzejewski-Szmek2019-04-121-5/+2
|
* cryptsetup-generator: set high OOM score for systemd-cryptsetup instancesMichal Sekletar2019-03-281-0/+1
| | | | | | | | | | | | | | | | With new LUKS2 header format it is possible to use Argon2 key derivation function. This function is "memory-hard" hence keyslot unlocking can potentially use a lot of RAM as this increases resistance to massively parallel GPU based password cracking. However, when multiple systemd-cryptsetup binaries run at the same time it is very likely that system using Argon2 (e.g. Fedora 30) will encounter memory-pressure during early boot, following OOM killing spree. This patch aims to lower the damage done by OOM killer and sets OOMScore for systemd-cryptsetup units to 500. Hopefully OOM killer will then shoot us down and leave rest of the system services alone.
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-272-0/+6
| | | | | This means we need to include many more headers in various files that simply included util.h before, but it seems cleaner to do it this way.
* cryptsetup: small refactoringLennart Poettering2019-03-201-11/+19
|
* util: split out nulstr related stuff to nulstr-util.[ch]Lennart Poettering2019-03-141-2/+2
|
* cryptsetup: add same-cpu-crypt and submit-from-crypt-cpus optionsYu Watanabe2019-03-131-0/+12
| | | | Closes #11946.
* cryptsetup: Treat key file errors as a failed password attemptRyan Gonzalez2019-02-261-0/+4
| | | | | | 6f177c7dc092eb68762b4533d41b14244adb2a73 caused key file errors to immediately fail, which would make it hard to correct an issue due to e.g. a crypttab typo or a damaged key file. Closes #11723.
* mount/generators: do not make unit wanted by its device unitTom Yan2019-02-151-4/+0
| | | | As device units will be reloaded by systemd whenever the corresponding device generates a "changed" event, if the mount unit / cryptsetup service is wanted by its device unit, the former can be restarted by systemd unexpectedly after the user stopped them explicitly. It is not sensible at all and can be considered dangerous. Neither is the behaviour conventional (as `auto` in fstab should only affect behaviour on boot and `mount -a`) or ever documented at all (not even in systemd, see systemd.mount(5) and crypttab(5)).
* cryptsetup: rework how we log about activation failuresLennart Poettering2019-01-231-18/+28
| | | | | | | | | | | | | | | | First of all let's always log where the errors happen, and not in an upper stackframe, in all cases. Previously we'd do this somethis one way and sometimes another, which resulted in sometimes duplicate logging and sometimes none. When we cannot activate something due to bad password the kernel gives us EPERM. Let's uniformly return this EAGAIN, so tha the next password is tried. (previously this was done in most cases but not in all) When we get EPERM let's also explicitly indicate that this probably means the password is simply wrong. Fixes: #11498
* cryptsetup: add comment what EAGAIN means when activatingLennart Poettering2019-01-231-1/+1
|
* cryptsetup: downgrade a log message we ignoreLennart Poettering2019-01-231-1/+1
|
* cryptsetup: don't line-break so aggressivelyLennart Poettering2019-01-231-10/+3
|
* cryptsetup: add some commenting about EAGAIN generationLennart Poettering2019-01-231-1/+1
|
* cryptsetup: modernize some log message invocationsLennart Poettering2019-01-231-16/+8
|
* cryptsetup: use free_and_replace() where appropriateLennart Poettering2019-01-231-2/+1
|
* generators: define custom main func definer and use it where applicableZbigniew Jędrzejewski-Szmek2018-12-121-11/+4
| | | | | | | | | | There should be no functional difference, except that the error message is changd from "three or no arguments" to "zero or three arguments". Somehow the inverted form always seemed strange. umask() call is also dropped from run-generator. I think it wasn't dropped in 053254e3cb215df3b8c905bc39b920f8817e1c7d because the run generator was merged around the same time.
* generators: configure logging before the first useZbigniew Jędrzejewski-Szmek2018-12-121-2/+2
|
* cryptsetup-generator: define main through macroYu Watanabe2018-12-021-30/+28
|
* tree-wide: port various places over to STARTSWITH_SET()Lennart Poettering2018-11-261-3/+1
|
* coccinelle: make use of SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek2018-11-222-22/+19
| | | | | | | | | | | Ideally, coccinelle would strip unnecessary braces too. But I do not see any option in coccinelle for this, so instead, I edited the patch text using search&replace to remove the braces. Unfortunately this is not fully automatic, in particular it didn't deal well with if-else-if-else blocks and ifdefs, so there is an increased likelikehood be some bugs in such spots. I also removed part of the patch that coccinelle generated for udev, where we returns -1 for failure. This should be fixed independently.
* generators: drop umask callsZbigniew Jędrzejewski-Szmek2018-11-211-2/+0
| | | | | | | | | systemd already sets the umask (see e3b8d0637dd755b3426f3363b2cdad63f738116c). When running under systemd, we don't need to set it. And when *not* running under systemd, for example during development, there is no reason to override the user config. Let's just drop those calls. $ git grep -e 'umask\(' -l 'src/*generator*' |xargs perl -i -0pe 's|^[^\n]*umask\([^\n]+\n\n||gms'
* Split out pretty-print.c and move pager.c and main-func.h to shared/Zbigniew Jędrzejewski-Szmek2018-11-201-1/+1
| | | | | This is high-level functionality, and fits better in shared/ (which is for our executables), than in basic/ (which is also for libraries).
* cryptsetup: use static destructor and DEFINE_MAIN_FUNCTION() macroYu Watanabe2018-11-201-43/+31
|
* log: introduce new helper call log_setup_service()Lennart Poettering2018-11-201-3/+1
| | | | | Let's reduce the common boilerplate and have a single setup function used by all service code to setup logging.
* generators: introduce a common implementation for the log setup boilerplateLennart Poettering2018-11-201-4/+1
|
* Move LONG_LINE_MAX definition to fileio.hZbigniew Jędrzejewski-Szmek2018-11-141-1/+0
| | | | | | | | | | | All users of the macro (except for one, in serialize.c), use the macro in connection with read_line(), so they must include fileio.h. Let's not play libc games and require multiple header file to be included for the most common use of a function. The removal of def.h includes is not exact. I mostly went over the commits that switch over to use read_line() and add def.h at the same time and reverted the addition of def.h in those files.
* cryptsetup-generator: allow whitespace characters in keydev specificationMichal Sekletar2018-10-301-21/+43
| | | | | | For example, <luks.uuid>=/keyfile:LABEL="KEYFILE FS" previously wouldn't work, because we truncated label at the first whitespace character, i.e. LABEL="KEYFILE".
* cryptsetup-generator: don't return error if target directory already existsMichal Sekletar2018-10-301-4/+4
|
* cryptsetup-generator: fgets() excorcismLennart Poettering2018-10-181-7/+12
|
* More polite passphrase promptMarko Myllynen2018-10-091-2/+2
| | | | | | | | | | | | Instead of Please enter passphrase for disk <disk-name>! use Please enter passphrase for disk <disk-name>: which is more polite and matches Plymouth convention.
* cryptsetup: use PATH_IN_SET() instead of STR_IN_SET() when comparing pathsLennart Poettering2018-10-051-1/+1
| | | | It's formally more correct.
* cryptsetup: don't use %m if there's no error to showLennart Poettering2018-10-051-2/+4
| | | | | | We are not the ones receiving an error here, but the ones generating it, hence we shouldn't show it with %m, that's just confusing, as it suggests we received an error from some other call.
* tree-wide: do not assign unused return valuesYu Watanabe2018-09-231-11/+5
|