summaryrefslogtreecommitdiff
path: root/src/socket-proxy
AgeCommit message (Collapse)AuthorFilesLines
2019-11-04tree-wide: drop socket.h when socket-util.h is includedYu Watanabe1-1/+0
2019-11-04tree-wide: drop string.h when string-util.h or friends are includedYu Watanabe1-1/+0
2019-04-10tree-wide: port users over to use new ERRNO_IS_ACCEPT_AGAIN() callLennart Poettering1-1/+1
2019-04-10tree-wide: voidify some socket callsLennart Poettering1-1/+1
2019-03-19tree-wide: use ERRNO_IS_DISCONNECT() at more placesLennart Poettering1-3/+4
2019-01-04tree-wide: use c99 static for array size declarationsZbigniew Jędrzejewski-Szmek1-1/+1
https://hamberg.no/erlend/posts/2013-02-18-static-array-indices.html This only works with clang, unfortunately gcc doesn't seem to implement the check (tested with gcc-8.2.1-5.fc29.x86_64). Simulated error: [2/3] Compiling C object 'systemd-nspawn@exe/src_nspawn_nspawn.c.o'. ../src/nspawn/nspawn.c:3179:45: warning: array argument is too small; contains 15 elements, callee requires at least 16 [-Warray-bounds] candidate = (uid_t) siphash24(arg_machine, strlen(arg_machine), hash_key); ^ ~~~~~~~~ ../src/basic/siphash24.h:24:64: note: callee declares array parameter as static here uint64_t siphash24(const void *in, size_t inlen, const uint8_t k[static 16]); ^~~~~~~~~~~~
2018-12-17socket-proxyd: use typesafe resolve_getaddrinfo()Yu Watanabe1-4/+3
2018-11-23socket-proxy: define main through macroYu Watanabe1-35/+24
2018-11-22coccinelle: make use of SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek1-16/+12
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.
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-10-15tree-wide: port various users over to sockaddr_un_set_path()Lennart Poettering1-10/+9
CID 1396140 CID 1396141
2018-08-20tree-wide: add clickable man page link to all --help textsLennart Poettering1-9/+21
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-22tree-wide: drop copyright lines for more authorsZbigniew Jędrzejewski-Szmek1-3/+0
Acks in https://github.com/systemd/systemd/issues/9320.
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-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.
2017-11-28Add set/hashmap helpers for non-trivial freeing and use where straighforwardZbigniew Jędrzejewski-Szmek1-11/+2
A macro is needed because otherwise we couldn't ensure type safety. Some simple tests are included. No functional change intended.
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-10-04tree-wide: use IN_SET macro (#6977)Yu Watanabe1-2/+2
2017-10-02tree-wide: use `!IN_SET(..)` for `a != b && a != c && …`Andreas Rammhold1-2/+2
The included cocci was used to generate the changes. Thanks to @flo-wer for pointing this case out.
2017-07-18build-sys: drop automake supportZbigniew Jędrzejewski-Szmek1-1/+0
v2: - also mention m4
2017-01-10socket-proxyd: fix --connections-max help message and docs (#5044)(GalaxyMaster)1-1/+1
2016-11-28socket-proxyd: Introduced dynamic connection limit via an option. (#4749)(GalaxyMaster)1-6/+23
2016-05-05tree-wide: introduce new SOCKADDR_UN_LEN() macro, and use it everywhereLennart Poettering1-13/+4
The macro determines the right length of a AF_UNIX "struct sockaddr_un" to pass to connect() or bind(). It automatically figures out if the socket refers to an abstract namespace socket, or a socket in the file system, and properly handles the full length of the path field. This macro is not only safer, but also simpler to use, than the usual offsetof() + strlen() logic.
2016-02-22tree-wide: make ++/-- usage consistent WRT spacingVito Caputo1-1/+1
Throughout the tree there's spurious use of spaces separating ++ and -- operators from their respective operands. Make ++ and -- operator consistent with the majority of existing uses; discard the spaces.
2016-02-10tree-wide: remove Emacs lines from all filesDaniel Mack1-2/+0
This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
2015-12-01journal-remote: split-mode=host, remove port from journal filenameKlearchos Chaloulos1-1/+1
When constructing the journal filename to store logs from a remote host, remove the port of the tcp connection, as the port will change with every reboot/connection loss between sender/reveiver machines. Having the port in the filename will cause a new journal file to be created for every reboot or connection loss. For the implementation, a new argument "bool include_port" is added to the getpeername_pretty() function. This is passed to the sockaddr_pretty() function. The value of the include_port argument is set to true in all calls of getpeername_pretty(), except for 2 calls in journal-remote.c, where it is set to false.
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering1-0/+1
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-8/+6
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-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.
2014-11-28treewide: another round of simplificationsMichal Schmidt1-16/+8
Using the same scripts as in f647962d64e "treewide: yet more log_*_errno + return simplifications".
2014-11-28treewide: use log_*_errno whenever %m is in the format stringMichal Schmidt1-8/+8
If the format string contains %m, clearly errno must have a meaningful value, so we might as well use log_*_errno to have ERRNO= logged. Using: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\((".*%m.*")/log_\1_errno(errno, \2/' Plus some whitespace, linewrap, and indent adjustments.
2014-11-28treewide: yet more log_*_errno + return simplificationsMichal Schmidt1-24/+12
Using: find . -name '*.[ch]' | while read f; do perl -i.mmm -e \ 'local $/; local $_=<>; s/(if\s*\([^\n]+\))\s*{\n(\s*)(log_[a-z_]*_errno\(\s*([->a-zA-Z_]+)\s*,[^;]+);\s*return\s+\g4;\s+}/\1\n\2return \3;/msg; print;' $f done And a couple of manual whitespace fixups.
2014-11-28treewide: more log_*_errno() conversionsMichal Schmidt1-1/+1
2014-11-28treewide: no need to negate errno for log_*_errno()Michal Schmidt1-16/+16
It corrrectly handles both positive and negative errno values.
2014-11-28treewide: auto-convert the simple cases to log_*_errno()Michal Schmidt1-16/+16
As a followup to 086891e5c1 "log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers", use sed to convert the simple cases to use the new macros: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/' Multi-line log_*() invocations are not covered. And we also should add log_unit_*_errno().
2014-10-09socket-proxyd: Unchecked return value from librarySusant Sahani1-1/+1
CID 1237543 (#1 of 1): Unchecked return value from library (CHECKED_RETURN)
2014-09-18include fcntl.h rather than sys/fcntl.hEmil Renner Berthing1-1/+1
2014-09-15hashmap: introduce hash_ops to make struct Hashmap smallerMichal Schmidt1-2/+2
It is redundant to store 'hash' and 'compare' function pointers in struct Hashmap separately. The functions always comprise a pair. Store a single pointer to struct hash_ops instead. systemd keeps hundreds of hashmaps, so this saves a little bit of memory.
2014-08-03Unify parse_argv styleZbigniew Jędrzejewski-Szmek1-10/+6
getopt is usually good at printing out a nice error message when commandline options are invalid. It distinguishes between an unknown option and a known option with a missing arg. It is better to let it do its job and not use opterr=0 unless we actually want to suppress messages. So remove opterr=0 in the few places where it wasn't really useful. When an error in options is encountered, we should not print a lengthy help() and overwhelm the user, when we know precisely what is wrong with the commandline. In addition, since help() prints to stdout, it should not be used except when requested with -h or --help. Also, simplify things here and there.
2014-06-06fix warningsThomas Hindoe Paaboel Andersen1-3/+0
Prevent use of uninitialized variable and removed a now unused cleanup function for freeaddrinfo
2014-06-05socket-proxyd: port to asynchronous name resolution using sd-resolveLennart Poettering1-131/+188
2014-03-24util: replace close_pipe() with new safe_close_pair()Lennart Poettering1-2/+2
safe_close_pair() is more like safe_close(), except that it handles pairs of fds, and doesn't make and misleading allusion, as it works similarly well for socketpairs() as for pipe()s...
2014-03-18util: replace close_nointr_nofail() by a more useful safe_close()Lennart Poettering1-10/+6
safe_close() automatically becomes a NOP when a negative fd is passed, and returns -1 unconditionally. This makes it easy to write lines like this: fd = safe_close(fd); Which will close an fd if it is open, and reset the fd variable correctly. By making use of this new scheme we can drop a > 200 lines of code that was required to test for non-negative fds or to reset the closed fd variable afterwards.
2014-02-20api: in constructor function calls, always put the returned object pointer ↵Lennart Poettering1-4/+4
first (or second) Previously the returned object of constructor functions where sometimes returned as last, sometimes as first and sometimes as second parameter. Let's clean this up a bit. Here are the new rules: 1. The object the new object is derived from is put first, if there is any 2. The object we are creating will be returned in the next arguments 3. This is followed by any additional arguments Rationale: For functions that operate on an object we always put that object first. Constructors should probably not be too different in this regard. Also, if the additional parameters might want to use varargs which suggests to put them last. Note that this new scheme only applies to constructor functions, not to all other functions. We do give a lot of freedom for those. Note that this commit only changes the order of the new functions we added, for old ones we accept the wrong order and leave it like that.
2013-12-13event: be more conservative when returning errors from event handler callbacksLennart Poettering1-8/+9
We really should return errors from event handlers if we have a continous problem and don't know any other solution.
2013-12-11event: hook up sd-event with the service watchdog logicLennart Poettering1-0/+2
Adds a new call sd_event_set_watchdog() that can be used to hook up the event loop with the watchdog supervision logic of systemd. If enabled and $WATCHDOG_USEC is set the event loop will ping the invoking systemd daemon right after coming back from epoll_wait() but not more often than $WATCHDOG_USEC/4. The epoll_wait() will sleep no longer than $WATCHDOG_USEC/4*3, to make sure the service manager is called in time. This means that setting WatchdogSec= in a .service file and calling sd_event_set_watchdog() in your daemon is enough to hook it up with the watchdog logic.
2013-11-27Revert "socket-proxyd: Add --listener option for listener/destination pairs."Lennart Poettering1-42/+21
This reverts commit adcf4c81c58511b67644e17fa743d1729d3c9ccf. We have a better solution for the problem of making two processes run in the same namespace, and --listener is not needed hence and should be dropped. Conflicts: man/systemd-socket-proxyd.xml