summaryrefslogtreecommitdiff
path: root/src/test/test-socket-util.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: replace IOVEC_INIT with IOVEC_MAKEYu Watanabe2023-03-061-8/+8
| | | | | | | | We use gnu11 to build, hence we can use structured initializer with casting, and it is not necessary to use different patterns on initialization and assignment. Addresses https://github.com/systemd/systemd/pull/26560#discussion_r1118875447.
* tree-wide: use -EBADF also in pipe initializersZbigniew Jędrzejewski-Szmek2022-12-191-5/+5
| | | | In some places, initialization is dropped when unnecesary.
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-5/+5
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* socket-util: change sockaddr_un_set_path() to return recognizable error on ↵Lennart Poettering2022-05-131-0/+47
| | | | | | | | | 108ch limit This way we can implement nice fallbacks later on. While we are at it, provide a test for this (one that is a bit over the top, but then again, we can never have enough tests).
* tests: add helper for creating tempfiles with contentZbigniew Jędrzejewski-Szmek2022-03-291-14/+5
| | | | | I put it in tests because I think we're most likely to use it in tests. If necessary, it can be moved somewhere else later.
* test: Use TEST macroJan Janssen2021-11-251-54/+14
| | | | | | | | | This converts to TEST macro where it is trivial. Some additional notable changes: - simplify HAVE_LIBIDN #ifdef in test-dns-domain.c - use saved_argc/saved_argv in test-copy.c, test-path-util.c, test-tmpfiles.c and test-unit-file.c
* test: use assert_se() instead of assert()Yu Watanabe2021-10-121-27/+27
|
* socket-util: add helper for checking if IPv6 is enabledLennart Poettering2021-03-051-0/+6
|
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* basic: convert ifname_valid_full() to take flags and allow numeric interfacesZbigniew Jędrzejewski-Szmek2020-09-101-7/+11
|
* test-in-addr-util: add log headersZbigniew Jędrzejewski-Szmek2020-09-101-6/+0
|
* test: move several tests from test-socket-util.cYu Watanabe2020-09-041-262/+0
|
* util: introduce in_addr_port_ifindex_name_from_string_auto() and ↵Yu Watanabe2020-07-211-0/+33
| | | | in_addr_port_ifindex_name_to_string()
* Merge pull request #15669 from andir/systemd-ipv6-pd-subnet-idLennart Poettering2020-05-271-0/+40
|\ | | | | networkd: subnet id support for ipv6 prefix delegation
| * in-addr-util: introduce in_addr_prefix_nthAndreas Rammhold2020-05-261-0/+40
| |
* | shared: move in_addr_ifindex_name_from_string_auto() thereMarc-André Lureau2020-05-071-0/+19
|/
* util-lib: move things that parse ifnames to shared/Zbigniew Jędrzejewski-Szmek2020-01-111-217/+3
| | | | | | | | | In subsequent commits, calls to if_nametoindex() will be replaced by a wrapper that falls back to alternative name resolution over netlink. netlink support requires libsystemd (for sd-netlink), and we don't want to add any functions that require netlink in basic/. So stuff that calls if_nametoindex() for user supplied interface names, and everything that depends on that, needs to be moved.
* util: introduce ifname_valid_full()Yu Watanabe2019-12-161-0/+1
|
* test-socket-util: avoid writing past the defined bufferZbigniew Jędrzejewski-Szmek2019-10-241-3/+2
| | | | | | | | .sun_path has 108 bytes, and we'd write a string of 108 bytes + NUL. I added this test, but I don't know what it was supposed to test. Let's just remove. Fixes #13713. CID#1405854.
* test: add test for flush_accept()Lennart Poettering2019-04-181-0/+62
| | | | Fixes: #12335
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-271-2/+3
| | | | | 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.
* socket-util: re-implement socket_address_parse_netlink() by using ↵Yu Watanabe2019-02-211-5/+20
| | | | | | | | | extract_first_word() This drops support of trailing white space when a multicast group is specified. Fixes one of issues in #11738.
* util: drop missing.h from socket-util.hYu Watanabe2018-12-061-0/+1
|
* util-lib: split out all temporary file related calls into tmpfiles-util.cLennart Poettering2018-12-021-2/+2
| | | | | | | | 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.
* basic/socket-util: use c-escaping to print unprintable socket pathsZbigniew Jędrzejewski-Szmek2018-11-301-0/+52
| | | | | | | | | | | | | | | | | We are pretty careful to reject abstract sockets that are too long to fit in the address structure as a NUL-terminated string. And since we parse sockets as strings, it is not possible to embed a NUL in the the address either. But we might receive an external socket (abstract or not), and we want to be able to print its address in all cases. We would call socket_address_verify() and refuse to print various sockets that the kernel considers legit. Let's do the strict verification only in case of socket addresses we parse and open ourselves, and do less strict verification when printing addresses of existing sockets, and use c-escaping to print embedded NULs and such. More tests are added. This should make LGTM happier because on FIXME comment is removed.
* shared/socket-util: do not print empty CIDZbigniew Jędrzejewski-Szmek2018-11-301-1/+1
| | | | That's just ugly.
* test-socket-util: add test for socket_address_printZbigniew Jędrzejewski-Szmek2018-11-301-31/+39
|
* test-socket-util: the usual modernizationZbigniew Jędrzejewski-Szmek2018-11-301-47/+83
|
* socket-util: include trailing NUL byte in SOCKADDR_UN_LEN() count for fs socketsLennart Poettering2018-10-151-1/+1
| | | | This is what unix(7) recommends, hence do so.
* tests: use a helper function to parse environment and open loggingZbigniew Jędrzejewski-Szmek2018-09-141-1/+2
| | | | | The advantages are that we save a few lines, and that we can override logging using environment variables in more test executables.
* test-socket-util: avoid "memleak" reported by valgrindZbigniew Jędrzejewski-Szmek2018-08-231-6/+9
| | | | | valgrind reports the allocation done in the short-lived child as a leak. Let's restructure the code to avoid this.
* test-socket-util: Add tests for receive_fd_iov() and friends.Filipe Brandenburger2018-08-021-0/+215
| | | | | | | | Test it when sending an FD without any contents, or an FD and some contents, or only contents and no FD (using a bare send().) Also fix the previous test which forked but was missing an _exit() at the end of the child execution code.
* 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: 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.
* 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.
* test-socket-util: add test for ListenNetlink with spacesZbigniew Jędrzejewski-Szmek2018-03-181-0/+10
|
* fuzz: commit test case for oss-fuzz issue 6884Zbigniew Jędrzejewski-Szmek2018-03-141-0/+3
| | | | | | | | | | | | This seems to be a false positive in msan: https://github.com/google/sanitizers/issues/767. I don't see anything wrong with the code either, and valgrind does not see the issue. Anyway, let's add the test case. We don't have msan hooked up yet, but hopefully we'll in the future. oss-fuzz #6884.
* socket-util: drop getnameinfo_pretty()Yu Watanabe2018-02-101-54/+0
|
* log: minimize includes in log.hLennart Poettering2018-01-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* test: free after useYu Watanabe2018-01-101-1/+1
| | | | CID 1384238.
* socket-util: add new getpeergroups() callLennart Poettering2018-01-041-0/+68
| | | | | It's a wrapper around the new SO_PEERGROUPS sockopt, similar in style as getpeersec() and getpeercred().
* 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.
* test: add support for in_addr_is_multicast testsSusant Sahani2017-02-241-0/+19
|
* socket-utils: revert f1811313f42dc7ddaed3c47edc834c2bfd1309b2Susant Sahani2017-01-241-2/+1
| | | | ':' in not a a valid interface name.
* network: accept colons in network interface names, normally used for alias ↵peoronoob2017-01-231-1/+2
| | | | interfaces (#5117)
* socket-util: add AF_VSOCK address familyStefan Hajnoczi2017-01-101-0/+26
| | | | | | | | The AF_VSOCK address family facilitates guest<->host communication on VMware and KVM (virtio-vsock). Adding support to systemd 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 systemd socket activation.
* tree-wide: htonl() is weird, let's use htobe32() instead (#3538)Lennart Poettering2016-06-151-4/+4
| | | Super-important change, yeah!
* resolved: support IPv6 DNS servers on the local linkLennart Poettering2016-06-061-0/+51
| | | | | | | | | | | Make sure we can parse DNS server addresses that use the "zone id" syntax for local link addresses, i.e. "fe80::c256:27ff:febb:12f%wlp3s0", when reading /etc/resolv.conf. Also make sure we spit this out correctly again when writing /etc/resolv.conf and via the bus. Fixes: #3359
* util-lib: add new ifname_valid() call that validates interface namesLennart Poettering2016-05-091-0/+25
| | | | | Make use of this in nspawn at a couple of places. A later commit should port more code over to this, including networkd.