summaryrefslogtreecommitdiff
path: root/src/basic/socket-util.c
Commit message (Collapse)AuthorAge
* socket-util: rename parse_socket_address_bind_ipv6_only_or_bool() to ↵Yu Watanabe2018-08-24
| | | | | | | socket_address_bind_ipv6_only_or_bool_from_string() Hence, we can define config_parse_socket_bind() by using DEFINE_CONFIG_PARSE_ENUM() macro.
* tree-wide: drop spurious newlines (#8764)Lennart Poettering2018-08-24
| | | | | | | | | 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-08-24
| | | | | | | | | | 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-08-24
|
* macro: introduce TAKE_PTR() macroLennart Poettering2018-08-24
| | | | | | | | | | | | | | | | 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)
* Prep v238: Remove getnameinfo_pretty(), it is no longer used.Sven Eden2018-06-29
|
* Prep v238: Uncomment now needed headers and unmask now needed functions in ↵Sven Eden2018-06-05
| | | | src/basic (1/6)
* Prep v238: Applied some upstream updates to src/basic (3/5)Sven Eden2018-06-04
|
* socket-util: drop getnameinfo_pretty()Yu Watanabe2018-05-30
|
* basic/socket-util: drop use of NI_IDN_USE_STD3_ASCII_RULESZbigniew Jędrzejewski-Szmek2018-05-30
| | | | | | | The only use of socknameinfo_pretty() is in src/journal-remote/journal-remote.c, to determine the output filename. Replaces #8120.
* socket-util: fix getpeergroups() assert(fd) (#8080)Vito Caputo2018-05-30
| | | | | | | | Don't assert on zero-value fds. Fixes #8075. (cherry picked from commit 75f40779607ea79f20441c7fb46744d04ee2c7ae)
* log: minimize includes in log.hLennart Poettering2018-05-30
| | | | | | | | | | | | | | | | | | | | | | | | | | log.h really should only include the bare minimum of other headers, as it is really pulled into pretty much everything else and already in itself one of the most basic pieces of code we have. Let's hence drop inclusion of: 1. sd-id128.h because it's entirely unneeded in current log.h 2. errno.h, dito. 3. sys/signalfd.h which we can replace by a simple struct forward declaration 4. process-util.h which was needed for getpid_cached() which we now hide in a funciton log_emergency_level() instead, which nicely abstracts the details away. 5. sys/socket.h which was needed for struct iovec, but a simple struct forward declaration suffices for that too. Ultimately this actually makes our source tree larger (since users of the functionality above must now include it themselves, log.h won't do that for them), but I think it helps to untangle our web of includes a tiny bit. (Background: I'd like to isolate the generic bits of src/basic/ enough so that we can do a git submodule import into casync for it)
* socket-util: use parse_ip_port() for parsing IP portsLennart Poettering2018-05-30
| | | | | Let's unify some code here, and also use parse_ip_port() for all our IP port parsing needs in socket_address_parse().
* socket-util: slight rework of getpeersec()Lennart Poettering2018-05-30
| | | | | | | | | | Let's call getsockopt() in a loop, so that we can deal correctly with the label changing while we are trying to read it. (also, while we are at it, let's make sure that there's always one trailing NUL byte at the end of the buffer, after all SO_PEERSEC has zero documentation, and multiple implementing backends, hence let's better be safe than sorry)
* tree-wide: use {pid,uid,gid}_is_valid() where appropriateLennart Poettering2018-05-30
| | | | | | Also, drop UID/GID validity checks from getpeercred() as the kernel will never pass us invalid UID/GID on userns, but the overflow UID/GID instead. Add a comment about this.
* socket-util: add new getpeergroups() callLennart Poettering2018-05-30
| | | | | It's a wrapper around the new SO_PEERGROUPS sockopt, similar in style as getpeersec() and getpeercred().
* socket-util: introduce parse_socket_address_bind_ipv6_only_or_bool()Yu Watanabe2018-05-30
|
* socket-util: clarify why sockaddr_port returns unsigned rather than uint16_tLennart Poettering2018-05-30
|
* socket-util: add socket_address_type_{from,to}_string()Yu Watanabe2018-05-30
|
* Prep v236 : Add missing SPDX-License-Identifier (2/9) src/basicSven Eden2018-03-26
|
* Apply missing updates from upstreamSven Eden2017-12-08
|
* tree-wide: use IN_SET macro (#6977)Yu Watanabe2017-12-08
|
* Apply updates from upstreamSven Eden2017-12-07
|
* build-sys: use #if Y instead of #ifdef Y everywhereZbigniew Jędrzejewski-Szmek2017-11-23
| | | | | | | | | | | | | | | 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
* tree-wide: use `!IN_SET(..)` for `a != b && a != c && …`Andreas Rammhold2017-09-29
| | | | | | The included cocci was used to generate the changes. Thanks to @flo-wer for pointing this case out.
* tree-wide: use IN_SET where possibleAndreas Rammhold2017-09-29
| | | | | In addition to the changes from #6933 this handles cases that could be matched with the included cocci file.
* Support 'rdma' as a ListenNetlink= argument (#6626)Jason Gunthorpe2017-08-29
| | | | NETLINK_RDMA has been in the kernel since v3.0.
* basic/path-util: allow flags for path_equal_or_files_sameZbigniew Jędrzejewski-Szmek2017-07-25
| | | | | No functional change, just a new parameters and the tests that AT_SYMLINK_NOFOLLOW works as expected.
* Make IDN support conditionalWaldemar Brodkorb2017-07-25
| | | | [zj: rename HAVE_IDN to ENABLE_IDN]
* Prep v233.2: Mask unneeded functions and definitions in src/basicSven Eden2017-07-18
|
* socket-util: introduce address_label_validSusant Sahani2017-07-17
|
* fs-util: unify code we use to check if dirent's d_name is "." or ".."Lennart Poettering2017-07-17
| | | | | We use different idioms at different places. Let's replace this is the one true new idiom, that is even a bit faster...
* socket-utils: revert f1811313f42dc7ddaed3c47edc834c2bfd1309b2Susant Sahani2017-07-17
| | | | ':' in not a a valid interface name.
* network: accept colons in network interface names, normally used for alias ↵peoronoob2017-07-17
| | | | interfaces (#5117)
* socket-util: add AF_VSOCK address familyStefan Hajnoczi2017-07-17
| | | | | | | | The AF_VSOCK address family facilitates guest<->host communication on VMware and KVM (virtio-vsock). Adding support to elogind allows guest agents to be launched through .socket unit files. Today guest agents are stand-alone daemons running inside guests that do not take advantage of elogind socket activation.
* socket-util: introduce port argument in sockaddr_port()Stefan Hajnoczi2017-07-17
| | | | | | | | sockaddr_port() either returns a >= 0 port number or a negative errno. This works for AF_INET and AF_INET6 because port ranges are only 16-bit. In AF_VSOCK ports are 32-bit so an int cannot represent all port number and negative errnos. Separate the port and the return code.
* Rename formats-util.h to format-util.hZbigniew Jędrzejewski-Szmek2017-07-17
| | | | | | We don't have plural in the name of any other -util files and this inconsistency trips me up every time I try to type this file name from memory. "formats-util" is even hard to pronounce.
* Prep v232.2: Mask more unneeded functionsSven Eden2017-07-07
|
* sd-device/networkd: unify code to get a socket for issuing netdev ioctls onLennart Poettering2017-07-05
| | | | | | | | | | | As suggested here: https://github.com/elogind/elogind/pull/4296#issuecomment-251911349 Let's try AF_INET first as socket, but let's fall back to AF_NETLINK, so that we can use a protocol-independent socket here if possible. This has the benefit that our code will still work even if AF_INET/AF_INET6 is made unavailable (for exmple via seccomp), at least on current kernels.
* basic: fix for IPv6 status (#4224)Susant Sahani2017-07-05
| | | | | | | | | | | | | | | | | | | | | | Even if ``` cat /proc/sys/net/ipv6/conf/all/disable_ipv6 1 ``` is disabled cat /proc/net/sockstat6 ``` TCP6: inuse 2 UDP6: inuse 1 UDPLITE6: inuse 0 RAW6: inuse 0 FRAG6: inuse 0 memory 0 ``` Looking for /proc/net/if_inet6 is the right choice.
* core: add a concept of "dynamic" user ids, that are allocated as long as a ↵Lennart Poettering2017-07-05
| | | | | | | | | | | | | | | | | | | service is running This adds a new boolean setting DynamicUser= to service files. If set, a new user will be allocated dynamically when the unit is started, and released when it is stopped. The user ID is allocated from the range 61184..65519. The user will not be added to /etc/passwd (but an NSS module to be added later should make it show up in getent passwd). For now, care should be taken that the service writes no files to disk, since this might result in files owned by UIDs that might get assigned dynamically to a different service later on. Later patches will tighten sandboxing in order to ensure that this cannot happen, except for a few selected directories. A simple way to test this is: elogind-run -p DynamicUser=1 /bin/sleep 99999
* socket-util: Run the fallback when the kernel complains about the null ↵Kai Ruhnau2017-06-16
| | | | | | | | | | | buffer (#3541) Calling recv with a NULL buffer returns EFAULT instead of EOPNOTSUPP on older kernels (3.14). Fixes #3407 Signed-off-by: Kai Ruhnau <kai.ruhnau@target-sg.com>
* tree-wide: htonl() is weird, let's use htobe32() instead (#3538)Lennart Poettering2017-06-16
| | | | Super-important change, yeah!
* Prep v230: Apply missing upstream fixes and updates (2/8) src/basic.Sven Eden2017-06-16
|
* Prep v229: Add missing fixes from upstream [1/6] src/basicSven Eden2017-05-17
|
* coredump: rework coredumping logicLennart Poettering2017-05-17
| | | | | | | | | | | | | | | | This reworks the coredumping logic so that the coredump handler invoked from the kernel only collects runtime data about the crashed process, and then submits it for processing to a socket-activate coredump service, which extracts a stacktrace and writes the coredump to disk. This has a number of benefits: the disk IO and stack trace generation may take a substantial amount of resources, and hence should better be managed by PID 1, so that resource management applies. This patch uses RuntimeMaxSec=, Nice=, OOMScoreAdjust= and various sandboxing settings to ensure that the coredump handler doesn't take away unbounded resources from normally priorized processes. This logic is also nice since this makes sure the coredump processing and storage is delayed correctly until /var/elogind/coredump is mounted and writable. Fixes: #2286
* journal: unbreak sd_journal_sendvZbigniew Jędrzejewski-Szmek2017-05-17
| | | | | | | | | | | | Borked since commit 3ee897d6c2401effbc82f5eef35fce405781d6c8 Author: Lennart Poettering <lennart@poettering.net> Date: Wed Sep 23 01:00:04 2015 +0200 tree-wide: port more code to use send_one_fd() and receive_one_fd() because here our fd is not connected and we need to specify the address.
* basic: re-sort includesThomas Hindoe Paaboel Andersen2017-05-17
| | | | | My previous patch to only include what we use accidentially placed the added inlcudes in non-sorted order.
* journal-remote: split-mode=host, remove port from journal filenameKlearchos Chaloulos2017-05-17
| | | | | 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.
* basic: include only what we useThomas Hindoe Paaboel Andersen2017-05-17
| | | | | This is a cleaned up result of running iwyu but without forward declarations on src/basic.