Commit Graph

102 Commits

Author SHA1 Message Date
Lennart Poettering 9a98c7a156 util: split off time related calls from util.[ch] into time-util.[ch] 2012-11-23 22:07:24 +01:00
Lennart Poettering 525716e2f9 util: drop "," between week day and date when formatting timestamps
The glibc default (as shown by the command line tool "date") doesn't put a comma there,
and so we shouldn't either.
2012-11-23 16:26:28 +01:00
Anders Olofsson 7009eec208 shared/utils: systemd-cgls shows 'n/a' when piping output
-1 was used to signal failure, but the type was unsigned.

https://bugs.freedesktop.org/show_bug.cgi?id=56644
2012-11-19 17:12:17 +01:00
Zbigniew Jędrzejewski-Szmek 943aad8ca5 journal, shared: fix warnings during compilation on 32 bits
Some filesystem magics are too big to fit in 31 bits,
and are wrapped to negative. f_type is an int on 32 bits, so
it is signed, and we get a warning on comparison.
2012-11-16 23:26:44 +01:00
Lennart Poettering 409bc9c33e util: add strreplace() to replace a substring by another string 2012-11-14 22:21:16 +01:00
Michal Schmidt 45a5ff0de7 util: nicer tree drawings
Draw trees more similar to pstree/findmnt/lsblk/...
2012-11-12 22:27:48 +01:00
Kay Sievers c1e5704657 shared: add is_efiboot() 2012-11-04 16:06:27 +01:00
Michal Schmidt c339d9775d util : fallback to plain ASCII drawing if locale is not UTF-8
When printing cgroup and sysfs hierarchies, avoid using UTF-8 box drawing
characters if the locale is not UTF-8.

https://bugzilla.redhat.com/show_bug.cgi?id=871153
2012-11-02 17:39:52 +01:00
Michal Schmidt 0901758558 util: add is_locale_utf8()
journalctl and vconsole-setup both implement utf8 locale detection.
Let's have a common function for it.
The next patch will add another use.
2012-11-02 17:27:15 +01:00
Michal Schmidt f8b69d1dfc shared, core: do not always accept numbers in string lookups
The behaviour of the common name##_from_string conversion is surprising.
It accepts not only the strings from name##_table but also any number
that falls within the range of the table. The order of items in most of
our tables is an internal affair. It should not be visible to the user.

I know of a case where the surprising numeric conversion leads to a crash.

We will allow the direct numeric conversion only for the tables where the
mapping of strings to numeric values has an external meaning. This holds
for the following lookup tables:
 - netlink_family, ioprio_class, ip_tos, sched_policy - their numeric
   values are stable as they are defined by the Linux kernel interface.
 - log_level, log_facility_unshifted - the well-known syslog interface.

We allow the user to use numeric values whose string names systemd does
not know. For instance, the user may want to test a new kernel featuring
a scheduling policy that did not exist when his systemd version was
released. A slightly unpleasant effect of this is that the
name##_to_string conversion cannot return pointers to constant strings
anymore. The strings have to be allocated on demand and freed by the
caller.
2012-10-30 15:41:15 +01:00
Michal Schmidt f3910003bc shared, libsystemd-daemon: check for empty strings in strto*l conversions
strtol() and friends may set EINVAL if no conversion was performed, but
they are not required to do so. In practice they don't. We need to check
for it.

https://bugzilla.redhat.com/show_bug.cgi?id=870577
2012-10-30 10:30:04 +01:00
Michal Schmidt fd09c93de9 util: improve overflow checks
commit 49371bb fixed the observed division by zero, but missed another
occurrence of the same bug. It was also not the optimal fix. We can
simply make the divisor a constant by swapping it with the compared
value.
2012-10-29 22:57:24 +01:00
Dave Reisner 49371bb50e util: avoid divide by zero FPE
In early userspace, if kernel initialization happens extremely quickly,
a call to systemd-timestamp can potentially result in division by zero.
Ensure that the check in timespec_load, which only makes sense if tv_sec
is greater than zero, is guarded by this condition.
2012-10-29 15:53:03 -04:00
Michal Sekletar 3dd8ee8fa6 util: fix possible integer overflows 2012-10-28 02:14:41 +02:00
Lennart Poettering 6524990fdc logind: support for hybrid sleep (i.e. suspend+hibernate at the same time) 2012-10-28 00:50:35 +02:00
Lennart Poettering e8988fc2a2 util: return the remaining string in startswith() 2012-10-27 01:20:01 +02:00
Kay Sievers 1c574591db udev: hwdb - remove run_once 2012-10-25 21:44:33 +02:00
Kay Sievers a9e12476ed util: add (x)bsearch_r(), the missing counterpart of qsort_r() 2012-10-22 14:31:46 +02:00
Lennart Poettering 8c7c140fca util: change endswith() to return a pointer to the suffix 2012-10-19 04:53:46 +02:00
Lennart Poettering ed757c0cb0 util: unify line caching and column caching 2012-10-19 00:07:55 +02:00
Lennart Poettering 8481248b9f util: unify usage of on_tty() in util.c 2012-10-19 00:07:55 +02:00
Lennart Poettering 28917d7dc7 util: simplify column caching logic 2012-10-19 00:07:55 +02:00
Lennart Poettering 01539d6ef9 hostnamed: allow UTF8 chars in pretty hostname again 2012-10-17 21:25:42 +02:00
Lennart Poettering 6d0274f115 timedatectl: introduce new command line client for timedated
Much like logind has a client in loginctl, and journald in journalctl
introduce timedatectl, to change the system time (incl. RTC), timezones
and related settings.
2012-10-17 21:25:42 +02:00
Lennart Poettering b1c806231b util: properly handle -1 timespec/timeval 2012-10-16 01:04:32 +02:00
Lennart Poettering cfbc22abd0 journalctl: implement --since= and --until for filtering by time 2012-10-11 16:43:37 +02:00
Martin Mikkelsen 011afa76fb shared: fix broken string_is_safe 2012-10-08 14:35:46 +02:00
Lennart Poettering 0b507b17a7 dbus: add some more safety checks before accepting data from bus clients 2012-10-03 13:29:20 -04:00
Lennart Poettering 08ace05beb logs-show: various cleanups
Among other cleanups this introduces a threshold for the size of binary
blobs we serialize as integer arrays in the JSON output. THis can be
disabled via --all.
2012-09-28 00:55:24 +02:00
Lennart Poettering 9086e840ff util: don't export parsed_columns 2012-09-24 14:43:07 +02:00
Dave Reisner 585314e84c journalctl: reset cached column count on SIGWINCH
This requires a little bit of tip-toeing around to explicitly avoid
touching the environment from a sig handler. Instead, simply create a
function to reset the var to its "unset" state, allowing the next call
to columns() to recalculate and cache the new value.
2012-09-24 08:38:03 -04:00
Lukas Nykryn e98055de98 shared: call va_end in all cases 2012-09-21 12:07:41 +02:00
Lennart Poettering aa408e7799 util: fix overflow checks 2012-09-20 17:53:03 +02:00
Lennart Poettering 040f18ea8a util: overflow hardening 2012-09-20 11:08:27 +02:00
Lennart Poettering 7d5e9c0f60 util: define union dirent_storage and make use of it everywhere
Make sure to allocate enough space for readdir_r().

https://bugzilla.redhat.com/show_bug.cgi?id=858754
2012-09-19 22:21:09 +02:00
Lennart Poettering 57f3067825 util: fix bad strstrip() return value in normalize_env_assignment()
https://bugzilla.redhat.com/show_bug.cgi?id=858780
2012-09-19 22:01:31 +02:00
Lennart Poettering 901c3d0d85 util: introduce get_process_gid() 2012-09-18 01:53:15 +02:00
Lennart Poettering faa368e337 conf-parser: don't unescape parsed configuration strings by default
In many cases this might have a negative effect since we drop escaping
from strings where we better shouldn't have dropped it.

If unescaping makes sense for some settings we can readd it later again,
on a per-case basis.

https://bugs.freedesktop.org/show_bug.cgi?id=54522
2012-09-17 21:58:03 +02:00
Lennart Poettering 669bec5d17 util: various cleanups for printing boot status 2012-09-17 19:05:32 +02:00
Zbigniew Jędrzejewski-Szmek 25ea79fe07 nspawn: use automatic cleanup for umask 2012-09-16 16:20:09 +02:00
Lennart Poettering 424a19f8a2 timedate: assorted improvements
- Make writing/reading of /etc/timezone dependendent of HAVE_SYSV_COMPAT

- Introduce symlink_atomic() after all, and use it

- Use relative symlink for /etc/localtime
2012-09-14 20:02:52 +02:00
Lennart Poettering 73836c5c43 util: more modernizations 2012-09-14 10:36:50 +02:00
Lennart Poettering a05f97b3ac util: various additional modernizations 2012-09-14 10:24:27 +02:00
Lennart Poettering e67f47e55b util: modernize a few functions with automatic cleanup variables
Just trying to get the feel for it. And it's pretty cool.
2012-09-14 10:06:42 +02:00
Lennart Poettering 2fbe635a83 macro: introduce _cleanup_free_ macro for automatic freeing of scoped vars and make use of it 2012-09-13 22:30:26 +02:00
Tom Gundersen b3d284696c util: rm_rf_children_dangerous: delete all descendants dangerously
Call rm_rf_children_dangerous() recursively rather than falling back to
rm_rf_children(). This fixes a bug in systemd-tmpfiles.

The problem can easily be reproduced by:

  # mount /dev/sda1 /mnt
  # mkdir /mnt/test
  # echo "D /mnt" > /root/test.conf
  # systemd-tmpfiles --remove /root/test.conf
  Attempted to remove disk file system, and we can't allow that.
  rm_rf(/root/test): Operation not permitted

Reported-by: Lukas Jirkovsky <l.jirkovsky@gmail.com>
2012-09-11 02:55:29 +02:00
Lennart Poettering d87be9b0af nspawn: handle poweroff/reboot nicely in containers 2012-09-05 16:23:41 -07:00
Lennart Poettering 5809560d85 journal: move syslog specific calls out of util.c 2012-08-22 03:24:46 +02:00
Lennart Poettering ef63833d53 journald: split /dev/kmsg related stuff into its own .c file 2012-08-22 03:09:44 +02:00
Dave Reisner 84cc2abf34 shared/util: add fstab support for partuuid/partlabel
udev has supported this since 172, so it should be a safe (and welcome)
addition for users of GPT partitioned disks.
2012-08-21 11:48:26 -04:00