Commit graph

1181 commits

Author SHA1 Message Date
g0tar 73e669e0fd terminal reset should honour default_utf8 kernel setting (#6606)
terminal reset should honour default_utf8 kernel setting
2017-08-30 10:00:44 +02:00
Lennart Poettering e8132d63fe seccomp: default to something resembling the current personality when locking it
Let's lock the personality to the currently set one, if nothing is
specifically specified. But do so with a grain of salt, and never
default to any exotic personality here, but only PER_LINUX or
PER_LINUX32.
2017-08-29 15:56:57 +02:00
Lennart Poettering 54d564a212 Merge pull request #6636 from sourcejedi/fsync
"Don't fear the fsync()"
2017-08-29 15:19:44 +02:00
Alan Jenkins 265710c205 fileio: rename function parameter to avoid masking global symbol
> glibc exports a function called sync(), we should probably avoid
> overloading that as a variable here locally (gcc even used to warn about
> that, not sure why it doesn't anymore), to avoid confusion around what
> "if (sync)" actually means
2017-08-29 10:56:32 +01:00
Jason Gunthorpe 5570d7f956 Support 'rdma' as a ListenNetlink= argument (#6626)
NETLINK_RDMA has been in the kernel since v3.0.
2017-08-28 17:22:10 +02:00
Yu Watanabe 5ce96b141a Merge pull request #6582 from poettering/logind-tty
various tty path parsing fixes
2017-08-26 22:12:48 +09:00
Alan Jenkins 0675e94ab5 "Don't fear the fsync()"
For files which are vital to boot

1. Avoid opening any window where power loss will zero them out or worse.
   I know app developers all coded to the ext3 implementation, but
   the only formal documentation we have says we're broken if we actually
   rely on it.  E.g.

   * `man mount`, search for `auto_da_alloc`.
   * http://www.linux-mtd.infradead.org/faq/ubifs.html#L_atomic_change
   * https://thunk.org/tytso/blog/2009/03/15/dont-fear-the-fsync/

2. If we tell the kernel we're interested in writing them to disk, it will
   tell us if that fails.  So at minimum, this means we play our part in
   notifying the user about errors.

I refactored error-handling in `udevadm-hwdb` a little.  It turns out I did
exactly the same as had already been done in the `systemd-hwdb` version,
i.e. commit d702dcd.
2017-08-17 20:26:36 +01:00
Lennart Poettering 39f608e4b0 capability: add new ambient_capabilities_supported() helper
This new function reports whether ambient caps are available, and should
be quick because the result is cached.
2017-08-10 15:02:50 +02:00
Lennart Poettering 6067611a08 capability: change capability_bounding_set_drop() to be work without privileges when executing a NOP
This way daemons which already dropped all caps may use the call to
drop priviliges again, which becomes a non-failing NOP.
2017-08-10 15:02:50 +02:00
Lennart Poettering 8f2c2f20b6 mkdir: chmod_and_chown() returns errors as "return -errno", not in errno itself 2017-08-10 15:02:50 +02:00
Lennart Poettering 27458ed629 tree-wide: use path_startswith() rather than startswith() where ever that's appropriate
When checking path prefixes we really should use the right APIs, just in
case people add multiple slashes to their paths...
2017-08-09 19:03:39 +02:00
Lennart Poettering a119ec7c82 util-lib: add a new skip_dev_prefix() helper
This new helper removes a leading /dev if there is one. We have code
doing this all over the place, let's unify this, and correct it while
we are at it, by using path_startswith() rather than startswith() to
drop the prefix.
2017-08-09 19:01:18 +02:00
Lennart Poettering 4e7b57eb0e Merge pull request #6497 from yuwata/bus-prop
core: add missing properties in bus_exec_context_set_transient_property()
2017-08-09 17:06:26 +02:00
bengal b1f24b75af dhcp-network: adjust sockaddr length for addresses longer than 8 bytes (#6527)
An infiniband hardware address is 20 bytes, but sockaddr_ll.sll_addr is only 8
bytes. Explicitly ensure that sockaddr_union has enough space for infiniband
addresses, even if they run over sockaddr_ll and add a macro to compute the
proper size to pass to kernel.
2017-08-08 18:55:31 +02:00
Torstein Husebø ed88a9007a treewide: fix typos (#6566) 2017-08-08 10:05:29 -04:00
Yu Watanabe 29ea9f0f42 process-util: add sched_{policy,priority}_is_valid() 2017-08-07 23:41:39 +09:00
Yu Watanabe 032cf8e4d2 cpu-set-util: add parse_cpu_set() 2017-08-07 23:40:40 +09:00
Yu Watanabe 07d46372fe securebits-util: add secure_bits_{from_string,to_string_alloc}() 2017-08-07 23:40:25 +09:00
Yu Watanabe dd1f5bd0aa cap-list: add capability_set_{from_string,to_string_alloc}() 2017-08-07 23:25:11 +09:00
Jouke Witteveen 01f989c662 process-util: update the end pointer of the process name on rename (#6492)
We only updated the end pointer when allocating new memory, i.e. on the first
call to rename_process.
2017-08-04 11:25:49 +02:00
Lennart Poettering f19ca6105e Merge pull request #6420 from keszybz/gateway-name
Rename "gateway" to "_gateway" and other resolved changes
2017-08-01 09:43:41 +02:00
Zbigniew Jędrzejewski-Szmek 5248e7e1f1 resolved,nss-myhostname: use _gateway for the gateway
This changes the symbolic name for the default gateway from "gateway" to
"_gateway". A new configuration option -Dcompat-gateway-hostname=true|false
is added. If it is set, the old name is also supported, but the new name
is used as the canonical name in either case. This is intended as a temporary
measure to make the transition easier, and the option should be removed
after a few releases, at which point only the new name will be used.

The old "gateway" name mostly works OK, but hasn't gained widespread acceptance
because of the following (potential) conflicts:
- it is completely legal to have a host called "gateway"
- there is no guarantee that "gateway" will not be registered as a TLD, even
  though this currently seems unlikely. (Even then, there would be no
  conflict except for the case when the top-level domain itself was being resolved.
  The "gateway" or "_gateway" labels have only special meaning when the
  whole name consists of a single label, so resolution of any subdomain
  of the hypothetical gateway. TLD would still work OK. )
Moving to "_gateway" avoids those issues because underscores are not allowed
in host names (RFC 1123, §2.1) and avoids potential conflicts with local or
global names.

v2:
- simplify the logic to hardcode "_gateway" and allow
  -Dcompat-gateway-hostname=true as a temporary measure.
2017-07-31 14:41:56 -04:00
Lennart Poettering 47b33c7d52 string-util: optimize strshorten() a bit
There's no reason to determine the full length of the string, it's
sufficient to know whether it is larger than the intended size...
2017-07-31 18:20:28 +02:00
Lennart Poettering c165d97d16 alloc-util: add new helpers memdup_suffix0() and newdup_suffix0()
These are similar to memdup() and newdup(), but reserve one extra NUL
byte at the end of the new allocation and initialize it. It's useful
when copying out data from fixed size character arrays where NUL
termination can't be assumed.
2017-07-31 18:20:28 +02:00
Lennart Poettering 7bf7ce28b5 string-util: add strlen_ptr() helper
strlen_ptr() is to strlen() what streq_ptr() is to streq(): i.e. it
handles NULL strings in a smart way.
2017-07-31 18:20:28 +02:00
Lennart Poettering 6f8cbcdb27 process-util: slightly optimize querying of our own process metadata
When we are checking our own data, we can optimize things a bit.
2017-07-31 18:20:28 +02:00
Lennart Poettering 54191eb3e7 parse-util: introduce pid_is_valid()
Checking for validity of a PID is relatively easy, but let's add a
helper cal for this too, in order to make things more readable and more
similar to uid_is_valid(), gid_is_valid() and friends.
2017-07-31 18:01:42 +02:00
Lennart Poettering 3a87a86e33 audit: introduce audit_session_is_valid() and make use of it everywhere
Let's add a proper validation function, since validation isn't entirely
trivial. Make use of it where applicable. Also make use of
AUDIT_SESSION_INVALID where we need a marker for an invalid audit
session.
2017-07-31 18:01:42 +02:00
Martin Pitt 9fcaa574f0 Merge pull request #6465 from keszybz/drop-kdbus
Drop kdbus-dependent code
2017-07-28 09:29:07 +02:00
Yu Watanabe 2d5dece8ec basic: cosmetic changes (#6440) 2017-07-24 19:32:34 -04:00
Zbigniew Jędrzejewski-Szmek a132bef023 Drop kdbus bits
Some kdbus_flag and memfd related parts are left behind, because they
are entangled with the "legacy" dbus support.

test-bus-benchmark is switched to "manual". It was already broken before
(in the non-kdbus mode) but apparently nobody noticed. Hopefully it can
be fixed later.
2017-07-23 12:01:54 -04:00
Zbigniew Jędrzejewski-Szmek 4bc5d27b94 Drop busname unit type
Since busname units are only useful with kdbus, they weren't actively
used. This was dead code, only compile-tested. If busname units are
ever added back, it'll be cleaner to start from scratch (possibly reverting
parts of this patch).
2017-07-23 09:29:02 -04:00
Lennart Poettering 4b61c87511 tree-wide: fput[cs]() → fput[cs]_unlocked() wherever that makes sense (#6396)
As a follow-up for db3f45e2d2 let's do the
same for all other cases where we create a FILE* with local scope and
know that no other threads hence can have access to it.

For most cases this shouldn't change much really, but this should speed
dbus introspection and calender time formatting up a bit.
2017-07-21 10:35:45 +02:00
Lennart Poettering df0ff12775 tree-wide: make use of getpid_cached() wherever we can
This moves pretty much all uses of getpid() over to getpid_raw(). I
didn't specifically check whether the optimization is worth it for each
replacement, but in order to keep things simple and systematic I
switched over everything at once.
2017-07-20 20:27:24 +02:00
Lennart Poettering 5c30a6d2b8 process-util: add getpid_cached() as a caching wrapper for getpid()
Let's make getpid() fast again.
2017-07-20 20:27:24 +02:00
Lennart Poettering f7a2b4213c Merge pull request #6266 from keszybz/drop-autotools
Drop support for autotools / automake / make
2017-07-20 19:56:07 +02:00
Daniel Berrange 5588612e9e virt: enable detecting QEMU (TCG) via CPUID (#6399)
QEMU >= 2.10 will include a CPUID leaf with value "TCGTCGTCGTCG"
on x86 when running with the TCG CPU emulator:

  https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg05231.html

Existing methods of detecting QEMU are left unchanged for sake of
backcompatibility.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-07-19 11:06:07 +02:00
Zbigniew Jędrzejewski-Szmek e5f752082e build-sys: drop gitignore patterns for in-tree builds
... and other autotools-generated files.
2017-07-18 10:05:06 -04:00
Zbigniew Jędrzejewski-Szmek 72cdb3e783 build-sys: drop automake support
v2:
- also mention m4
2017-07-18 10:04:44 -04:00
Yu Watanabe 3536f49e8f core: add {State,Cache,Log,Configuration}Directory= (#6384)
This introduces {State,Cache,Log,Configuration}Directory= those are
similar to RuntimeDirectory=. They create the directories under
/var/lib, /var/cache/, /var/log, or /etc, respectively, with the mode
specified in {State,Cache,Log,Configuration}DirectoryMode=.

This also fixes #6391.
2017-07-18 14:34:52 +02:00
Vito Caputo db3f45e2d2 basic: use _unlocked() stdio in strip_tab_ansi() (#6385)
Trivial performance boost by explicitly bypassing the implicit
locking of stdio.

This significantly affects common cases of `journalctl` usage:

 Before:

  # time ./journalctl -b -1 > /dev/null
   real    0m26.628s
   user    0m26.495s
   sys     0m0.125s

  # time ./journalctl -b -1 > /dev/null
   real    0m27.069s
   user    0m26.936s
   sys     0m0.134s

  # time ./journalctl -b -1 > /dev/null
   real    0m26.727s
   user    0m26.607s
   sys     0m0.119s

 After:

  # time ./journalctl -b -1 > /dev/null
   real    0m23.394s
   user    0m23.244s
   sys     0m0.142s

  # time ./journalctl -b -1 > /dev/null
   real    0m23.283s
   user    0m23.160s
   sys     0m0.121s

  # time ./journalctl -b -1 > /dev/null
   real    0m23.274s
   user    0m23.125s
   sys     0m0.144s

Fixes https://github.com/systemd/systemd/issues/6341
2017-07-18 00:05:52 +02:00
Lennart Poettering 782c925f7f Revert "core: link user keyring to session keyring (#6275)" (#6342)
This reverts commit 437a85112e.

The outcome of this isn't that clear, let's revert this for now, see
discussion on #6286.
2017-07-12 10:00:43 -04:00
Yu Watanabe 68bdd2d2d3 time-util: make parse_timestamp() return -EINVAL if the input is very old date (#6327)
This reverts 7635ab8e74 and makes parse_timestamp()
return -EINVAL if the input is older than 1970-01-01.

Fixes #6290.
2017-07-11 19:12:48 +02:00
Zbigniew Jędrzejewski-Szmek 3616ca15f0 Merge pull request #6329 from poettering/random-mini-fixes
random-util.c mini fixes
2017-07-11 11:25:26 -04:00
Zbigniew Jędrzejewski-Szmek e3e42fc2b5 Add comments to log_functions which shouldn't be called from library code (#6326) 2017-07-11 10:40:11 +02:00
Lennart Poettering b5fa4c7706 random-util: we are fine if ints are 16 bytes actually
Not that it matters IRL, but let's make this less surprising to read...
2017-07-11 10:37:40 +02:00
Lennart Poettering 7b54715d19 random-util: always cast from smaller to bigger type when comparing
When we compare two size values, let's make sure we cast from the
smaller to the bigger type first, if both types differ, rather than the
reverse in order to not run into overflows.
2017-07-11 10:37:40 +02:00
Lennart Poettering f3b57eaf45 Merge pull request #6325 from keszybz/make-delta-boring-again
Make delta output repeatable
2017-07-11 10:00:21 +02:00
Zbigniew Jędrzejewski-Szmek f6d703c395 basic/strv: use existing qsort_safe() helper
strv_sort() predates qsort_safe(), but we can convert it to it to
save a few lines.
2017-07-10 15:40:47 -04:00
Djalal Harouni 09b4922aff Merge pull request #6289 from keszybz/config-tweaks
Config parsing tweaks
2017-07-10 00:19:44 +02:00