summaryrefslogtreecommitdiff
path: root/src/test/test-process-util.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek2018-06-201-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
* tree-wide: beautify remaining copyright statementsLennart Poettering2018-06-141-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.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-1/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-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.
* process-util: also filter non-printable characters in get_process_com()Lennart Poettering2018-06-011-0/+33
| | | | | | | | | | | | We already do that in get_process_cmdline(), which is very similar in behaviour otherwise. Hence, let's be safe and also filter them in get_process_comm(). Let's try to retain as much information as we can though and escape rather than suppress unprintable characters. Let's not increase comm names beyond the kernel limit on such names however. Also see discussion about this here: https://marc.info/?l=linux-api&m=152649570404881&w=2
* missing: define kernel internal limit TASK_COMM_LEN in userspace tooLennart Poettering2018-06-011-1/+1
| | | | | We already use it at two places, and we are about to add one too. Arbitrary literally hardcoded limits suck.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-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.
* unit-file: do not allow bogus IOSchedulingClass valuesZbigniew Jędrzejewski-Szmek2018-03-171-1/+27
| | | | | | | | We have only three bits of space, i.e. 8 possible classes. Immediately reject anything outside of that range. Add the fuzzer test case and an additional unit test. oss-fuzz #6908.
* tests: make / private after creating a mount namespaceEvegeny Vereshchagin2018-03-091-0/+2
| | | | so that the test never affects the root namespace.
* test-process-util: one more (void)Zbigniew Jędrzejewski-Szmek2018-02-191-1/+1
|
* test: test-process-util additionsLennart Poettering2018-01-231-0/+20
| | | | | Add some extra paranoia tests that PTR_TO_PID() and PID_TO_PTR() deals correctly with negative PID.
* tree-wide: use EXIT_SUCCESS/EXIT_FAILURE in exit() where we canLennart Poettering2017-12-251-2/+2
|
* tree-wide: introduce new safe_fork() helper and port everything overLennart Poettering2017-12-251-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a new safe_fork() wrapper around fork() and makes use of it everywhere. The new wrapper does a couple of things we previously did manually and separately in a safer, more correct and automatic way: 1. Optionally resets signal handlers/mask in the child 2. Sets a name on all processes we fork off right after forking off (and the patch assigns useful names for all processes we fork off now, following a systematic naming scheme: always enclosed in () – in order to indicate that these are not proper, exec()ed processes, but only forked off children, and if the process is long-running with only our own code, without execve()'ing something else, it gets am "sd-" prefix.) 3. Optionally closes all file descriptors in the child 4. Optionally sets a PR_SET_DEATHSIG to SIGTERM in the child, in a safe way so that the parent dying before this happens being handled safely. 5. Optionally reopens the logs 6. Optionally connects stdin/stdout/stderr to /dev/null 7. Debug logs about the forked off processes.
* tree-wide: make use of new STRLEN() macro everywhere (#7639)Lennart Poettering2017-12-141-2/+2
| | | | | Let's employ coccinelle to do this for us. Follow-up for #7625.
* test-process-util: add (void) cast to make coverity happyZbigniew Jędrzejewski-Szmek2017-11-281-1/+1
| | | | | The intent is for the call to succeed only when privileged, so make that clear.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-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.
* build-sys: use #if Y instead of #ifdef Y everywhereZbigniew Jędrzejewski-Szmek2017-10-041-3/+3
| | | | | | | | | | | | | | | The advantage is that is the name is mispellt, cpp will warn us. $ git grep -Ee "conf.set\('(HAVE|ENABLE)_" -l|xargs sed -r -i "s/conf.set\('(HAVE|ENABLE)_/conf.set10('\1_/" $ git grep -Ee '#ifn?def (HAVE|ENABLE)' -l|xargs sed -r -i 's/#ifdef (HAVE|ENABLE)/#if \1/; s/#ifndef (HAVE|ENABLE)/#if ! \1/;' $ git grep -Ee 'if.*defined\(HAVE' -l|xargs sed -i -r 's/defined\((HAVE_[A-Z0-9_]*)\)/\1/g' $ git grep -Ee 'if.*defined\(ENABLE' -l|xargs sed -i -r 's/defined\((ENABLE_[A-Z0-9_]*)\)/\1/g' + manual changes to meson.build squash! build-sys: use #if Y instead of #ifdef Y everywhere v2: - fix incorrect setting of HAVE_LIBIDN2
* test-process-util: test multiple invocations of rename_processJouke Witteveen2017-08-041-23/+54
|
* tree-wide: make use of getpid_cached() wherever we canLennart Poettering2017-07-201-38/+38
| | | | | | | This moves pretty much all uses of getpid() over to getpid_raw(). I didn't specifically check whether the optimization is worth it for each replacement, but in order to keep things simple and systematic I switched over everything at once.
* process-util: add getpid_cached() as a caching wrapper for getpid()Lennart Poettering2017-07-201-0/+57
| | | | Let's make getpid() fast again.
* util-lib: rework rename_process() to be able to make use of PR_SET_MM_ARG_STARTLennart Poettering2016-12-141-0/+61
| | | | | | | | | PR_SET_MM_ARG_START allows us to relatively cleanly implement process renaming. However, it's only available with privileges. Hence, let's try to make use of it, and if we can't fall back to the traditional way of overriding argv[0]. This removes size restrictions on the process name shown in argv[] at least for privileged processes.
* test-process-util: bind mount fails under selinux, skip testZbigniew Jędrzejewski-Szmek2016-11-171-1/+8
|
* tests: skip process 1 tests if systemd not is runningDavide Cavalca2016-07-291-1/+2
| | | | | No point running tests against process 1 if systemd is not running as that process. This is a rework of an unpublished patch by @9muir.
* treewide: remove unused variablesThomas Hindoe Paaboel Andersen2016-07-181-1/+1
|
* tests: don't run test_get_process_cmdline_harder under valgrindEvgeny Vereshchagin2016-06-191-0/+11
| | | | See https://github.com/systemd/systemd/pull/3555#issuecomment-226564908
* util-lib: rework get_process_cmdline() (#3529)Lennart Poettering2016-06-141-1/+191
| | | | | | | | | | | | | | | | | | | | | This reworks get_process_cmdline() quite substantially, fixing the following: - Fixes: https://github.com/systemd/systemd/pull/3512/commits/a4e3bf4d7ac2de51191ce136ee9361ba319e106c#r66837630 - The passed max_length is also applied to the "comm" name, if comm_fallback is set. - The right thing happens if max_length == 1 is specified - when the cmdline "foobar" is abbreviated to 6 characters the result is not "foobar" instead of "foo...". - trailing whitespace are removed before the ... suffix is appended. The 7 character abbreviation of "foo barz" is hence "foo..." instead of "foo ...". - leading whitespace are suppressed from the cmdline - a comprehensive test case is added
* test-process-util: allow pid to be specified on the command lineZbigniew Jędrzejewski-Szmek2016-06-121-2/+11
| | | | | This makes it easy to test the query code on "ssh localhost" and similar.
* test-process-util: rework the test function to take pid as argumentZbigniew Jędrzejewski-Szmek2016-06-121-38/+32
| | | | This fixes a bunch of copy&paste errors in the output.
* tests: add personality testsLennart Poettering2016-02-221-0/+26
|
* process-util: rename get_parent_of_pid() → get_process_ppid()Lennart Poettering2015-10-271-1/+1
| | | | In order to match the other get_process_xyz() calls.
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-4/+5
| | | | | | | | | | | | | | 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.
* basic: rework virtualization detection APILennart Poettering2015-09-071-1/+1
| | | | | | Introduce a proper enum, and don't pass around string ids anymore. This simplifies things quite a bit, and makes virtualization detection more similar to architecture detection.
* sd-bus: properly handle creds that are known but undefined for a processLennart Poettering2015-04-291-3/+2
| | | | | | | | | | | | | | | A number of fields do not apply to all processes, including: there a processes without a controlling tty, without parent process, without service, user services or session. To distuingish these cases from the case where we simply don't have the data, always return ENXIO for them, while returning ENODATA for the case where we really lack the information. Also update the credentials dumping code to show this properly. Fields that are known but do not apply are now shown as "n/a". Note that this also changes some of the calls in process-util.c and cgroup-util.c to return ENXIO for these cases.
* shared: add terminal-util.[ch]Ronny Chevalier2015-04-111-0/+1
|
* shared: add process-util.[ch]Ronny Chevalier2015-04-101-0/+138