summaryrefslogtreecommitdiff
path: root/src/shared/fileio.c
Commit message (Collapse)AuthorAge
* fileio: simplify write_string_file_atomic() by reusing write_string_stream()Lennart Poettering2014-11-07
|
* copy: teach copy_bytes() sendfile() support, and then replace ↵Lennart Poettering2014-11-07
| | | | sendfile_full() by it
* fileio: make parse_env_file() return number of parsed itemsMichal Sekletar2014-09-25
| | | | | | | | | | This commit introduces possibility to call parse_env_file_internal() and hand over extra argument where we will accumulate how many items were successfully parsed and pushed by callback. We make use of this in parse_env_file() and return number of parsed items on success instead of always returning zero. As a side-effect this commit should fix bug that locale settings in /etc/locale.conf are not overriden by options passed via kernel command line.
* cgroup: never try to create files in cgroupfs, only open them for writingLennart Poettering2014-08-15
| | | | | This should have the benefit that cg_set_attribute() returns ENOENT instead of EACCESS when we use it for non-existing attributes.
* fileio: quote more shell characters in envfilesMantas Mikulėnas2014-07-13
| | | | | | | | | Turns out, making strings shell-proof is harder than expected: # machinectl set-hostname "foo|poweroff" && . /etc/machine-info (This could be simplified by quoting *and* escaping all characters, which is harmless in shell but unnecessary.)
* fileio: simplify write_env_file()Lennart Poettering2014-07-07
|
* util: don't consider tabs special in string_has_cc() anymoreLennart Poettering2014-07-07
| | | | Instead, take a list of exceptions to our usual CC check
* machinectl: show /etc/os-release information of container in status outputLennart Poettering2014-07-03
|
* consistently order cleanup attribute before typeThomas Hindoe Paaboel Andersen2014-06-22
|
* Unify GREEDY_REALLOC and GREEDY_REALLOC_TZbigniew Jędrzejewski-Szmek2014-04-12
| | | | | | | | | | greedy_realloc() and greedy_realloc0() now store the allocated size as the count, not bytes. Replace GREEDY_REALLOC uses with GREEDY_REALLOC_T everywhere, and then rename GREEDY_REALLOC_T to GREEDY_REALLOC. It is just too error-prone to have two slightly different macros which do the same thing.
* Do not print invalid UTF-8 in error messagesZbigniew Jędrzejewski-Szmek2014-03-04
| | | | | Inexplicably, 550a40ec ('core: do not print invalid utf-8 in error messages') only fixed two paths. Convert all of them now.
* Introduce strv_consume which takes ownershipZbigniew Jędrzejewski-Szmek2014-03-04
| | | | This mirrors set_consume and makes the common use a bit nicer.
* everywhere: always use O_CLOEXEC where it makes senseLennart Poettering2014-02-13
|
* core: do not print invalid utf-8 in error messagesZbigniew Jędrzejewski-Szmek2014-02-08
|
* core: fix crashes if locale.conf contains invalid utf-8 stringGoffredo Baroncelli2014-02-08
| | | | | | | | | | | | | | | | | | | | | In the parse_env_file_push() and load_env_file_push() functions, there are two assert() call to check if the key or value parameters are utf8 valid. If the strings aren't utf8 valid, assert does abort. These function are used early by systemd to parse some files. For example '/etc/locale.conf'. In my case this file contained a not utf8 sequence, which is bad, but systemd crashed during the boot, which is even worse! The enclosed patch removes the assert and return -EINVAL if the sequence is invalid. This is possible because the caller of these function [1] checks the errors. So the check of an invalid utf8 sequence is still performed, but systemd doesn't crash anymore and logs the error. [1] parse_env_file_internal(), invoked by load_env_file() and parse_env_file()
* fix regression of read_full_file() in fileio.cShawn Landden2013-11-30
| | | | my e93c33d4aa broke this stupidly
* systemctl: add "systemctl cat"Shawn Landden2013-11-30
|
* Never call qsort on potentially NULL arraysZbigniew Jędrzejewski-Szmek2013-10-13
| | | | | | This extends 62678ded 'efi: never call qsort on potentially NULL arrays' to all other places where qsort is used and it is not obvious that the count is non-zero.
* Add more tests and fix capability loggingZbigniew Jędrzejewski-Szmek2013-09-19
|
* Spelling fix from later revision of committed patch from Shawn Landden ↵David Strauss2013-09-18
| | | | <shawn@churchofgit.com>.
* Fix capability logging when effective caps are 0Zbigniew Jędrzejewski-Szmek2013-09-18
| | | | | Shawn Landen> Doesn't this also skip the last '0' when it is all '0's? You need to keep the last one.
* util: restore get_process_capeff behaviourZbigniew Jędrzejewski-Szmek2013-09-17
| | | | | | | 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.
* Advertise hibernation only if there's enough free swapZbigniew Jędrzejewski-Szmek2013-09-13
| | | | | | | | | | | | | | | | | | | 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
* Disallow invalid UTF-8 configurationZbigniew Jędrzejewski-Szmek2013-08-28
| | | | | | | 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.
* journalctl: use _COMM= match for scriptsZbigniew Jędrzejewski-Szmek2013-07-26
| | | | | | | | | | | In case of scripts, _EXE is set to the interpreter name, and _COMM is set based on the file name. Add a match for _COMM, and _EXE if the interpreter is not a link (e.g. for yum, the interpreter is /usr/bin/python, but it is a link to /usr/bin/python2, which in turn is a link to /usr/bin/python2.7, at least on Fedora, so we end up with _EXE=/usr/bin/python2.7). I don't think that such link chasing makes sense, because the final _EXE name is more likely to change.
* core: general cgroup reworkLennart Poettering2013-06-27
| | | | | | | | | | | | | | | | Replace the very generic cgroup hookup with a much simpler one. With this change only the high-level cgroup settings remain, the ability to set arbitrary cgroup attributes is removed, so is support for adding units to arbitrary cgroup controllers or setting arbitrary paths for them (especially paths that are different for the various controllers). This also introduces a new -.slice root slice, that is the parent of system.slice and friends. This enables easy admin configuration of root-level cgrouo properties. This replaces DeviceDeny= by DevicePolicy=, and implicitly adds in /dev/null, /dev/zero and friends if DeviceAllow= is used (unless this is turned off by DevicePolicy=).
* fileio: split write_one_line_file into twoZbigniew Jędrzejewski-Szmek2013-05-06
| | | | | The new function allows one to write to an already open file.
* fileio: unify how we chop off whitespace from key and value in ↵Lennart Poettering2013-04-24
| | | | parse_env_file_internal()
* fileio.c: do not parse comments after non-whitespace charsHarald Hoyer2013-04-18
| | | | | | | | | | systemd does not want to understand comments after the first non-whitespace char occured. key=foo #comment will result into key == "foo #comment" key="foo" #comment will result into key == "foo#comment" "key= #comment" will result into key == "#comment" "key #comment" is an invalid line
* move _cleanup_ attribute in front of the typeHarald Hoyer2013-04-18
| | | | http://lists.freedesktop.org/archives/systemd-devel/2013-April/010510.html
* core/execute: report invalid environment variables from filesHarald Hoyer2013-04-17
| | | | | | | | | | | Because "export key=val" is not supported by systemd, an error is logged where the invalid assignment is coming from. Introduce strv_env_clean_log() to log invalid environment assignments, where logging is possible and allowed. parse_env_file_internal() is modified to allow WHITESPACE in keys, to report the issues later on.
* fileio:parse_env_file_internal() fix environment file parsingHarald Hoyer2013-04-17
| | | | | | | parse_env_file_internal() could not parse the following lines correctly: export key="val" key="val"#comment
* fileio: also escape $ and ` when writing out env varsMantas Mikulėnas2013-04-17
| | | | These are also considered special by sh and bash.
* fileio: don't check for errors more often than really necessaryLennart Poettering2013-04-03
|
* fileio: write proper env var write-out codeLennart Poettering2013-04-03
| | | | | | | | | This will properly escape all weird chars when writing env var files. With this in place we can now read and write environment files where the values contain arbitrary weird chars. This enables hostnamed and suchlike to finally properly save pretty host names with backlashes or quotes in them.
* shared: rework env file readerLennart Poettering2013-04-03
| | | | | | Implement this with a proper state machine, so that newlines and escaped chars can appear in string assignments. This should bring the parser much closer to shell.
* util: rename write_one_line_file() to write_string_file()Lennart Poettering2013-04-03
| | | | | You can write much more than just one line with this call (and we frequently do), so let's correct the naming.
* Always use errno > 0 to help gccZbigniew Jędrzejewski-Szmek2013-03-29
| | | | | | gcc thinks that errno might be negative, and functions could return something positive on error (-errno). Should not matter in practice, but makes an -O4 build much quieter.
* fileio: use _cleanup_Zbigniew Jędrzejewski-Szmek2013-03-13
|
* honor SELinux labels, when creating and writing config filesHarald Hoyer2013-02-14
Also split out some fileio functions to fileio.c and provide a SELinux aware pendant in fileio-label.c see https://bugzilla.redhat.com/show_bug.cgi?id=881577