Commit Graph

77 Commits

Author SHA1 Message Date
Lennart Poettering 1c8da04446 shared: introduce cmsg_close_all() call
The call iterates through cmsg list and closes all fds passed via
SCM_RIGHTS.

This patch also ensures the call is used wherever appropriate, where we
might get spurious fds sent and we should better close them, then leave
them lying around.
2015-02-18 19:42:24 +01:00
Thomas Hindoe Paaboel Andersen 0a6f50c0af include <poll.h> instead of <sys/poll.h>
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.
2015-02-12 20:47:38 +01:00
Lennart Poettering a38d99451f Revert "tree-wide: Always use recvmsg with MSG_CMSG_CLOEXEC"
This reverts commit d6d810fbf8.

It's apparently not OK to pass MSG_CMSG_CLOEXEC to recvmsg() of raw
sockets.
2015-02-12 11:45:39 +01:00
Cristian Rodríguez d6d810fbf8 tree-wide: Always use recvmsg with MSG_CMSG_CLOEXEC 2015-02-10 21:20:16 +01:00
Zbigniew Jędrzejewski-Szmek 1fa2f38f0f Assorted format fixes
Types used for pids and uids in various interfaces are unpredictable.
Too bad.
2015-01-22 01:14:52 -05:00
Michal Schmidt 56f64d9576 treewide: use log_*_errno whenever %m is in the format string
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.
2014-11-28 19:49:27 +01:00
Michal Schmidt da927ba997 treewide: no need to negate errno for log_*_errno()
It corrrectly handles both positive and negative errno values.
2014-11-28 13:29:21 +01:00
Michal Schmidt 0a1beeb642 treewide: auto-convert the simple cases to log_*_errno()
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().
2014-11-28 12:04:41 +01:00
Tom Gundersen 65fea570f0 udev: fix typos
Spotted by Andreas Henriksson.
2014-09-18 20:25:33 +02:00
Tom Gundersen 4bbdff757e udev: ctrl - log if setting SO_PASSCRED fails
No functional change.

Found by Coverity. Fixes CID #1237533.
2014-09-18 19:26:11 +02:00
Kay Sievers 9ec6e95b04 udev: place opening { at the same line as the function declaration 2014-07-29 15:49:25 +02:00
Kay Sievers 9ea28c55a2 udev: remove seqnum API and all assumptions about seqnums
The way the kernel namespaces have been implemented breaks assumptions
udev made regarding uevent sequence numbers. Creating devices in a
namespace "steals" uevents and its sequence numbers from the host. It
confuses the "udevadmin settle" logic, which might block until util a
timeout is reached, even when no uevent is pending.

Remove any assumptions about sequence numbers and deprecate libudev's
API exposing these numbers; none of that can reliably be used anymore
when namespaces are involved.
2014-04-13 17:12:14 -07:00
Lennart Poettering 39883f622f make gcc shut up
If -flto is used then gcc will generate a lot more warnings than before,
among them a number of use-without-initialization warnings. Most of them
without are false positives, but let's make them go away, because it
doesn't really matter.
2014-02-19 17:53:50 +01:00
Lennart Poettering 955d98c9c1 everywhere: make use of new0() and macro() macros, and stop using perror() 2014-02-13 14:45:51 +01:00
Greg KH 29804cc1e0 use memzero(foo, length); for all memset(foo, 0, length); calls
In trying to track down a stupid linker bug, I noticed a bunch of
memset() calls that should be using memzero() to make it more "obvious"
that the options are correct (i.e. 0 is not the length, but the data to
set).  So fix up all current calls to memset(foo, 0, length) to
memzero(foo, length).
2014-01-31 11:55:01 +01:00
Lennart Poettering 9f6445e34a log: log_error() and friends add a newline after each line anyway, so avoid including it in the log strings 2013-12-24 16:39:37 +01:00
Lennart Poettering eff0527098 util: unify SO_PEERCRED/SO_PEERSEC invocations
Introduce new call getpeercred() which internally just uses SO_PEERCRED
but checks if the returned data is actually useful due to namespace
quirks.
2013-12-24 15:53:04 +01:00
Thomas Hindoe Paaboel Andersen f168c27313 trivial coding style clean ups
- Add space between if/for and the opening parentheses
- Place the opening brace on same line as the function (not for  udev)

From the CODING_STYLE
Try to use this:
    void foo() {
    }
instead of this:
    void foo()
    {
    }
2013-12-03 22:27:45 +01:00
Kay Sievers b26618399e udev: declare some symbols static 2013-11-13 03:34:24 +01:00
Zbigniew Jędrzejewski-Szmek 97fec53e5e udev: use initialization instead of zeroing in one place 2013-10-13 17:56:55 -04:00
Harald Hoyer b97caef538 udev/udev-ctrl.c:udev_ctrl_new_from_fd() enable SO_PASSCRED
Avoid "sender uid=65534, message ignored" case, where no credentials can
be read on the sender side.

Seems, the server socket does not enable credential receiving fast
enough, and the message from the client (without credential) sometimes
is queued before the credential passing was active.
2013-04-08 20:03:50 +02:00
Kay Sievers d5a89d7dc1 udev: move string copy functions to shared/ 2013-01-09 19:06:46 +01:00
Kay Sievers 1298001ec5 use the same email address everywhere 2012-11-12 19:47:43 +01:00
Kay Sievers 6ada823a9a udev: remove configuration options for /dev, /sys, /run directories 2012-04-16 19:20:57 +02:00
Kay Sievers 04a9d3a00a udev: fix gcc warnings showing up after adding $(AM_CFLAGS) 2012-04-10 17:27:46 +02:00
Kay Sievers baa30fbc2c udev: switch to systemd logging functions 2012-04-08 16:06:20 +02:00
Kay Sievers 3e2147858f move imported udev into place 2012-04-04 05:05:07 +02:00
Renamed from src/udev/src/udev-ctrl.c (Browse further)