summaryrefslogtreecommitdiff
path: root/src/shared/util.c
Commit message (Collapse)AuthorAge
* Prep v221: Update and clean up build system to sync with upstreamSven Eden2017-03-14
| | | | | | | | | | | | | | This commit replays the moving around of source files that have been done between systemd-219 and systemd-221. Further the Makefile.am is synchronized with the upstream version and then "re-cleaned". A lot of functions, that are not used anywhere in elogind have been coated into #if 0/#endif directives to further shorten the list of dependencies. All unneeded files have been removed.
* fileio: consolidate write_string_file*()Daniel Mack2017-03-14
| | | | | | | Merge write_string_file(), write_string_file_no_create() and write_string_file_atomic() into write_string_file() and provide a flags mask that allows combinations of atomic writing, newline appending and automatic file creation. Change all users accordingly.
* util: Introduce unquote_first_word_and_warnFilipe Brandenburger2017-03-14
| | | | | | | | | It will try to unquot_first_word, but if it runs into escaping problems it will retry it adding UNQUOTE_CUNESCAPE_RELAX to the flags. If it succeeds on the second try, it will log a warning about it. If it fails both times, it will log an error. Add test cases to confirm it behaves as expected.
* util: New flag UNQUOTE_UNESCAPE_RELAX for unquote_first_wordFilipe Brandenburger2017-03-14
| | | | | | | | | | | | | | | | The new flag UNQUOTE_UNESCAPE_RELAX preserves unrecognized escape sequences verbatim in unquote_first_word, either when it's a trailing backslash (similar to UNQUOTE_RELAX, but in this case keep the extra backslash in the output) or in the middle of a sequence string. Add unit test cases to ensure the new flag works as expected and to prevent regressions from being introduced. Tested with a follow up commit converting config_parse_exec() to start using unquote_first_word, in which case this flags makes it possible to preserve unrecognized escape sequences. Relevant bug: https://bugs.freedesktop.org/show_bug.cgi?id=90794
* tree-wide: whenever we fork off a foreign child process reset signal ↵Lennart Poettering2017-03-14
| | | | | | | | | | mask/handlers Also, when the child is potentially long-running make sure to set a death signal. Also, ignore the result of the reset operations explicitly by casting them to (void).
* util: split out signal-util.[ch] from util.[ch]Lennart Poettering2017-03-14
| | | | No functional changes.
* treewide: fix typosTorstein Husebø2017-03-14
|
* Compiling.Andy Wingo2017-03-14
|
* util: introduce PERSONALITY_INVALID as macro for 0xffffffffLULennart Poettering2017-03-14
|
* util: introduce reset_uid_gid() for resetting all uids and gids to 0Lennart Poettering2017-03-14
|
* core,nspawn: unify code that moves the root dirLennart Poettering2017-03-14
|
* util: fix typoJan Synacek2017-03-14
|
* util: split all hostname related calls into hostname-util.cLennart Poettering2017-03-14
|
* util: loop_write - accept 0-length messageTom Gundersen2017-03-14
| | | | write() can send empty messages, so make sure loop_write() can do the same.
* nspawn: allow access to device nodes listed in --bind= and --bind-ro= switchesStefan Junker2017-03-14
| | | | https://bugs.freedesktop.org/show_bug.cgi?id=90385
* nspawn: skip symlink to a combined cgroup hierarchy if it already existsIago López Galeiras2017-03-14
| | | | | | If a symlink to a combined cgroup hierarchy already exists and points to the right path, skip it. This avoids an error when the cgroups are set manually before calling nspawn.
* util: optimize free_and_strdup() if NOPLennart Poettering2017-03-14
| | | | | Under the assumption that strcmp() is cheaper than memory allocation, let's avoid the allocation, if the new value is identical to the old.
* shared: Use O_EXCL with O_TMPFILE in open_tmpfileCristian Rodríguez2017-03-14
| | | | | In this usecase, the file will never be materialized with linkat().
* lockfile-util.[ch]: Split out from util.[ch]Colin Walters2017-03-14
| | | | | | Continuing the general trend of splitting up util.[ch]. I specifically want to reuse this code in https://github.com/GNOME/libglnx and having it split up will make future copy-pasting easier.
* util: be a bit safer in path_is_safe()Lennart Poettering2017-03-14
| | | | | | We should be more strict when verifying paths with path_is_safe() for potentially dangerous constructs, and that includes lengths of PATH_MAX-1 and larger. Be more accurate here.
* core: rework cgroup path parse logicLennart Poettering2017-03-14
| | | | | | | 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.
* util: make sure fd refers to regular file or directory when applying file ↵Lennart Poettering2017-03-14
| | | | | | | | | | attributes Before invoking file system ioctls we need to make sure that the specified fd actually refers to a file system object, and not a device node or similar. Otherwise we might by accident invoke unrelated device driver ioctls. For example, DRM ioctls use the same ioctl numbers as the various file system ioctls.
* util: fix typoRaul Gutierrez S2017-03-14
|
* shared: move replace_env* from util to env-utilRonny Chevalier2017-03-14
|
* shared: add terminal-util.[ch]Ronny Chevalier2017-03-14
|
* shared: add random-util.[ch]Ronny Chevalier2017-03-14
|
* shared: add formats-util.hRonny Chevalier2017-03-14
|
* shared: add process-util.[ch]Ronny Chevalier2017-03-14
|
* util: unify how we parse mode_t stringsLennart Poettering2017-03-14
|
* util: remove normalize_env_assignment(), it's unusedLennart Poettering2017-03-14
|
* util: mark unquote() static, so that new code doesn't use this anymoreLennart Poettering2017-03-14
|
* util: fix unicode decoding in unquote_first_word()Lennart Poettering2017-03-14
|
* util: when unescaping C escape sequences support C++11 \u and \U unicode ↵Lennart Poettering2017-03-14
| | | | | | literals We simply recode them in utf8.
* util: fix a typo in commentThomas Hindoe Paaboel Andersen2017-03-14
|
* util: add shell_maybe_quote() call for preparing a string for shell cmdline ↵Lennart Poettering2017-03-14
| | | | | | | | | | inclusion If necessary the passed string is enclosed in "", and all special characters escapes. This also ports over usage in bus-util.c and job.c to use this, instead of a incorrect local implementation that forgets to properly escape.
* util: cunescape - fix memleak in error pathRonny Chevalier2017-03-14
|
* util: merge change_attr_fd() and chattr_fd()Lennart Poettering2017-03-14
|
* remove duplicated includesRonny Chevalier2017-03-14
|
* util: rework cunescape(), improve error handlingLennart Poettering2017-03-14
| | | | | | | | | Change cunescape() to return a normal error code, so that we can distuingish OOM errors from parse errors. This also adds a flags parameter to control whether "relaxed" or normal parsing shall be done. If set no parse failures are generated, and the only reason why cunescape() can fail is OOM.
* util: rework rm_rf() logicLennart Poettering2017-03-14
| | | | | | | | - Move to its own file rm-rf.c - Change parameters into a single flags parameter - Remove "honour sticky" logic, it's unused these days
* bootctl: modernizationZbigniew Jędrzejewski-Szmek2017-03-14
| | | | | | | | | | | | | Use strjoina to avoid error handling, and openat to simplify things. Some fixes on the way: - ferror does not set errno, so the return value was wrong in some cases - errors are propagated in more cases - EFI/systemd was created, but EFI/systemd-boot was deleted - something is always printed on error - when checking the version, comparison was done against "systemd-bo" for some reason - return value was converted from negative to EXIT_SUCCESS/EXIT_FAILURE twice, resulting in EXIT_SUCCESS all the time
* Compiling.Andy Wingo2015-04-08
|
* fix gcc warnings about uninitialized variablesHarald Hoyer2015-03-27
| | | | | | | | | | | | | like: src/shared/install.c: In function ‘unit_file_lookup_state’: src/shared/install.c:1861:16: warning: ‘r’ may be used uninitialized in this function [-Wmaybe-uninitialized] return r < 0 ? r : state; ^ src/shared/install.c:1796:13: note: ‘r’ was declared here int r; ^
* util: rework word parsing and c unescaping codeLennart Poettering2015-03-26
| | | | | | | | | | | When parsing words from input files, optionally automatically unescape the passed strings, controllable via a new flags parameter. Make use of this in tmpfiles, and port everything else over, too. This improves parsing quite a bit, since we no longer have to process the same string multiple times with different calls, where an earlier call might corrupt the input for a later call.
* fstab-generator: don't accept missing root=, but accept root=noneTobias Hunger2015-03-25
| | | | | | | | | | | | | | | | | | | | | | | And other non-device entries (like fstab does). Mount whatever the user asked to be mounted on / on the kernel command line. Do less sanity check and do *not* bail out when the mount device looks strange or does not exist. This basically makes the changes for deviceless filesystems from yesterday unnecessary and is in line with what we do for filesystems set up in fstab. Remove some code that is now dead (reverting fb02a2775a65 and b0438462). [tomegun: - change patch title/description a bit. - don't touch the /usr logic, that would be a separate change and we don't currently have a convincing use-case for that. - don't bail out on /sys ro. This only makes sense in containers, where we would not be doing this anyway. If there is a use-case we could consider that as a separate patch.]
* fstab-generator: Support root on tmpfs (or other deviceless FS)Tobias Hunger2015-03-24
| | | | This allows for stateless systems.
* Add change_attr_fd()Goffredo Baroncelli2015-03-19
| | | | Add change_attr_fd() function to modify the file/directory attribute.
* shared - reinstate plymouth_running()Tom Gundersen2015-03-16
| | | | | This will be used by fsckd. This reverts part of 031886edfc6e96ab778c241035a8d00fb0de99d3.
* core: Remove explicit Plymouth integrationJasper St. Pierre2015-03-16
| | | | | | | | | | | | | | | | | | | | | Even if plymouth is running, it might have not displayed the splash yet, so we'll see a few lines on fbcon when we should have otherwise had nothing. Plymouth integration was added to systemd in commit 6faa11140bf776cdaeb8d22d01816e6e48296971. That same day, Plymouth got systemd integration [0]. As such, the Plymouth integration has always been obsolete, and was probably only for older Plymouth's. But I can't imagine anybody running a Plymouth from 2011 with a systemd from 2015. Remove the Plymouth/systemd integration, and let Plymouth's code tell systemd to print the details. [0] http://cgit.freedesktop.org/plymouth/commit/?id=537c16422cd49f1beeaab1ad39846a00018faec1 Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net> Cc: Daniel Drake <dsd@endlessm.com> Cc: Ray Strode <rstrode@redhat.com>
* util: check asprintf return valueZbigniew Jędrzejewski-Szmek2015-03-15
| | | | CID #1237546.