Commit graph

59 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 90e74a66e6 tree-wide: define iterator inside of the macro 2020-09-08 12:14:05 +02:00
Lennart Poettering 49f16281c9 tree-wide: use READ_FULL_FILE_CONNECT_SOCKET at various places
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.)
2020-07-21 10:32:01 +02:00
Lennart Poettering f294470262 fileio: add explicit flag for generating world executable warning when reading file 2020-07-21 09:56:44 +02:00
Yu Watanabe d96edb2c6e network: downgrade log level in conf parsers 2020-07-17 00:40:09 +09:00
Zbigniew Jędrzejewski-Szmek 44e9342078 netdev/wireguard: do not invalidate peer on invalid syntax
We would say "ignoring", but invalidate the peer anyway.
Let's only do that if we modified the peer irreperably.

Also add comments explaining allocation handling.
2020-06-22 16:32:37 +02:00
Zbigniew Jędrzejewski-Szmek de7fef4b6e tree-wide: use set_ensure_put()
Patch contains a coccinelle script, but it only works in some cases. Many
parts were converted by hand.

Note: I did not fix errors in return value handing. This will be done separate
to keep the patch comprehensible. No functional change is intended in this
patch.
2020-06-22 16:32:37 +02:00
Yu Watanabe 50254f5500 network: wireguard: set ListenPort= when no peers are configured
Closes #15786.
2020-06-01 14:22:08 +09:00
Yu Watanabe 3267cb45e9
Merge pull request #14208 from poettering/json-homed-prepare
json bits from homed PR
2019-12-17 23:10:08 +09:00
Lennart Poettering 8241f785f4 fileio: add 'dir_fd' parameter to read_full_file_full()
Let's introduce an "at" version of read_full_file().
2019-12-02 09:47:00 +01:00
Zbigniew Jędrzejewski-Szmek 130b812f9d network: warn about unknown sections when parsing .netdev files
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1774242.
Now we'll emit the warning about unknown section [Netdev], making the issue
much easier to diagnose.
2019-11-25 16:45:29 +01:00
Yu Watanabe 737f140546 network: cleanup header inclusion 2019-10-30 22:23:43 +09:00
Yu Watanabe 0bae857564 network: also check the permission of key file 2019-09-11 21:11:01 +09:00
Lennart Poettering 2caa38e99f tree-wide: some more [static] related fixes
let's add [static] where it was missing so far

Drop [static] on parameters that can be NULL.

Add an assert() around parameters that have [static] and can't be NULL
hence.

Add some "const" where it was forgotten.
2019-07-12 16:40:10 +02:00
Zbigniew Jędrzejewski-Szmek e693a93235 Use _cleanup(free_and_erasep) where appropriate
Replaces #12959.
2019-07-10 11:39:03 +02:00
Yu Watanabe daf0f8ca87 network: add NetDevVTable::generate_mac flag 2019-05-28 22:45:35 +09:00
Yu Watanabe 86e2be7bc3 network: drop unnecessary initializations 2019-05-11 06:24:04 +09:00
Yu Watanabe a62b7bb79e network: fix ListenPort= in [WireGuard] section
This fixes a bug introduced by f1368a333e.

Fixes #12377.
2019-04-25 02:43:03 +02:00
Yu Watanabe 01234e1fe7 tree-wide: drop several missing_*.h and import relevant headers from kernel-5.0 2019-04-11 19:00:37 +02:00
Yu Watanabe 86a3d44de5 network: fix use-of-uninitialized-value or null dereference
This fixes a bug introduced by 6ef5c881dd.

Fixes oss-fuzz#14157 and oss-fuzz#14158.
2019-04-10 18:18:11 +09:00
Yu Watanabe 2b942a926c network: make wireguard_decode_key_and_warn() take uint8_t buf[static WG_KEY_LEN] 2019-04-09 15:50:23 +09:00
Yu Watanabe 26f86d500e network: warn when wireguard keys are stored in world readable files 2019-04-09 15:50:22 +09:00
Yu Watanabe a3945c6361 network: add WireGuardPeer.PresharedKeyFile= setting 2019-04-09 15:50:22 +09:00
Yu Watanabe 6ef5c881dd network: clear wireguard keys on failure or on exit 2019-04-09 15:50:22 +09:00
Yu Watanabe cb31e7c861 network: make reading PrivateKeyFile= failure always fatal
This also refactor wireguard_read_key_file().
2019-04-09 15:50:22 +09:00
Yu Watanabe 03fec54396 network: re-indent conf parsers in wireguard.c 2019-04-08 00:52:34 +09:00
Jörg Thalheim 7232c1f9da wireguard: fix exponential backoff when resolving hosts
It should stop at 25s, not start.
Fixes #12134
2019-03-28 20:00:19 +01:00
Zbigniew Jędrzejewski-Szmek 10c353e1c5 Remove variable only used for an assert
When compiled with -DNDEBUG, we get warnings about set-but-unused variables.
In general, it's not something we care about, but since removing those
variables arguably makes the code nicer, let's just to it in this case.
2019-03-28 09:03:06 +01:00
Yu Watanabe 5f07d640ca network: clear previous assignment
Fixes oss-fuzz#13719.
2019-03-15 23:44:51 +09:00
Lennart Poettering 0a9707187b util: split out memcmp()/memset() related calls into memory-util.[ch]
Just some source rearranging.
2019-03-13 12:16:43 +01:00
Yu Watanabe 76df77794a wireguard: add PrivateKeyFile= option
Closes #11878.
2019-03-13 12:02:03 +09:00
Yu Watanabe 9cc9021aed wireguard: check whether PrivateKey= and PublicKey= are set 2019-03-13 11:59:18 +09:00
Yu Watanabe fedcb4c3eb wireguard: drop unused arguments and rename parse_wireguard_key() 2019-03-13 11:59:18 +09:00
Yu Watanabe 583eb170f0 wireguard: do not log wireguard key
It may be PrivateKey=.
2019-03-13 11:59:18 +09:00
Yu Watanabe 85c987a82d wireguard: reuse sd_event_source object 2019-03-13 11:59:18 +09:00
Yu Watanabe f1368a333e wireguard: use NetworkConfigSection to manage [WireGuardPeer] sections
This also contains huge refactoring of wireguard support.
2019-03-13 11:59:18 +09:00
Yu Watanabe 434094864c network: use netlink_message_append_{in_addr,sockaddr}_union() 2019-02-11 01:28:09 +09:00
Yu Watanabe 624a47694c network/wireguard: use sd_netlink_message_append_sockaddr_in{,6}() 2019-01-28 12:27:37 +01:00
Yu Watanabe 2301c54fa9 network/wireguard: fixes sending wireguard peer settings
This fixes a bug introduced by e1f717d4a0.

Fixes #11579.
2019-01-28 10:09:57 +01:00
Zbigniew Jędrzejewski-Szmek 29a93cb19d
Merge pull request #11418 from yuwata/fix-11404
network: fix infinite loop in setting up wireguard
2019-01-15 21:04:32 +01:00
Yu Watanabe 9e2bbf9915 network: make Link and NetDev always have the valid poiter to Manager
c4397d94c3 introduces
link_detach_from_manager() and netdev_detach_from_manager(), and they
set Link::manager or NetDev::manager NULL.
But, at the time e.g. link is removed, hence link_drop() is called,
there may be still some asynchronous netlink call is waiting, and
their callbacks hit assertion.

This make {link,netdev}_detach_from_manager() just drop all references
from manager, but keep the pointer to manager.

Fixes #11411.
2019-01-15 14:48:53 +01:00
Yu Watanabe e1f717d4a0 network: wireguard: rename and split set_wireguard_interface()
This does not change the behavior except for fixing the issue #11404.

Fixes #11404.
2019-01-14 10:08:40 +09:00
Yu Watanabe 1061dab129 netdev: use typesafe resolve_getaddrinfo() in wireguard.c 2018-12-17 10:02:36 +09:00
Yu Watanabe a4c9ae400f netdev: sort headers 2018-12-17 10:02:36 +09:00
Yu Watanabe 302a796f5a network: use typesafe netlink_call_async() macro where applicable 2018-12-02 06:29:32 +01:00
Yu Watanabe fc72155321 network: use structured initializers in wireguard.c 2018-11-05 13:19:02 +09:00
Yu Watanabe c195364da5 network: fix crash in wireguard_done()
Fixes another issue in #10629.
2018-11-05 13:19:02 +09:00
Yu Watanabe 56ba90c2df network: use destroy callback to unref netdev attached to event source 2018-11-05 13:19:02 +09:00
Yu Watanabe 8173d1d0ec network: use destroy callback to clear resolved wireguard endpoints 2018-11-05 13:19:02 +09:00
Yu Watanabe 14cb109d45 tree-wide: replace 'unsigned int' with 'unsigned' 2018-10-19 22:19:12 +02:00
Jason A. Donenfeld 7d0b26a027 networkd: fix attribute length for wireguard (#10380)
This is actually a u16, not a u32, so the kernel complains:

kernel: netlink: 'systemd-network': attribute type 5 has an invalid length

This is due to:

if (nla_attr_len[pt->type] && attrlen != nla_attr_len[pt->type]) {
        pr_warn_ratelimited("netlink: '%s': attribute type %d has an invalid length.\n",
                            current->comm, type);
}

Presumably this has been working fine in functionality on little-endian
systems, but nobody bothered to try on big-endian systems.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-10-13 17:28:49 +09:00