summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* test/udev-test.pl: drop test cases that add mutliple devicesv239-45.1Michal Sekletar2021-05-251-179/+0
| | | | | | | | [msekleta: It is easier to delete test-cases that would make udev test fail. Once we reintroduce the fix for link_update() we will revert this commit.] Related: #1963980
* Revert "udev: make algorithm that selects highest priority devlink less ↵Michal Sekletar2021-05-252-216/+99
| | | | | | | | susceptible to race conditions" This reverts commit 1d5f966c1758eb620755fcae54abd07a1ac36d3d. Related: #1963980
* Revert "udev: run link_update() with increased retry count in second invocation"Michal Sekletar2021-05-251-1/+2
| | | | | | This reverts commit 1f3165bda13c8572c8c31d23c998835c4e2ad8f3. Related: #1963980
* pam-systemd: use secure_getenv() rather than getenv()v239-45Lennart Poettering2021-03-101-23/+32
| | | | | | | | | | And explain why in a comment. (cherry picked from commit 83d4ab55336ff8a0643c6aa627b31e351a24040a) CVE-2019-3842 Resolves: #1687514
* udev: run link_update() with increased retry count in second invocationMichal Sekletar2021-03-101-2/+1
| | | | | | | | | | | | | | | | | In PR #17431 we have introduced retry loop in link_update() in order to maximize the chance that we end up with correct target when there are multiple contenders for given symlink. Number of iterations in retry loop is either 1 or LINK_UPDATE_MAX_RETRIES, depending on the value of 'initialized' db flag. When device appears for the first time we need to set the flag before calling link_update() via update_devnode() for the second time to make sure we run the second invocation with higher retry loop counter. (cherry picked from commit 996c83903da5bf8b371314b4207ff97afeef65a4) Related: #1931947
* core: prevent excessive /proc/self/mountinfo parsingMichal Sekletár2021-03-101-0/+6
| | | | | | (cherry picked from commit d586f642fd90e3bb378f7b6d3e3a64a753e51756) Resolves: #1819868
* test: add ratelimiting testMichal Sekletár2021-03-101-0/+96
| | | | | | | | (Taken from Michal's #17274 by Lennart, and slightly adjusted) (cherry picked from commit 68d890651781904a4c762ac866af36e30c4f7ff8) Related: #1819868
* sd-event: add ability to ratelimit event sourcesLennart Poettering2021-03-104-82/+369
| | | | | | | | | | | | | | | | | | | Let's a concept of "rate limiting" to event sources: if specific event sources fire too often in some time interval temporarily take them offline, and take them back online once the interval passed. This is a simple scheme of avoiding starvation of event sources if some event source fires too often. This introduces the new conceptual states of "offline" and "online" for event sources: an event source is "online" only when enabled *and* not ratelimited, and offline in all other cases. An event source that is online hence has its fds registered in the epoll, its signals in the signalfd and so on. (cherry picked from commit b6d5481b3d9f7c9b1198ab54b54326ec73e855bf) Related: #1819868
* sd-event: increase n_enabled_child_sources just onceZbigniew Jędrzejewski-Szmek2021-03-101-2/+1
| | | | | | | | | Neither source_child_pidfd_register() nor event_make_signal_data() look at n_enabled_child_sources. (cherry picked from commit ac9f2640cb9c107b43f47bba7e068d3b92b5337b) Related: #1819868
* sd-event: update state at the end in event_source_enableZbigniew Jędrzejewski-Szmek2021-03-101-22/+29
| | | | | | | | | | | | | | | Coverity in CID#1435966 was complaining that s->enabled is not "restored" in all cases. But the code was actually correct, since it should only be "restored" in the error paths. But let's still make this prettier by not setting the state before all operations that may fail are done. We need to set .enabled for the prioq reshuffling operations, so move those down. No functional change intended. (cherry picked from commit d2eafe61ca07f8300dc741a0491a914213fa2b6b) Related: #1819868
* sd-event: remove earliest_index/latest_index into common part of event ↵Lennart Poettering2021-03-101-12/+13
| | | | | | | | | | | | | | | | | | source objects So far we used these fields to organize the earliest/latest timer event priority queue. In a follow-up commit we want to introduce ratelimiting to event sources, at which point we want any kind of event source to be able to trigger time wakeups, and hence they all need to be included in the earliest/latest prioqs. Thus, in preparation let's make this generic. No change in behaviour, just some shifting around of struct members from the type-specific to the generic part. (cherry picked from commit f41315fceb5208c496145cda2d6c865a5458ce44) Related: #1819868
* sd-event: follow coding style with naming return parameterLennart Poettering2021-03-101-4/+5
| | | | | | (cherry picked from commit cad143a8f26976a23e634d5e1ecfb7d7ba75c3bf) Related: #1819868
* sd-event: ref event loop while in sd_event_prepare() ot sd_event_run()Lennart Poettering2021-03-101-6/+9
| | | | | | | | | | | | | | | | sd_event_prepare() invokes callbacks that might drop the last user ref on our event loop. Let's make sure we keep an explicit ref around it, so that we won't end up with an invalid pointer. Similar in sd_event_run(). Basically, any function that is publically callable that might end up invoking callbacks should ref the relevant objects to be protected against callbacks destroying these objects while we still want to access them. We did this correctly in sd_event_dispatch() and sd_event_loop(), but these are not the only ones which are callable from the outside. (cherry picked from commit f814c871e65df8552a055dd887bc94b074037833) Related: #1819868
* sd-event: refuse running default event loops in any other thread than the ↵Lennart Poettering2021-03-102-1/+5
| | | | | | | | one they are default for (cherry picked from commit e544601536ac13a288d7476f4400c7b0f22b7ea1) Related: #1819868
* sd-event: let's suffix last_run/last_log with "_usec"Lennart Poettering2021-03-101-6/+6
| | | | | | | | Otherwise it's a bit confusing what this is about: two timestamps. (cherry picked from commit e6a7bee538f6638c2d5ca2afc66bf47cba3f075c) Related: #1819868
* sd-event: fix delays assert brain-o (#17790)Vito Caputo2021-03-101-1/+1
| | | | | | | | | | s/sizeof/ELEMENTSOF/ Bug introduced in 34b87517749caa4142b19eb3c63bdf349fafbc49. (cherry picked from commit cb9d621ebbfa30bbd620c17e143daeb0d78c12f0) Related: #1819868
* sd-event: split out code to add/remove timer event sources to ↵Lennart Poettering2021-03-101-16/+41
| | | | | | | | | | | earliest/latest prioq Just some refactoring that makes code prettier, and will come handy later, because we can reuse these functions at more places. (cherry picked from commit 1e45e3fecc303e7ae9946220c742f69675e99c34) Related: #1819868
* sd-event: split clock data allocation out of sd_event_add_time()Lennart Poettering2021-03-101-11/+23
| | | | | | | | | Just some simple refactoring, that will make things easier for us later. But it looks better this way even without the later function reuse. (cherry picked from commit 41c63f36c3352af8bebf03b6181f5d866431d0af) Related: #1819868
* sd-event: mention that two debug logged events are ignoredLennart Poettering2021-03-101-5/+2
| | | | | | (cherry picked from commit f80a5d6a86dc2346f406ee086ba179879afaab70) Related: #1819868
* sd-event: split out enable and disable codepaths from ↵Lennart Poettering2021-03-101-106/+121
| | | | | | | | | | | | | | | | | | | | sd_event_source_set_enabled() So far half of sd_event_source_set_enabled() was doing enabling, the other half was doing disabling. Let's split that into two separate calls. (This also adds a new shortcut to sd_event_source_set_enabled(): if the caller toggles between "ON" and "ONESHOT" we'll now shortcut this, since the event source is already enabled in that case and shall remain enabled.) This heavily borrows and is inspired from Michal Sekletár's #17284 refactoring. (cherry picked from commit ddfde737b546c17e54182028153aa7f7e78804e3) Related: #1819868
* sd-event: split out helper functions for reshuffling prioqsMichal Sekletár2021-03-101-58/+38
| | | | | | | | | | | | | | | | | | | | We typically don't just reshuffle a single prioq at once, but always two. Let's add two helper functions that do this, and reuse them everywhere. (Note that this drops one minor optimization: sd_event_source_set_time_accuracy() previously only reshuffled the "latest" prioq, since changing the accuracy has no effect on the earliest time of an event source, just the latest time an event source can run. This optimization is removed to simplify things, given that it's not really worth the effort as prioq_reshuffle() on properly ordered prioqs has practically zero cost O(1)). (Slightly generalized, commented and split out of #17284 by Lennart) (cherry picked from commit e1951c16a8fbe5b0b9ecc08f4f835a806059d28f) Related: #1819868
* test/sys-script.py: add missing DEVNAME entries to ueventsMartin Wilck2021-03-041-0/+7
| | | | Resolves: #1931947
* Revert "test: add test cases for empty string match" and "test: add test ↵Michal Sekletar2021-03-041-98/+0
| | | | | | | | | case for multi matches when use ||" This effectively reverts commits 03bc565e6e3249385c4e1ca0ae27670ca2ad9a41 and 03b766cc937ffa4dcb7cfb25b2ac20d8a00cb6db. Resolves: #1931947
* test/udev-test: gracefully exit when imports failv239-44Zbigniew Jędrzejewski-Szmek2021-01-251-5/+13
| | | | | | | | | | | | | In Fedora rawhide various perl modules are now available as separate packages that are not pulled in by dependencies. If we don't have some package, skip the tests. This ugly code is apparently the way to do conditional imports: https://www.cs.ait.ac.th/~on/O/oreilly/perl/cookbook/ch12_03.htm. (cherry picked from commit d40763838278246e2073d15ca927ee700e583afc) Related: #1642728
* test/udev_test.pl: add "expected good" countMartin Wilck2021-01-251-2/+19
| | | | | | | | | | Since 'test/udev-test.pl: count "good" results', we know how many checks succeeded. Add an "expected good" count to make that number more meaningful. (cherry picked from commit cbeb23d863d540408cd1fb274d78213f59639df2) Related: #1642728
* test/udev-test.pl: suppress umount error message at startupMartin Wilck2021-01-251-1/+1
| | | | | | | | | | umount emits an error message "no mount point specified" if the tmpfs isn't mounted yet, which is the normal case. Suppress that by redirecting stderr. (cherry picked from commit f1cb0860549e775be5f91237b5a3b97698dd14dd) Related: #1642728
* test/udev-test.pl: generator for large list of block devicesMartin Wilck2021-01-251-1/+59
| | | | | | | | | | Manually listing all devices in the test definition becomes cumbersome with lots of devices. Add a function that scans on all block devices in the test sysfs and generates a list of devices to test. (cherry picked from commit eb44d715ebee2fe11288433b99f8e1dc5fdac84a) Related: #1642728
* test/udev-test.pl: add repeat countMartin Wilck2021-01-251-0/+5
| | | | | | | | for easier reproduction of sporadic test failures. (cherry picked from commit 2ab0a8d00bc48d3531e953d938db889d8a932d65) Related: #1642728
* tests/udev-test.pl: add multiple device testMartin Wilck2021-01-251-0/+169
| | | | | | | | | | | | | Add 4 new tests using multiple devices. Number 2-4 use many devices claiming the same symlink, where only one device has a higher priority thatn the others. They fail sporadically with the current code, if a race condition causes the symlink to point to the wrong device. Test 4 is like test 2 with sleeps in between, it's much less likely to fail. (cherry picked from commit 4a0ec82daf32446519e1d86329bb802325b82104) Related: #1642728
* test/udev-test.pl: count "good" resultsMartin Wilck2021-01-251-2/+15
| | | | | | | | | This is helpful to catch possible regressions in the test. Also, don't count wait() errors, they are likely not udev errors. (cherry picked from commit b95c43982ab7d0253b552ad56cffb3d68fcbb4f6) Related: #1642728
* test/udev-test.pl: merge import parent tests into oneMartin Wilck2021-01-251-12/+5
| | | | | | | | | As we can test multiple devices and multiple links per device in one test now, these two tests can be merged into one. (cherry picked from commit a96cd21d31cb7af211862768e133b50b085634e7) Related: #1642728
* test/udev-test.pl: merge "space and var with space" testsMartin Wilck2021-01-251-28/+3
| | | | | | | | | As we can check multiple links in a single test now, these 3 tests can be merged into one. (cherry picked from commit 2084fe0d3290c525ecb9faa07d07c3abc2488e59) Related: #1642728
* test/udev-test.pl: remove bogus rules from magic subsys testMartin Wilck2021-01-251-2/+0
| | | | | | | | | These rules have survived from an ancient version of the code and save no purpose any more. (cherry picked from commit 86634df43b715f3f77c7de73a3ef6566e5cdf571) Related: #1642728
* test/udev-test.pl: Make some tests a little harderMartin Wilck2021-01-251-4/+9
| | | | | | | | | Add some rules that make it a bit harder to pass, mainly the non-existence checks. (cherry picked from commit 06d4d4e24e7d0b51120b165e540d278842e8b1a3) Related: #1642728
* test/udev-test.pl: last_rule is unsupportedMartin Wilck2021-01-251-0/+3
| | | | | | | | | | the "last_rule" option hasn't been supported for some time. Therefore this test fails if a "not_exp_links" attribute is added, as it should be. Mark it appropriately. (cherry picked from commit 17cce031531a5d3f38a27374c99d1bdba5959dbd) Related: #1642728
* test/udev-test.pl: fix wrong test descriptionsMartin Wilck2021-01-251-7/+8
| | | | | | | | udev hasn't supported renaming device nodes for some time. (cherry picked from commit 46bc71b2b73f8a1e27dc5e142730e9877dd05e3e) Related: #1642728
* test/udev-test.pl: allow checking multiple symlinksMartin Wilck2021-01-251-199/+296
| | | | | | | | | | | Instead of testing the existence or non-exisitence of just a single symlink, allow testing of several links per device. Change the test definitions accordingly. (cherry picked from commit e62acc3159935781f05fa59c48e5a74e85c61ce2) Related: #1642728
* test/udev-test.pl: test correctness of symlink targetsMartin Wilck2021-01-251-5/+18
| | | | | | | | | | | Test if symlinks are created correctly by comparing the symlink targets to the devnode path. This implies (for the symlink) that major/minor numbers and permissions are correct, as we have tested that on the devnode already. (cherry picked from commit 997683c8f152e1c139a7ce537de81a0aeae4627f) Related: #1642728
* test/udev-test.pl: use computed devnode nameMartin Wilck2021-01-251-26/+66
| | | | | | | | | | | | | | | | | | | | More often than not, the created devnode is the basename of the sysfs entry. The "devnode" device may be used to override the auto-detected node name. Permissions and major/minor number are now verified on the devnode itself, not on symlinks. For those tests where exp_name is set to the computed devnode name, the explicit "exp_name" can be removed. "exp_name" is only required for symlinks. This allows separate testing for devnodes and symlinks an a follow-up patch. (cherry picked from commit f0dccf01a7b4e72278e14effd74782ea83d0a73b) Related: #1642728
* test/udev-test.pl: allow concurrent additions and removalsMartin Wilck2021-01-251-18/+72
| | | | | | | | | | | | Allow testing cases where multiple devices are added and removed simultaneously. Tests are started as synchronously as possible using a semaphore, in order to test possible race conditions. If this isn't desired, the test parameter "sleep_us" can be set to the number of microseconds to wait between udev invocations. (cherry picked from commit 09a4062d70b3a10d022e40066e2adf09df05bbbc) Related: #1642728
* test/udev-test.pl: create rules only onceMartin Wilck2021-01-251-4/+9
| | | | | | | | | It's not necessary to write the rules for every udev run, as we now may have many (rather than just 2) per test. (cherry picked from commit af7ee3eae689f9c31b49ea13758ad9c901918ce3) Related: #1642728
* test/udev-test.pl: allow multiple devices per testMartin Wilck2021-01-251-423/+929
| | | | | | | | | | | Allow testing cases where multiple devices are added and removed. This implies a change of the data structure: every test allows for multiple devices to be added, and "exp_name" etc. are now properties of the device, not of the test. (cherry picked from commit 255c05b72455dcad1b5552d12a813b31f68201a7) Related: #1642728
* udev-test: do not rely on "mail" group being definedZbigniew Jędrzejewski-Szmek2021-01-251-2/+2
| | | | | | | | | | | "audio" should be there, at least we declare it. "mail" nowadays is less likely to exist than in the past. Fixes one of the items in #16942. (cherry picked from commit a9030b81c154c3ec92227d04cad6b13cc1125608) Related: #1642728
* test: add test case for multi matches when use "||"gaoyi2021-01-251-0/+11
| | | | | | | Signed-off-by: gaoyi <ymuemc@163.com> (cherry picked from commit 0d3a8bc7ebd76591e14f7098b4266fd2065ac4db) Related: #1642728
* test: add test cases for empty string matchYu Watanabe2021-01-251-0/+66
| | | | | | (cherry picked from commit 48d26c90852c22ec94be961f5fbdcf462bb9a6e8) Related: #1642728
* test/udev-test.pl: cleanup if skipping testDan Streetman2021-01-251-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | In Ubuntu CI, udev-test.pl is run from the debian/test/udev script, in a test dir created for it; but udev-test.pl setup mounts a dir, so if it doesn't cleanup/unmount before exiting, the test dir autopkgtest created for it can't be removed, and autopkgtest aborts the entire test suite, for example this output (from a test run inside an armhf container): autopkgtest [12:45:36]: test udev: [----------------------- umount: test/tmpfs: no mount point specified. mknod: test/tmpfs/dev/null: Operation not permitted unable to create test/tmpfs/dev/null at ./udev-test.pl line 1611. Failed to set up the environment, skipping the test at ./udev-test.pl line 1731. autopkgtest [12:45:41]: test udev: -----------------------] autopkgtest [12:45:44]: test udev: - - - - - - - - - - results - - - - - - - - - - udev FAIL non-zero exit status 77 rm: cannot remove '/tmp/autopkgtest.ocPFA6/autopkgtest_tmp/test/tmpfs': Device or resource busy autopkgtest [12:46:22]: ERROR: "rm -rf /tmp/autopkgtest.ocPFA6/udev-artifacts /tmp/autopkgtest.ocPFA6/autopkgtest_tmp" failed with stderr "rm: (cherry picked from commit abb9cc50afb3949c442849f43301fb33578f3888) Related: #1642728
* test-udev: fix alignment and drop unnecessary white spacesYu Watanabe2021-01-251-57/+57
| | | | | | (cherry picked from commit 3dd2d524141d09d57443ae339e1a77d7ce40f847) Related: #1642728
* test-udev: add more tests for line continuationYu Watanabe2021-01-251-0/+34
| | | | | | (cherry picked from commit 84a0819c9d89a2ddb195a5d975ae1fd5c62fde3c) Related: #1642728
* test-udev: add more tests for line continuations and commentsYu Watanabe2021-01-251-2/+10
| | | | | | (cherry picked from commit d35976c670b0e5c2d4081b781e5af88c0689ff00) Related: #1642728
* test-udev: use proper semantics for too long line with continuationYu Watanabe2021-01-251-3/+4
| | | | | | | | Follow-up for 1e797cf596df50a6bdd8cbf8e9b2467a3a934171. (cherry picked from commit e37a5d90b0c624b95f8d0c3400288fec60417ec4) Related: #1642728