summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
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-20path-util: fix breakage in path_is_mount_pointDave Reisner
This fixes 2 problems introduced by 6feeeab0bc: 1) If name_to_handle_at returns ENOSYS for the child, we'll wrongly return -ENOSYS when it returns the same for the parent. Immediately jump to the fallback logic when we get ENOSYS. 2) If name_to_handle_at returns EOPNOTSUPP for the child but suceeds for the parent, we'll be comparing an uninitialized value (mount_id) to an initialized value (mount_id_parent). Initialize the mount_id variables to invalid mount_ids to avoid this. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-20path: make the check for unsupported name_to_handle_at symmetricZbigniew Jędrzejewski-Szmek
If child supports, but the parent does not, or when the child does not support, but the parent does, assume the child is a mount point. Only if neither supports use the fallback. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-20path: follow symbolic link for parent path (2)Umut Tezduyar Lindskog
c0e57ba9e22ee937722958d8b912ade2a37f206d fixed the fallback path. We should do the same for name_to_handle_at(). Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-20path: follow symbolic link for parent pathUmut Tezduyar Lindskog
[zj: When we lstat the target path, symlinks above the last component will be followed by both stat and lstat. So when we look at the parent, we should follow symlinks.] Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-20shared: strv - add strv_clear()Tom Gundersen
This frees the elements of the strv without freeing the strv itself. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-20shared: path-util - memory leakTom Gundersen
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-20fix compiler warningSusant Sahani
src/shared/utf8.c:268:13: warning: unused variable 'd' [-Wunused-variable] int d;
2014-12-20src/shared/util.c: fix tempfn_xxxxxx()Anthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-20configure.ac: add a generic --enable-debug, replace --enable-hashmap-debugMichal Schmidt
There will be more debugging options later. --enable-debug will enable them all. --enable-debug=hashmap will enable only hashmap debugging. Also rename the C #define to ENABLE_DEBUG_* pattern. NOTE: We add the debugging code to hashmap.{c,h} but do not add the option in configure.ac. We may do so at a later time. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-20src/shared/utf8.c: follow upstream adding utf8_encode_unichar()Lennart Poettering
This is part of upstream's e7eebcfc42f00aa481ef31abc8e7e243c16f5b2c in which they add a minimal JSON tokenizer. We don't add that but update utf8 stuff from that commit to follow upstream more closely. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-20shared/hashmap.h: fix commentMichal Schmidt
An early version used underscore prefixes for internal functions, but the current version uses the prefix "internal_". 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-17path-util: no need to check whether p is absolute twiceLennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-17blkid: Warn when rejecting a superblock with a bad csumGabriel de Perthuis
Bump libblkid requirement from 2.20 to 2.24. util-linux 2.25 is actually required since fdbbad981cc5da8bb4ed7e9b6646e7a114745ec5 Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-17udev-builtin-btrfs: properly initialize ioctl struct to zeroesLennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-17use correct format typesThomas Hindoe Paaboel Andersen
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-11core: unify how we iterate over inotify eventsLennart Poettering
Let's add some syntactic sugar for iterating through inotify events, and use it everywhere. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-11treewide: correct spacing near eol in code commentsTorstein Husebø
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-04smack-util: remove warning when building without SMACK supportLennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-04selinux: figure out selinux context applied on exec() before closing all fdsMichal Sekletar
We need original socket_fd around otherwise mac_selinux_get_child_mls_label fails with -EINVAL return code. Also don't call setexeccon twice but rather pass context value of SELinuxContext option as an extra argument. 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-04udevd: SAS: use SAS addr + PHY id in by-path whenever possible.Maurizio Lombardi
This patch changes the naming scheme for sas disks. The original names used disk's sas address and lun, the new scheme uses sas address of the nearest expander (if available) and a phy id of the used connection. If no expander is used, the phy id of hba phy is used. Note that names that refer to RAID or other abstract devices are unchanged. Name in raid configuration: hba_pci_address-sas-raid_sas_address-lunY-partZ Name in expander bare disk configuration: hba_pci_address-sas-expander_sas_address-phyX-lunY-partZ Name format without expanders: hba_pci_address-sas-phyX-lunY-partZ Signed-off-by: Maurizio Lombardi <mlombard@redhat.com> Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-04libudev: set errno properly in all error conditions of ↵Lennart Poettering
udev_device_new_from_syspath() Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-01udev: strings in C are NUL-terminated anyway, no need to add a second NUL...Lennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-01udev: rules - ignore the lack of trailing newlineTom Gundersen
Also accept '\r' as newline character. This dropps warnings of the type: invalid key/value pair in file /usr/lib/udev/rules.d/40-usb-media-players.rules on line 26, starting at character 25 ('') Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-01udev: rules - print the first invalid characterTom Gundersen
The current code would print the character following the first invalid character. Given an udev rules-file without a trailing newline we would otherwise print garbage: invalid key/value pair in file /usr/lib/udev/rules.d/40-usb-media-players.rules on line 26, starting at character 25 ('m') This is now changed to print invalid key/value pair in file /usr/lib/udev/rules.d/40-usb-media-players.rules on line 26, starting at character 25 ('') (still not very good as printing \0 just gives the empty string) Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-01udev: rules - modernise add_rule a bitTom Gundersen
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-01udevadm hwdb: discard extra leading whitespaces in hwdbPeter Hutterer
Currently a property in the form of FOO=bar is stored as " FOO=bar", i.e. the property name contains a leading space. That's quite hard to spot. This patch discards all extra whitespaces but the first one which is required by libudev's hwdb_add_property. [zj: modify the check a bit] https://bugs.freedesktop.org/show_bug.cgi?id=82311 Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-01cgroup-util: Don't send SIGCONT after SIGKILLRoss Lagerwall
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: another round of simplificationsMichal Schmidt
Using the same scripts as in f647962d64e "treewide: yet more log_*_errno + return simplifications". 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-30treewide: drop unnecessary trailing \n in log_*() callsMichal Schmidt
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-28treewide: more log_*_errno() conversionsMichal Schmidt
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-11-28treewide: no need to negate errno for log_*_errno()Michal Schmidt
It corrrectly handles both positive and negative errno values. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
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(). Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-11-28log: rearrange log function namingLennart Poettering
- Rename log_meta() → log_internal(), to follow naming scheme of most other log functions that are usually invoked through macros, but never directly. - Rename log_info_object() to log_object_info(), simply because the object should be before any other parameters, to follow OO-style programming style. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-11-28log: add an "error" parameter to all low-level logging calls and intrdouce ↵Lennart Poettering
log_error_errno() as log calls that take error numbers This change has two benefits: - The format string %m will now resolve to the specified error (or to errno if the specified error is 0. This allows getting rid of a ton of strerror() invocations, a function that is not thread-safe. - The specified error can be passed to the journal in the ERRNO= field. Now of course, we just need somebody to convert all cases of this: log_error("Something happened: %s", strerror(-r)); into thus: log_error_errno(-r, "Something happened: %m"); Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-11-28udevadm trigger: allow matching by device nameZbigniew Jędrzejewski-Szmek
This makes udevadm trigger mirror udevadm info, except that multiple device names can be specified. Instructions in 60-keyboard.hwdb should now actually work. udevadm(8) is updated, but it could use a bit more polishing. https://bugs.freedesktop.org/show_bug.cgi?id=82311 Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-11-28udevadm: split out find_device helperZbigniew Jędrzejewski-Szmek
The idea is to unify the way that devices can be specified. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-11-27smack: introduce new SmackProcessLabel optionWaLyong Cho
In service file, if the file has some of special SMACK label in ExecStart= and systemd has no permission for the special SMACK label then permission error will occurred. To resolve this, systemd should be able to set its SMACK label to something accessible of ExecStart=. So introduce new SmackProcessLabel. If label is specified with SmackProcessLabel= then the child systemd will set its label to that. To successfully execute the ExecStart=, accessible label should be specified with SmackProcessLabel=. Additionally, by SMACK policy, if the file in ExecStart= has no SMACK64EXEC then the executed process will have given label by SmackProcessLabel=. But if the file has SMACK64EXEC then the SMACK64EXEC label will be overridden. [zj: reword man page] Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-11-20set: make set_consume() actually free the allocated string if the string ↵Lennart Poettering
already is in the set Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-11-17log: unchecked return value from librarySusant Sahani
fix 1237557 Unchecked return value from library Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-11-17udev: silence TOCTOU warning when creating a directoryRonny Chevalier
CID#979416. There is no real race here to fix, but lets make coverity happy and rework the code. Note that we still fail if the directory is removed _after_ we ran mkdir(), so the same race is still there. Coverity is complaining, though. Rewrite the code to make it happy. (David: rewrote the commit-message to note that this is not a race. If I'm wrong, blame me, not Ronny!) Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-11-16src/udev: update the definition of udev_event_execute_ruleAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>