summaryrefslogtreecommitdiff
path: root/src/shared/util.c
AgeCommit message (Collapse)Author
2014-12-25machined: beef up machined image listing with creation/modification times of ↵Lennart Poettering
subvolumes We make use of the btrfs subvol crtime for this, and for gpt images of a manually managed xattr, if we can.
2014-12-24util: make creation time xattr logic more genericLennart Poettering
2014-12-24util: fix strict aliasing violations in use of struct inotify_event v5Shawn Paul Landden
There is alot of cleanup that will have to happen to turn on -fstrict-aliasing, but I think our code should be "correct" to the rule.
2014-12-23machined: add new call OpenMachineLogin() that starts a getty in a container ↵Lennart Poettering
on a pty and returns the pty master fd to the client This is a one-stop solution for "machinectl login", and should simplify getting logins in containers.
2014-12-23util: add allocation loop to gettyname_malloc()Lennart Poettering
2014-12-23systemd-run: support -t mode when combined with -MLennart Poettering
For that, ask machined for a container PTY and use that.
2014-12-19machined: add new GetImage() bus call for retrieving the bus path for an imageLennart Poettering
2014-12-19util: rename ignore_file() to hidden_file()Lennart Poettering
hidden_file() is a bit more precise, since dot files usually shouldn't be ignored, but certainly be considered hidden.
2014-12-19util: when creating temporary filename for atomic creation of files, add an ↵Lennart Poettering
extra "#" to the name That way, we have a simple, somewhat reliable way to detect such temporary files, by simply checking if they start with ".#".
2014-12-19util: make sure rm_rf() can be called on symlinks (with the effect of ↵Lennart Poettering
deleting it)
2014-12-18Treat a trailing backslash as an errorZbigniew Jędrzejewski-Szmek
Commit a2a5291b3f5 changed the parser to reject unfinished quoted strings. Unfortunately it introduced an error where a trailing backslash would case an infinite loop. Of course this must fixed, but the question is what to to instead. Allowing trailing backslashes and treating them as normal characters would be one option, but this seems suboptimal. First, there would be inconsistency between handling of quoting and of backslashes. Second, a trailing backslash is most likely an error, at it seems better to point it out to the user than to try to continue. Updated rules: ExecStart=/bin/echo \\ → OK, prints a backslash ExecStart=/bin/echo \ → error ExecStart=/bin/echo "x → error ExecStart=/bin/echo "x"y → error
2014-12-18util: in make_stdio() use dup2() rather than dup3()Lennart Poettering
dup3() allows setting O_CLOEXEC which we are not interested in. However, it also fails if called with the same fd as input and output, which is something we don't want. Hence use dup2(). Also, we need to explicitly turn off O_CLOEXEC for the fds, in case the input fd was O_CLOEXEC and < 3.
2014-12-12nspawn: allow spawning ephemeral nspawn containers based on the root file ↵Lennart Poettering
system of the OS This works now: # systemd-nspawn -xb -D / -M foobar Which boots up an ephemeral container, based on the host's root file system. Or in other words: you can now run the very same host OS you booted your system with also in a container, on top of it, without having it interfere. Great for testing whether the init system you are hacking on still boots without reboot the system!
2014-12-12util: minor simplification for loop_write() and loop_read()Lennart Poettering
2014-12-12util: when using basename() for creating temporary files, verify the ↵Lennart Poettering
resulting name is actually valid Also, rename filename_is_safe() to filename_is_valid(), since it actually does a full validation for what the kernel will accept as file name, it's not just a heuristic.
2014-12-11shared: correct spacing near eol in code commentsTorstein Husebø
2014-12-09treewide: sanitize loop_writeZbigniew Jędrzejewski-Szmek
loop_write() didn't follow the usual systemd rules and returned status partially in errno and required extensive checks from callers. Some of the callers dealt with this properly, but many did not, treating partial writes as successful. Simplify things by conforming to usual rules.
2014-12-10core: unify how we iterate over inotify eventsLennart Poettering
Let's add some syntactic sugar for iterating through inotify events, and use it everywhere.
2014-12-09sd-bus: get rid of PID starttime conceptLennart Poettering
As kdbus no longer exports this, remove all traces from sd-bus too
2014-12-03util: don't shadow variableThomas Hindoe Paaboel Andersen
environ is already defined in unistd.h
2014-12-03machine-id-setup: add a machine_id_commit call to commit on disk a transient ↵Didier Roche
machine-id If /etc was read only at boot time with an empty /etc/machine-id, the latter will be mounted as a tmpfs and get reset at each boot. If the system becomes rw later, this functionality enables to commit in a race-free manner the transient machine-id to disk.
2014-11-29delta: diff returns 1 when files differ, ignore thisZbigniew Jędrzejewski-Szmek
https://bugs.debian/org/771397
2014-11-28treewide: introduce UID_INVALID (and friends) as macro for (uid_t) -1Lennart Poettering
2014-11-28treewide: use log_*_errno whenever %m is in the format stringMichal Schmidt
If the format string contains %m, clearly errno must have a meaningful value, so we might as well use log_*_errno to have ERRNO= logged. Using: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\((".*%m.*")/log_\1_errno(errno, \2/' Plus some whitespace, linewrap, and indent adjustments.
2014-11-28treewide: yet more log_*_errno + return simplificationsMichal Schmidt
Using: find . -name '*.[ch]' | while read f; do perl -i.mmm -e \ 'local $/; local $_=<>; s/(if\s*\([^\n]+\))\s*{\n(\s*)(log_[a-z_]*_errno\(\s*([->a-zA-Z_]+)\s*,[^;]+);\s*return\s+\g4;\s+}/\1\n\2return \3;/msg; print;' $f done And a couple of manual whitespace fixups.
2014-11-28treewide: no need to negate errno for log_*_errno()Michal Schmidt
It corrrectly handles both positive and negative errno values.
2014-11-28treewide: auto-convert the simple cases to log_*_errno()Michal Schmidt
As a followup to 086891e5c1 "log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers", use sed to convert the simple cases to use the new macros: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/' Multi-line log_*() invocations are not covered. And we also should add log_unit_*_errno().
2014-11-27kdbus: set kernel attach mask before creating the first busLennart Poettering
2014-11-27util: add function getting proc environJakub Filak
On the contrary of env, the added function returns all characters cescaped, because it improves reproducibility.
2014-11-25util: skip incomplete ucred information in getpeersec()Lennart Poettering
2014-11-21util: add functions getting proc cwd and rootJakub Filak
/proc/[pid]/cwd and /proc/[pid]/root are symliks to corresponding directories The added functions returns values of that symlinks.
2014-11-14busctl: add new "call" command to invoke methods on a serviceLennart Poettering
2014-11-10strv: rework strv_split_quoted() to use unquote_first_word()Lennart Poettering
This should make the unquoting scheme a bit less naive.
2014-11-07shared: add readlink_valueTom Gundersen
Reads the basename of the target of a symlink.
2014-11-07util: simplify normalize_env_assignment() a bitLennart Poettering
2014-11-07util: file_is_priv_sticky() is used internally in util.c only nowadays, make ↵Lennart Poettering
it static
2014-11-07util: rework /proc/cmdline parser to use unquote_first_word()Lennart Poettering
2014-11-07util: simplify proc_cmdline() to reuse get_process_cmdline()Lennart Poettering
Also, make all parsing of the kernel cmdline non-fatal.
2014-11-07util: make use of isempty() where appropriateLennart Poettering
2014-11-06condition: unify condition logic in one fileLennart Poettering
2014-11-05util: minor modernisationsLennart Poettering
2014-10-30util: unify how we see srand()Lennart Poettering
2014-10-30util: don't block on getrandom()Lennart Poettering
2014-10-29util: make use of the new getrandom() syscall if it is available when ↵Lennart Poettering
needing entropy Doesn't require an fd, and could be a bit faster, so let's make use of it, if it is available.
2014-10-27util: fix copy-paste error and actually set the new hostnameMichal Sekletar
Reported-by: sztanpet on irc
2014-10-27util: introduce sethostname_idempotentMichal Sekletar
Function queries system hostname and applies changes only when necessary. Also, migrate all client of sethostname to sethostname_idempotent while at it.
2014-10-23label: move is_dir() to util.cLennart Poettering
2014-10-09util: avoid double close of fdThomas Hindoe Paaboel Andersen
We could end with a double close if we close the fd loop and flush_fd fails. That would make us goto fail and there we close the fd once again. This patch sets the fd to the return value for safe_close: -1 A fd with negative value will be ignored by the next call to safe_close. CID#996223
2014-10-01shared: util - use nicer idiom to silence CoverityZbigniew Jędrzejewski-Szmek
Change the other spot too.
2014-09-30shared: util - use nicer idiom to silence CoverityTom Gundersen
Suggested by Zbigniew.