| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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)
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We always need to make them unions with a "struct cmsghdr" in them, so
that things properly aligned. Otherwise we might end up at an unaligned
address and the counting goes all wrong, possibly making the kernel
refuse our buffers.
Also, let's make sure we initialize the control buffers to zero when
sending, but leave them uninitialized when reading.
Both the alignment and the initialization thing is mentioned in the
cmsg(3) man page.
|
|\
| |
| | |
CMSG_FIND_DATA() and cmsg_find() work
|
| |
| |
| |
| |
| |
| |
| | |
around cmsg_find()
let's take this once step further, and add type-safety to cmsg_find(),
and imply the CMSG_DATA() macro for finding the cmsg payload.
|
|/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Let's be extra careful whenever we return from recvmsg() and see
MSG_CTRUNC set. This generally means we ran into a programming error, as
we didn't size the control buffer large enough. It's an error condition
we should at least log about, or propagate up. Hence do that.
This is particularly important when receiving fds, since for those the
control data can be of any size. In particular on stream sockets that's
nasty, because if we miss an fd because of control data truncation we
cannot recover, we might not even realize that we are one off.
(Also, when failing early, if there's any chance the socket might be
AF_UNIX let's close all received fds, all the time. We got this right
most of the time, but there were a few cases missing. God, UNIX is hard
to use)
|
|
|
|
|
| |
Otherwise, seeing this in the log output is confusing since we don't
know what kind of timeout or what kind if key we are adjusting here.
|
|
|
|
|
|
|
|
|
| |
It's pretty, and it highlights that the pw prompt is kinda special and
needs user input.
We suppress the emoji entirel if there's no emoji support (i.e. this
means we suppress the ASCII replacement), since it carries no additional
information, it is just decoration to highlight a line.
|
|
|
|
|
| |
Mechanical change to eliminate some cruft by using the
new take_fdopen{_unlocked}() wrappers where trivial.
|
|
|
|
|
|
|
|
| |
Giving --echo to systemd-ask-password allows to echo the user input instead
of masking it. This is useful when querying for usernames or similar.
Showing "(press TAB for no echo)" does not make sense there, so do not.
Note that pressing TAB or ESC still disables echo.
|
| |
|
|
|
|
|
|
|
|
|
| |
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.)
|
|
|
|
|
|
|
|
| |
For #8495: it is arguably useful to not show the length of the password
in public spaces. It is possible to press TAB or BS to cancel the asterisks,
but this is not very discoverable. Let's make it discoverable by showing
a message (in gray). The message is "erased" after the first character
is entered.
|
|
|
|
|
|
|
|
| |
test-ask-password-api would crash if ^D was pressed.
If think the callers generally expect a non-empty strv as reply. Let's
return an error if we have nothing to return.
Also modernize test-ask-password-api a bit.
|
|
|
|
|
|
|
|
|
|
|
| |
We can break if KEYCTL_READ return value is equal to our buffer size.
From keyctl(2):
On a successful return, the return value is always the total size of
the payload data. To determine whether the buffer was of sufficient
size, check to see that the return value is less than or equal to the
value supplied in arg4.
|
|
|
|
|
| |
Let's improve compat with container managers that block the keyring
logic and return EPERM for them.
|
|
|
|
| |
caching is enabled
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
Let's not have a file with a single define.
|
| |
|
|
|
|
|
| |
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'.
|
|
|
|
|
|
|
|
|
| |
We'd call loop_write() separately for each char. Let's be nice to
serial console users, and write the full string in one go.
Coverity was complaining that we're not checking the return value
from loop_write(). Rework the code a bit and add voidify.
CID#1402323.
|
|
|
|
| |
Replaces #12959.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When we read from keyring, a temporary buffer is allocated in order to
determine the size needed for the entire data. However, when zeroing that area,
we use the data size returned by the read instead of the lesser size allocate
for the buffer.
That will cause memory corruption that causes systemd-cryptsetup to crash
either when a single large password is used or when multiple passwords have
already been pushed to the keyring.
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
|
| |
|
|
|
|
|
| |
This is much nicer, since it means we erase the character regardless how
we exit the scope.
|
|
|
|
| |
Just some source rearranging.
|
|
|
|
|
|
|
| |
sequence
This is untested, but I don't see how the previous code could have worked
for multibyte characters (with echo on).
|
|
|
|
|
|
| |
character
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9341.
|
|
|
|
| |
Fixes #11295.
|
| |
|
|
|
|
|
|
|
|
| |
This splits out a bunch of functions from fileio.c that have to do with
temporary files. Simply to make the header files a bit shorter, and to
group things more nicely.
No code changes, just some rearranging of source files.
|
| |
|
|\
| |
| | |
change handling of environment block of PID1's manager object
|
| | |
|
| |
| |
| |
| | |
CID 1396557
|
|/
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
The only real difference is that this wrapper can deal with NULL
pointer arguments, but only if the length is also zero.
CID 1396277
|
|
|
|
|
|
| |
As suggested by @heftig:
https://github.com/systemd/systemd/commit/6d5e65f6454212cd400d0ebda34978a9f20cc26a#commitcomment-30938667
|
|
|
|
|
|
|
|
|
|
| |
All over the place we define local variables for the various sockopts
that take a bool-like "int" value. Sometimes they are const, sometimes
static, sometimes both, sometimes neither.
Let's clean this up, introduce a common const variable "const_int_one"
(as well as one matching "const_int_zero") and use it everywhere, all
acorss the codebase.
|
|
|
|
|
| |
CID 1396140
CID 1396141
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|