aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-145-17/+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-147-14/+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.
* basic/log: add the log_struct terminator to macroZbigniew Jędrzejewski-Szmek2018-06-041-2/+1
| | | | | This way all callers do not need to specify it. Exhaustively tested by running test-log under valgrind ;)
* tree-wide: make use of memory_startswith() at various placesLennart Poettering2018-05-301-7/+4
|
* coredumpctl: always output proper english sentenceLennart Poettering2018-05-221-2/+2
| | | | Let's uppercase the first character, and finish them in a full stop.
* coredump: properly treat Storage=none as disabled storageZbigniew Jędrzejewski-Szmek2018-05-171-3/+14
| | | | | Also don't attempt to create /var/lib/systemd/coredump if storage limit is set to 0 and coredump processing is disabled.
* coredumpctl: Add debug as a gdb alias, and add lldb support (closes #8722) ↵Ryan Gonzalez2018-04-181-23/+44
| | | | (#8744)
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-068-104/+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.
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-04-053-18/+8
|
* coccinelle: run safe_fclose.cocci againLennart Poettering2018-03-231-2/+1
|
* macro: introduce TAKE_PTR() macroLennart Poettering2018-03-223-6/+3
| | | | | | | | | | | | | | | | This macro will read a pointer of any type, return it, and set the pointer to NULL. This is useful as an explicit concept of passing ownership of a memory area between pointers. This takes inspiration from Rust: https://doc.rust-lang.org/std/option/enum.Option.html#method.take and was suggested by Alan Jenkins (@sourcejedi). It drops ~160 lines of code from our codebase, which makes me like it. Also, I think it clarifies passing of ownership, and thus helps readability a bit (at least for the initiated who know the new macro)
* coredumpctl: drop unnecessary NULL initialization, and use const where ↵Lennart Poettering2018-03-211-2/+2
| | | | possible (#8515)
* tree-wide: voidify pager_open()Yu Watanabe2018-03-191-1/+1
| | | | | | Even if pager_open() fails, in general, we should continue the operations. All erroneous cases in pager_open() show log message in the function. So, it is not necessary to check the returned value.
* coredumpctl: use dispatch_verb()Yu Watanabe2018-03-191-105/+95
|
* coredump: do not leak memory (#8352)Yu Watanabe2018-03-051-4/+1
| | | Fixes #8351.
* tree-wide: reopen log when we need to log in FORK_CLOSE_ALL_FDS childrenLennart Poettering2018-02-221-0/+1
| | | | | | | | | | | | | | | | | | In a number of occasions we use FORK_CLOSE_ALL_FDS when forking off a child, since we don't want to pass fds to the processes spawned (either because we later want to execve() some other process there, or because our child might hang around for longer than expected, in which case it shouldn't keep our fd pinned). This also closes any logging fds, and thus means logging is turned off in the child. If we want to do proper logging, explicitly reopen the logs hence in the child at the right time. This is particularly crucial in the umount/remount children we fork off the shutdown binary, as otherwise the children can't log, which is why #8155 is harder to debug than necessary: the log messages we generate about failing mount() system calls aren't actually visible on screen, as they done in the child processes where the log fds are closed.
* journalctl: improve hint about lack of access for --user-unit=...Zbigniew Jędrzejewski-Szmek2018-02-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | When running journalctl --user-unit=foo as an unprivileged user we could get the usual hint: Hint: You are currently not seeing messages from the system and other users. Users in groups 'adm', 'systemd-journal', 'wheel' can see all messages. ... But with --user-unit our filter is: (((_UID=0 OR _UID=1000) AND OBJECT_SYSTEMD_USER_UNIT=foo.service) OR ((_UID=0 OR _UID=1000) AND COREDUMP_USER_UNIT=foo.service) OR (_UID=1000 AND USER_UNIT=foo.service) OR (_UID=1000 AND _SYSTEMD_USER_UNIT=foo.service)) so we would never see messages from other users. We could still see messages from the system. In fact, on my machine the only messages with OBJECT_SYSTEMD_USER_UNIT= are from the system: journalctl $(journalctl -F OBJECT_SYSTEMD_USER_UNIT|sed 's/.*/OBJECT_SYSTEMD_USER_UNIT=\0/') Thus, a more correct hint is that we cannot see messages from the system. Make it so. Fixes #7887.
* tree-wide: make use of fsync_directory_of_file() all over the placeLennart Poettering2018-02-201-0/+2
| | | | | | Let's make use this at various places we call fsync(), to make things fully reliable, as the kernel devs suggest to first fsync() files and then fsync() the directories they are located in.
* coredump: accept hostname on command line (#8033)Jakub Filak2018-02-151-6/+15
| | | | | | | | | | | | | | | | | | This commint adds a new command line parameter to sytemd-coredump. The parameter should be mappend to core_pattern's placeholder %h - hostname. The field _HOSTNAME holds the name from the kernel's namespaces which might be different then the one comming from process' namespaces. It is true that the real hostname is usually available in the field COREDUMP_ENVIRON (environment variables) but I believe it is more reliable to use the value passed by kernel. ---- The length of iovec is no longer static and hence I corrected the declarations of the functions set_iovec_field and set_iovec_field_free. Thank you @yuwata and @poettering!
* coredump,journal: when vacuuming use new unlinkat_deallocate() callsLennart Poettering2018-02-121-7/+7
| | | | | | | | | This ensures that clients can't keep all files pinned interfering with our vacuuming logic. This should fix the last issue pointed out in #7998 and #8032 Fixes: #7998
* util: minor tweaks to disable_core_dumps()Lennart Poettering2018-01-101-1/+1
| | | | | | | | | First, let's rename it to disable_coredumps(), as in the rest of our codebase we spell it "coredump" rather than "core_dump", so let's stick to that. However, also log about failures to turn off core dumpling on LOG_DEBUG, because debug logging is always a good idea.
* tree-wide: introduce disable_core_dumps helper and port existing usersJan Klötzke2018-01-101-1/+1
| | | | | | Changes the core_pattern to prevent any core dumps by the kernel. Does nothing if we're in a container environment as this is system wide setting.
* tree-wide: make use of wait_for_terminate_and_check() at various placesLennart Poettering2018-01-041-8/+1
| | | | | | Using wait_for_terminate_and_check() instead of wait_for_terminate() let's us simplify, shorten and unify the return value checking and logging of waitid(). Hence, let's use it all over the place.
* process-util: add another fork_safe() flag for enabling LOG_ERR/LOG_WARN loggingLennart Poettering2018-01-041-4/+2
|
* tree-wide: use EXIT_SUCCESS/EXIT_FAILURE in exit() where we canLennart Poettering2017-12-251-1/+1
|
* tree-wide: introduce new safe_fork() helper and port everything overLennart Poettering2017-12-251-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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: add DEBUG_LOGGING macro that checks whether debug logging is on ↵Lennart Poettering2017-12-151-1/+1
| | | | | | | (#7645) This makes things a bit easier to read I think, and also makes sure we always use the _unlikely_ wrapper around it, which so far we used sometimes and other times we didn't. Let's clean that up.
* tree-wide: make use of new STRLEN() macro everywhere (#7639)Lennart Poettering2017-12-141-3/+3
| | | | | Let's employ coccinelle to do this for us. Follow-up for #7625.
* tree-wide: use __fsetlocking() instead of fxyz_unlocked()Lennart Poettering2017-12-142-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | Let's replace usage of fputc_unlocked() and friends by __fsetlocking(f, FSETLOCKING_BYCALLER). This turns off locking for the entire FILE*, instead of doing individual per-call decision whether to use normal calls or _unlocked() calls. This has various benefits: 1. It's easier to read and easier not to forget 2. It's more comprehensive, as fprintf() and friends are covered too (as these functions have no _unlocked() counterpart) 3. Philosophically, it's a bit more correct, because it's more a property of the file handle really whether we ever pass it on to another thread, not of the operations we then apply to it. This patch reworks all pieces of codes that so far used fxyz_unlocked() calls to use __fsetlocking() instead. It also reworks all places that use open_memstream(), i.e. use stdio FILE* for string manipulations. Note that this in some way a revert of 4b61c8751135c58be043d86b9fef4c8ec7aadf18.
* tree-wide: drop a few == NULL and != NULL comparisonLennart Poettering2017-12-111-1/+1
| | | | | | | Our CODING_STYLE suggests not comparing with NULL, but relying on C's downgrade-to-bool feature for that. Fix up some code to match these guidelines. (This is not comprehensive, the coccinelle output for this is unfortunately kinda borked)
* journal,coredump: do not do ACL magic for "nobody" user eitherLennart Poettering2017-12-061-1/+1
| | | | | | | | The "nobody" user might possibly be seen by the journal or coredumping code if unmapped userns-using processes are somehow visible to them. Let's make sure we don't do the ACL magic for this user either, since this is a special system user that might be backed by different real users in different contexts.
* coredump,journal: do not do ACL magic for processes of dynamic UIDsLennart Poettering2017-12-061-1/+1
| | | | Dynamic UIDs should be treated like system users in this regard.
* user-util: add new uid_is_system() helperLennart Poettering2017-12-061-1/+1
| | | | | | | This adds uid_is_system() and gid_is_system(), similar in style to uid_is_dynamic(). That a helper like this is useful is illustrated by the fact that test-condition.c didn't get the check right so far, which this patch fixes.
* coredump: fix typo and use hashmap_free_with_destructorZbigniew Jędrzejewski-Szmek2017-11-281-9/+4
|
* Remove NULL as last parameter to strjoinDaniel Lockyer2017-11-241-1/+1
|
* Add license headers and SPDX identifiers to meson.build filesZbigniew Jędrzejewski-Szmek2017-11-191-0/+17
| | | | | | | So far I avoided adding license headers to meson files, but they are pretty big and important and should carry license headers like everything else. I added my own copyright, even though other people modified those files too. But this is mostly symbolic, so I hope that's OK.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-197-0/+7
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* conf-parser: turn three bool function params into a flags fieldsLennart Poettering2017-11-131-1/+1
| | | | | This makes things more readable and fixes some issues with incorrect flag propagation between the various flavours of config_parse().
* build-sys: use #if Y instead of #ifdef Y everywhereZbigniew Jędrzejewski-Szmek2017-10-043-6/+6
| | | | | | | | | | | | | | | 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
* io-util: add new IOVEC_INIT/IOVEC_MAKE macrosLennart Poettering2017-09-221-16/+14
| | | | | | | | | | | | | | | | | | | | | | This adds IOVEC_INIT() and IOVEC_MAKE() for initializing iovec structures from a pointer and a size. On top of these IOVEC_INIT_STRING() and IOVEC_MAKE_STRING() are added which take a string and automatically determine the size of the string using strlen(). This patch removes the old IOVEC_SET_STRING() macro, given that IOVEC_MAKE_STRING() is now useful for similar purposes. Note that the old IOVEC_SET_STRING() invocations were two characters shorter than the new ones using IOVEC_MAKE_STRING(), but I think the new syntax is more readable and more generic as it simply resolves to a C99 literal structure initialization. Moreover, we can use very similar syntax now for initializing strings and pointer+size iovec entries. We canalso use the new macros to initialize function parameters on-the-fly or array definitions. And given that we shouldn't have so many ways to do the same stuff, let's just settle on the new macros. (This also converts some code to use _cleanup_ where dynamically allocated strings were using IOVEC_SET_STRING() before, to modernize things a bit)
* tree-wide: fput[cs]() → fput[cs]_unlocked() wherever that makes sense (#6396)Lennart Poettering2017-07-212-2/+2
| | | | | | | | As a follow-up for db3f45e2d2586d78f942a43e661415bc50716d11 let's do the same for all other cases where we create a FILE* with local scope and know that no other threads hence can have access to it. For most cases this shouldn't change much really, but this should speed dbus introspection and calender time formatting up a bit.
* build-sys: drop automake supportZbigniew Jędrzejewski-Szmek2017-07-181-1/+0
| | | | | v2: - also mention m4
* meson: use booleans for conf.set and drop unecessary conditionalsZbigniew Jędrzejewski-Szmek2017-05-021-1/+1
| | | | | | | | | Using conf.set() with a boolean argument does the right thing: either #ifdef or #undef. This means that conf.set can be used unconditionally. Previously I used '1' as the placeholder value, and that needs to be changed to 'true' for consistency (under meson 1 cannot be used in boolean context). All checks need to be adjusted.
* meson: reindent all files with 8 spacesZbigniew Jędrzejewski-Szmek2017-04-231-14/+12
| | | | | | | The indentation for emacs'es meson-mode is added .dir-locals. All files are reindented automatically, using the lasest meson-mode from git. Indentation should now be fairly consistent.
* meson: define testsZbigniew Jędrzejewski-Szmek2017-04-231-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tests can be run with 'ninja-build test' or using 'mesontest'. '-Dtests=unsafe' can be used to include the "unsafe" tests in the test suite, same as with autotools. v2: - use more conf.get guards are optional components - declare deps on generated headers for test-{af,arphrd,cap}-list v3: - define environment for tests Most test don't need this, but to be consistent with autotools-based build, and to avoid questions which tests need it and which don't, set the same environment for all tests. v4: - rework test generation Use a list of lists to define each test. This way we can reduce the boilerplate somewhat, although the test listings are still pretty verbose. We can also move the definitions of the tests to the subdirs. Unfortunately some subdirs are included earlier than some of the libraries that test binaries are linked to. So just dump all definitions of all tests that cannot be defined earlier into src/test. The `executable` definitions are still at the top level, so the binaries are compiled into the build root. v5: - tag test-dnssec-complex as manual v6: - fix HAVE_LIBZ typo - add missing libgobject/libgio defs - mark test-qcow2 as manual
* meson: build systemd using mesonZbigniew Jędrzejewski-Szmek2017-04-231-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's crucial that we can build systemd using VS2010! ... er, wait, no, that's not the official reason. We need to shed old systems by requring python 3! Oh, no, it's something else. Maybe we need to throw out 345 years of knowlege accumulated in autotools? Whatever, this new thing is cool and shiny, let's use it. This is not complete, I'm throwing it out here for your amusement and critique. - rules for sd-boot are missing. Those might be quite complicated. - rules for tests are missing too. Those are probably quite simple and repetitive, but there's lots of them. - it's likely that I didn't get all the conditions right, I only tested "full" compilation where most deps are provided and nothing is disabled. - busname.target and all .busname units are skipped on purpose. Otherwise, installation into $DESTDIR has the same list of files and the autoconf install, except for .la files. It'd be great if people had a careful look at all the library linking options. I added stuff until things compiled, and in the end there's much less linking then in the old system. But it seems that there's still a lot of unnecessary deps. meson has a `shared_module` statement, which sounds like something appropriate for our nss and pam modules. Unfortunately, I couldn't get it to work. For the nss modules, we need an .so version of '2', but `shared_module` disallows the version argument. For the pam module, it also didn't work, I forgot the reason. The handling of .m4 and .in and .m4.in files is rather awkward. It's likely that this could be simplified. If make support is ever dropped, I think it'd make sense to switch to a different templating system so that two different languages and not required, which would make everything simpler yet. v2: - use get_pkgconfig_variable - use sh not bash - use add_project_arguments v3: - drop required:true and fix progs/prog typo v4: - use find_library('bz2') - add TTY_GID definition - define __SANE_USERSPACE_TYPES__ - use join_paths(prefix, ...) is used on all paths to make them all absolute v5: - replace all declare_dependency's with [] - add more conf.get guards around optional components v6: - drop -pipe, -Wall which are the default in meson - use compiler.has_function() and compiler.has_header_symbol instead of the hand-rolled checks. - fix duplication in 'liblibsystemd' library name - use the right .sym file for pam_systemd - rename 'compiler' to 'cc': shorter, and more idiomatic. v7: - use ENABLE_ENVIRONMENT_D not HAVE_ENVIRONMENT_D - rename prefix to prefixdir, rootprefix to rootprefixdir ("prefix" is too common of a name and too easy to overwrite by mistake) - wrap more stuff with conf.get('ENABLE...') == 1 - use rootprefix=='/' and rootbindir as install_dir, to fix paths under split-usr==true. v8: - use .split() also for src/coredump. Now everything is consistent ;) - add rootlibdir option and use it on the libraries that require it v9: - indentation v10: - fix check for qrencode and libaudit v11: - unify handling of executable paths, provide options for all progs This makes the meson build behave slightly differently than the autoconf-based one, because we always first try to find the executable in the filesystem, and fall back to the default. I think different handling of loadkeys, setfont, and telinit was just a historical accident. In addition to checking in $PATH, also check /usr/sbin/, /sbin for programs. In Fedora $PATH includes /usr/sbin, (and /sbin is is a symlink to /usr/sbin), but in Debian, those directories are not included in the path. C.f. https://github.com/mesonbuild/meson/issues/1576. - call all the options 'xxx-path' for clarity. - sort man/rules/meson.build properly so it's stable
* Merge pull request #5774 from keszybz/printf-annotationsDjalal Harouni2017-04-231-3/+2
|\ | | | | Printf annotation improvements
| * coredump: fix non-literal string used in printfZbigniew Jędrzejewski-Szmek2017-04-211-3/+2
| | | | | | | | | | | | | | | | This was exposed by the previous commit. This could be potentially unpleasant, but we are saved by the fact that this code path was only taken for journald crashes, where we control COMM and know that it doesn't contain any special characters. Use log_dispatch which does not do any format processing to push the message out.
* | tree-wide: fix wrong indent (#5757)Yu Watanabe2017-04-191-4/+4
|/ | | Fixes wrong indent introduced by the commit 43688c49d1fdb585196d94e2e30bb29755fa591b.
* coredump: fix handling of premature-eof data for --backtraceZbigniew Jędrzejewski-Szmek2017-03-051-1/+2
| | | | | We'd fail with an assert in journal_importer_process_data(), because that function requires the caller to handle EOF themselves.