summaryrefslogtreecommitdiff
path: root/src/tty-ask-password-agent
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-0/+1
| | | | | | | | | | | | | | string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
* strv: Add _cleanup_strv_free_erase_ and _cleanup_string_free_erase_Zbigniew Jędrzejewski-Szmek2015-10-191-6/+2
|
* tree-wide: whenever we deal with passwords, erase them from memory after useLennart Poettering2015-10-191-30/+67
| | | | A bit snake-oilish, but can't hurt.
* tty-ask-password-agent: don't warn if we cannot disable wall messages on the ↵Lennart Poettering2015-10-141-1/+1
| | | | | | | | | | | calling tty For example, due to perm issues. THis simply downgrades the message about it, since this is purely cosmetical anyway. Fixes #1543.
* util: do not reset terminal in acquire_terminal()Lennart Poettering2015-10-081-0/+4
| | | | | | | | | | Before, we'd always reset acquired terminals, which is not really desired, as we expose a setting TTYReset= which is supposed to control whether the TTY is reset or not. Previously that setting would only enable a second resetting of the TTY, which is of course pointless... Hence, move the implicit resetting out of acquire_terminal() and make the callers do it if they need it.
* ask-password: add support for caching passwords in the kernel keyringLennart Poettering2015-10-071-14/+20
| | | | | | | | | | | | | This adds support for caching harddisk passwords in the kernel keyring if it is available, thus supporting caching without Plymouth being around. This is also useful for hooking up "gdm-auto-login" with the collected boot-time harddisk password, in order to support gnome keyring passphrase unlocking via the HDD password, if it is the same. Any passwords added to the kernel keyring this way have a timeout of 2.5min at which time they are purged from the kernel.
* ask-password: various modernizationsLennart Poettering2015-10-061-38/+37
| | | | | | | | | | | Primarily clean-up error logging: log either all or no error messages in the various functions. Mostly this means the actual password querying calls no longer will log on their own, but the callers have to do so. Contains various other fixes too, for example ports some code over to use the clean-up macro. Should contain no functional changes.
* tree-wide: use strempty() where possibleDaniel Mack2015-09-301-1/+1
| | | | Also add a Coccinell patch to detect such locations in the future.
* tty-ask-password: minor modernizationsLennart Poettering2015-09-291-3/+2
|
* util: introduce common version() implementation and use it everywhereLennart Poettering2015-09-291-18/+15
| | | | | | This also allows us to drop build.h from a ton of files, hence do so. Since we touched the #includes of those files, let's order them properly according to CODING_STYLE.
* tree-wide: introduce mfree()David Herrmann2015-07-311-2/+1
| | | | | | | | | Pretty trivial helper which wraps free() but returns NULL, so we can simplify this: free(foobar); foobar = NULL; to this: foobar = mfree(foobar);
* everywhere: port everything to sigprocmask_many() and friendsLennart Poettering2015-06-151-3/+3
| | | | | | | | | | | This ports a lot of manual code over to sigprocmask_many() and friends. Also, we now consistly check for sigprocmask() failures with assert_se(), since the call cannot realistically fail unless there's a programming error. Also encloses a few sd_event_add_signal() calls with (void) when we ignore the return values for it knowingly.
* util: split out signal-util.[ch] from util.[ch]Lennart Poettering2015-05-291-0/+1
| | | | No functional changes.
* shared/utmp-wtmp: add parameter for origin tty and callback userdataDaniel Mack2015-04-241-2/+2
| | | | | | | | | Instead of looking up the tty from STDIN, let utmp_wall() take an argument to specify an origin tty for the wall message. Only if that argument is NULL do the STDIN lookup. Also add an void *userdata argument that is handed back to the callback function.
* shared: add terminal-util.[ch]Ronny Chevalier2015-04-111-0/+1
|
* shared: add process-util.[ch]Ronny Chevalier2015-04-101-0/+1
|
* include <poll.h> instead of <sys/poll.h>Thomas Hindoe Paaboel Andersen2015-02-121-1/+1
| | | | | | include-what-you-use automatically does this and it makes finding unnecessary harder to spot. The only content of poll.h is a include of sys/poll.h so should be harmless.
* util: rework strappenda(), and rename it strjoina()Lennart Poettering2015-02-031-1/+1
| | | | | | After all it is now much more like strjoin() than strappend(). At the same time, add support for NULL sentinels, even if they are normally not necessary.
* util: rename ignore_file() to hidden_file()Lennart Poettering2014-12-191-1/+1
| | | | | hidden_file() is a bit more precise, since dot files usually shouldn't be ignored, but certainly be considered hidden.
* treewide: sanitize loop_writeZbigniew Jędrzejewski-Szmek2014-12-091-6/+6
| | | | | | | loop_write() didn't follow the usual systemd rules and returned status partially in errno and required extensive checks from callers. Some of the callers dealt with this properly, but many did not, treating partial writes as successful. Simplify things by conforming to usual rules.
* treewide: another round of simplificationsMichal Schmidt2014-11-281-8/+4
| | | | | Using the same scripts as in f647962d64e "treewide: yet more log_*_errno + return simplifications".
* treewide: use log_*_errno whenever %m is in the format stringMichal Schmidt2014-11-281-4/+4
| | | | | | | | | | | If the format string contains %m, clearly errno must have a meaningful value, so we might as well use log_*_errno to have ERRNO= logged. Using: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\((".*%m.*")/log_\1_errno(errno, \2/' Plus some whitespace, linewrap, and indent adjustments.
* treewide: yet more log_*_errno + return simplificationsMichal Schmidt2014-11-281-4/+2
| | | | | | | | | | | | | Using: find . -name '*.[ch]' | while read f; do perl -i.mmm -e \ 'local $/; local $_=<>; s/(if\s*\([^\n]+\))\s*{\n(\s*)(log_[a-z_]*_errno\(\s*([->a-zA-Z_]+)\s*,[^;]+);\s*return\s+\g4;\s+}/\1\n\2return \3;/msg; print;' $f done And a couple of manual whitespace fixups.
* treewide: no need to negate errno for log_*_errno()Michal Schmidt2014-11-281-3/+3
| | | | It corrrectly handles both positive and negative errno values.
* treewide: auto-convert the simple cases to log_*_errno()Michal Schmidt2014-11-281-3/+3
| | | | | | | | | | | | | As a followup to 086891e5c1 "log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers", use sed to convert the simple cases to use the new macros: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/' Multi-line log_*() invocations are not covered. And we also should add log_unit_*_errno().
* ask-password: Add --echo to enable echoing the user inputDavid Sommerseth2014-10-051-2/+3
| | | | | | | | | | | | | | | | Programs such as OpenVPN may use ask-password for not only retrieving passwords, but also usernames. Masking usernames with * seems just silly. v2 - Don't mess with termios flags, instead print the input instead of an asterix. Resolves issues with backspace and TAB input. v3 - Renamed 'do_echo' variables and argument to 'echo'. Also modified the ask_password_{tty,agent,auto} API instead of additional wrapper functions. [zj: undo changes to ask_password_auto, since no callers were using the new argument.]
* Correct a few typosTorstein Husebø2014-10-021-1/+1
|
* tty-ask-password-agent: modernizationZbigniew Jędrzejewski-Szmek2014-08-031-151/+85
|
* Unify parse_argv styleZbigniew Jędrzejewski-Szmek2014-08-031-8/+5
| | | | | | | | | | | | | | | | getopt is usually good at printing out a nice error message when commandline options are invalid. It distinguishes between an unknown option and a known option with a missing arg. It is better to let it do its job and not use opterr=0 unless we actually want to suppress messages. So remove opterr=0 in the few places where it wasn't really useful. When an error in options is encountered, we should not print a lengthy help() and overwhelm the user, when we know precisely what is wrong with the commandline. In addition, since help() prints to stdout, it should not be used except when requested with -h or --help. Also, simplify things here and there.
* time-util: add and use USEC/NSEC_INFINIYKay Sievers2014-07-291-1/+1
|
* Always check asprintf return codeKarel Zak2014-07-261-2/+3
| | | | | | | There is a small number of the places in sources where we don't check asprintf() return code and assume that after error the function returns NULL pointer via the first argument. That's wrong, after error the content of pointer is undefined.
* tty-ask-password-agent: modernizationZbigniew Jędrzejewski-Szmek2014-07-161-57/+38
|
* Let config_parse open file where applicableZbigniew Jędrzejewski-Szmek2014-07-161-17/+6
| | | | | | | | Special care is needed so that we get an error message if the file failed to parse, but not when it is missing. To avoid duplicating the same error check in every caller, add an additional 'warn' boolean to tell config_parse whether a message should be issued. This makes things both shorter and more robust wrt. to error reporting.
* Constify ConfigTableItem tablesZbigniew Jędrzejewski-Szmek2014-07-151-1/+1
|
* tty-ask-password-agent: Do tell what directory we failed to openCristian Rodríguez2014-06-011-1/+1
|
* tty-ask-password-agent: return negative errnoFlorian Albrechtskirchinger2014-04-051-1/+1
| | | | | | | Return negative errno in wall_tty_block(). get_ctty_devnr() already returns a negative errno in case of failure, no need to negate it again. Reported-by: Simon <hwold@odai.homelinux.net>