summaryrefslogtreecommitdiff
path: root/src/shared
AgeCommit message (Collapse)Author
2013-10-01util.c: ignore pollfd.revent for loop_read/loop_writeChen Jie
Let read()/write() report any error/EOF.
2013-10-01hashmap: size hashmap bucket array dynamicallyLennart Poettering
Instead of fixing the hashmap bucket array to 127 entries dynamically size it, starting with a smaller one of 31. As soon as a fill level of 75% is reached, quadruple the size, and so on. This should siginficantly optimize the lookup time in large tables (from O(n) back to O(1)), and save memory on smaller tables (which most are).
2013-10-01local: fix memory leak when putting together locale settingsLennart Poettering
Also, we need to use proper strv_env_xyz() calls when putting together the environment array, since otherwise settings won't be properly overriden. And let's get rid of strv_appendf(), is overkill and there was only one user.
2013-10-01logs-show.c: show all messages for a sliceZbigniew Jędrzejewski-Szmek
2013-09-29Fix buffer overrun when enumerating filesZbigniew Jędrzejewski-Szmek
https://bugs.freedesktop.org/show_bug.cgi?id=69887 Based-on-a-patch-by: Hans Petter Jansson <hpj@copyleft.no>
2013-09-26core: rework how we match mount units against each otherLennart Poettering
Previously to automatically create dependencies between mount units we matched every mount unit agains all others resulting in O(n^2) complexity. On setups with large amounts of mount units this might make things slow. This change replaces the matching code to use a hashtable that is keyed by a path prefix, and points to a set of units that require that path to be around. When a new mount unit is installed it is hence sufficient to simply look up this set of units via its own file system paths to know which units to order after itself. This patch also changes all unit types to only create automatic mount dependencies via the RequiresMountsFor= logic, and this is exposed to the outside to make things more transparent. With this change we still have some O(n) complexities in place when handling mounts, but that's currently unavoidable due to kernel APIs, and still substantially better than O(n^2) as before. https://bugs.freedesktop.org/show_bug.cgi?id=69740
2013-09-26unit-name: when escaping a path consider the empty path identical to the ↵Lennart Poettering
root dir
2013-09-26util: properly handle the root dir in PATH_FOREACH_PREFIXLennart Poettering
Also add PATH_FOREACH_PREFIX_MORE which includes the specified dir itself in the iteration
2013-09-26cgroup: when referencing cgroup controller trees allow omission of the pathLennart Poettering
2013-09-25util: add macro for iterating through all prefixes of a pathLennart Poettering
Syntactic sugar in a macro PATH_FOREACH_PREFIX.
2013-09-25cgroup: if we do a cgroup operation then do something on all supported ↵Lennart Poettering
controllers Previously we did operations like attach, trim or migrate only on the controllers that were enabled for a specific unit. With this changes we will now do them for all supproted controllers, and fall back to all possible prefix paths if the specified paths do not exist. This fixes issues if a controller is being disabled for a unit where it was previously enabled, and makes sure that all processes stay as "far down" the tree as groups exist.
2013-09-24support acpi firmware performance data (FPDT)Kay Sievers
Prefer firmware-provided performance data over loader-exported ones; if ACPI data is available, always use it, otherwise try to read the loader data. The firmware-provided variables start at the time the first EFI image is executed and end when the operating system exits the boot services; the (loader) time calculated in systemd-analyze increases.
2013-09-24shared: device-nodes - add include guardKay Sievers
2013-09-19Add more tests and fix capability loggingZbigniew Jędrzejewski-Szmek
2013-09-19device-nodes: move device node specific code to own fileDave Reisner
In the process, rename udev_encode_string which is poorly named for what it does. It deals specifically with encoding names that udev creates and has its own rules: utf8 is valid but some ascii is not (e.g. path separators), and everything else is simply escaped. Rename it to encode_devnode_name.
2013-09-19shared/utf8: merge implementations, remove cruftDave Reisner
This unifies the utf8 handling code which was previously duplicated in udev and systemd.
2013-09-18Spelling fix from later revision of committed patch from Shawn Landden ↵David Strauss
<shawn@churchofgit.com>.
2013-09-18Fix capability logging when effective caps are 0Zbigniew Jędrzejewski-Szmek
Shawn Landen> Doesn't this also skip the last '0' when it is all '0's? You need to keep the last one.
2013-09-18polkit: Avoid race condition in scraping /procColin Walters
If a calling process execve()s a setuid program, it can appear to be uid 0. Since we're receiving requests over DBus, avoid this by simply passing system-bus-name as a subject.
2013-09-18logs-show.c: fix enum type in function declarationZbigniew Jędrzejewski-Szmek
2013-09-17util: restore get_process_capeff behaviourZbigniew Jędrzejewski-Szmek
69ab8088 unified parsing of status files and removed the logic of skipping extra '0's when getting the effective capabilities. Restore that logic, so that the same capabilities are always mapped to the same strings in the journal.
2013-09-17logind: introduce session-devicesDavid Herrmann
A session-device is a device that is bound to a seat and used by a session-controller to run the session. This currently includes DRM, fbdev and evdev devices. A session-device can be created via RequestDevice() on the dbus API of the session. You can drop it via ReleaseDevice() again. Once the session is destroyed or you drop control of the session, all session-devices are automatically destroyed. Session devices follow the session "active" state. A device can be active/running or inactive/paused. Whenever a session is not the active session, no session-device of it can be active. That is, if a session is not in foreground, all session-devices are paused. Whenever a session becomes active, all devices are resumed/activated by logind. If it fails, a device may stay paused. With every session-device you request, you also get a file-descriptor back. logind keeps a copy of this fd and uses kernel specific calls to pause/resume the file-descriptors. For example, a DRM fd is muted by logind as long as a given session is not active. Hence, the fd of the application is also muted. Once the session gets active, logind unmutes the fd and the application will get DRM access again. This, however, requires kernel support. DRM devices provide DRM-Master for synchronization, evdev devices have EVIOCREVOKE (pending on linux-input-ML). fbdev devices do not provide such synchronization methods (and never will). Note that for evdev devices, we call EVIOCREVOKE once a session gets inactive. However, this cannot be undone (the fd is still valid but mostly unusable). So we reopen a new fd once the session is activated and send it together with the ResumeDevice() signal. With this infrastructure in place, compositors can now run without CAP_SYS_ADMIN (that is, without being root). They use RequestControl() to acquire a session and listen for devices via udev_monitor. For every device they want to open, they call RequestDevice() on logind. This returns a fd which they can use now. They no longer have to open the devices themselves or call any privileged ioctls. This is all done by logind. Session-switches are still bound to VTs. Hence, compositors will get notified via the usual VT mechanisms and can cleanup their state. Once the VT switch is acknowledged as usual, logind will get notified via sysfs and pause the old-session's devices and resume the devices of the new session. To allow using this infrastructure with systems without VTs, we provide notification signals. logind sends PauseDevice("force") dbus signals to the current session controller for every device that it pauses. And it sends ResumeDevice signals for every device that it resumes. For seats with VTs this is sent _after_ the VT switch is acknowledged. Because the compositor already acknowledged that it cleaned-up all devices. However, for seats without VTs, this is used to notify the active compositor that the session is about to be deactivated. That is, logind sends PauseDevice("force") for each active device and then performs the session-switch. The session-switch changes the "Active" property of the session which can be monitored by the compositor. The new session is activated and the ResumeDevice events are sent. For seats without VTs, this is a forced session-switch. As this is not backwards-compatible (xserver actually crashes, weston drops the related devices, ..) we also provide an acknowledged session-switch. Note that this is never used for sessions with VTs. You use the acknowledged VT-switch on these seats. An acknowledged session switch sends PauseDevice("pause") instead of PauseDevice("force") to the active session. It schedules a short timeout and waits for the session to acknowledge each of them with PauseDeviceComplete(). Once all are acknowledged, or the session ran out of time, a PauseDevice("force") is sent for all remaining active devices and the session switch is performed. Note that this is only partially implemented, yet, as we don't allow multi-session without VTs, yet. A follow up commit will hook it up and implemented the acknowledgements+timeout. The implementation is quite simple. We use major/minor exclusively to identify devices on the bus. On RequestDevice() we retrieve the udev_device from the major/minor and search for an existing "Device" object. If no exists, we create it. This guarantees us that we are notified whenever the device changes seats or is removed. We create a new SessionDevice object and link it to the related Session and Device. Session->devices is a hashtable to lookup SessionDevice objects via major/minor. Device->session_devices is a linked list so we can release all linked session-devices once a device vanishes. Now we only have to hook this up in seat_set_active() so we correctly change device states during session-switches. As mentioned earlier, these are forced state-changes as VTs are currently used exclusively for multi-session implementations. Everything else are hooks to release all session-devices once the controller changes or a session is closed or removed.
2013-09-17Use first partition in /proc/swaps for hibernation testZbigniew Jędrzejewski-Szmek
It seems that the kernel uses the first configured partition for hibernation. If it is too full, hibernation will fail. Test that directly.
2013-09-17Use udev_encode_string in fstab_node_to_udev_nodeDave Reisner
Resolves a longstanding bug which caused this function to wrongly handle (escape) valid utf8 characters.
2013-09-17move utf8 functions from libudev-private.h to utf8.hDave Reisner
There's now some more obvious overlap amongst the two utf8 validation functions, but no more than there already was previously. This also adds some menial tests for anyone who wants to do more merging of these two in the future.
2013-09-17specifier: rework specifier calls to return proper error messageLennart Poettering
Previously the specifier calls could only indicate OOM by returning NULL. With this change they will return negative errno-style error codes like everything else.
2013-09-16Verify validity of session name when received from outsideZbigniew Jędrzejewski-Szmek
Only ASCII letters and digits are allowed.
2013-09-16Assume that /proc/meminfo can be missingZbigniew Jędrzejewski-Szmek
Travis tests are failing, probably because /proc/meminfo is not available in the test environment. The same might be true in some virtualized systems, so just treat missing /proc/meminfo as a sign that hibernation is not possible.
2013-09-13Advertise hibernation only if there's enough free swapZbigniew Jędrzejewski-Szmek
Condition that is checked is taken from upower: active(anon) < free swap * 0.98 This is really stupid, because the kernel knows the situation better, e.g. there could be two swap files, and then hibernation would be impossible despite passing this check, or the kernel could start supporting compressed swap and/or compressed hibernation images, and then this this check would be too stringent. Nevertheless, until we have something better, this should at least return a true negative if there's no swap. Logging of capabilities in the journal is changed to not strip leading zeros. I consider this more readable anyway. http://cgit.freedesktop.org/upower/tree/src/up-daemon.c#n613 https://bugzilla.redhat.com/show_bug.cgi?id=1007059
2013-09-12Actually allow tabs in environment filesZbigniew Jędrzejewski-Szmek
Fixup for ac4c8d6da8b5e.
2013-09-11Allow tabs in environment filesZbigniew Jędrzejewski-Szmek
bash allows them, and so should we. string_has_cc is changed to allow tabs, and if they are not wanted, they must be now checked for explicitly. There are two other callers, apart from the env file loaders, and one already checked anyway, and the other is changed to check. https://bugs.freedesktop.org/show_bug.cgi?id=68592 https://bugs.gentoo.org/show_bug.cgi?id=481554
2013-09-09Fix two compiler warningsZbigniew Jędrzejewski-Szmek
2013-09-09run: allow non-absolute paths as commandZbigniew Jędrzejewski-Szmek
2013-09-09path-util.c: small modernizationZbigniew Jędrzejewski-Szmek
2013-09-09systemd-run: properly escape argumentsZbigniew Jędrzejewski-Szmek
Spaces, quotes, and such, were not properly escaped. We should write them like we read them. https://bugs.freedesktop.org/show_bug.cgi?id=67971
2013-08-28Disallow invalid UTF-8 configurationZbigniew Jędrzejewski-Szmek
It is best to catch such errors early. If invalid UTF-8 ends up being given to dbus methods, the program will crash: process 20801: arguments to dbus_message_iter_append_basic() were incorrect, assertion "_dbus_check_is_valid_utf8 (*string_p)" failed in file dbus-message.c line 2598.
2013-08-23"-" prefix for InaccessibleDirectories and ReadOnlyDirectoriesMaciej Wereski
2013-08-22Optimize startswith() to macroKay Sievers
I guess it's easier and cleaner anyway to use simple static inline functions instead of defines.
2013-08-22remove hasprefix(), use startswith()Shawn Landden
2013-08-21logs-show: fix condition for ellipsizing multi-line messagesZbigniew Jędrzejewski-Szmek
falconindy> the ellipsizing seems a bit wrong here.... I got a bit carried away with putting dots everywhere :)
2013-08-20logs-show: show source timestamp in verbose modeZbigniew Jędrzejewski-Szmek
This makes verbose behave like short mode, i.e. try to show the source timestamp, and fall back to journald timestamp only if unavailable or unparsable. I think verbose should be like short, only showing more fields, and showing different timestamps would be confusing.
2013-08-20logs-show: add short-precise mode with us timestampsZbigniew Jędrzejewski-Szmek
Also, always show us timestamps in verbose mode. https://bugzilla.redhat.com/show_bug.cgi?id=991678
2013-08-20Rename F_TYPE_CMP() to F_TYPE_EQUAL()Zbigniew Jędrzejewski-Szmek
2013-08-16build-sys: Add configure check for linux/btrfs.hMichael Marineau
btrfs.h was added to uapi in Linux 3.9. To fix building with older header versions this adds a configure check for the header and re-adds btrfs definitions to missing.h which was removed in bed2e820 along with two other ioctls used by gpt-auto-generator. [ Apparently, btrfs.h was only added recently: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=55e301fd57a6239ec14b91a1cf2e70b3dd135194 let's re-add it for now -- kay ]
2013-08-15hashmap: remove empty linesKay Sievers
2013-08-13missing: use btrfs.h instead of defining our own btrfs structuresLennart Poettering
2013-08-11logs-show: limit to 3 lines and use dots if not showing full messageZbigniew Jędrzejewski-Szmek
So far, we would show up to 128 bytes from a message, simply cutting of the rest. With multiline messages, it is quite common for a message to be longer than that, and this model doesn't really work anymore. A new limit is added: up to 3 lines will be shown, unless --full is used (c.f. first line below). The limit for bytes is extended to 300 bytes. An ellipsis will always be used, if some form of truncation occurs. If the tail of the message is cut off, either because of length or line limit, dots will be shown at the end of the last line. If this last line is short, the dots will be simply appended. If the last line is too long for that, it will be ellipsized with dots at the very end. Note that the limits are in bytes, not characters, and we suck at outputting unicode strings (c.f. last three lines below). Aug 11 10:46:21 fedora python[67]: test message line line... Aug 11 10:50:47 fedora python[76]: test message word word word word word word word word word word word wor... Aug 11 10:55:11 fedora python[83]: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx... Aug 11 11:03:21 fedora python[90]: ąąąąąąąąąąąąąąąąąąąąąąąąąąąąąą... Aug 11 11:03:53 fedora python[97]: aąąąąąąąąąąąąąąąąąąąąąąąąąąąąąą... Aug 11 11:25:45 fedora python[121]: aąąąąąąąąąąąąąąąąąąąąąąąąąąąąąąąąąą�...
2013-08-11logs-show: fix indentation for 2nd and later lines, show lines in fullZbigniew Jędrzejewski-Szmek
Now --full will show long fields in full, like it already did with --all.
2013-08-11systemctl: show hint about --full when lines don't fitZbigniew Jędrzejewski-Szmek
2013-08-04systemd-delta: Only print colors when on a ttyDaniel Schaal
This make systemd-delta follow the behaviour of systemctl and journalctl. https://bugs.freedesktop.org/show_bug.cgi?id=67656 [zj: unify color query methods between those three programs.]