summaryrefslogtreecommitdiff
path: root/src/tty-ask-password-agent
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: use -EBADF moreYu Watanabe2022-12-211-1/+1
|
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-5/+5
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* Rename def.h to constants.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+1
| | | | | | The name "def.h" originates from before the rule of "no needless abbreviations" was established. Let's rename the file to clarify that it contains a collection of various semi-related constants.
* basic: move version() to build.h+cZbigniew Jędrzejewski-Szmek2022-11-081-0/+1
|
* shared/utmp-wtmp: pass information if entry is local to filter functionZbigniew Jędrzejewski-Szmek2022-05-311-1/+1
| | | | | This just adds an unused parameter for future use. No change in behaviour.
* tty-ask-password-agent: drop unnecessary code for non-absolute pathsZbigniew Jędrzejewski-Szmek2022-05-311-2/+1
| | | | | utmp_wall() always prepends /dev/, so we don't need to do this a second time here.
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-191-4/+1
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* time-util: add macros around timespec_store() that operates on compund ↵Lennart Poettering2022-03-181-5/+2
| | | | | | | | literal allocated timespec struct This way we can convert usec_t to timespec on-the-fly, without a buffer. No actual behaviour change just some shortening of code.
* conf-parser: merge config_parse_string() and config_parse_safe_string()Yu Watanabe2022-03-101-7/+7
| | | | | This also makes unsafe strings escaped when logged. Otherwise, journalctl may not show the log message unless '--all' is specified.
* conf-parser: add specific parser for PID valuesLennart Poettering2022-02-091-5/+5
|
* tree-wide: use config_parse_safe_string() at various placesLennart Poettering2022-02-091-7/+7
|
* Define FOREACH_DIRENT through FOREACH_DIRENT_ALLZbigniew Jędrzejewski-Szmek2021-12-151-1/+0
| | | | As in the previous commit, 'de' is used as the iterator variable name.
* shared: clean up mkdir.h/label.h situationLennart Poettering2021-11-161-1/+1
| | | | | | | | | | Previously the mkdir_label() family of calls was implemented in src/shared/mkdir-label.c but its functions partly declared ins src/shared/label.h and partly in src/basic/mkdir.h (!!). That's weird (and wrong). Let's clean this up, and add a proper mkdir-label.h matching the .c file.
* basic: split out inotify-related calls from fs-util.h → inotify-util.hLennart Poettering2021-10-051-1/+1
|
* tree-wide: mark set-but-not-used variables as unused to make LLVM happyFrantisek Sumsal2021-09-151-1/+2
| | | | | | | | | | | | | | LLVM 13 introduced `-Wunused-but-set-variable` diagnostic flag, which trips over some intentionally set-but-not-used variables or variables attached to cleanup handlers with side effects (`_cleanup_umask_`, `_cleanup_(notify_on_cleanup)`, `_cleanup_(restore_sigsetp)`, etc.): ``` ../src/basic/process-util.c:1257:46: error: variable 'saved_ssp' set but not used [-Werror,-Wunused-but-set-variable] _cleanup_(restore_sigsetp) sigset_t *saved_ssp = NULL; ^ 1 error generated. ```
* 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.
* tree-wide: "a" -> "an"Yu Watanabe2021-06-301-1/+1
|
* tty-ask-password-agent: log when starting a query on the consoleZbigniew Jędrzejewski-Szmek2021-05-311-2/+5
| | | | | | | | | | | | When looking at logs from a boot with an encrypted device, I see (with unrelevant messages snipped): [ 2.751692] systemd[1]: Started Dispatch Password Requests to Console. [ 7.929199] systemd-cryptsetup[258]: Set cipher aes, mode xts-plain64, key size 512 bits for device /dev/disk/by-uuid/2d9b648a-15b1-4204-988b-ec085089f8ce. [ 9.499483] systemd[1]: Finished Cryptography Setup for luks-2d9b648a-15b1-4204-988b-ec085089f8ce. There is a hug gap in timing without any explanatory message. If I didn't type in the password, there would be no way to figure out why things blocked from this log, so let's log something to the log too.
* tty-ask-password-agent: highlight summary in helpZbigniew Jędrzejewski-Szmek2021-05-311-1/+3
|
* tty-ask-password-agent: mention optional argument in helpZbigniew Jędrzejewski-Szmek2021-05-311-8/+9
| | | | | | | | | 0cf84693877f060254f04cf38120f52c2aa3059c added --console. 6af621248f2255f9ce50b0bafdde475305dc4e57 added an optional argument, but didn't update the help texts. Note that there is no ambiguity with the optional argument because no positional arguments are allowed.
* Add crypttab option silentSebastian Blunt2021-05-151-1/+3
| | | | | | Adds a crypttab option 'silent' that enables the AskPasswordFlag ASK_PASSWORD_SILENT. This allows usage of systemd-cryptsetup to default to silent mode, rather than requiring the user to press tab every time.
* tree-wide: avoid uninitialized warning on _cleanup_ variablesLuca Boccassi2021-04-141-1/+1
| | | | | | | With some versions of the compiler, the _cleanup_ attr makes it think the variable might be freed/closed when uninitialized, even though it cannot happen. The added cost is small enough to be worth the benefit, and optimized builds will help reduce it even further.
* tree-wide: use ppoll_usec()Yu Watanabe2021-03-041-12/+6
|
* 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
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* tree-wide: define iterator inside of the macroZbigniew Jędrzejewski-Szmek2020-09-081-3/+2
|
* tty-ask-pw-agent: properly propagate errorLennart Poettering2020-08-261-3/+2
|
* tty-ask-pw-agent: the message string might not be setLennart Poettering2020-08-261-6/+4
|
* tty-ask-pw-agent: make sure "--list" works correctlyLennart Poettering2020-08-261-2/+2
| | | | Fixes: #16836
* tree-wide: check POLLNVAL everywhereLennart Poettering2020-06-101-0/+4
| | | | | | | | | | | | | poll() sets POLLNVAL inside of the poll structures if an invalid fd is passed. So far we generally didn't check for that, thus not taking notice of the error. Given that this specific kind of error is generally indication of a programming error, and given that our code is embedded into our projects via NSS or because people link against our library, let's explicitly check for this and convert it to EBADF. (I ran into a busy loop because of this missing check when some of my test code accidentally closed an fd it shouldn't close, so this is a real thing)
* conf-parser: return mtime in config_parse() and friendsLennart Poettering2020-06-021-1/+3
| | | | | | | | | | | | | This is a follow-up for 9f83091e3cceb646a66fa9df89de6d9a77c21d86. Instead of reading the mtime off the configuration files after reading, let's do so before reading, but with the fd we read the data from. This is not only cleaner (as it allows us to save one stat()), but also has the benefit that we'll detect changes that happen while we read the files. This also reworks unit file drop-ins to use the common code for determining drop-in mtime, instead of reading system clock for that.
* tree-wide: use the return value from sockaddr_un_set_path()Zbigniew Jędrzejewski-Szmek2020-03-021-6/+8
| | | | | | | | | It fully initializes the address structure, so no need for pre-initialization, and also returns the length of the address, so no need to recalculate using SOCKADDR_UN_LEN(). socklen_t is unsigned, so let's not use an int for it. (It doesn't matter, but seems cleaner and more portable to not assume anything about the type.)
* tree-wide: drop signal.h when signal-util.h is includedYu Watanabe2019-11-041-1/+0
|
* tree-wide: drop socket.h when socket-util.h is includedYu Watanabe2019-11-041-1/+0
|
* tree-wide: drop string.h when string-util.h or friends are includedYu Watanabe2019-11-041-1/+0
|
* tty-ask-password: fix dead code pathZbigniew Jędrzejewski-Szmek2019-10-211-6/+4
| | | | | | | Coverity was complaining that watch==1 always at this point. CID #1405882. Use structured initialization while at it.
* tty-ask-pwd-agent: move ask_password_plymouth() in ask-password-api.cFranck Bui2019-10-051-181/+0
|
* tty-ask-pwd-agent: small cleanup in process_one_password_file()Franck Bui2019-10-051-44/+64
| | | | | | | Split the part dealing which asks for password on tty in a dedicated function making process_one_password_file() hopefully easier to read. No functional changes.
* tty-ask-pwd-agent: add a FIXMEFranck Bui2019-10-051-0/+3
|
* tty-ask-pwd-agent: share the same init code for --query and --watchFranck Bui2019-10-051-22/+25
| | | | | Previously we would have skipped the init code which consists in setting the signal handling up and the wall tty block thingie.
* tty-ask-pwd-agent: treat SIGINT as a request to exit immediatelyFranck Bui2019-10-051-1/+1
| | | | | | | | | | | | Unlike SIGTERM, SIGINT is now treated as a request to exit as soon as possible. IOW, if SIGINT is received, the agent wont process all remaining passwords before exiting. This allows a more comprehensive behavior when C-c is pressed and when the agent is spawned by systemctl. Before that patch, pressing C-c killed systemctl but left the agent waiting for a password since SIGINT was blocked. The result was pretty clumsy.
* tty-ask-pwd-agent: give the possiblity to skip a password promptFranck Bui2019-10-051-3/+15
| | | | | If multiple passwords are waiting the agent will prompt for each of them. Give the possiblity to the user to skip some of them by pressing 'C-d'.
* tty-ask-pwd-agent: minor simplification by using FOREACH_DIRENT instead of ↵Franck Bui2019-10-051-4/+1
| | | | FOREACH_DIRENT_ALL
* fs-util: introduce inotify_add_watch_and_warn() helperFranck Bui2019-10-051-7/+4
| | | | | | | | The default message for ENOSPC is very misleading: it says that the disk is filled, but in fact the inotify watch limit is the problem. So let's introduce and use a wrapper that simply calls inotify_add_watch(2) and which fixes the error message up in case ENOSPC is returned.
* tty-ask-pwd-agent: rename watch_passwords() and show_passwords()Franck Bui2019-10-041-8/+8
| | | | | | | | | | Those names were a bit confusing both functions process password files the former relies one the later and waits for new files. Also show_passwords() was not only used to list password files/requests but also to query the user. No functional changes.
* tty-ask-pwd-agent: simplify handling of --wall a bitFranck Bui2019-09-171-55/+49
| | | | | | | | | | "wall" was always NULL when passed to parse_password() so let's simplify this part a bit. The effective changes are small but wall_tty_match() needed to be moved so it's still visible from parse_password(). No functional changes.
* tty-ask-pwd-agent: fix message forwarded to wall(1)Franck Bui2019-09-161-1/+1
| | | | | | | | | Commit a1c111c2d12429d2 wrongly replaced '!' with ':' when the message is forwarded to wall(1). Indeed in this case we are not requesting the user for providing a password but instead we are simply displaying a message to suggest starting tty-ask-password-agent for providing the password.
* shared/exit-status: use Bitmap instead of SetsZbigniew Jędrzejewski-Szmek2019-07-291-0/+1
| | | | | | | | | | | | | | | | | | I opted to embed the Bitmap structure directly in the ExitStatusSet. This means that memory usage is a bit higher for units which don't define this setting: Service changes: /* size: 2720, cachelines: 43, members: 73 */ /* sum members: 2680, holes: 9, sum holes: 39 */ /* sum bitfield members: 7 bits, bit holes: 1, sum bit holes: 1 bits */ /* last cacheline: 32 bytes */ /* size: 2816, cachelines: 44, members: 73 */ /* sum members: 2776, holes: 9, sum holes: 39 */ /* sum bitfield members: 7 bits, bit holes: 1, sum bit holes: 1 bits */ But this way the code is simpler and we do less pointer chasing.
* tree-wide: get rid of strappend()Lennart Poettering2019-07-121-1/+1
| | | | | It's a special case of strjoin(), so no need to keep both. In particular as typing strjoin() is even shoert than strappend().