Commit Graph

19870 Commits

Author SHA1 Message Date
Lennart Poettering c687863750 util: rework rm_rf() logic
- Move to its own file rm-rf.c

- Change parameters into a single flags parameter

- Remove "honour sticky" logic, it's unused these days
2015-04-06 10:57:53 +02:00
Lennart Poettering 2f653bded3 update TODO 2015-04-06 10:57:52 +02:00
Shawn Landden eaf15609da bootchart: fix check for no fd
found with coverty report
2015-04-05 21:20:23 +02:00
Tom Gundersen de9b34b6d4 sd-device: don't use alloca() within loops
I shall not use alloca() within loops
 I shall not use alloca() within loops
 I shall not use alloca() within loops
 I shall not use alloca() within loops
...
2015-04-05 12:17:29 +02:00
Thomas Hindoe Paaboel Andersen 4835f5639a libudev-util: check length before accesing the array 2015-04-05 08:46:01 +02:00
Thomas Hindoe Paaboel Andersen afbbf1369b service: remove unnecessary forward declare 2015-04-05 08:45:56 +02:00
Tom Gundersen 401cb61499 sd-device,udevd: fix spelling /ammend/amend/ 2015-04-03 22:51:09 +02:00
Tom Gundersen 4df4fd1127 sd-device: fix deserialization from netlink
Use the standard FOREACH_WORD* macros.

The current code was broken in the devlink case so the last one received
was being dropped, causing https://bugs.freedesktop.org/show_bug.cgi?id=89894
2015-04-03 22:17:52 +02:00
Tom Gundersen aa20f49a1c sd-device: get_properties_{nulstr,strv} - don't recreate the buffer unnecessarily 2015-04-03 22:17:41 +02:00
Tom Gundersen 2fe29a46a3 sd-device: get_sysattr_value - don't leak returned value
This was getting leaked as a copy was added to the hashmap, simply add the
returned value instead.

This should fix CID #1292806.
2015-04-03 17:45:51 +02:00
Tom Gundersen b3f2490072 test: udev, valgrind - track origins of uninitiaziled memory 2015-04-03 17:27:45 +02:00
Tom Gundersen afcac065c0 sd-device: initialize variable
sysnum would not be initialized if sysname had no trailing digits.
2015-04-03 17:27:00 +02:00
Tom Gundersen cdfee94318 networkd: improve logging when processing links and addresses 2015-04-03 15:35:07 +02:00
Daniel Mack af672f03ec bootchart: assorted coding style fixes
* kill unnecessary {}
* add newlines where appropriate
* remove dead code
* reorder variable declarations
* fix more return code logic
* pass O_CLOEXEC to all open*() calles
* use safe_close() where possible
2015-04-03 15:29:18 +02:00
Daniel Mack 1f2ecb0393 bootchart: kill a bunch of global variables
This code is in a confusingly bad shape. Kill a bunch of global variables
and pass needed variables around in function calls.
2015-04-03 15:29:18 +02:00
Daniel Mack f91781329c bootchart: clean up sysfd and proc handling
Retrieve the handle to procfs in main(), and pass it functions
that need it. Kill the global variables.

Also, refactor lots of code in svg_title(). There's no need to access any
global variables from there either, and we really should return proper
errors from there as well.
2015-04-03 15:29:18 +02:00
Daniel Mack 34a4071e99 bootchart: clean up control flow logic
Don't blindly exit() from random functions, but return a proper error
and upchain error conditions.

squash! bootchart: clean up control flow logic

When pread() returns "0", it's a read failure, so don't make the caller think
log_sample() was successful, return meaningful error code instead of 0.
2015-04-03 15:29:18 +02:00
Daniel Mack 0399586320 bootchart: switch to log_* helpers
Let the helper functions take care of the string message output.
2015-04-03 15:29:18 +02:00
Lennart Poettering 61192f1d69 update TODO 2015-04-03 14:34:59 +02:00
Lennart Poettering 49d7fc99b9 units: explicitly require /var, /tmp and /var/tmp to be mounted before basic.target
We support /var, /tmp and /var/tmp on NFS. NFS shares however are by
default ordered only before remote-fs.target which is a late-boot
service. /var, /tmp, /var/tmp need to be around earlier though, hence
explicitly order them before basic.target.

Note that this change simply makes explicit what was implicit before,
since many early-boot services pulled in parts of /var anyway early.
2015-04-03 14:32:32 +02:00
Lennart Poettering efb3e19be9 units: explicitly order systemd-user-sessions.service after nss-user-lookup.target
We should not allow logins before NIS/LDAP users are available.
2015-04-03 14:31:35 +02:00
Lennart Poettering d8f0930eec units: move After=systemd-hwdb-update.service dependency from udev to udev-trigger
Let's move the hwdb regeneration a bit later. Given that hwdb is
non-essential it should be OK to allow udev to run without it until we
do the full trigger.

http://lists.freedesktop.org/archives/systemd-devel/2015-April/030074.html
2015-04-03 14:27:16 +02:00
Lennart Poettering 9ff3e22aa9 CODING_STYLE: mention that dup() should not be used 2015-04-03 14:26:22 +02:00
Lennart Poettering d95a74ed11 timedatectl: many fixes
- print runtime warnings with log_warning()

- save and restore $TZ properly

- Get rid of exit() pseudo error handling

- Using time() is OK when connecting to a local container or when
  showing data about local host, but certainly not for remote hosts.
2015-04-02 12:17:41 +02:00
Lennart Poettering c4f5472117 man: don't mention "journalctl /dev/sda"
It never worked, and nobody ever worked on it, hence don't mention it.
2015-04-02 12:17:41 +02:00
Lennart Poettering ac749874bb update TODO 2015-04-02 12:17:41 +02:00
Lennart Poettering 3dbafa39b0 CODING_STYLE: clarify that exit() is never OK to call 2015-04-02 12:17:41 +02:00
Tom Gundersen f4ac4d1a82 libudev: device - replace by a thin wrapper around sd-device 2015-04-02 00:18:27 +02:00
Tom Gundersen 9102fdc5c6 fsck: port from libudev to sd-device 2015-04-02 00:18:27 +02:00
Tom Gundersen 9a97aaae3b cryptsetup: port from libudev to sd-device 2015-04-02 00:18:27 +02:00
Tom Gundersen 914d6c09f1 networkctl: port from libudev to sd-device 2015-04-02 00:18:27 +02:00
Tom Gundersen 57fa1d094c libsystemd: add sd-device library
This provides equivalent functionality to libudev-device, but in the
systemd style. The public API only caters to creating sd_device objects
from for devices that already exist in /sys, there is no support for
listening for monitoring events or creating devices received over
the udev netlink protocol.

The private API contains the necessary functionality to make sd-device
a drop-in replacement for libudev-device, but which we would not
otherwise want to export.
2015-04-02 00:18:27 +02:00
Tom Gundersen 309b578d31 udev: net_id - improve comments
The dev_port concept is a bit confusing, expand on the comment a bit.
2015-04-01 23:34:19 +02:00
Tom Gundersen c0a43734ca udev: net_id - support multi-port enpo* device names
I'd argue that having firmware labels for such devices makes
no sense, but they exist, so make sure we handle them as best
as we can.
2015-04-01 22:56:27 +02:00
Tom Gundersen 16f948cb20 udev: net_id - fix copy-paste error
In case pci_slot overflows we were truncating pci_path instead.
2015-04-01 22:56:26 +02:00
Tom Gundersen e6ac88ddf2 libudev: monitor - improve logging 2015-04-01 14:45:34 +02:00
Tom Gundersen 4a9185c438 shared: set - make argument to set_remove() const 2015-04-01 14:45:22 +02:00
Michal Sekletar 340a1d2330 mount: fix up wording in the comment 2015-04-01 13:08:25 +02:00
Lukas Nykryn 11041c8488 mount: don't run quotaon only for network filesystems
If you have for example ext4 on iscsi devices it is possible to setup
qoutas there. Unfortunately, because such fstab entry contains _netdev,
systemd will not add dependency to quotaon.service.
2015-04-01 12:16:53 +02:00
Marcel Holtmann c185834d77 hwdb: Update database of Bluetooth company identifiers 2015-03-31 22:59:12 +02:00
Alban Crequy 81f5049b7c nspawn: fallback on bind mount when mknod fails
Some systems abusively restrict mknod, even when the device node already
exists in /dev. This is unfortunate because it prevents systemd-nspawn
from creating the basic devices in /dev in the container.

This patch implements a workaround: when mknod fails, fallback on bind
mounts.

Additionally, /dev/console was created with a mknod with the same
major/minor as /dev/null before bind mounting a pts on it. This patch
removes the mknod and creates an empty regular file instead.

In order to test this patch, I used the following configuration, which I
think should replicate the system with the abusive restriction on mknod:

  # grep devices /proc/self/cgroup
  4:devices:/user.slice/restrict
  # cat /sys/fs/cgroup/devices/user.slice/restrict/devices.list
  c 1:9 r
  c 5:2 rw
  c 136:* rw
  # systemd-nspawn --register=false -D .

v2:
 - remove "bind", it is not needed since there is already MS_BIND
v3:
 - fix error management when calling touch()
 - fix lowercase in error message
2015-03-31 17:21:03 +02:00
Lennart Poettering 4f923a1984 nspawn: drop sd_booted() check
We have no such check in any of the other tools, hence don't have one in
nspawn either.

(This should make things nicer for Rocket, among other things)

Note: removing this check does not mean that we support running nspawn
on non-systemd. We explicitly don't. It just means that we remove the
check for running it like that. You are still on your own if you do...
2015-03-31 15:36:53 +02:00
Iago López Galeiras 4543768d13 nspawn: change filesystem type from "bind" to NULL in mount() syscalls
Try to keep syscalls as minimal as possible.
2015-03-31 15:36:53 +02:00
Lennart Poettering ffd8644641 man: fix line breaks in code examples 2015-03-31 15:36:53 +02:00
Andrew Jones ce09c71d56 ARM: detect-virt: detect QEMU/KVM
QEMU/KVM guests do not have hypervisor nodes, but they do have
fw-cfg nodes (since qemu v2.3.0-rc0). fw-cfg nodes are documented,
see kernel doc Documentation/devicetree/bindings/arm/fw-cfg.txt,
and therefore we should be able to rely on it in this detection.

Unfortunately, we currently don't have enough information in the
DT, or elsewhere, to determine if we're using KVM acceleration
with QEMU or not, so we can only report 'qemu' at this time, even
if KVM is in use. This shouldn't really matter in practice though,
because if detect-virt is used interactively it will be clear to
the user whether or not KVM acceleration is present by the overall
speed of the guest. If used by a script, then the script's behavior
should not change whether it's 'qemu' or 'kvm'. QEMU emulated
guests and QEMU/KVM guests of the same type should behave
identically, only the speed at which they run should differ.
2015-03-31 15:36:53 +02:00
Andrew Jones db6a86897e ARM: detect-virt: detect Xen 2015-03-31 15:36:53 +02:00
Andrew Jones b8f1df8264 detect-virt: use /proc/device-tree
Kernel doc Documentation/ABI/testing/sysfs-firmware-ofw says that
the /proc/device-tree symlink should be used, as opposed to
directly accessing /sys/firmware/devicetree/base. The former is
ABI, but not the later.
2015-03-31 15:36:53 +02:00
Alexander Sverdlin c87664fef4 systemd-bootchart: Repair Entropy Graph
Entropy Graph code doesn't handle the error condition if open() of /proc entry
fails. Moreover, the file is only opened once and only first sample will contain
the correct value because the return value of pread() is also not handled
properly and file is not re-opened. Fix both problems.
2015-03-30 09:38:17 +02:00
Alexander Sverdlin 58ec01b35c systemd-bootchart: Prevent leaking file descriptors in open-fdopen combination
Correctly handle the potential failure of fdopen() (because of OOM, for instance)
after potentially successful open(). Prevent leaking open fd in such case.
2015-03-30 09:37:11 +02:00
Alexander Sverdlin 9964a9eb7b systemd-bootchart: Prevent closing random file descriptors
If the kernel has no CONFIG_SCHED_DEBUG option set, systemd-bootchart produces
empty .svg file. The reason for this is very fragile file descriptor logic in
log_sample() and main() (/* do some cleanup, close fd's */ block). There are
many places where file descriptors are closed on failure (missing SCHED_DEBUG
provokes it), but there are several problems with it:
 - following iterations in the loop see that the descriptor is non zero and do
   not open the corresponding file again;
 - "some cleanup" code closes already closed files and the descriptors are reused
   already, in particular for resulting .svg file;
 - static "vmstat" and "schedstat" variables in log_sample() made the situation
   even worse.

These are the strace fragments:

[...]
close(7)                                = -1 EBADF (Bad file descriptor)
close(-1)                               = -1 EBADF (Bad file descriptor)
pread(7, 0xbea60a2c, 4095, 0)           = -1 EBADF (Bad file descriptor)
close(7)                                = -1 EBADF (Bad file descriptor)
close(-1)                               = -1 EBADF (Bad file descriptor)
pread(7, 0xbea60a2c, 4095, 0)           = -1 EBADF (Bad file descriptor)
close(7)                                = -1 EBADF (Bad file descriptor)
close(-1)                               = -1 EBADF (Bad file descriptor)
getdents64(4, /* 0 entries */, 32768)   = 0
clock_gettime(CLOCK_MONOTONIC, {24, 783843501}) = 0
nanosleep({0, 5221792}, NULL)           = 0
clock_gettime(CLOCK_MONOTONIC, {24, 789726835}) = 0
lseek(4, 0, SEEK_SET)                   = 0
pread(5, "nr_free_pages 52309\nnr_alloc_bat"..., 4095, 0) = 685
pread(6, "version 15\ntimestamp 4294939775\n"..., 4095, 0) = 86
getdents64(4, /* 99 entries */, 32768)  = 2680
pread(7, 0xbea60a2c, 4095, 0)           = -1 EBADF (Bad file descriptor)
close(7)                                = -1 EBADF (Bad file descriptor)
close(-1)                               = -1 EBADF (Bad file descriptor)
pread(8, 0xbea60a2c, 4095, 0)           = -1 EBADF (Bad file descriptor)
close(8)                                = -1 EBADF (Bad file descriptor)
close(-1)                               = -1 EBADF (Bad file descriptor)
pread(9, 0xbea60a2c, 4095, 0)           = -1 EBADF (Bad file descriptor)
close(9)                                = -1 EBADF (Bad file descriptor)
[...]

where it obviously tries to close same and reused decriptors many times, also
passing return code "-1" instead of descriptor...

[...]
close(7)                                = -1 EBADF (Bad file descriptor)
close(-1)                               = -1 EBADF (Bad file descriptor)
pipe2([7, 8], O_CLOEXEC)                = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb6fd0068) = 192
close(8)                                = 0
fcntl64(7, F_SETFD, 0)                  = 0
fstat64(7, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6fd2000
read(7, "[    0.074507] calling  vfp_init"..., 4096) = 4096
[...]
read(7, "s)\n[    6.228910] UBIFS: reserve"..., 4096) = 4096
read(7, "trary Executable File Formats Fi"..., 4096) = 1616
read(7, "", 4096)                       = 0
close(7)                                = 0
wait4(192, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 192
2015-03-30 01:08:05 +02:00