summaryrefslogtreecommitdiff
path: root/src/tty-ask-password-agent
Commit message (Collapse)AuthorAgeFilesLines
...
* tty-ask-password: drop redundant local variableLennart Poettering2019-04-021-3/+1
|
* tty-ask-password: copy argv[] before forking childLennart Poettering2019-04-021-11/+22
| | | | | | | | | | | | | | | Another fix in style of bd169c2be0fbdaf6eb2ea7951e650d5e5983fbf6. Let's also avoid strjoina() in a loop (i.e. stack allocation). While in this specific caseone could get away with it (since we'd immediately afterwards leave the loop) it's still ugly, and every static checker would be totally within its rights to complain. Also, let's simplify things by not relying on argc, since it's redundant anyway, and it's nicer to just treat things as NULL terminated strv array. Fixes: #12180
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-271-1/+3
| | | | | 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.
* util: split out plymouth related stuffLennart Poettering2019-03-141-0/+1
|
* util: split out memcmp()/memset() related calls into memory-util.[ch]Lennart Poettering2019-03-131-1/+1
| | | | Just some source rearranging.
* coccinelle: make use of SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek2018-11-221-20/+15
| | | | | | | | | | | 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.
* Split out pretty-print.c and move pager.c and main-func.h to shared/Zbigniew Jędrzejewski-Szmek2018-11-201-0/+1
| | | | | This is high-level functionality, and fits better in shared/ (which is for our executables), than in basic/ (which is also for libraries).
* 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.
* util-lib: move main() definition macros to its own header fileLennart Poettering2018-11-191-0/+1
| | | | | | | | | This way, we can extend the macro a bit with stuff pulled in from other headers without this affecting everything which pulls in macro.h, which is one of our most basic headers. This is just refactoring, no change in behaviour, in prepartion for later changes.
* tty-ask-password-agent: define main through macroZbigniew Jędrzejewski-Szmek2018-11-171-21/+18
|
* ask-password: improve log message when inotify limit is reachedJan Synacek2018-11-071-2/+6
| | | | | | | | | When inotify_add_watch() fails because of the inotify limit, errno is set to ENOSPC and then gets shown to users as "No space left on device". That is very confusing and requires in-depth knowledge of the C library. Therefore, show user-friendly message when inotify limit is reached. Fixes #6030.
* ask-password: check keyring in ask_password_tty and ask_password_agentXiang Fan2018-10-311-8/+1
| | | | | | | A race condition happens when calling ask_password_auto() multiple times to unlock several disks on boot and effectively no password caching is utilized. This patch fixes it by polling the cache when waiting for the password.
* string-util: introduce explicit_zero_safe()Lennart Poettering2018-10-241-2/+2
| | | | | | | The only real difference is that this wrapper can deal with NULL pointer arguments, but only if the length is also zero. CID 1396277
* tree-wide: port various users over to sockaddr_un_set_path()Lennart Poettering2018-10-151-5/+7
| | | | | CID 1396140 CID 1396141
* More polite passphrase promptMarko Myllynen2018-10-091-1/+1
| | | | | | | | | | | | 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.
* tree-wide: add clickable man page link to all --help textsLennart Poettering2018-08-201-5/+16
| | | | | | | | | | This is a bit like the info link in most of GNU's --help texts, but we don't do info but man pages, and we make them properly clickable on terminal supporting that, because awesome. I think it's generally advisable to link up our (brief) --help texts and our (more comprehensive) man pages a bit, so this should be an easy and straight-forward way to do it.
* tree-wide: beautify remaining copyright statementsLennart Poettering2018-06-141-1/+1
| | | | | | Let's unify an beautify our remaining copyright statements, with a unicode ©. This means our copyright statements are now always formatted the same way. Yay.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-1/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* fixed 3 occurences of 'Failed top open' (#8349)SjonHortensius2018-03-041-1/+1
|
* tty-ask-password-agent: reenable color for boot-time password promptLennart Poettering2018-02-141-2/+4
| | | | | | | The password prompt used to be highlighted, and that was a good thing. Let's fix things to make the prompt highlighted again. Fixes: #3853
* tty-ask-password-agent: don't open terminal multiple timesLennart Poettering2018-02-141-1/+1
| | | | | | | | | We already have the terminal open, hence pass the fd we got to ask_password_tty(), so that it doesn't have to reopen it a second time. This is mostly an optimization, but it has the nice benefit of making us independent from RLIMIT_NOFILE issues and so on, as we don't need to allocate another fd needlessly.
* tty-ask-password-agent: show right TTY path in error messageLennart Poettering2018-02-131-1/+2
|
* tty-ask-password-agent: assing sendto() result to a ssize_t variable, not an intLennart Poettering2018-02-131-2/+7
| | | | | | We should be careful with these types, and if we do convert between "int" and "ssize_t" we should do so explicitly rather than implicitly. Otherwise this just looks like a bug.
* terminal-util: rework acquire_terminal()Lennart Poettering2018-02-131-1/+1
| | | | | | | | | | | | | | This modernizes acquire_terminal() in a couple of ways: 1. The three boolean arguments are replaced by a flags parameter, that should be more descriptive in what it does. 2. We now properly handle inotify queue overruns 3. We use _cleanup_ for closing the fds now, to shorten the code quite a bit. Behaviour should not be altered by this.
* tty-ask-password-agent: make code a tiny bit shorterLennart Poettering2018-02-131-1/+1
|
* tty-ask-password-agent: add (void) cast to mkdir/mkfifo calls we knowingly ↵Lennart Poettering2018-01-111-2/+2
| | | | ignore
* io-util: make flush_fd() return how many bytes where flushedLennart Poettering2018-01-051-1/+1
| | | | | | | | | | | This is useful so that callers know whether anything at all and how much was flushed. This patches through users of this functions to ensure that the return values > 0 which may be returned now are not propagated in public APIs. Also, users that ignore the return value are changed to do so explicitly now.
* process-util: add another fork_safe() flag for enabling LOG_ERR/LOG_WARN loggingLennart Poettering2018-01-041-2/+2
|
* tree-wide: introduce new safe_fork() helper and port everything overLennart Poettering2017-12-251-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a new safe_fork() wrapper around fork() and makes use of it everywhere. The new wrapper does a couple of things we previously did manually and separately in a safer, more correct and automatic way: 1. Optionally resets signal handlers/mask in the child 2. Sets a name on all processes we fork off right after forking off (and the patch assigns useful names for all processes we fork off now, following a systematic naming scheme: always enclosed in () – in order to indicate that these are not proper, exec()ed processes, but only forked off children, and if the process is long-running with only our own code, without execve()'ing something else, it gets am "sd-" prefix.) 3. Optionally closes all file descriptors in the child 4. Optionally sets a PR_SET_DEATHSIG to SIGTERM in the child, in a safe way so that the parent dying before this happens being handled safely. 5. Optionally reopens the logs 6. Optionally connects stdin/stdout/stderr to /dev/null 7. Debug logs about the forked off processes.
* tty-ask-password-agent: drop NULL sentinelLennart Poettering2017-11-291-1/+1
| | | | found by coccinelle
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* conf-parser: turn three bool function params into a flags fieldsLennart Poettering2017-11-131-1/+1
| | | | | This makes things more readable and fixes some issues with incorrect flag propagation between the various flavours of config_parse().
* tree-wide: use IN_SET macro (#6977)Yu Watanabe2017-10-041-1/+1
|
* tree-wide: use IN_SET where possibleAndreas Rammhold2017-10-021-3/+2
| | | | | In addition to the changes from #6933 this handles cases that could be matched with the included cocci file.
* build-sys: drop automake supportZbigniew Jędrzejewski-Szmek2017-07-181-1/+0
| | | | | v2: - also mention m4
* treewide: replace homegrown memory_erase with explicit_bzeroZbigniew Jędrzejewski-Szmek2017-02-051-2/+2
| | | | | | | | explicit_bzero was added in glibc 2.25. Make use of it. explicit_bzero is hardcoded to zero the memory, so string erase now truncates the string, instead of overwriting it with 'x'. This causes a visible difference only in the journalctl case.
* core: when determining whether a process exit status is clean, consider ↵Lennart Poettering2016-10-101-1/+1
| | | | | | | | | | | | | | whether it is a command or a daemon SIGTERM should be considered a clean exit code for daemons (i.e. long-running processes, as a daemon without SIGTERM handler may be shut down without issues via SIGTERM still) while it should not be considered a clean exit code for commands (i.e. short-running processes). Let's add two different clean checking modes for this, and use the right one at the appropriate places. Fixes: #4275
* ask-password: ask for passphrases not only on the first console of /dev/consoleWerner Fink2016-05-241-17/+212
| | | | | | | | | | | | | | | | | | | | | | | | | | | | but also on all other consoles. This does help on e.g. mainframes where often a serial console together with other consoles are used. Even rack based servers attachted to both a serial console as well as having a virtual console do sometimes miss a connected monitor. To be able to ask on all terminal devices of /dev/console the devices are collected. If more than one device are found, then on each of the terminals a inquiring task for passphrase is forked and do not return to the caller. Every task has its own session and its own controlling terminal. If one of the tasks does handle a password, the remaining tasks will be terminated. Also let contradictory options on the command of systemd-tty-ask-password-agent fail. Spwan for each device of the system console /dev/console a own process. Replace the system call wait() with with system call waitid(). Use SIGTERM instead of SIGHUP to get unresponsive childs down. Port the collect_consoles() function forward to a pulbic and strv based function "get_kernel_consoles()" in terminal-util.c and use this in tty-ask-password-agent.c.
* tree-wide: introduce new SOCKADDR_UN_LEN() macro, and use it everywhereLennart Poettering2016-05-051-4/+3
| | | | | | | | | | The macro determines the right length of a AF_UNIX "struct sockaddr_un" to pass to connect() or bind(). It automatically figures out if the socket refers to an abstract namespace socket, or a socket in the file system, and properly handles the full length of the path field. This macro is not only safer, but also simpler to use, than the usual offsetof() + strlen() logic.
* tree-wide: rename hidden_file to hidden_or_backup_file and optimizeZbigniew Jędrzejewski-Szmek2016-04-281-1/+1
| | | | | | | | | | | In standard linux parlance, "hidden" usually means that the file name starts with ".", and nothing else. Rename the function to convey what the function does better to casual readers. Stop exposing hidden_file_allow_backup which is rather ugly and rewrite hidden_file to extract the suffix first. Note that hidden_file_allow_backup excluded files with "~" at the end, which is quite confusing. Let's get rid of it before it gets used in the wrong place.
* Merge pull request #2495 from heftig/masterLennart Poettering2016-02-101-62/+57
|\ | | | | tty-ask-password: Split out password sending
| * tty-ask-password: Split out password sendingJan Alexander Steffens (heftig)2016-02-031-62/+57
| | | | | | | | | | | | | | | | This is a piece of refactoring I've done while looking for a solution to bug #2378. It separates the password sending from `parse_password`, which only needs to know about the socket path and the list of passwords to send. As a caveat, the `ask_password_tty` path needs to construct a one-password strv, too.
* | tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
|/ | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* tty-ask-password-agent: fix typo in error messageMichal Schmidt2015-11-051-1/+1
|
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: introduce dirent-util.[ch] for directory entry callsLennart Poettering2015-10-271-0/+1
| | | | Also, move a couple of more path-related functions to path-util.c.
* util-lib: split out IO related calls to io-util.[ch]Lennart Poettering2015-10-261-0/+1
|
* util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering2015-10-251-0/+1
| | | | | There are more than enough to deserve their own .c file, hence move them over.