Commit Graph

68 Commits

Author SHA1 Message Date
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Zbigniew Jędrzejewski-Szmek 38b38500c6 tree-wide: use "hostname" spelling everywhere
It's not that I think that "hostname" is vastly superior to "host name". Quite
the opposite — the difference is small, and in some context the two-word version
does fit better. But in the tree, there are ~200 occurrences of the first, and
>1600 of the other, and consistent spelling is more important than any particular
spelling choice.
2020-04-21 16:58:04 +02:00
Yu Watanabe 455fa9610c tree-wide: drop string.h when string-util.h or friends are included 2019-11-04 00:30:32 +09:00
Lennart Poettering e09e7ac3c4 nss-myhostname: unify code that handles NOT_FOUND case
Just some minor rework to make this more like nss-resolve.
2019-04-11 11:13:10 +02:00
Lennart Poettering 2b2fec7db0 util: split out errno related stuff 2019-03-14 13:25:51 +01:00
Lennart Poettering cdccd29f39 nss: unportect errno before writing to NSS' *errnop
Fixes: #11321
2019-02-08 10:34:47 +01:00
Zbigniew Jędrzejewski-Szmek 0192cbdb2c Revert "nss: prevent PROTECT_ERRNO from squashing changes to *errnop"
This reverts commit b26c904113.

I don't see anythign wrong, but Ubuntu autopkgtest CI started failing fairly
consistently since this was merged. Let's see if reverting fixes things.
2019-01-10 21:23:14 +01:00
Sam Morris b26c904113 nss: prevent PROTECT_ERRNO from squashing changes to *errnop
glibc passes in &errno for errnop, which means PROTECT_ERRNO ends up
squashing our intentional changes to *errnop.

Fixes #11321.
2019-01-10 11:08:42 +01:00
Yu Watanabe 06202b9e65 nss: do not modify errno when NSS_STATUS_NOTFOUND or NSS_STATUS_SUCCESS
This also adds PROTECT_ERRNO for all nss module functions.

C.f. glibc NSS documents https://www.gnu.org/software/libc/manual/html_node/NSS-Modules-Interface.html
and discussion in https://sourceware.org/bugzilla/show_bug.cgi?id=23410.

Fixes #9585.
2018-07-25 10:23:22 +02:00
Lennart Poettering 0c69794138 tree-wide: remove Lennart's copyright lines
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.
2018-06-14 10:20:20 +02:00
Lennart Poettering 818bf54632 tree-wide: drop 'This file is part of systemd' blurb
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-06-14 10:20:20 +02:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
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.
2018-04-06 18:58:55 +02:00
Zbigniew Jędrzejewski-Szmek d9215cd838 Add SPDX license headers to various assorted files 2017-11-19 19:08:15 +01:00
Zbigniew Jędrzejewski-Szmek 53e1b68390 Add SPDX license identifiers to source files under the LGPL
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-11-19 19:08:15 +01:00
Andreas Rammhold ec2ce0c5d7
tree-wide: use `!IN_SET(..)` for `a != b && a != c && …`
The included cocci was used to generate the changes.

Thanks to @flo-wer for pointing this case out.
2017-10-02 13:09:56 +02:00
Lennart Poettering f19ca6105e Merge pull request #6420 from keszybz/gateway-name
Rename "gateway" to "_gateway" and other resolved changes
2017-08-01 09:43:41 +02:00
Zbigniew Jędrzejewski-Szmek 5248e7e1f1 resolved,nss-myhostname: use _gateway for the gateway
This changes the symbolic name for the default gateway from "gateway" to
"_gateway". A new configuration option -Dcompat-gateway-hostname=true|false
is added. If it is set, the old name is also supported, but the new name
is used as the canonical name in either case. This is intended as a temporary
measure to make the transition easier, and the option should be removed
after a few releases, at which point only the new name will be used.

The old "gateway" name mostly works OK, but hasn't gained widespread acceptance
because of the following (potential) conflicts:
- it is completely legal to have a host called "gateway"
- there is no guarantee that "gateway" will not be registered as a TLD, even
  though this currently seems unlikely. (Even then, there would be no
  conflict except for the case when the top-level domain itself was being resolved.
  The "gateway" or "_gateway" labels have only special meaning when the
  whole name consists of a single label, so resolution of any subdomain
  of the hypothetical gateway. TLD would still work OK. )
Moving to "_gateway" avoids those issues because underscores are not allowed
in host names (RFC 1123, §2.1) and avoids potential conflicts with local or
global names.

v2:
- simplify the logic to hardcode "_gateway" and allow
  -Dcompat-gateway-hostname=true as a temporary measure.
2017-07-31 14:41:56 -04:00
Lennart Poettering 7bf7ce28b5 string-util: add strlen_ptr() helper
strlen_ptr() is to strlen() what streq_ptr() is to streq(): i.e. it
handles NULL strings in a smart way.
2017-07-31 18:20:28 +02:00
Zbigniew Jędrzejewski-Szmek 72cdb3e783 build-sys: drop automake support
v2:
- also mention m4
2017-07-18 10:04:44 -04:00
Lennart Poettering cda458a54a nss: fix error to ERANGE for nss calls with too little buffer space (#5365)
This is a follow-up for #5359, fixing the error codes in a similar way
for the other NSS modules.

(user/group lookup calls don't have h_errnop, hence we don't update that
in those cases)
2017-02-16 21:29:09 +01:00
Lennart Poettering a1077c8447 nss-myhostname: don't fill scopeid for non-link-local addresses
Inspired by #4465, we shouldn't do this for nss-myhostname either.
2017-02-09 16:13:07 +01:00
Torstein Husebø 61233823aa treewide: fix typos and remove accidental repetition of words 2016-07-11 16:18:43 +02:00
Lennart Poettering 8e38570ebe tree-wide: htonl() is weird, let's use htobe32() instead (#3538)
Super-important change, yeah!
2016-06-15 01:26:01 +02:00
Zbigniew Jędrzejewski-Szmek 82e4c2d656 nss-myhostname: remove dead test of variable that was not set 2016-04-05 23:19:56 -04:00
Zbigniew Jędrzejewski-Szmek 68a9c7c4f0 nss-myhostname: trivial style fixes 2016-04-02 20:11:41 -04:00
Daniel Mack b26fa1a2fb tree-wide: remove Emacs lines from all files
This should be handled fine now by .dir-locals.el, so need to carry that
stuff in every file.
2016-02-10 13:41:57 +01:00
Lennart Poettering 0c5eb0562a nss: block various signals while running NSS lookups
Let's make sure our poll() calls don't get interrupted where they shouldn't (SIGALRM, ...), but allow them to be
interrupted where they should (SIGINT, ...).

Fixes #1965
2016-01-27 02:22:58 +01:00
Lennart Poettering b5efdb8af4 util-lib: split out allocation calls into alloc-util.[ch] 2015-10-27 13:45:53 +01:00
Lennart Poettering 07630cea1f util-lib: split our string related calls from util.[ch] into its own file 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-10-24 23:05:02 +02:00
Lennart Poettering 46a5e0e742 hostname-util: introduce new is_gateway_hostname() call
This moves is_gateway() from nss-myhostname into the basic APIs, and
makes it more like is_localhost(). Also, we rename it to
is_gateway_hostname() to make it more expressive.

Sharing this function in src/basic/ allows us to reuse the function for
routing name requests in resolved (in a later commit).
2015-08-21 12:07:13 +02:00
Lennart Poettering f43242886c nss-myhostname: use LOOPBACK_IFINDEX instead of if_nametoindex("lo")
Given that we already hardocde the loopback ifindex, following the
kernel's own logic, we can replace the invocation of
if_nametoindex("lo") with LOOPBACK_IFINDEX.
2015-08-14 13:11:04 +02:00
David Herrmann 97b11eedff tree-wide: introduce mfree()
Pretty trivial helper which wraps free() but returns NULL, so we can
simplify this:
        free(foobar);
        foobar = NULL;
to this:
        foobar = mfree(foobar);
2015-07-31 19:56:38 +02:00
Lennart Poettering 958b66ea16 util: split all hostname related calls into hostname-util.c 2015-05-18 17:10:07 +02:00
Thomas Hindoe Paaboel Andersen 2eec67acbb remove unused includes
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.
2015-02-23 23:53:42 +01:00
Lennart Poettering 3fdcecc87e nss-myhostname: always will in canonical hostname field when resolving addresses to hostnames
https://bugs.freedesktop.org/show_bug.cgi?id=87634
2015-01-05 16:24:41 +01:00
Lennart Poettering b7d1319393 nss-myhostname: introduce is_gateway() similar to the existing is_hostname() 2014-12-19 02:07:42 +01:00
Harald Hoyer df17ddee08 nss-myhostname: also recognize "gateway."
"gateway." skips adding the domain search path and saves some queries to
the nameserver.
2014-12-16 00:30:34 -05:00
Lennart Poettering 1d050e1e0a rtnl: when querying local addresses and gateways, take address family into account 2014-12-04 01:42:42 +01:00
Lennart Poettering e9140aff75 nss-myhostname: always resolve the host name "gateway" to the local default gateway
This is useful inside of containers or local networks to intrdouce a
stable name of the default gateway host (in case of containers usually
the host, in case of LANs usually local router).
2014-12-03 21:48:45 +01:00
Lennart Poettering ee8c456895 networkd: add minimal client tool "networkd" to query network status
In the long run this should become a full fledged client to networkd
(but not before networkd learns bus support). For now, just pull
interesting data out of networkd, udev, and rtnl and present it to the
user, in a simple but useful output.
2014-08-12 01:54:40 +02:00
Lennart Poettering e70df46b97 nss: always explicitly reset all error variables
glibc appears to be broken if we don't explicitly reset all error
variables, let's work around that.

https://bugzilla.redhat.com/show_bug.cgi?id=1125975
2014-08-01 16:06:39 +02:00
Lennart Poettering a3eca41994 nss-myhostname: don't include assert.h twice 2014-07-23 02:00:39 +02:00
Lennart Poettering 9d48598533 shared: rename PROTO_ADDRESS_SIZE() to FAMILY_ADDRESS_SIZE()
We mostly use "family" to refer to AF_INET, AF_INET6, etc, let's use
this terminology here, too
2014-07-18 12:38:32 +02:00
Lennart Poettering 555bd6e95b nss: various minor fixes to nss-myhostname + nss-mymachines 2014-07-16 03:30:40 +02:00
Lennart Poettering d4c9895d93 nss-myhostname: simplify array building a bit 2014-07-11 15:35:22 +02:00
Lennart Poettering c9fdc26e96 nss-myhostname: move NSS boilerplate to nss-util.h 2014-07-10 23:33:55 +02:00
Lennart Poettering e80af1bddd nss-myhostname: move local address listing logic into shared, so that we can make use of it from machined 2014-07-10 21:01:25 +02:00
Lennart Poettering 947127ff62 nss-myhostname: only export the NSS entry point symbols, nothing else 2014-07-10 20:38:07 +02:00
Lennart Poettering 47efffc22b nss-myhostname: following the usual naming scheme for .c/.h files 2014-07-10 20:25:21 +02:00
Lennart Poettering 5502f0d971 nss-myhostname: various modernizations 2014-07-10 20:12:34 +02:00