Commit graph

809 commits

Author SHA1 Message Date
Lennart Poettering 9bf3b53533 shared: switch our hash table implementation over to SipHash
SipHash appears to be the new gold standard for hashing smaller strings
for hashtables these days, so let's make use of it.
2013-12-22 21:12:25 +01:00
Florian Weimer 4ff4ebb1fb util: remove union dirent_storage 2013-12-21 18:35:55 -05:00
Florian Weimer a2be63f922 conf-files: replace readdir_r with readdir 2013-12-21 18:35:55 -05:00
Florian Weimer 3fd11280e8 util: replace readdir_r with readdir
This fixes rm_rf_children_dangerous to detect errors during directory
reading.  Previously, it could dereference an uninitialized pointer.
2013-12-21 18:35:55 -05:00
Florian Weimer 4d993c8cb7 install: replace readdir_r with readdir
The old code incorrectly assumed that readdir_r updates errno.
2013-12-21 18:35:55 -05:00
Shawn Landden e10a55fd72 DEFAULT_PATH_SPLIT_USR macro 2013-12-20 23:14:21 -05:00
Zbigniew Jędrzejewski-Szmek 4d89874af6 logging: reduce send timeout to something more sensible
For a user, the timeout of 1 min per message seems equivalent to a hang.
If journald cannot process a message from PID1 for 10 ms then something
is significantly wrong. It's better to lose the message and continue.
2013-12-20 22:47:26 -05:00
Lennart Poettering f7cf00fa51 def: lower exit-on-idle time 2013-12-19 22:18:39 +01:00
Zbigniew Jędrzejewski-Szmek 44433ebdb1 udevadm: modernization 2013-12-18 23:58:23 -05:00
Lennart Poettering 8674debc67 Revert "ptyfwd: make master terminal attributes raw, too"
This reverts commit e7d43b3cc3.

This broke the console terminal when booting up a container, so let's
not do this.
2013-12-18 19:26:10 +01:00
Lennart Poettering e7d43b3cc3 ptyfwd: make master terminal attributes raw, too 2013-12-18 18:21:28 +01:00
Lennart Poettering 0e6eaa2d98 log: when we log to /dev/console and got disconnected (maybe due to vhangup) reconnect 2013-12-18 18:21:27 +01:00
Lennart Poettering 99f098257f log: don't reopen /dev/console each time we call log_open()
Instead, force reopen it only if we really really have to.
2013-12-18 18:21:27 +01:00
Lennart Poettering bf108e5541 service: watch main pid even in final states
In some circumstances, for example when start-up times out we
immediately jump into the final state, at which point we still should
try to watch the main pid so that the SIGCHLD allows us to quickly
move into dead state.
2013-12-18 18:21:27 +01:00
Lennart Poettering 5e2f14e62b busctl: output a single sorted list of names, including activatable and activated 2013-12-18 02:54:16 +01:00
Shawn Landden 919ce0b7af _noreturn_ --> noreturn for C11 compat
also define noreturn w/o <stdnoreturn.h>
2013-12-17 21:51:24 +01:00
Shawn Landden 73020ab241 util: no need for in_initrd() cache to be thread-local
the process only has one working directory, and a race is
harmless
2013-12-17 21:45:43 +01:00
Shawn Landden ec202eae8e __thread --> thread_local for C11 compat
Also make thread_local available w/o including <threads.h>.
(as the latter hasn't been implemented, but this part is trivial)
2013-12-17 21:45:43 +01:00
Lukasz Skalski 5232c42ec4 libsystemd-bus: true/false instead of yes/no in msg dump
Due to this patch, message dump (for message which includes boolean
type) is more consistent with dbus-send (which display true/false
instead of yes/no for boolean). It's only simple 'cosmetics change'.

** For dbus-send **

dbus-send --system --dest=org.freedesktop.DBus --type=method_call --print-reply / org.freedesktop.DBus.NameHasOwner string:org.freedesktop.login1

method return sender=org.freedesktop.DBus -> dest=:1.97 reply_serial=2
   boolean true

** For libsystemd-bus (without this patch) **

‣ Type=method_call  Endian=l  Flags=0  Version=2 Serial=8
  Destination=org.freedesktop.DBus  Path=/org/freedesktop/DBus  Interface=org.freedesktop.DBus  Member=NameHasOwner
  MESSAGE "s" {
  	STRING "org.freedesktop.login1";
  };

‣ Type=method_return  Endian=l  Flags=1  Version=2 Serial=51  ReplySerial=8
  Sender=:1.59  Destination=:1.67
  UniqueName=:1.59  WellKnownNames={org.freedesktop.DBus}
  MESSAGE "b" {
  	BOOLEAN yes;
  };

For me true/false seems to be better readable than yes/no for BOOLEAN.
2013-12-17 21:45:43 +01:00
Zbigniew Jędrzejewski-Szmek c0fdf09885 systemctl: highlight filenames in cat 2013-12-16 23:21:51 -05:00
Lennart Poettering a4475f577b bus: when entering an existing namespace to connect to a container's system bus also switch over PID namespace
This is necessary to ensure that kdbus can collect creds of the
destination namespace when connecting.
2013-12-17 01:05:37 +01:00
Lennart Poettering 92d75ca419 util: try harder to increase the send/recv buffers of sockets
If we have the priviliges we will try SO_SNDBUFFORCE/SO_RCVBUFFORCE and
only fall back to SO_SNDBUF/SO_RCVBUF if that fails.
2013-12-16 17:04:36 +01:00
Lennart Poettering 2cfbd749af core: refuse doing %h, %s, %U specifier resolving in PID 1
These specifiers require NSS lookups to work, and we really shouldn't do
them from PID 1 hence. With this change they are now only supported for
user systemd instance, or when the configured user for a unit is root.
2013-12-16 04:59:31 +01:00
Zbigniew Jędrzejewski-Szmek b5dd814873 Fix a few signed/unsigned format string issues
Since numbers involved are all small, behaviour was correct already.

https://bugzilla.redhat.com/show_bug.cgi?id=1043304
2013-12-15 17:49:28 -05:00
Lennart Poettering e04b0cdb90 util: port last code over to new namespace utility calls 2013-12-14 05:10:25 +01:00
Lennart Poettering 5e2b3214aa util: when joining a namespace make sure to reset all uids to 0 after
the transition
2013-12-14 05:10:25 +01:00
Lennart Poettering bc9fd78c7b bus: when connecting to a container's kdbus instance, enter namespace first
Previously we'd open the connection in the originating namespace, which
meant most peers of the bus would not be able to make sense of the
PID/UID/... identity of us since we didn't exist in the namespace they
run in. However they require this identity for privilege decisions,
hence disallowing access to anything from the host.

Instead, when connecting to a container, create a temporary subprocess,
make it join the container's namespace and then connect from there to
the kdbus instance. This is similar to how we do it for socket
conections already.

THis also unifies the namespacing code used by machinectl and the bus
APIs.
2013-12-14 05:10:25 +01:00
Patrik Flykt e88bc7958c shared: Add struct sockaddr_ll to sockaddr_union 2013-12-12 11:43:34 -05:00
Lennart Poettering e5ca092c27 log: protect errno when we use assert_return() 2013-12-12 15:59:13 +01:00
Marc-Antoine Perennou 2a410422ec shared: add missing include
Needed for socketpair, recv
2013-12-12 08:49:25 -05:00
Zbigniew Jędrzejewski-Szmek 50f72bca65 Do not log all assert_return failures
% build/journalctl help
Assertion 'match_is_valid(data, size)' failed at ../src/journal/sd-journal.c:227, function sd_journal_add_match(). Ignoring.

Callers cannot be expect to check all arguments always.
2013-12-11 22:26:55 -05:00
Lennart Poettering e9174f29c7 journald: cache cgroup root path, instead of querying it on every incoming log message 2013-12-11 23:31:07 +01:00
Lennart Poettering b6741478e7 journal: add ability to browse journals of running OS containers
This adds the new library call sd_journal_open_container() and a new
"-M" switch to journalctl. Particular care is taken that journalctl's
"-b" switch resolves to the current boot ID of the container, not the
host.
2013-12-11 22:04:03 +01:00
Lennart Poettering 842129f587 service: clean up watchdog logic a bit 2013-12-11 20:55:09 +01:00
Luke Shumaker 90d14d2015 ptyfwd: Don't set the output prop of stdin, nor the input props of stdout.
It was calling cfmakeraw(3) on the properties for STDIN_FILENO; cfmakeraw
sets both input and output properties.  If (and only if) stdin and stdout
are the same device is this correct.  Otherwise, we must change only the
input properties of stdin, and only the output properties of stdout.
2013-12-11 01:04:21 +00:00
Luke Shumaker eaf73b0616 ptyfwd: Set the size of the PTY base on the size of stdout, not stdin. 2013-12-11 01:01:40 +00:00
Lennart Poettering 65a6df56f1 hashmap: make gcc shut up on old glibcs that lack getauxval() 2013-12-10 19:52:16 +00:00
Lennart Poettering 98088803bb util: check for overflow in greedy_realloc() 2013-12-10 18:53:56 +00:00
Lennart Poettering 80514f9c9b macro: log assertion at debug level in assert_return() 2013-12-10 17:01:10 +00:00
Zbigniew Jędrzejewski-Szmek 2b6bf07dd2 Get rid of our reimplementation of basename
The only problem is that libgen.h #defines basename to point to it's
own broken implementation instead of the GNU one. This can be fixed
by #undefining basename.
2013-12-06 21:29:55 -05:00
Yuxuan Shui 85ca9433ab util: fix misuse of memcmp 2013-12-05 22:49:02 -05: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
Lennart Poettering 059d9fbb5a macro: better make IN_SET() macro use const arrays 2013-12-03 16:41:15 +01:00
Lennart Poettering 674eb68520 bus: add generator that turns old dbus1 activation files into .busname + .service units 2013-12-03 01:13:48 +01:00
Lennart Poettering e821075a23 bus: add .busname unit type to implement kdbus-style bus activation 2013-12-02 23:32:34 +01:00
Lennart Poettering cabb780688 macro: add a macro to test whether a value is in a specified list
Introduce IN_SET() macro to nicely check whether a value a is one of a
few listed values.

This makes writing this:

        if (a == 1 || a == 7 || a == 8 || a == 9)

nicer, by allowing this:

        if (IN_SET(a, 1, 7, 8, 9))

This is particularly useful for state machine enums.
2013-12-02 23:32:34 +01:00
David Herrmann 4545a231fc util: add greedy_realloc0()
Compared to greedy_realloc(), this sets all newly allocated memory to 0.
As the old variant has been used a lot for string-handling, we avoid
changing it as clearing memory is not needed there.
2013-12-01 12:17:08 +01:00
Shawn Landden d78a28e3d7 fix regression of read_full_file() in fileio.c
my e93c33d4aa broke this stupidly
2013-11-30 23:04:17 -05:00
Shawn Landden e93c33d4aa systemctl: add "systemctl cat" 2013-11-30 22:20:20 -05:00
Thomas Hindoe Paaboel Andersen 27373e4427 util.c: check if return value from ttyname_r is > 0 instead of != 0
We must return a negative error code from getttyname_malloc but
that would not be the case if ttyname_r returned a negative value.

ttyname_r should only return EBADF, ENOTTY, or ERANGE so it should
be safe to change.
2013-12-01 00:14:28 +01:00