summaryrefslogtreecommitdiff
path: root/src/shared/util.c
AgeCommit message (Collapse)Author
2016-04-24shared: remove unused function `execute_command`Murray Calavera
Signed-off-by: Murray Calavera <murray.calavera@gmail.com> Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2016-03-21src/shared/util.c: fix typoAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2016-03-21src/shared/util.c: add fallback for ppoll(), issue #129.Anthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-27src/shared/util.h: import loop_write() from upstreamAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-26src/shared/util.[ch]: import functions from upstream for previous commitsAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-04core: rework cgroup path parse logicLennart Poettering
Various cleanups, be stricter when parsing unit paths. Most importantly: return the root slice "-.slice" when asked for slice of paths that contain no slice component. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-04util: Fix assertion in split() on missing 'Martin Pitt
When parsing a unit with a trailing slash after an escaped line break, like ExecStart=/bin/echo 'foo \ bar' the split() function (through config_parse()) asserted and crashed pid 1: Assertion 'current[*l + 1] == quotechars[0]' failed at ../src/shared/util.c:583, function split(). Aborting. Fix this by returning an error in this case ("trailing garbage"). Add corresponding test case. Also fix the missing "unit" argument of config_parse_exec() in the comment. https://launchpad.net/bugs/1447243
2015-04-15Ronny Chevalier <chevalier.ronny@gmail.com>shared: add terminal-util.[ch]Ronny Chevalier
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-14shared: add random-util.[ch]Ronny Chevalier
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-14shared: add process-util.[ch]Ronny Chevalier
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12util.c: follow upstream's comments.Anthony G. Basile
2015-03-18Check that EWOULDBLOCK is the same as EAGAINZbigniew Jędrzejewski-Szmek
It certainly is everywhere on Linux, but as a courtesy to people doing some strange cross-compilation, check that the assumption holds. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-18libudev: udev_device_add_property - implicitly mark properties for saving to dbTom Gundersen
Note: We also ported touch() and touch_file() from upstream. -AGB. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-18shared: import close_many() from upstreamAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-01shared: introduce cmsg_close_all() callLennart Poettering
The call iterates through cmsg list and closes all fds passed via SCM_RIGHTS. This patch also ensures the call is used wherever appropriate, where we might get spurious fds sent and we should better close them, then leave them lying around. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-02-11Minor cleanupsAnthony G. Basile
2015-02-11udev: event - move renaming of udev_device to libudevTom Gundersen
This is not exposed in the public API. We want to simplify the internal libudev-device API as much as possible so that it will be simpler to rip the whole thing out in the future. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-01-25util: Add some missing hidden_file() suffixesMartin Pitt
dpkg itself also uses *.dpkg-dist, while .dpkg-{bak,backup,remove} are being used by dpkg-maintscript-helper. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-01-25src/shared/util.{c,h}: fix build when mkostemp is not supportedPeter Seiderer
Not all instance of mkostemp were protected with #ifndef HAVE_DECL_MKOSTEMP. We fix this for the definition of the wrapper mkostemp_safe() in the c file and in the header. Signed-off-by: Peter Seiderer <ps.report@gmx.net> Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-29util: 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. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-20util: 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. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-20util: 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 ".#". Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-20Treat 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 Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-20src/shared/util.c: fix tempfn_xxxxxx()Anthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-20src/shared/util.c: follow upstream on tempfn_xxxxxx()Lennart Poettering
Upstream change the behaviour of tempfn_xxxxxx() to make the following work: # systemd-nspawn -xb -D / -M foobar in commit c4e34a612c81266773cf8358cb38a43d2e43474e. We have no reason not to follow that change even though eudev has nothing to do with nspawn. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-20util: minor simplification for loop_write() and loop_read()Lennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-20util: 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. NOTE: eudev doesn't have filename_is_safe() -- AGB Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-04util: don't shadow variableThomas Hindoe Paaboel Andersen
environ is already defined in unistd.h Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-01treewide: introduce UID_INVALID (and friends) as macro for (uid_t) -1Lennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-01treewide: 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. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-11-28util: add function getting proc environJakub Filak
On the contrary of env, the added function returns all characters cescaped, because it improves reproducibility. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-11-28util: skip incomplete ucred information in getpeersec()Lennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-11-14src/shared/util.{c,h}: import needed functions from upstreamAnthony G. Basile
2014-11-14util: simplify proc_cmdline() to reuse get_process_cmdline()Lennart Poettering
Also, make all parsing of the kernel cmdline non-fatal. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-11-14condition: unify condition logic in one fileLennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-31util: don't block on getrandom()Lennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-31util: 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. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-30util: unify how we see srand()Lennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-26label: move is_dir() to util.cLennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-13src/shared/util.c: remove unneeded error check, following upstreamAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-13src/shared/util.c: final cosmetic changeAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-13src/shared/util.c: more cosmetic changesAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-13src/shared/util.c: cosmetic changes to more easily follow upstreamAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-09-18src/shared: import upstream code needed for recent commitsAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-08-22util: change return value of startswith() to non-constLennart Poettering
This way we can use it on non-const strings, and don't end up with a const'ified result. This is similar to libc's strstr() which also takes a const string but returns a non-const one. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-08-14src/shared: import more code cleanups from upstreamAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-08-14src/shared: import many code cleanups from upstreamAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-08-05src/shared: refactor shared codeAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2012-11-15Isolation of udev code from remaining systemdAnthony G. Basile
This commit is a first attempt to isolate the udev code from the remaining code base. It intentionally does not modify any files but purely delete files which, on a first examination, appear to not be needed. This is a sweeping commit which may easily have missed needed code. Files can be retrieved by doing a checkout from the previous commit: git checkout 2944f347d0 -- <filename>
2012-11-14util: add strreplace() to replace a substring by another stringLennart Poettering