summaryrefslogtreecommitdiffstats
path: root/src/journal-remote/journal-gatewayd.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* fileio: teach read_full_file_full() to read from offset/with maximum sizeLennart Poettering2020-12-011-3/+11
|
* journal-remote: suffix cmdline option that expects arg with =Lennart Poettering2020-12-011-1/+1
|
* journal-remote: use READ_FULL_FILE_SECURE|READ_FULL_FILE_WARN_WORLD_READABLE ↵Lennart Poettering2020-12-011-1/+5
| | | | | | when reading PEM secret key It's secret data, hence use the appropriate flags.
* journal-remote: erase secret PEM key from memory after useLennart Poettering2020-12-011-1/+2
|
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket ↵Lennart Poettering2020-11-031-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | name This beefs up the READ_FULL_FILE_CONNECT_SOCKET logic of read_full_file_full() a bit: when used a sender socket name may be specified. If specified as NULL behaviour is as before: the client socket name is picked by the kernel. But if specified as non-NULL the client can pick a socket name to use when connecting. This is useful to communicate a minimal amount of metainformation from client to server, outside of the transport payload. Specifically, these beefs up the service credential logic to pass an abstract AF_UNIX socket name as client socket name when connecting via READ_FULL_FILE_CONNECT_SOCKET, that includes the requesting unit name and the eventual credential name. This allows servers implementing the trivial credential socket logic to distinguish clients: via a simple getpeername() it can be determined which unit is requesting a credential, and which credential specifically. Example: with this patch in place, in a unit file "waldo.service" a configuration line like the following: LoadCredential=foo:/run/quux/creds.sock will result in a connection to the AF_UNIX socket /run/quux/creds.sock, originating from an abstract namespace AF_UNIX socket: @$RANDOM/unit/waldo.service/foo (The $RANDOM is replaced by some randomized string. This is included in the socket name order to avoid namespace squatting issues: the abstract socket namespace is open to unprivileged users after all, and care needs to be taken not to use guessable names) The services listening on the /run/quux/creds.sock socket may thus easily retrieve the name of the unit the credential is requested for plus the credential name, via a simpler getpeername(), discarding the random preifx and the /unit/ string. This logic uses "/" as separator between the fields, since both unit names and credential names appear in the file system, and thus are designed to use "/" as outer separators. Given that it's a good safe choice to use as separators here, too avoid any conflicts. This is a minimal patch only: the new logic is used only for the unit file credential logic. For other places where we use READ_FULL_FILE_CONNECT_SOCKET it is probably a good idea to use this scheme too, but this should be done carefully in later patches, since the socket names become API that way, and we should determine the right amount of info to pass over.
* Removing unused n_fields in journal-gatewaydSamuel BF2020-09-281-10/+0
|
* tree-wide: use READ_FULL_FILE_CONNECT_SOCKET at various placesLennart Poettering2020-07-211-3/+3
| | | | | | | | | | | Let's use the new flag wherever we read key material/passphrases/hashes off disk, so that people can plug in their own IPC service as backend if they like, easily. (My main goal was actually to support this for crypttab key files — i.e. that you can specify AF_UNIX sockets as third column in crypttab — but that's harder to implement, since the keys are read via libcryptsetup's API, not ours.)
* Fix build with µhttpd 0.9.71Zbigniew Jędrzejewski-Szmek2020-07-011-2/+2
| | | | The return type of callbacks was changed from int to an enum.
* *: use _cleanup_close_ with fdopen() where trivialVito Caputo2020-03-311-5/+3
| | | | Also convert these to use take_fdopen().
* tree-wide: introduce strerror_safe()Yu Watanabe2019-07-041-2/+3
|
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-271-0/+2
| | | | | This means we need to include many more headers in various files that simply included util.h before, but it seems cleaner to do it this way.
* µhttpd: use a cleanup function to call MHD_destroy_responseZbigniew Jędrzejewski-Szmek2019-01-091-39/+14
|
* journal-gateway: define main through macroYu Watanabe2018-12-081-70/+68
|
* journal-gateway: use _cleanup_ attribute to stop microhttpd daemonYu Watanabe2018-12-081-4/+1
|
* util-lib: split out all temporary file related calls into tmpfiles-util.cLennart Poettering2018-12-021-0/+1
| | | | | | | | This splits out a bunch of functions from fileio.c that have to do with temporary files. Simply to make the header files a bit shorter, and to group things more nicely. No code changes, just some rearranging of source files.
* coccinelle: make use of SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek2018-11-221-26/+20
| | | | | | | | | | | Ideally, coccinelle would strip unnecessary braces too. But I do not see any option in coccinelle for this, so instead, I edited the patch text using search&replace to remove the braces. Unfortunately this is not fully automatic, in particular it didn't deal well with if-else-if-else blocks and ifdefs, so there is an increased likelikehood be some bugs in such spots. I also removed part of the patch that coccinelle generated for udev, where we returns -1 for failure. This should be fixed independently.
* Split out pretty-print.c and move pager.c and main-func.h to shared/Zbigniew Jędrzejewski-Szmek2018-11-201-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).
* log: introduce new helper call log_setup_service()Lennart Poettering2018-11-201-3/+1
| | | | | Let's reduce the common boilerplate and have a single setup function used by all service code to setup logging.
* journalctl: port JSON output mode to new JSON APILennart Poettering2018-10-111-0/+3
| | | | | | Also, while we are at it, beef it up, by adding json-seq support (i.e. https://tools.ietf.org/html/rfc7464). This is particularly useful in conjunction with jq's --seq switch.
* tree-wide: add clickable man page link to all --help textsLennart Poettering2018-08-201-5/+17
| | | | | | | | | | 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.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+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.
* journal: rename output_journal to show_journal_entryZbigniew Jędrzejewski-Szmek2018-05-311-1/+1
| | | | | We have show_journal, and output_journal, and it's not immediately clear how they related. Rename the first to show that it just prints one entry.
* os-util: add helpers for finding /etc/os-releaseLennart Poettering2018-05-241-4/+3
| | | | | Place this new helpers in a new source file os-util.[ch], and move the existing and related call path_is_os_tree() to it as well.
* fileio: accept FILE* in addition to path in parse_env_file()Lennart Poettering2018-05-241-2/+2
| | | | | | | Most our other parsing functions do this, let's do this here too, internally we accept that anyway. Also, the closely related load_env_file() and load_env_file_pairs() also do this, so let's be systematic.
* tree-wide: drop spurious newlines (#8764)Lennart Poettering2018-04-191-1/+0
| | | | | | | | Double newlines (i.e. one empty lines) are great to structure code. But let's avoid triple newlines (i.e. two empty lines), quadruple newlines, quintuple newlines, …, that's just spurious whitespace. It's an easy way to drop 121 lines of code, and keeps the coding style of our sources a bit tigther.
* 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.
* journalctl: add highlighting for matched substringZbigniew Jędrzejewski-Szmek2018-01-281-1/+2
| | | | | | | | | Red is used for highligting, the same as grep does. Except when the line is highlighted red already, because it has high priority, in which case plain ansi highlight is used for the matched substring. Coloring is implemented for short and cat outputs, and not for other types. I guess we could also add it for verbose output in the future.
* 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.
* journalctl: add --output-fields= (#7181)Lars Karlitski2017-10-271-1/+1
| | | | | | | | | This option allows restricting the shown fields in the output modes that would normally show all fields. It allows clients that are only interested in a subset of the fields to access those more efficiently. Also, it makes the resulting size of the output more predictable. It has no effect on the various `short` output modes, because those already only show a subset of the fields.
* build-sys: use #if Y instead of #ifdef Y everywhereZbigniew Jędrzejewski-Szmek2017-10-041-1/+1
| | | | | | | | | | | | | | | 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
* journal-gateway: use MHD_USE_POLL_INTERNAL_THREAD instead of MHD_USE_POLLYu Watanabe2017-07-281-1/+1
| | | | | | | | | | | | | | | The option MHD_USE_THREAD_PER_CONNECTION requires MHD_USE_POLL_INTERNAL_THREAD since libmicrohttpd-0.9.53. If MHD_USE_POLL is used instead of MHD_USE_POLL_INTERNAL_THREAD, then the library outputs the following warning: ``` Warning: MHD_USE_THREAD_PER_CONNECTION must be used only with MHD_USE_INTERNAL_POLLING_THREAD. Flag MHD_USE_INTERNAL_POLLING_THREAD was added. Consider setting MHD_USE_INTERNAL_POLLING_THREAD explicitly. ``` The option MHD_USE_POLL_INTERNAL_THREAD is defined as `MHD_USE_POLL_INTERNAL_THREAD = MHD_USE_POLL | MHD_USE_INTERNAL_POLLING_THREAD,` So, let's use MHD_USE_POLL_INTERNAL_THREAD instead of MHD_USE_POLL.
* journal-remote,gateway: use MHD_USE_TLS instead of MHD_USE_SSLYu Watanabe2017-07-281-2/+2
| | | | The option is renamed in libmicrohttpd-0.9.52.
* Merge pull request #5166 from keszybz/gcc7Evgeny Vereshchagin2017-02-011-5/+4
|\ | | | | Fixes for gcc 7 and new µhttpd & glibc warnings
| * microhttpd-util: silence warnings about deprecated optionsZbigniew Jędrzejewski-Szmek2017-01-311-5/+4
| |
* | journal-gatewayd: return -EINVAL if ARG_TRUST and HAVE_GNUTLS (#5181)Yi EungJun2017-01-301-0/+1
| | | | | | This bug was introduced by 1aa1e59.
* | journal-gatewayd: actually recognize -D as a synonym for --directory (#5180)Ivan Shapovalov2017-01-291-1/+1
|/
* journal-gatewayd: align closing braces (#5060)Robert Kreuzer2017-01-111-1/+1
|
* tree-wide: drop NULL sentinel from strjoinZbigniew Jędrzejewski-Szmek2016-10-231-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.
* journal-remote: fix error format stringZbigniew Jędrzejewski-Szmek2016-09-251-2/+2
| | | | Bug introduced in 1b4cd64683.
* microhttpd-util: add the trailing newline automaticallyZbigniew Jędrzejewski-Szmek2016-09-141-19/+18
| | | | | It's prone to error and annoying to have to add it manually. It was missing from a few places.
* journal-remote: implement %m support in mhd_respondfZbigniew Jędrzejewski-Szmek2016-09-141-9/+9
| | | | | | errno value is not protected (it is undefined after this function returns). Various mhd_* functions are not documented to protect errno, so this could not guaranteed anyway.
* journal-gatewayd: fix typo; s/Certificat/Certificate/ (#3931)Vito Caputo2016-08-091-1/+1
|
* journal-gatewayd: fix segfault with certain request (#3893)Yi EungJun2016-08-061-0/+3
| | | | | | | | | When client requests to get logs with `follow` and `KEY=match` that doesn't match any log entry, journal-gatewayd segfaulted. Make request_reader_entries to return zero in such case to wait for matching entries. This fixes https://github.com/systemd/systemd/issues/3873.
* journal-gatewayd: add --directory option (#3913)Yi EungJun2016-08-061-7/+16
| | | Serve journals in the specified directory instead of default journals.
* journal-remote: remove unnecessary gnutls includes (#3895)Vito Caputo2016-08-051-3/+0
| | | | journal-(gatewayd,remote).c don't actually utilize libgnutls even when HAVE_GNUTLS is defined.
* coredump,basic: generalize O_TMPFILE handling a bitLennart Poettering2016-04-221-1/+3
| | | | | | | | | | | | | | | | | | | This moves the O_TMPFILE handling from the coredumping code into common library code, and generalizes it as open_tmpfile_linkable() + link_tmpfile(). The existing open_tmpfile() function (which creates an unlinked temporary file that cannot be linked into the fs) is renamed to open_tmpfile_unlinkable(), to make the distinction clear. Thus, code may now choose between: a) open_tmpfile_linkable() + link_tmpfile() b) open_tmpfile_unlinkable() Depending on whether they want a file that may be linked back into the fs later on or not. In a later commit we should probably convert fopen_temporary() to make use of open_tmpfile_linkable(). Followup for: #3065
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* journal-gatewayd: fix offsetZbigniew Jędrzejewski-Szmek2016-01-201-1/+1
| | | | | I was checking something when writing the patch and committed this by mistake.