summaryrefslogtreecommitdiff
path: root/src/hwdb
AgeCommit message (Collapse)AuthorFilesLines
2018-11-20Split out pretty-print.c and move pager.c and main-func.h to shared/Zbigniew Jędrzejewski-Szmek1-1/+1
This is high-level functionality, and fits better in shared/ (which is for our executables), than in basic/ (which is also for libraries).
2018-11-19util-lib: move main() definition macros to its own header fileLennart Poettering1-0/+1
This way, we can extend the macro a bit with stuff pulled in from other headers without this affecting everything which pulls in macro.h, which is one of our most basic headers. This is just refactoring, no change in behaviour, in prepartion for later changes.
2018-11-17hwdb: define main through macroZbigniew Jędrzejewski-Szmek1-6/+5
2018-09-19hwdb,udevadm: also unify hwdb_query() and hwdb_test()Yu Watanabe1-19/+1
2018-09-19hwdb: unify duplicated code and move it to hwdb-util.cYu Watanabe1-650/+11
Both 'systemd-hwdb update' and 'udevadm hwdb --update' creates hwdb database. The database created by systemd-hwdb containes additional information such that priority, line number, and source filename. The unified function 'hwdb_update()' can take a flag 'compat' which controls the format version of created database.
2018-09-19hwdb: use _cleanup_ attribute at one more placeYu Watanabe1-11/+9
2018-09-19hwdb: make trie_node_cleanup() can take NULLYu Watanabe1-3/+4
2018-09-19tree-wide: use typesafe_bsearch() or typesafe_bsearch_r()Yu Watanabe1-2/+2
2018-09-19tree-wide: use typesafe_qsort_r()Yu Watanabe1-9/+5
2018-09-19tree-wide: use typesafe_qsort()Yu Watanabe1-7/+4
2018-08-20tree-wide: add clickable man page link to all --help textsLennart Poettering1-6/+18
This is a bit like the info link in most of GNU's --help texts, but we don't do info but man pages, and we make them properly clickable on terminal supporting that, because awesome. I think it's generally advisable to link up our (brief) --help texts and our (more comprehensive) man pages a bit, so this should be an easy and straight-forward way to do it.
2018-06-20tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek1-3/+0
Fixes #9320. for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms' done
2018-06-14tree-wide: beautify remaining copyright statementsLennart Poettering1-1/+1
Let's unify an beautify our remaining copyright statements, with a unicode ©. This means our copyright statements are now always formatted the same way. Yay.
2018-06-14tree-wide: drop 'This file is part of systemd' blurbLennart Poettering1-2/+0
This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
2018-04-24systemd-hwdb: reflow help() to avoid a line breakZbigniew Jędrzejewski-Szmek1-8/+7
2018-04-23systemd-hwdb update: Return non-zero exit code on error when --strict is usedNicolas Boichat1-21/+41
- Add a new flag --strict to tell systemd-hwdb to return a non-zero code on error. - Make systemd-hwdb update return an error when any parsing error occurs (only if strict flag is set).
2018-04-06tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek1-13/+0
Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
2018-03-27Merge pull request #8576 from keszybz/oss-fuzzEvgeny Vereshchagin1-1/+1
oss-fuzz adjustments and other cleanups
2018-03-27label: rework label_fix() implementations (#8583)Lennart Poettering1-1/+1
This reworks the SELinux and SMACK label fixing calls in a number of ways: 1. The two separate boolean arguments of these functions are converted into a flags type LabelFixFlags. 2. The operations are now implemented based on O_PATH. This should resolve TTOCTTOU races between determining the label for the file system object and applying it, as it it allows to pin the object while we are operating on it. 3. When changing a label fails we'll query the label previously set, and if matches what we want to set anyway we'll suppress the error. Also, all calls to label_fix() are now (void)ified, when we ignore the return values. Fixes: #8566
2018-03-26tree-wide: add bsearch_safe and use where appropriateZbigniew Jędrzejewski-Szmek1-1/+1
Should fix #8557.
2018-03-19networkctl,hwdb: make verbs staticYu Watanabe1-1/+1
2018-03-02coccinelle: add reallocarray() coccinelle scriptLennart Poettering1-2/+2
Let's systematically make use of reallocarray() whereever we invoke realloc() with a product of two values.
2017-11-19Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek1-0/+1
This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
2017-09-13exec-util,conf-files: skip non-executable files in execute_directories()Lennart Poettering1-1/+1
Fixes: #6787
2017-08-17"Don't fear the fsync()"Alan Jenkins1-9/+16
For files which are vital to boot 1. Avoid opening any window where power loss will zero them out or worse. I know app developers all coded to the ext3 implementation, but the only formal documentation we have says we're broken if we actually rely on it. E.g. * `man mount`, search for `auto_da_alloc`. * http://www.linux-mtd.infradead.org/faq/ubifs.html#L_atomic_change * https://thunk.org/tytso/blog/2009/03/15/dont-fear-the-fsync/ 2. If we tell the kernel we're interested in writing them to disk, it will tell us if that fails. So at minimum, this means we play our part in notifying the user about errors. I refactored error-handling in `udevadm-hwdb` a little. It turns out I did exactly the same as had already been done in the `systemd-hwdb` version, i.e. commit d702dcd.
2017-07-18build-sys: drop automake supportZbigniew Jędrzejewski-Szmek1-1/+0
v2: - also mention m4
2017-05-31hwdb: use path_join() to generate the hwdb_bin path (#6063)Michael Biebl1-1/+2
This avoids having double slashes which can confuse selinux.
2017-04-04tree-wide: standardize on $(PACKAGE_VERSION) for the version stringZbigniew Jędrzejewski-Szmek1-1/+1
We defined both $(VERSION) and $(PACKAGE_VERSION) with the same contents. $(PACKAGE_VERSION) is slightly more descriptive, so settle on that, and drop the other define.
2016-12-11hwdb: emit warning when matches are specified at the very end of fileZbigniew Jędrzejewski-Szmek1-2/+6
This is also an error, but it wasn't caught. [/tmp/tmp.YWeKax4fMI/etc/udev/hwdb.d/10-bad.hwdb:26] Property expected, ignoring record with no properties
2016-12-01hwdb: fix detection of assignments with no keyZbigniew Jędrzejewski-Szmek1-3/+7
The code was trying to detect an empty key, but property lines always start with a space, so the condition was wrong. Now: [/tmp/tmp.YWeKax4fMI/etc/udev/hwdb.d/10-bad.hwdb:14] Empty key in " =NO_NAME", ignoring [/tmp/tmp.YWeKax4fMI/etc/udev/hwdb.d/10-bad.hwdb:15] Empty value in " NO_VALUE=", ignoring
2016-12-01hwdb: improve and test syntax error messagesZbigniew Jędrzejewski-Szmek1-14/+16
Since syntax error are non-fatal, downgrade them to warnings. Use log_syntax to have uniform formatting including the line number. State machine states like DATA and MATCH are internal, user-facing messages should use the names from hwdb(7): match, property, record. Also change "key/value" to "key-value", since there's no alternative here, both parts must be present. [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:2] Property expected, ignoring record with no properties [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:5] Property expected, ignoring record with no properties [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:9] Property expected, ignoring record with no properties [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:11] Key/value pair expected but got " NO_VALUE", ignoring [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:18] Property or empty line expected, got "BAD:7:match at wrong place", ignoring record [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:22] Property or empty line expected, got "BAD:8:match at wrong place", ignoring record [/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:23] Match expected but got indented property " Z=z", ignoring line squash! hwdb: improve syntax error messages
2016-11-30hwdb: rename err to r and use _cleanup_ in two more placesZbigniew Jędrzejewski-Szmek1-20/+20
2016-11-30hwdb: simplify error handling in trie_storeZbigniew Jędrzejewski-Szmek1-23/+18
fclose() can also set errno, so the attempts to protect errno that the code made were not successful. Simplify things by immediately saving errno to r.
2016-11-30hwdb, sd-hwdb: rework priority comparison when loading propertiesZbigniew Jędrzejewski-Szmek1-13/+18
We cannot compare filenames directly, because paths are not sortable lexicographically, e.g. /etc/udev is "later" (has higher priority) than /usr/lib/udev. The on-disk format is changed to have a separate field for "file priority", which is stored when writing the binary file, and then loaded and used in comparisons. For data in the previous format (as generated by systemd 232), this information is not available, and we use a trick where the offset into the string table is used as a proxy for priority. Most of the time strings are stored in the order in which the files were processed. This is not entirely reliable, but is good enough to properly order /usr/lib and /etc/, which are the two most common cases. This hack is included because it allows proper parsing of files until the binary hwdb is regenerated. Instead of adding a new field, I reduced the size of line_number from 64 to 32 bits, and added a 16 bit priority field, and 16 bits of padding. Adding a new field of 16 bytes would significantly screw up alignment and increase file size, and line number realistically don't need more than ~20 bits. Fixes #4750.
2016-11-30hwdb: remove path comparison which broke overriding of propertiesZbigniew Jędrzejewski-Szmek1-11/+2
Partial fix for #4750. We would compare strings like "/usr/lib/udev/hwdb.d/something.hwdb" and "/etc/udev/hwdb.db/something.hwdb" and conclude that the first has higher priority. Since we process files in order (higher priority later), no comparison is necessary when loading. This partially undoes 3a04b789c6f17dff2000a3cdbeaaf86baa604524 (not in spirit, but in the implementation).
2016-11-03Merge pull request #4510 from keszybz/tree-wide-cleanupsLennart Poettering1-1/+1
Tree wide cleanups
2016-10-26hwdb: fix error check of wrong variable (#4499)Thomas H. P. Andersen1-2/+2
We updated 'fn' but checked 'v' instead. From 698c5a17 Spotted with PVS
2016-10-23tree-wide: drop NULL sentinel from strjoinZbigniew Jędrzejewski-Szmek1-1/+1
This makes strjoin and strjoina more similar and avoids the useless final argument. spatch -I . -I ./src -I ./src/basic -I ./src/basic -I ./src/shared -I ./src/shared -I ./src/network -I ./src/locale -I ./src/login -I ./src/journal -I ./src/journal -I ./src/timedate -I ./src/timesync -I ./src/nspawn -I ./src/resolve -I ./src/resolve -I ./src/systemd -I ./src/core -I ./src/core -I ./src/libudev -I ./src/udev -I ./src/udev/net -I ./src/udev -I ./src/libsystemd/sd-bus -I ./src/libsystemd/sd-event -I ./src/libsystemd/sd-login -I ./src/libsystemd/sd-netlink -I ./src/libsystemd/sd-network -I ./src/libsystemd/sd-hwdb -I ./src/libsystemd/sd-device -I ./src/libsystemd/sd-id128 -I ./src/libsystemd-network --sp-file coccinelle/strjoin.cocci --in-place $(git ls-files src/*.c) git grep -e '\bstrjoin\b.*NULL' -l|xargs sed -i -r 's/strjoin\((.*), NULL\)/strjoin(\1)/' This might have missed a few cases (spatch has a really hard time dealing with _cleanup_ macros), but that's no big issue, they can always be fixed later.
2016-09-21hwdb: store file-name and file-number with propertiesDavid Herrmann1-14/+42
Extend the hwdb to store the source file-name and file-number for each property. We simply extend the stored value struct with the new information. It is fully backwards compatible and old readers will continue to work. The libudev/sd-hwdb reader is updated in a followup. Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2016-06-07hwdb: selinuxify a bit (#3460)Evgeny Vereshchagin1-2/+6
-bash-4.3# rm /etc/udev/hwdb.bin -bash-4.3# systemd-hwdb update -bash-4.3# ls -Z /etc/udev/hwdb.bin system_u:object_r:systemd_hwdb_etc_t:s0 /etc/udev/hwdb.bin Fixes: #3458
2015-11-27tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering1-1/+1
GLIB has recently started to officially support the gcc cleanup attribute in its public API, hence let's do the same for our APIs. With this patch we'll define an xyz_unrefp() call for each public xyz_unref() call, to make it easy to use inside a __attribute__((cleanup())) expression. Then, all code is ported over to make use of this. The new calls are also documented in the man pages, with examples how to use them (well, I only added docs where the _unref() call itself already had docs, and the examples, only cover sd_bus_unrefp() and sd_event_unrefp()). This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we tend to call our destructors these days. Note that this defines no public macro that wraps gcc's attribute and makes it easier to use. While I think it's our duty in the library to make our stuff easy to use, I figure it's not our duty to make gcc's own features easy to use on its own. Most likely, client code which wants to make use of this should define its own: #define _cleanup_(function) __attribute__((cleanup(function))) Or similar, to make the gcc feature easier to use. Making this logic public has the benefit that we can remove three header files whose only purpose was to define these functions internally. See #2008.
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering1-0/+1
2015-10-27util-lib: move a number of fs operations into fs-util.[ch]Lennart Poettering1-0/+1
2015-10-27util-lib: move more file I/O related calls into fileio.[ch]Lennart Poettering1-1/+2
2015-10-25util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering1-0/+1
There are more than enough to deserve their own .c file, hence move them over.
2015-10-24util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering1-0/+1
string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
2015-09-29util: introduce common version() implementation and use it everywhereLennart Poettering1-12/+8
This also allows us to drop build.h from a ton of files, hence do so. Since we touched the #includes of those files, let's order them properly according to CODING_STYLE.
2015-06-09Revert "hwdb: actually search /run/udev/hwdb.d"Lennart Poettering1-1/+0
2015-06-09hwdb: actually search /run/udev/hwdb.dPeter Hutterer1-0/+1
The documentation claims hwdb entries may be placed in the volatile /run/udev/hwdb.d directory but nothing actually looked at it.
2015-02-23remove unused includesThomas Hindoe Paaboel Andersen1-2/+0
This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.