Vincent Bernat [Sun, 6 Apr 2014 21:41:40 +0000 (23:41 +0200)]
snmp: link with Net-SNMP later
Some systems contain static libraries in the output of `net-snmp-config
--agent-libs`. It is not possible to build a convenience library with a
static library. Therefore, we just link with the appropriate libs in the
last step. This should fix #57.
Vincent Bernat [Wed, 2 Apr 2014 15:10:08 +0000 (17:10 +0200)]
build: use __EXTENSIONS__ and _XOPEN_SOURCE_EXTENDED everywhere
It is needed for Solaris and HP-UX. It doesn't seem to harm other
platforms. Let's hope that the autoconf test will catch
problems. Otherwise, we can still conditionally use them.
Vincent Bernat [Tue, 1 Apr 2014 16:29:07 +0000 (18:29 +0200)]
asprintf: globally define _GNU_SOURCE
And also provide a replacement for asprintf if it is not available. I
would prefer to not use _GNU_SOURCE everywhere but it seems cleaner than
putting it at the top of random files. Ideally, I should wrap every
function in a separate file to just use _GNU_SOURCE for those
functions. There are `asprintf()` and `setres[ug]id()`.
Vincent Bernat [Sun, 2 Mar 2014 23:48:55 +0000 (00:48 +0100)]
lib: don't use strlcpy() when strcpy() just works
clang complains when we use strlcpy() with strlen() on the source. The
change was made because some other tools complained that we used
strcpy() instead of a more secure version. Since they don't agree, let's
switch to the saner thing to do: use strcpy() when it is safe to do.
Vincent Bernat [Thu, 20 Feb 2014 20:52:46 +0000 (21:52 +0100)]
lldpcli: check for privileges by checking access to control socket
Instead of relying on having used the suid bit to run the program, we
check if the real UID/GID could have opened the control socket. This
really fix #56.
Vincent Bernat [Thu, 20 Feb 2014 20:37:22 +0000 (21:37 +0100)]
lldpcli: root is privileged
For some reason, this bug was not catched before. It was expected that
`lldpcli` can be installed as suid `_lldpd` to give user read access to
the neighbor information. However, to avoid write access, we checked if
the user was privileged by checking equality of effective and real user
uid. However, even for root, they don't have to match. Maybe they
matched in the past?
Vincent Bernat [Wed, 19 Feb 2014 14:50:41 +0000 (15:50 +0100)]
interfaces: reset router and wlan capability bits
When adding capability for new interfaces, reset them if the interfaces
providing the capability are not present anymore. Also, add stationOnly
capability if no capability is currently present.
Vincent Bernat [Fri, 13 Dec 2013 22:25:04 +0000 (23:25 +0100)]
priv: add the ability to disable privilege separation
This is a compile time switch in ./configure. It should only be used for
debugging purposes or when memory and number of processes matter or for
running on platforms without a real `fork()` syscall. We add it to the
NEWS but we make no further mention in the documentation.
Vincent Bernat [Fri, 13 Dec 2013 21:48:41 +0000 (22:48 +0100)]
privsep: IO should specify the context
Currently, the context is not needed because IO is always done to the
"remote" process. If we remove privilege separation, the remote process
is ourselves and we need to know which file descriptor to use.
Vincent Bernat [Tue, 31 Dec 2013 14:00:23 +0000 (15:00 +0100)]
include: don't ship `linux/socket.h`
It needs to be paired with `sys/socket.h` (and we don't want to ship it
as it is bound to userland interface). On older libc, like Android's
bionic, `sys/socket.h` is almost empty and all the definitions,
including non-kernel related ones, are in `linux/socket.h`. If we ship
our version of `linux/socket.h`, we have an empty `linux/socket.h` and
an empty `sys/socket.h` and almost no definitions.
Since `linux/netlink.h` extract `__kernel_sa_family_t` from
`linux/socket.h` and we don't have it anymore, we just replace its
definition by `unsigned short`. Being a Linux kernel interface, it is
quite unlikely to change anytime soon.
Vincent Bernat [Mon, 9 Dec 2013 21:42:52 +0000 (22:42 +0100)]
lldp: don't hard-code sysname, sysdescr and portdescr
Instead of using "Not received" when we don't have them, just keep a
pointer to NULL. However, we need to handle that gracefully everywhere:
don't send them over SNMP, don't display them in lldpcli, be ready for
the fact that it should not be sent (even if this is not possible for
the local chassis), don't use it on places were we display the neighbor
and update tests.
Vincent Bernat [Fri, 22 Nov 2013 22:03:51 +0000 (23:03 +0100)]
coverity: fix TOCTOU problem when creating chroot
It is believed that checking for existence of a directory or a file
before an action is useless since it could be created after the check
and before the action. Therefore, it is better to just try to do the
action and handle any failure gracefully.
When setting up the chroot, instead of checking if it already exists, we
create it and don't display an error if it is already set up.
Vincent Bernat [Sun, 10 Nov 2013 15:10:34 +0000 (16:10 +0100)]
osx: update homebrew recipe
The patch is not needed anymore. We replace it with the appropriate
`./configure` option. We could use the shipped launchd file but it
does not contain provision to specify options to enable SNMP support.
Vincent Bernat [Fri, 8 Nov 2013 13:26:34 +0000 (14:26 +0100)]
lldpd: tell `lldpcli` to use the appropriate control socket
When using a non-default control socket, lldpd was not providing the
appropriate name to lldpcli which was then not able to configure lldpd
during startup.
Vincent Bernat [Wed, 23 Oct 2013 08:01:12 +0000 (10:01 +0200)]
privsep: put /etc/localtime in chroot
The chroot directory was created by lldpd if missing. We also copy
`/etc/localtime` in it if not already present. This allows us to
remove duplicate code in many init scripts. Since this file is not
essential, we don't make a fuzz for some edge cases.
Vincent Bernat [Tue, 22 Oct 2013 19:24:19 +0000 (21:24 +0200)]
systemd: also read /etc/sysconfig/lldpd
While systemd's author says that we should get rid of those
pseudo-configuration files, keeping compatibility with previous ways
to configure daemons seem a valid reason to keep them. `/etc/default`
is Debian specific. We also read the equivalent one for RedHat to
ensure that everything will also continue to work here.
Vincent Bernat [Sun, 13 Oct 2013 10:19:01 +0000 (12:19 +0200)]
tests: only test if we have `check` installed
There should have been a good reason to put `TESTS` outside the
conditional but I don't remember it. It works by putting `TESTS`
inside the conditional and avoid an odd error message when trying to
execute tests without check installed.