On 2020-12-30 18:39 -0300, Leandro Cunha wrote:
> Package: sponsorship-requests
> Severity: normal
>
> Dear mentors,
>
> I am looking for a sponsor for my package "dhcpcd-dbus":
>
> * Package name : dhcpcd-dbus
> Version : 0.6.1-1
> Upstream Author : Roy Marples <roy@marples.name>
> * URL : https://roy.marples.name/projects/dhcpcd
> * License : BSD-2
> * Vcs : [fill in URL of packaging vcs]
> Section : net
>
> It builds those binary packages:
>
> dhcpcd-dbus - DBus bindings for dhcpcd
>
> To access further information about this package, please visit the following URL:
>
> https://mentors.debian.net/package/dhcpcd-dbus/
>
> Alternatively, one can download the package with dget using this command:
>
> dget -x https://mentors.debian.net/debian/pool/main/d/dhcpcd-dbus/dhcpcd-dbus_0.6.1-1.dsc
>
> Changes since the last upload:
>
> dhcpcd-dbus (0.6.1-1) unstable; urgency=medium
> .
> * QA upload.
> * New upstream release.
> * Fixed Lintian reports.
> * debian/control:
> - Bumped Standards-Version to 4.5.1.
> - Added Rules-Requires-Root: no.
> - Updated homepage field.
> * debian/watch:
> - Fixed problem to import tarball via uscan.
> - Updated version of 3 to 4.
> * debian/copyright:
> - Updated year upstream author.
> - Updated source field.
> - Updated file following DEP-5.
> - Added files debian/* and people involved with year of contribution.
> - Added myself.
> * debian/rules:
> - Set ignore dh_auto_test to fix FTBFS (Fails To Build From Source) and
> thanks to Simon McVitie maintainer of the dbus who helped me with this.
> * Added debian/gbp.conf.
> * Added debian/upstream/metadata.
> * Added debian/test/control to autopkgtest.
> * Added debian/salsa-ci.yml.
OK. That all looks sensible.
I note that lintian complains about the dbus policy:
W: dhcpcd-dbus: dbus-policy-without-send-destination etc/dbus-1/system.d/dhcpcd-dbus.conf <policy context="default"><allow send_interface="name.marples.roy.dhcpcd" />
https://lintian.debian.org/tags/dbus-policy-without-send-destination.html
says:
The package contains D-Bus policy configuration that uses one of the send_* conditions, but does not specify a send_destination, and is not specific to root.
Rules of the form
<allow send_interface="com.example.MyInterface"/>
allow messages with the given interface to be sent to any service, not just the one installing the rule, which is rarely what was intended.
Similarly, on the system bus, rules of the form
<deny send_interface="com.example.MyInterface"/>
are redundant with the system bus's default-deny policy, and have unintended effects on other services.
This check ignores rules of the form
<policy user="root"> <allow ... /> </policy>
which are commonly used for the "agent" pattern seen in services like BlueZ and NetworkManager: a root-privileged daemon calls out to one or more per-user user interface agent processes with no specific name, so send_destination is not easily applicable. However, such rules should still be made as specific as possible to avoid undesired side-effects.
-----
I'm not sure if this is something that should be fixed or ignored?
The config file has not changed from what is in the current version and the file _does_ seem to specify a send_destination, so is there in fact a lintian bug?
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- Only root can own the dhcpcd service -->
<policy user="root">
<allow own="name.marples.roy.dhcpcd"/>
<allow send_interface="name.marples.roy.dhcpcd" />
<allow send_destination="name.marples.roy.dhcpcd" />
</policy>
<policy context="default">
<allow send_interface="name.marples.roy.dhcpcd" />
<allow send_destination="name.marples.roy.dhcpcd" />
</policy>
</busconfig>
Wookey
--
Principal hats: Linaro, Debian, Wookware, ARM
http://wookware.org/
Attachment:
dhcpcd-dbus_0.6.0-2_amd64-2020-12-31T00:43:08Z.build
Description: Binary data
diff -Nru dhcpcd-dbus-0.6.0/config-null.mk dhcpcd-dbus-0.6.1/config-null.mk --- dhcpcd-dbus-0.6.0/config-null.mk 1969-12-31 21:00:00.000000000 -0300 +++ dhcpcd-dbus-0.6.1/config-null.mk 2014-07-14 17:56:47.000000000 -0300 @@ -0,0 +1 @@ +# This space left intentionally blank diff -Nru dhcpcd-dbus-0.6.0/configure dhcpcd-dbus-0.6.1/configure --- dhcpcd-dbus-0.6.0/configure 2012-02-02 16:22:44.000000000 -0200 +++ dhcpcd-dbus-0.6.1/configure 2014-07-14 17:56:47.000000000 -0300 @@ -75,49 +75,37 @@ CONFIG_MK=config.mk if [ -z "$BUILD" ]; then - BUILD=`uname -m`-`uname -s | tr '[:upper:]' '[:lower:]'` -fi -if [ -z "$HOST" ]; then - [ -z "$TARGET" ] && TARGET=$BUILD - HOST=$TARGET -fi -if [ -z "$TARGET" ]; then - [ -z "$HOST" ] && HOST=$BUILD - TARGET=$HOST -fi - -# Debian and Slackware have linux in different places when dealing with -# autoconf, so we deal with that here. -if [ -z "$OS" ]; then - case "$TARGET" in - *-linux-*|linux-*|*-linux|linux) OS=linux;; - esac + # autoconf target triplet: cpu-vendor-os + BUILD=$(uname -m)-unknown-$(uname -s | tr '[:upper:]' '[:lower:]') fi +: ${HOST:=$BUILD} if [ -z "$OS" ]; then - # Derive OS from cpu-manufacturer-os-kernel - CPU=${TARGET%%-*} - REST=${TARGET#*-} + echo "Deriving operating system from ... $HOST" + # Derive OS from cpu-vendor-[kernel-]os + CPU=${HOST%%-*} + REST=${HOST#*-} if [ "$CPU" != "$REST" ]; then - MANU=${REST%%-*} + VENDOR=${REST%%-*} REST=${REST#*-} - if [ "$MANU" != "$REST" ]; then + if [ "$VENDOR" != "$REST" ]; then + # Use kernel if given, otherwise os OS=${REST%%-*} - REST=${REST#*-} - if [ "$OS" != "$REST" ]; then - KERNEL=${REST%%-*} - else - # 3 tupple - KERNEL=$OS - OS=$MANU - MANU= - fi else # 2 tupple - OS=$MANU - MANU= + OS=$VENDOR + VENDOR= fi fi + + # Work with cpu-kernel-os, ie Debian + case "$VENDOR" in + linux*|kfreebsd*) OS=$VENDOR; VENDOR= ;; + esac + # Special case + case "$OS" in + gnu*) OS=hurd;; # No HURD support as yet + esac fi echo "Configuring dhcpcd-dbus for ... $OS" @@ -125,12 +113,42 @@ echo "# $OS" >$CONFIG_MK echo "/* $OS */" >$CONFIG_H -# Linux gets -lrt via -case "$OS" in -linux|kfreebsd) - echo "LDADD+= -lrt" >>$CONFIG_MK - ;; -esac +# Always obey CC. +# However, if CC is not specified and we are given GNU style +# --host or --build targets the expectation is we try and match that +# to a compiler. +if [ -n "$CC" ]; then + HOSTCC= +else + CC=cc + _COMPILERS="cc clang gcc pcc icc" +fi +if [ -n "$HOSTCC" ]; then + for _CC in $_COMPILERS; do + _CC=$(_which "$HOSTCC$_CC") + if [ -x "$_CC" ]; then + CC=$_CC + break + fi + done +fi +if ! type "$CC" >/dev/null 2>&1; then + for _CC in $_COMPILERS; do + _CC=$(_which "$_CC") + if [ -x "$_CC" ]; then + CC=$_CC + break + fi + done +fi + +echo "Using compiler .. $CC" +if ! type "$CC" >/dev/null 2>&1; then + echo "$CC is not an executable" + exit 1 +fi +[ "$CC" != cc ] && echo "CC= $CC" >>$CONFIG_MK +$CC --version | $SED -e '1!d' for x in PREFIX SYSCONFDIR LIBEXECDIR RUNDIR; do eval v=\$$x @@ -144,28 +162,6 @@ echo "#define $x$t \"$v\"" >>$CONFIG_H done -if [ -z "$CC" ]; then - printf "Looking for compiler ... " - for b in $TARGET- ""; do - for cc in gcc pcc clang icc cc; do - if type $b$cc >/dev/null 2>&1; then - CC=$b$cc - echo "$CC" - break - fi - done - [ -n "$CC" ] && break - done - if [ -z "$CC" ]; then - echo - echo "no suitable compiler found - aborting" >&2 - exit 1 - fi -else - echo "Using compiler $CC" -fi -echo "CC= $CC" >>$CONFIG_MK - if [ -n "$CFLAGS" ]; then echo "CFLAGS= $CFLAGS" >>$CONFIG_MK fi @@ -176,11 +172,8 @@ echo "CPPFLAGS+= -I$x" >>$CONFIG_MK done -if [ -n "$DEBUG" -a "$DEBUG" != no -a "$DEBUG" != false ]; then - echo "Enabling memory debugging" - echo "CPPFLAGS+= -DDEBUG_MEMORY" >>$CONFIG_MK -elif [ -z "$DEBUG" -a -d .git ]; then - printf "Found git ... " +if [ -z "$DEBUG" -a -f .fslckout ]; then + printf "Found fossil checkout ... " DEBUG=yes else DEBUG=no @@ -188,21 +181,47 @@ if [ "$DEBUG" != no -a "$DEBUG" != false ]; then echo "Adding debugging CFLAGS" cat <<EOF >>$CONFIG_MK -CFLAGS+= -Wall -Wextra -Wimplicit -Wshadow -Wformat=2 +CFLAGS+= -g -Wall -Wextra -Wshadow -Wformat=2 CFLAGS+= -Wmissing-prototypes -Wmissing-declarations CFLAGS+= -Wmissing-noreturn -Wmissing-format-attribute -CFLAGS+= -Wredundant-decls -Wnested-externs +CFLAGS+= -Wnested-externs CFLAGS+= -Winline -Wwrite-strings -Wcast-align -Wcast-qual -CFLAGS+= -Wpointer-arith -CFLAGS+= -Wdeclaration-after-statement -Wsequence-point -CFLAGS+= -fno-common +CFLAGS+= -Wpointer-arith -Wstrict-overflow +CFLAGS+= -Wdeclaration-after-statement +CFLAGS+= -Wconversion EOF + case "$OS" in + mirbsd*|openbsd*);; # OpenBSD has many redundant decs in system headers + *) echo "CFLAGS+= -Wredundant-decls" >>$CONFIG_MK;; + esac fi # Add CPPFLAGS and CFLAGS to CC for testing features XCC="$CC `$SED -n -e 's/CPPLAGS+=*\(.*\)/\1/p' $CONFIG_MK`" XCC="$XCC `$SED -n -e 's/CFLAGS+=*\(.*\)/\1/p' $CONFIG_MK`" +abort=false +printf "Testing for clock_gettime ... " +cat <<EOF >_clock_gettime.c +#include <time.h> +int main(void) { + struct timespec ts; + return clock_gettime(CLOCK_MONOTONIC, &ts); +} +EOF +if $XCC _clock_gettime.c -o _clock_gettime 2>/dev/null; then + echo "yes" +elif $XCC _clock_gettime.c -lrt -o _clock_gettime 2>/dev/null; then + echo "yes (-lrt)" + echo "LDADD+= -lrt" >>$CONFIG_MK +else + echo "no" + echo "libc support for clock_getttime is required - aborting" >&2 + abort=true +fi +rm -f _clock_gettime.c _clock_gettime +$abort && exit 1 + if [ -z "$STRLCPY" ]; then printf "Testing for strlcpy ... " cat <<EOF >_strlcpy.c diff -Nru dhcpcd-dbus-0.6.0/dbus-dict.c dhcpcd-dbus-0.6.1/dbus-dict.c --- dhcpcd-dbus-0.6.0/dbus-dict.c 2012-02-02 16:22:44.000000000 -0200 +++ dhcpcd-dbus-0.6.1/dbus-dict.c 2014-07-14 17:56:47.000000000 -0300 @@ -1,6 +1,6 @@ /* * dhcpcd-dbus - * Copyright 2009-2012 Roy Marples <roy@marples.name> + * Copyright 2009-2014 Roy Marples <roy@marples.name> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -63,7 +63,7 @@ retval = 0; break; case DBUS_TYPE_BYTE: - byte = strtoul(data, NULL, 0); + byte = (unsigned char)strtoul(data, NULL, 0); dbus_message_iter_open_container(entry, DBUS_TYPE_VARIANT, DBUS_TYPE_BYTE_AS_STRING, &var); if (dbus_message_iter_append_basic(&var, DBUS_TYPE_BYTE, @@ -78,7 +78,7 @@ retval = 0; break; case DBUS_TYPE_INT16: - i16 = strtol(data, NULL, 0); + i16 = (dbus_int16_t)strtol(data, NULL, 0); dbus_message_iter_open_container(entry, DBUS_TYPE_VARIANT, DBUS_TYPE_INT16_AS_STRING, &var); if (dbus_message_iter_append_basic(&var, @@ -86,7 +86,7 @@ retval = 0; break; case DBUS_TYPE_UINT16: - u16 = strtoul(data, NULL, 0); + u16 = (dbus_uint16_t)strtoul(data, NULL, 0); dbus_message_iter_open_container(entry, DBUS_TYPE_VARIANT, DBUS_TYPE_UINT16_AS_STRING, &var); if (dbus_message_iter_append_basic(&var, @@ -94,7 +94,7 @@ retval = 0; break; case DBUS_TYPE_INT32: - i32 = strtol(data, NULL, 0); + i32 = (dbus_int32_t)strtol(data, NULL, 0); dbus_message_iter_open_container(entry, DBUS_TYPE_VARIANT, DBUS_TYPE_INT32_AS_STRING, &var); if (dbus_message_iter_append_basic(&var, @@ -105,7 +105,7 @@ if (strchr(data, '.') != NULL && inet_aton(data, &in) == 1) u32 = in.s_addr; else - u32 = strtoul(data, NULL, 0); + u32 = (dbus_uint32_t)strtoul(data, NULL, 0); dbus_message_iter_open_container(entry, DBUS_TYPE_VARIANT, DBUS_TYPE_UINT32_AS_STRING, &var); if (dbus_message_iter_append_basic(&var, @@ -168,7 +168,7 @@ inet_aton(tok, &in) == 1) u32 = in.s_addr; else - u32 = strtoul(tok, NULL, 0); + u32 = (dbus_uint32_t)strtoul(tok, NULL, 0); ok = dbus_message_iter_append_basic(&array, DBUS_TYPE_UINT32, &u32); break; diff -Nru dhcpcd-dbus-0.6.0/debian/changelog dhcpcd-dbus-0.6.1/debian/changelog --- dhcpcd-dbus-0.6.0/debian/changelog 2020-05-09 15:30:37.000000000 -0300 +++ dhcpcd-dbus-0.6.1/debian/changelog 2020-12-30 12:25:53.000000000 -0300 @@ -1,3 +1,31 @@ +dhcpcd-dbus (0.6.1-1) unstable; urgency=medium + + * QA upload. + * New upstream release. + * Fixed Lintian reports. + * debian/control: + - Bumped Standards-Version to 4.5.1. + - Added Rules-Requires-Root: no. + - Updated homepage field. + * debian/watch: + - Fixed problem to import tarball via uscan. + - Updated version of 3 to 4. + * debian/copyright: + - Updated year upstream author. + - Updated source field. + - Updated file following DEP-5. + - Added files debian/* and people involved with year of contribution. + - Added myself. + * debian/rules: + - Set ignore dh_auto_test to fix FTBFS (Fails To Build From Source) and + thanks to Simon McVitie maintainer of the dbus who helped me with this. + * Added debian/gbp.conf. + * Added debian/upstream/metadata. + * Added debian/test/control to autopkgtest. + * Added debian/salsa-ci.yml. + + -- Leandro Cunha <leandrocunha016@gmail.com> Wed, 30 Dec 2020 12:25:53 -0300 + dhcpcd-dbus (0.6.0-2) unstable; urgency=medium * QA upload. diff -Nru dhcpcd-dbus-0.6.0/debian/control dhcpcd-dbus-0.6.1/debian/control --- dhcpcd-dbus-0.6.0/debian/control 2020-05-09 15:30:37.000000000 -0300 +++ dhcpcd-dbus-0.6.1/debian/control 2020-12-30 12:25:53.000000000 -0300 @@ -3,8 +3,9 @@ Priority: optional Maintainer: Debian QA Group <packages@qa.debian.org> Build-Depends: debhelper-compat (= 13), libdbus-1-dev (>=1) -Standards-Version: 4.5.0 -Homepage: http://roy.marples.name/projects/dhcpcd-dbus +Standards-Version: 4.5.1 +Rules-Requires-Root: no +Homepage: https://roy.marples.name/projects/dhcpcd Package: dhcpcd-dbus Architecture: any diff -Nru dhcpcd-dbus-0.6.0/debian/copyright dhcpcd-dbus-0.6.1/debian/copyright --- dhcpcd-dbus-0.6.0/debian/copyright 2012-04-01 12:57:52.000000000 -0300 +++ dhcpcd-dbus-0.6.1/debian/copyright 2020-12-30 12:25:53.000000000 -0300 @@ -1,27 +1,50 @@ -Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=135 -Maintainer: Roy Marples <roy@marples.name> -Source: http://roy.marples.name/projects/dhcpcd-dbus +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: dhcpcd-dbus +Upstream-Contact: Roy Marples <roy@marples.name> +Source: https://roy.marples.name/downloads/dhcpcd -Copyright: 2009-2010 Roy Marples <roy@marples.name> +Files: * +Copyright: 2009-2014 Roy Marples <roy@marples.name> License: BSD-2 - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - 1. Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. + . + THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +Files: debian/* +Copyright: 2010-2012 Roy Marples <roy@marples.name> + 2014 Chen Baozi <baozich@gmail.com> + 2020 Deivite Huender Ribeiro Cardoso <deivite@riseup.net> + 2020 Leandro Cunha <leandrocunha016@gmail.com> +License: GPL-2+ + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + . + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + On Debian systems, the complete text of the GNU General Public + License can be found in `/usr/share/common-licenses/GPL-2'. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. diff -Nru dhcpcd-dbus-0.6.0/debian/gbp.conf dhcpcd-dbus-0.6.1/debian/gbp.conf --- dhcpcd-dbus-0.6.0/debian/gbp.conf 1969-12-31 21:00:00.000000000 -0300 +++ dhcpcd-dbus-0.6.1/debian/gbp.conf 2020-12-30 12:25:53.000000000 -0300 @@ -0,0 +1,19 @@ +[DEFAULT] +pristine-tar = True +cleaner = /bin/true + +[buildpackage] +sign-tags = True +export-dir = ../build-area/ +ignore-branch = True + +[import-orig] +filter-pristine-tar = True +debian-branch = debian/master + +[pq] +patch-numbers = False + +[dch] +multimaint-merge = True +ignore-branch = True diff -Nru dhcpcd-dbus-0.6.0/debian/rules dhcpcd-dbus-0.6.1/debian/rules --- dhcpcd-dbus-0.6.0/debian/rules 2014-06-06 02:04:02.000000000 -0300 +++ dhcpcd-dbus-0.6.1/debian/rules 2020-12-30 12:25:53.000000000 -0300 @@ -5,3 +5,5 @@ override_dh_auto_clean: [ ! -f config.mk ] || dh_auto_clean +# Commands not to run: +override_dh_auto_test: diff -Nru dhcpcd-dbus-0.6.0/debian/salsa-ci.yml dhcpcd-dbus-0.6.1/debian/salsa-ci.yml --- dhcpcd-dbus-0.6.0/debian/salsa-ci.yml 1969-12-31 21:00:00.000000000 -0300 +++ dhcpcd-dbus-0.6.1/debian/salsa-ci.yml 2020-12-30 12:25:53.000000000 -0300 @@ -0,0 +1,4 @@ +--- +include: + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml diff -Nru dhcpcd-dbus-0.6.0/debian/test/control dhcpcd-dbus-0.6.1/debian/test/control --- dhcpcd-dbus-0.6.0/debian/test/control 1969-12-31 21:00:00.000000000 -0300 +++ dhcpcd-dbus-0.6.1/debian/test/control 2020-12-30 12:25:53.000000000 -0300 @@ -0,0 +1,5 @@ +Test-Command: dbus-send --system --print-reply \ + --dest=name.marples.roy.dhcpcd \ + /name/marples/roy/dhcpcd \ + name.marples.roy.dhcpcd.GetInterfaces +Restrictions: superficial diff -Nru dhcpcd-dbus-0.6.0/debian/upstream/metadata dhcpcd-dbus-0.6.1/debian/upstream/metadata --- dhcpcd-dbus-0.6.0/debian/upstream/metadata 1969-12-31 21:00:00.000000000 -0300 +++ dhcpcd-dbus-0.6.1/debian/upstream/metadata 2020-12-30 12:25:53.000000000 -0300 @@ -0,0 +1,5 @@ +Bug-Database: https://github.com/kobolabs/dhcpcd-dbus/issues +Bug-Submit: https://github.com/kobolabs/dhcpcd-dbus/issues/new +Contact: roy@marples.name +Repository: https://github.com/kobolabs/dhcpcd-dbus.git +Repository-Browse: https://github.com/kobolabs/dhcpcd-dbus \ Nenhum caractere de nova linha no final do arquivo diff -Nru dhcpcd-dbus-0.6.0/debian/watch dhcpcd-dbus-0.6.1/debian/watch --- dhcpcd-dbus-0.6.0/debian/watch 2012-04-01 12:57:52.000000000 -0300 +++ dhcpcd-dbus-0.6.1/debian/watch 2020-12-30 12:25:53.000000000 -0300 @@ -1,2 +1,2 @@ -version=3 -ftp://roy.marples.name/pub/dhcpcd/dhcpcd-dbus-(.*)\.tar\.bz2 debian uupdate +version=4 +https://roy.marples.name/downloads/dhcpcd/dhcpcd-dbus-(.*)\.tar\.bz2 debian uupdate diff -Nru dhcpcd-dbus-0.6.0/defs.h dhcpcd-dbus-0.6.1/defs.h --- dhcpcd-dbus-0.6.0/defs.h 2012-02-02 16:22:44.000000000 -0200 +++ dhcpcd-dbus-0.6.1/defs.h 2014-07-14 17:56:47.000000000 -0300 @@ -1,6 +1,6 @@ /* * dhcpcd-dbus - * Copyright 2008-2012 Roy Marples <roy@marples.name> + * Copyright 2008-2014 Roy Marples <roy@marples.name> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,7 +28,7 @@ #define DEFS_H #define PACKAGE "dhcpcd-dbus" -#define VERSION "0.6.0" +#define VERSION "0.6.1" #include "config.h" diff -Nru dhcpcd-dbus-0.6.0/dhcpcd.c dhcpcd-dbus-0.6.1/dhcpcd.c --- dhcpcd-dbus-0.6.0/dhcpcd.c 2012-02-02 16:22:44.000000000 -0200 +++ dhcpcd-dbus-0.6.1/dhcpcd.c 2014-07-14 17:56:47.000000000 -0300 @@ -1,6 +1,6 @@ /* * dhcpcd-dbus - * Copyright 2009-2012 Roy Marples <roy@marples.name> + * Copyright 2009-2014 Roy Marples <roy@marples.name> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -24,12 +24,16 @@ * SUCH DAMAGE. */ +// For strverscmp(3) +#define _GNU_SOURCE + #include <sys/socket.h> #include <sys/stat.h> #include <sys/un.h> #include <errno.h> #include <fcntl.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -42,15 +46,24 @@ #include "eloop.h" #include "wpa.h" +#ifndef SUN_LEN +#define SUN_LEN(su) \ + (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) +#endif + char *dhcpcd_version = NULL; const char *dhcpcd_status = NULL; struct dhcpcd_config *dhcpcd_configs = NULL; +static bool terminate_commands = false; static char *order; static char *cffile; -int command_fd = -1; +static int command_fd = -1; static int listen_fd = -1; +static const char * const dhcpcd_types[] = + { "link", "ipv4", "ra", "dhcp6", NULL }; + int set_nonblock(int fd) { @@ -68,14 +81,6 @@ static char *lbuf; static size_t lbuf_len; -#ifdef DEBUG_MEMORY -static void -free_lbuf(void) -{ - free(lbuf); -} -#endif - /* Handy routine to read very long lines in text files. * This means we read the whole line and avoid any nasty buffer overflows. * We strip leading space and avoid comment lines, making the code that calls @@ -86,20 +91,10 @@ { char *p, *e, *nbuf; size_t last; -#ifdef DEBUG_MEMORY - static int setup; -#endif if (feof(fp)) return NULL; -#ifdef DEBUG_MEMORY - if (setup == 0) { - setup = 1; - atexit(free_lbuf); - } -#endif - last = 0; do { if (lbuf == NULL || last != 0) { @@ -135,48 +130,63 @@ } static ssize_t -_dhcpcd_command(int fd, const char *cmd, char **buffer) +_dhcpcd_command(int fd, const char *cmd, char **buffer) { - ssize_t bytes, len; + size_t len; + ssize_t bytes; char c[1024], *p; + char *nbuf; /* each argument is NULL seperated. * We may need to send a space one day, so the API * in this function may need to be improved */ - bytes = strlen(cmd) + 1; + len = strlen(cmd) + 1; + if (terminate_commands) + len++; + if (len > sizeof(c)) { + errno = ENOBUFS; + return -1; + } strlcpy(c, cmd, sizeof(c)); p = c; while ((p = strchr(p, ' ')) != NULL) *p++ = '\0'; - bytes = write(fd, c, bytes); - if (bytes == -1) + if (terminate_commands) { + c[len - 2] = '\n'; + c[len - 1] = '\0'; + } else + c[len - 1] = '\0'; + if (write(fd, c, len) == -1) return -1; if (buffer == NULL) return 0; - bytes = read(fd, c, sizeof(ssize_t)); + bytes = read(fd, c, sizeof(size_t)); if (bytes == 0 || bytes == -1) return bytes; - memcpy(&len, c, sizeof(ssize_t)); - *buffer = malloc(len + 1); - if (*buffer == NULL) + memcpy(&len, c, sizeof(size_t)); + nbuf = realloc(*buffer, len + 1); + if (nbuf == NULL) return -1; + *buffer = nbuf; bytes = read(fd, *buffer, len); - if (bytes != -1 && bytes < len) + if (bytes != -1 && (size_t)bytes < len) *buffer[bytes] = '\0'; return bytes; } ssize_t -dhcpcd_command(const char *cmd, char **buffer) +dhcpcd_command(const char *cmd, char **buffer) { + return _dhcpcd_command(command_fd, cmd, buffer); } static int dhcpcd_open(void) { - int fd, len; + int fd; + socklen_t len; struct sockaddr_un sun; if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) @@ -184,7 +194,7 @@ memset(&sun, 0, sizeof(sun)); sun.sun_family = AF_UNIX; strlcpy(sun.sun_path, DHCPCD_SOCKET, sizeof(sun.sun_path)); - len = sizeof(sun.sun_family) + strlen(sun.sun_path) + 1; + len = (socklen_t)SUN_LEN(&sun); if (connect(fd, (struct sockaddr *)&sun, len) == 0) return fd; close(fd); @@ -210,6 +220,7 @@ const char * dhcpcd_get_value(const struct dhcpcd_config *c, const char *var) { + return _get_value(c->data, c->data_len, var); } @@ -250,17 +261,17 @@ { struct dhcpcd_config *c, *nc = NULL, *nl = NULL; char *tmp, *p, *token; - static const char *types[] = { "ipv4", "ra", NULL }; int i; if (order == NULL) return; + tmp = p = strdup(order); while ((token = strsep(&p, " "))) { if (*token == '\0') continue; - for (i = 0; i < 2; i++) { - c = dhcpcd_get_config(token, types[i]); + for (i = 0; dhcpcd_types[i]; i++) { + c = dhcpcd_get_config(token, dhcpcd_types[i]); if (c == NULL) continue; if (c->next) @@ -280,11 +291,6 @@ } free(tmp); dhcpcd_configs = nc; - - printf ("new order: "); - for (c = dhcpcd_configs; c; c = c->next) - printf ("%s(%s) ", c->iface, c->type); - printf ("\n"); } static struct dhcpcd_config * @@ -294,24 +300,43 @@ struct dhcpcd_config *c; iface = _get_value(data, len, "interface="); - if (iface == NULL) { + if (iface == NULL || *iface == '\0') { syslog(LOG_ERR, "dhcpcd: no interface in config"); return NULL; } + type = _get_value(data, len, "ifclass="); + if (type && *type != '\0') { + syslog(LOG_DEBUG, "dhcpcd: %s: skipping ifclass %s", + iface, type); + return NULL; + } reason = _get_value(data, len, "reason="); - if (reason == NULL) { + if (reason == NULL || *reason == '\0') { syslog(LOG_ERR, "dhcpcd: no reason in config"); return NULL; } - if (strcmp(reason, "ROUTERADVERT") == 0) + if (strcmp(reason, "RECONFIGURE") == 0) { + syslog(LOG_WARNING, "no RECONFIGURE support as yet"); + return NULL; + } + if (strcmp(reason, "PREINIT") == 0 || + strcmp(reason, "UNKNOWN") == 0 || + strcmp(reason, "CARRIER") == 0 || + strcmp(reason, "NOCARRIER") == 0 || + strcmp(reason, "DEPARTED") == 0 || + strcmp(reason, "STOPPED") == 0) + type = "link"; + else if (strcmp(reason, "ROUTERADVERT") == 0) type = "ra"; + else if (reason[strlen(reason) - 1] == '6') + type = "dhcp6"; else type = "ipv4"; c = dhcpcd_get_config(iface, type); if (c == NULL) { c = malloc(sizeof(*c)); if (c == NULL) { - syslog(LOG_ERR, "malloc: %m"); + syslog(LOG_ERR, "%s: malloc: %m", __func__); return NULL; } if (dhcpcd_configs) @@ -332,28 +357,26 @@ static struct dhcpcd_config * read_config(int fd) { - char sbuf[sizeof(ssize_t)], *rbuf; - ssize_t bytes, len; + char sbuf[sizeof(size_t)], *rbuf; + size_t len; + ssize_t bytes; struct dhcpcd_config *c; bytes = read(fd, sbuf, sizeof(sbuf)); - if (bytes == 0 || bytes == -1) { - syslog(LOG_ERR, "lost connection to dhcpcd"); - return NULL; - } + if (bytes == 0 || bytes == -1) + goto lost; memcpy(&len, sbuf, sizeof(len)); rbuf = malloc(len + 1); if (rbuf == NULL) { - syslog(LOG_ERR, "malloc: %m"); + syslog(LOG_ERR, "%s: malloc: %m", __func__); return NULL; } bytes = read(fd, rbuf, len); if (bytes == 0 || bytes == -1) { - syslog(LOG_ERR, "lost connection to dhcpcd"); free(rbuf); - return NULL; + goto lost; } - if (bytes != len) { + if ((size_t)bytes != len) { free(rbuf); syslog(LOG_ERR, "dhcpcd: failed to read buffer"); return NULL; @@ -365,6 +388,12 @@ return NULL; } return c; + +lost: + syslog(LOG_ERR, "lost connection to dhcpcd"); + dhcpcd_close(); + add_timeout_sec(1, dhcpcd_init, NULL); + return NULL; } static void @@ -421,6 +450,7 @@ void free_option_value(struct option_value *o) { + free(o->option); free(o->value); free(o); @@ -574,11 +604,10 @@ } if (block == NULL) { if (!skip) - fputc('\n', fp); + fputc('\n', fp); for (i = 0; i < buf_len; i++) { fputs(buf[i], fp); fputc('\n', fp); - skip = buf[i][0] == '\0' ? 1 : 0; } } } else @@ -606,6 +635,7 @@ struct option_value * dhcpcd_read_options(const char *block, const char *name) { + return _options(ACT_READ, block, name, NULL, NULL); } @@ -634,11 +664,37 @@ return list; } +#ifndef __GLIBC__ +/* Good enough for our needs */ +static int +strverscmp(const char *s1, const char *s2) +{ + int s1maj, s1min, s1part; + int s2maj, s2min, s2part; + int r; + + s1min = s1part = 0; + if (sscanf(s1, "%d.%d.%d", &s1maj, &s1min, &s1part) < 1) + return -1; + s2min = s2part = 0; + if (sscanf(s2, "%d.%d.%d", &s2maj, &s2min, &s2part) < 1) + return -1; + r = s1maj - s2maj; + if (r != 0) + return r; + r = s1min - s2min; + if (r != 0) + return r; + return s1part - s2part; +} +#endif + void dhcpcd_init(_unused void *data) { char cmd[128]; - ssize_t nifs, bytes; + ssize_t bytes; + size_t nifs; struct dhcpcd_config *c; static int last_errno; const char *ifo; @@ -662,6 +718,8 @@ syslog(LOG_ERR, "failed to get dhcpcd version"); exit(EXIT_FAILURE); } + terminate_commands = + strverscmp(dhcpcd_version, "6.4.1") >= 0 ? true : false; if (dhcpcd_command("--getconfigfile", &cffile) <= 0) { syslog(LOG_ERR, "failed to get dhcpcd config file"); @@ -679,19 +737,19 @@ free_configs(); dhcpcd_command("--getinterfaces", NULL); - bytes = read(command_fd, cmd, sizeof(ssize_t)); - if (bytes != sizeof(ssize_t)) + bytes = read(command_fd, cmd, sizeof(nifs)); + if (bytes != sizeof(nifs)) return; - memcpy(&nifs, cmd, sizeof(ssize_t)); + memcpy(&nifs, cmd, sizeof(nifs)); for (; nifs > 0; nifs--) { c = read_config(command_fd); + if (c == NULL) + return; ifo = dhcpcd_get_value(c, "interface_order="); if (ifo != NULL) { free(order); order = strdup(ifo); } - if (c == NULL) - return; syslog(LOG_INFO, "retrieved interface %s (%s)", c->iface, dhcpcd_get_value(c, "reason=")); } @@ -717,13 +775,13 @@ free_configs(); free(cffile); cffile = NULL; -#ifdef DEBUG_MEMORY free(dhcpcd_version); dhcpcd_version = NULL; free(order); order = NULL; -#endif dhcpcd_status = "down"; dhcpcd_dbus_signal_status(dhcpcd_status); + free(lbuf); + lbuf = NULL; return retval; } diff -Nru dhcpcd-dbus-0.6.0/dhcpcd-dbus.c dhcpcd-dbus-0.6.1/dhcpcd-dbus.c --- dhcpcd-dbus-0.6.0/dhcpcd-dbus.c 2012-02-02 16:22:44.000000000 -0200 +++ dhcpcd-dbus-0.6.1/dhcpcd-dbus.c 2014-07-14 17:56:47.000000000 -0300 @@ -1,6 +1,6 @@ /* * dhcpcd-dbus - * Copyright 2009-2012 Roy Marples <roy@marples.name> + * Copyright 2009-2014 Roy Marples <roy@marples.name> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -91,7 +91,7 @@ " <arg name=\"status\" type=\"s\"/>\n" " </signal>\n"; -static const struct o_dbus const dhos[] = { +static const struct o_dbus dhos[] = { { "interface=", DBUS_TYPE_STRING, 0, "Interface" }, { "reason=", DBUS_TYPE_STRING, 0, "Reason" }, { "if_up=", DBUS_TYPE_BOOLEAN, 0, "Up" }, @@ -226,11 +226,15 @@ { "subnet_selection=", DBUS_TYPE_UINT32, 0, "SubnetSelection" }, { "domain_search=", DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, "DomainSearch" }, - { "ra1_prefix=", DBUS_TYPE_STRING, 0, "RA_Prefix" }, - { "ra1_prefix_len=", DBUS_TYPE_BYTE, 0, "RA_PrefixLen" }, + + { "ra1_prefix=", DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, "RA_Prefix" }, { "ra1_mtu=", DBUS_TYPE_UINT16, 0, "RA_MTU" }, { "ra1_rdnss=", DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, "RA_RDNSS" }, { "ra1_dnssl=", DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, "RA_DNSSL" }, + + { "dhcp6_ia_na1_ia_addr1=", DBUS_TYPE_STRING, 0, "D6_IPAddress" }, + { "dhcp6_domain_search=", DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, + "D6_DomainSearch" }, { NULL, 0, 0, NULL } }; @@ -311,6 +315,11 @@ DBusMessageIter args; syslog(LOG_INFO, "status changed to %s", status); + if (connection == NULL) { + syslog(LOG_WARNING, + "no DBus connection to notify of status change"); + return; + } msg = dbus_message_new_signal(DHCPCD_PATH, DHCPCD_SERVICE, "StatusChanged"); if (msg == NULL) { @@ -333,6 +342,13 @@ DBusMessageIter args, dict; const char *reason; struct o_dbus type; + const char *up; + + if (connection == NULL) { + syslog(LOG_WARNING, + "no DBus connection for dhcpcd event"); + return; + } msg = dbus_message_new_signal(DHCPCD_PATH, DHCPCD_SERVICE, "Event"); if (msg == NULL) { @@ -349,9 +365,10 @@ DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); + up = dhcpcd_get_value(c, "if_up="); if (strcmp(c->type, "ra") == 0) { retval = append_config(&dict, NULL, c); - } else if (dhcpcd_get_value(c, "new_ip_address") || + } else if ((up && strcmp(up, "true") == 0) || strcmp(reason, "CARRIER") == 0) retval = append_config(&dict, "new_", c); else @@ -550,7 +567,7 @@ if (blocks == NULL && errno) return return_dbus_error(con, msg, S_EINVAL, "dhcpcd_list_blocks: %s", strerror(errno)); - + reply = dbus_message_new_method_return(msg); dbus_message_iter_init_append(reply, &args); dbus_message_iter_open_container(&args, DBUS_TYPE_ARRAY, @@ -595,7 +612,7 @@ if (opts == NULL && errno) return return_dbus_error(con, msg, S_EINVAL, "dhcpcd_read_config: %s", strerror(errno)); - + reply = dbus_message_new_method_return(msg); dbus_message_iter_init_append(reply, &args); dbus_message_iter_open_container(&args, DBUS_TYPE_ARRAY, @@ -672,7 +689,7 @@ opt->value = NULL; dbus_message_iter_next(&array); } - dhcpcd_write_options(*block == '\0' ? NULL : block, + dhcpcd_write_options(block == NULL || *block == '\0' ? NULL : block, *name == '\0' ? NULL : name, opts); while (opts) { opt = opts->next; @@ -688,6 +705,7 @@ static DBusHandlerResult msg_handler(DBusConnection *con, DBusMessage *msg, _unused void *data) { + if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) return introspect(con, msg); @@ -730,7 +748,7 @@ static void dbus_event(int revents, void *watch) { - int flags; + unsigned int flags; flags = 0; if (revents & POLLIN) @@ -744,7 +762,7 @@ if (flags != 0) dbus_watch_handle((DBusWatch *)watch, flags); - if (connection != NULL) { + if (connection) { dbus_connection_ref(connection); while (dbus_connection_dispatch(connection) == DBUS_DISPATCH_DATA_REMAINS) @@ -756,7 +774,9 @@ static dbus_bool_t add_watch(DBusWatch *watch, _unused void *data) { - int fd, flags, eflags; + int fd; + unsigned int flags; + short eflags; fd = dbus_watch_get_unix_fd(watch); flags = dbus_watch_get_flags(watch); @@ -790,24 +810,15 @@ dbus_error_init(&err); connection = dbus_bus_get(DBUS_BUS_SYSTEM, &err); - if (connection == NULL) { - if (dbus_error_is_set(&err)) - syslog(LOG_ERR, "%s", err.message); - else - syslog(LOG_ERR, "failed to get a dbus connection"); - return -1; - } - - ret = dbus_bus_request_name(connection, DHCPCD_SERVICE, - DBUS_NAME_FLAG_REPLACE_EXISTING, &err); if (dbus_error_is_set(&err)) { syslog(LOG_ERR, "%s", err.message); return -1; } - if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - syslog(LOG_ERR, "dbus: not primary owner"); + if (connection == NULL) { + syslog(LOG_ERR, "failed to get a dbus connection"); return -1; } + if (!dbus_connection_set_watch_functions(connection, add_watch, remove_watch, NULL, NULL, NULL)) { @@ -820,12 +831,29 @@ syslog(LOG_ERR, "dbus: failed to register object path"); return -1; } + + /* We need to request our name last */ + ret = dbus_bus_request_name(connection, DHCPCD_SERVICE, + DBUS_NAME_FLAG_REPLACE_EXISTING, &err); + if (dbus_error_is_set(&err)) { + syslog(LOG_ERR, "%s", err.message); + return -1; + } + if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + syslog(LOG_ERR, "dbus: not primary owner"); + return -1; + } + + /* Process the queue as the watchers don't seem to pickup + * the first call if we have just been activated */ + dbus_event(0, NULL); return 0; } void dhcpcd_dbus_close(void) { + if (connection) { dbus_connection_unref(connection); connection = NULL; diff -Nru dhcpcd-dbus-0.6.0/dhcpcd.h dhcpcd-dbus-0.6.1/dhcpcd.h --- dhcpcd-dbus-0.6.0/dhcpcd.h 2012-02-02 16:22:44.000000000 -0200 +++ dhcpcd-dbus-0.6.1/dhcpcd.h 2014-07-14 17:56:47.000000000 -0300 @@ -1,4 +1,4 @@ -/* +/* * dhcpcd-dbus * Copyright 2009-2012 Roy Marples <roy@marples.name> * All rights reserved diff -Nru dhcpcd-dbus-0.6.0/eloop.c dhcpcd-dbus-0.6.1/eloop.c --- dhcpcd-dbus-0.6.0/eloop.c 2012-02-02 16:22:44.000000000 -0200 +++ dhcpcd-dbus-0.6.1/eloop.c 2014-07-14 17:56:47.000000000 -0300 @@ -1,6 +1,6 @@ -/* +/* * dhcpcd-dbus - * Copyright 2009 Roy Marples <roy@marples.name> + * Copyright 2009-2014 Roy Marples <roy@marples.name> * All rights reserved * Redistribution and use in source and binary forms, with or without @@ -52,7 +52,7 @@ static struct event { int fd; - int flags; + short flags; void (*callback)(void *); void (*callback_f)(int, void *); void *arg; @@ -140,7 +140,7 @@ static int _add_event_flags(int fd, - int flags, + short flags, void (*callback)(void *), void (*callback_f)(int, void *), void *arg) @@ -184,12 +184,14 @@ int add_event(int fd, void (*callback)(void *), void *arg) { + return _add_event_flags(fd, 0, callback, NULL, arg); } int -add_event_flags(int fd, int flags, void (*callback)(int, void *), void *arg) +add_event_flags(int fd, short flags, void (*callback)(int, void *), void *arg) { + return _add_event_flags(fd, flags, NULL, callback, arg); } @@ -264,7 +266,7 @@ t->next = timeouts; timeouts = t; return 0; - } + } for (tt = timeouts; tt->next; tt = tt->next) if (timercmp(&t->when, &tt->next->when, <)) { t->next = tt->next; @@ -346,7 +348,6 @@ return n; } -#ifdef DEBUG_MEMORY /* Define this to free all malloced memory. * Normally we don't do this as the OS will do it for us at exit, * but it's handy for debugging other leaks in valgrind. */ @@ -378,7 +379,6 @@ } free(fds); } -#endif _noreturn void start_eloop(void) @@ -389,9 +389,7 @@ struct timeout *t; struct timeval tv; -#ifdef DEBUG_MEMORY atexit(cleanup); -#endif for (;;) { /* Run all timeouts first. @@ -412,8 +410,8 @@ (tv.tv_usec + 999) / 1000 > INT_MAX % 1000)) msecs = INT_MAX; else - msecs = tv.tv_sec * 1000 + - (tv.tv_usec + 999) / 1000; + msecs = (int)(tv.tv_sec * 1000 + + (tv.tv_usec + 999) / 1000); } else /* No timeouts, so wait forever. */ msecs = -1; @@ -431,7 +429,7 @@ free(fds); fds = malloc(sizeof(*fds) * nfds); if (fds == NULL) { - syslog(LOG_ERR, "malloc: %m"); + syslog(LOG_ERR, "%s: malloc: %m", __func__); exit(EXIT_FAILURE); } fds_len = nfds; diff -Nru dhcpcd-dbus-0.6.0/eloop.h dhcpcd-dbus-0.6.1/eloop.h --- dhcpcd-dbus-0.6.0/eloop.h 2012-02-02 16:22:44.000000000 -0200 +++ dhcpcd-dbus-0.6.1/eloop.h 2014-07-14 17:56:47.000000000 -0300 @@ -31,7 +31,7 @@ #include <time.h> int add_event(int, void (*)(void *), void *); -int add_event_flags(int, int, void (*)(int, void *), void *); +int add_event_flags(int, short, void (*)(int, void *), void *); int delete_event(int); int add_timeout_sec(time_t, void (*)(void *), void *); int add_timeout_tv(const struct timeval *, void (*)(void *), void *); diff -Nru dhcpcd-dbus-0.6.0/GNUmakefile dhcpcd-dbus-0.6.1/GNUmakefile --- dhcpcd-dbus-0.6.0/GNUmakefile 2012-02-02 16:22:44.000000000 -0200 +++ dhcpcd-dbus-0.6.1/GNUmakefile 2014-07-14 17:56:47.000000000 -0300 @@ -1,4 +1,8 @@ # GNU Make does not automagically include .depend # Luckily it does read GNUmakefile over Makefile so we can work around it + +# Nasty hack so that make clean works without configure being run +CONFIG_MK?=$(shell test -e config.mk && echo config.mk || echo config-null.mk) + include Makefile --include $(shell test -e .depend && echo .depend) +-include .depend diff -Nru dhcpcd-dbus-0.6.0/iconfig.mk dhcpcd-dbus-0.6.1/iconfig.mk --- dhcpcd-dbus-0.6.0/iconfig.mk 1969-12-31 21:00:00.000000000 -0300 +++ dhcpcd-dbus-0.6.1/iconfig.mk 2014-07-14 17:56:47.000000000 -0300 @@ -0,0 +1,6 @@ +# Nasty hack so that make clean works without configure being run +# Requires gmake4 +_CONFIG_MK!= test -e ${TOP}/config.mk && echo config.mk || echo config-null.mk +CONFIG_MK?= ${_CONFIG_MK} +TOP?= . +include ${TOP}/${CONFIG_MK} diff -Nru dhcpcd-dbus-0.6.0/main.c dhcpcd-dbus-0.6.1/main.c --- dhcpcd-dbus-0.6.0/main.c 2012-02-02 16:22:44.000000000 -0200 +++ dhcpcd-dbus-0.6.1/main.c 2014-07-14 17:56:47.000000000 -0300 @@ -1,6 +1,6 @@ /* * dhcpcd-dbus - * Copyright 2009 Roy Marples <roy@marples.name> + * Copyright 2009-2014 Roy Marples <roy@marples.name> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -36,21 +36,21 @@ #include "dhcpcd-dbus.h" #include "wpa.h" -const char copyright[] = "Copyright (c) 2009-2012 Roy Marples"; +const char copyright[] = "Copyright (c) 2009-2014 Roy Marples"; static void cleanup(void) { + dhcpcd_dbus_close(); wpa_close(NULL); -#ifdef DEBUG_MEMORY dhcpcd_close(); -#endif } static void handle_signal(int sig) { + if (sig) { syslog(LOG_INFO, "Got signal %d, exiting", sig); exit(EXIT_SUCCESS); @@ -60,6 +60,7 @@ int main(void) { + openlog(PACKAGE, LOG_PERROR, LOG_DAEMON); setlogmask(LOG_UPTO(LOG_INFO)); syslog(LOG_INFO, "starting " PACKAGE "-" VERSION); @@ -71,9 +72,11 @@ /* Ignore pipes */ signal(SIGPIPE, SIG_IGN); + dhcpcd_init(NULL); if (dhcpcd_dbus_init() == -1) exit(EXIT_FAILURE); - dhcpcd_init(NULL); + + syslog(LOG_INFO, "init completed, waiting for events"); start_eloop(); exit(EXIT_SUCCESS); } diff -Nru dhcpcd-dbus-0.6.0/Makefile dhcpcd-dbus-0.6.1/Makefile --- dhcpcd-dbus-0.6.0/Makefile 2012-02-02 16:22:44.000000000 -0200 +++ dhcpcd-dbus-0.6.1/Makefile 2014-07-14 17:56:47.000000000 -0300 @@ -5,7 +5,9 @@ OBJS= ${SRCS:.c=.o} CFLAGS?= -O2 -include config.mk + +TOP?= . +include ${TOP}/iconfig.mk CONFFILES= dhcpcd-dbus.conf FILES= name.marples.roy.dhcpcd.service @@ -13,12 +15,13 @@ FILESDIR= ${PREFIX}/share/dbus-1/system-services CLEANFILES+= name.marples.roy.dhcpcd.service -_VERSION_SH= sed -n 's/\#define VERSION[[:space:]]*"\(.*\)".*/\1/p' defs.h -_VERSION!= ${_VERSION_SH} -VERSION= ${_VERSION}$(shell ${_VERSION_SH}) +DEPEND!= test -e .depend && echo "depend" || echo "" +VERSION!= sed -n 's/\#define VERSION[[:space:]]*"\(.*\)".*/\1/p' \ + ${TOP}/defs.h -GITREF?= HEAD +FOSSILID?= current DISTPREFIX?= ${PROG}-${VERSION} +DISTFILEGZ?= ${DISTPREFIX}.tar.gz DISTFILE?= ${DISTPREFIX}.tar.bz2 .SUFFIXES: .in @@ -36,12 +39,20 @@ depend: .depend -${PROG}: .depend ${OBJS} +${PROG}: ${DEPEND} ${OBJS} ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD} -install: +test: + dbus-send --system --print-reply \ + --dest=name.marples.roy.dhcpcd \ + /name/marples/roy/dhcpcd \ + name.marples.roy.dhcpcd.GetInterfaces + +proginstall: ${INSTALL} -d ${DESTDIR}${LIBEXECDIR} ${INSTALL} -m ${BINMODE} ${PROG} ${DESTDIR}${LIBEXECDIR} + +install: proginstall ${INSTALL} -d ${DESTDIR}${CONFDIR} ${INSTALL} -m ${FILESMODE} ${CONFFILES} ${DESTDIR}${CONFDIR} ${INSTALL} -d ${DESTDIR}${FILESDIR} @@ -51,9 +62,11 @@ rm -f ${OBJS} ${PROG} ${PROG}.core ${CLEANFILES} distclean: clean - rm -f .depend config.h config.mk + rm -f .depend config.h config.mk *.bz2 dist: - git archive --prefix=${DISTPREFIX}/ ${GITREF} | bzip2 > ${DISTFILE} + fossil tarball --name ${DISTPREFIX} ${FOSSILID} ${DISTFILEGZ} + gunzip -c ${DISTFILEGZ} | bzip2 >${DISTFILE} + rm ${DISTFILEGZ} include Makefile.inc diff -Nru dhcpcd-dbus-0.6.0/README dhcpcd-dbus-0.6.1/README --- dhcpcd-dbus-0.6.0/README 2012-02-02 16:22:44.000000000 -0200 +++ dhcpcd-dbus-0.6.1/README 2014-07-14 17:56:47.000000000 -0300 @@ -1,5 +1,5 @@ dhcpcd-dbus -Copyright 2009-2010 Roy Marples <roy@marples.name> +Copyright 2009-2014 Roy Marples <roy@marples.name> Installation diff -Nru dhcpcd-dbus-0.6.0/wpa.c dhcpcd-dbus-0.6.1/wpa.c --- dhcpcd-dbus-0.6.0/wpa.c 2012-02-02 16:22:44.000000000 -0200 +++ dhcpcd-dbus-0.6.1/wpa.c 2014-07-14 17:56:47.000000000 -0300 @@ -1,6 +1,6 @@ /* * dhcpcd-dbus - * Copyright 2009-2012 Roy Marples <roy@marples.name> + * Copyright 2009-2014 Roy Marples <roy@marples.name> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -41,6 +41,11 @@ #include "wpa.h" #include "wpa-dbus.h" +#ifndef SUN_LEN +#define SUN_LEN(su) \ + (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) +#endif + struct if_sock { char *iface; int cmd_fd; @@ -58,7 +63,8 @@ _wpa_open(const char *iface, char **path) { static int counter; - int fd, len; + int fd; + socklen_t len; struct sockaddr_un sun; if ((fd = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) @@ -68,7 +74,7 @@ snprintf(sun.sun_path, sizeof(sun.sun_path), "/tmp/" PACKAGE "-wpa-%d.%d", getpid(), counter++); *path = strdup(sun.sun_path); - len = sizeof(sun.sun_family) + strlen(sun.sun_path) + 1; + len = (socklen_t)SUN_LEN(&sun); if (bind(fd, (struct sockaddr *)&sun, len) == -1) { close(fd); unlink(*path); @@ -78,7 +84,7 @@ } snprintf(sun.sun_path, sizeof(sun.sun_path), WPA_CTRL_DIR "/%s", iface); - len = sizeof(sun.sun_family) + strlen(sun.sun_path) + 1; + len = (socklen_t)SUN_LEN(&sun); if (connect(fd, (struct sockaddr *)&sun, len) == 0) { set_nonblock(fd); return fd; @@ -103,7 +109,7 @@ } static ssize_t -_wpa_cmd(int fd, const char *cmd, char *buffer, ssize_t len) +_wpa_cmd(int fd, const char *cmd, char *buffer, size_t len) { int retval; ssize_t bytes; @@ -134,7 +140,7 @@ } ssize_t -wpa_cmd(const char *iface, const char *cmd, char *buffer, ssize_t len) +wpa_cmd(const char *iface, const char *cmd, char *buffer, size_t len) { struct if_sock *ifs; @@ -235,15 +241,15 @@ return retval; } -static int +static ssize_t read_event(const struct if_sock *ifs) { char buffer[256], *p; - ssize_t bytes; + size_t bytes; - bytes = read(ifs->ctrl_fd, buffer, sizeof(buffer)); - if (bytes == -1 || bytes == 0) - return -1; + bytes = (size_t)read(ifs->ctrl_fd, buffer, sizeof(buffer)); + if ((ssize_t)bytes == -1 || bytes == 0) + return (ssize_t)bytes; buffer[bytes] = '\0'; bytes = strlen(buffer); if (buffer[bytes - 1] == ' ') @@ -255,12 +261,13 @@ } if (strcmp(p, "CTRL-EVENT-SCAN-RESULTS") == 0) wpa_dbus_signal_scan_results(ifs->iface); - return bytes; + return (ssize_t)bytes; } static void handle_wpa(void *ifs) { + read_event((const struct if_sock *)ifs); } @@ -280,7 +287,7 @@ syslog(LOG_ERR, "lost connection to wpa_supplicant on interface %s", ifs->iface); - c = dhcpcd_get_config(ifs->iface, "ipv4"); + c = dhcpcd_get_config(ifs->iface, "link"); wpa_close(c->iface); add_timeout_sec(1, wpa_init, (void *)UNCONST(c->iface)); } diff -Nru dhcpcd-dbus-0.6.0/wpa-dbus.c dhcpcd-dbus-0.6.1/wpa-dbus.c --- dhcpcd-dbus-0.6.0/wpa-dbus.c 2012-02-02 16:22:44.000000000 -0200 +++ dhcpcd-dbus-0.6.1/wpa-dbus.c 2014-07-14 17:56:47.000000000 -0300 @@ -1,6 +1,6 @@ /* * dhcpcd-dbus - * Copyright 2009 Roy Marples <roy@marples.name> + * Copyright 2009-2014 Roy Marples <roy@marples.name> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -24,6 +24,9 @@ * SUCH DAMAGE. */ + +#include <errno.h> +#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -98,7 +101,7 @@ " <arg name=\"interface\" direction=\"out\" type=\"s\"/>\n" " </signal>\n"; -static const struct o_dbus const wpaos[] = { +static const struct o_dbus wpaos[] = { { "bssid=", DBUS_TYPE_STRING, 0, "BSSID" }, { "freq=", DBUS_TYPE_INT32, 0, "Frequency" }, { "beacon_int=", DBUS_TYPE_INT32, 0, "BeaconInterval" }, @@ -113,12 +116,13 @@ { NULL, 0, 0, NULL} }; -static int +static ssize_t attach_scan_results(const char *iface, DBusMessageIter *iter) { DBusMessageIter array, dict; char buffer[2048], cmd[20], *p, *s; - ssize_t bytes, i, l; + ssize_t bytes, i; + size_t l; const struct o_dbus *wpaop; int retval; @@ -172,6 +176,11 @@ DBusMessageIter args; syslog(LOG_INFO, "scan results on interface %s", iface); + if (connection == NULL) { + syslog(LOG_WARNING, + "no DBus connection to notify of status change"); + return; + } msg = dbus_message_new_signal(DHCPCD_PATH, DHCPCD_SERVICE, "ScanResults"); if (msg == NULL) { @@ -215,7 +224,7 @@ DBusMessageIter args, array, item; DBusError err; char *s, buffer[2048], *t, *ssid, *bssid, *flags; - ssize_t bytes; + long l; int id; dbus_error_init(&err); @@ -233,7 +242,7 @@ DBUS_TYPE_STRING_AS_STRING DBUS_STRUCT_END_CHAR_AS_STRING, &array); - bytes = wpa_cmd(s, "LIST_NETWORKS", buffer, sizeof(buffer)); + wpa_cmd(s, "LIST_NETWORKS", buffer, sizeof(buffer)); s = strchr(buffer, '\n'); if (s != NULL) { while ((t = strsep(&s, "\n")) != NULL) { @@ -251,7 +260,10 @@ if (flags == NULL) break; *flags++ = '\0'; - id = strtoul(t, NULL, 0); + l = strtol(t, NULL, 0); + if (l < 0 || l > INT32_MAX) + break; + id = (int)l; dbus_message_iter_open_container(&array, DBUS_TYPE_STRUCT, NULL, &item); dbus_message_iter_append_basic(&item, @@ -280,6 +292,7 @@ DBusError err; char *s, buffer[2048]; ssize_t bytes; + long l; int id; dbus_error_init(&err); @@ -293,8 +306,13 @@ return return_dbus_error(con, msg, S_WPA, "Failed to add a new network"); reply = dbus_message_new_method_return(msg); - id = strtol(buffer, NULL, 0); + errno = 0; + l = strtol(buffer, NULL, 0); + if (l < 0 || l > INT32_MAX) + return return_dbus_error(con, msg, S_WPA, + "Network ID conversion error"); dbus_message_iter_init_append(reply, &args); + id = (int)l; dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &id); dbus_connection_send(con, reply, NULL); dbus_message_unref(reply); @@ -355,6 +373,7 @@ static DBusHandlerResult scan(DBusConnection *con, DBusMessage *msg) { + return _cmd(con, msg, "SCAN", "Failed to save configuration"); } @@ -362,6 +381,7 @@ static DBusHandlerResult remove_network(DBusConnection *con, DBusMessage *msg) { + return _network(con, msg, "REMOVE_NETWORK", "Failed to remove the network"); } @@ -369,6 +389,7 @@ static DBusHandlerResult enable_network(DBusConnection *con, DBusMessage *msg) { + return _network(con, msg, "ENABLE_NETWORK", "Failed to enable the network"); } @@ -376,6 +397,7 @@ static DBusHandlerResult disable_network(DBusConnection *con, DBusMessage *msg) { + return _network(con, msg, "DISABLE_NETWORK", "Failed to disable the network"); } @@ -383,6 +405,7 @@ static DBusHandlerResult select_network(DBusConnection *con, DBusMessage *msg) { + return _network(con, msg, "SELECT_NETWORK", "Failed to select the network"); } @@ -390,6 +413,7 @@ static DBusHandlerResult save_config(DBusConnection *con, DBusMessage *msg) { + return _cmd(con, msg, "SAVE_CONFIG", "Failed to save configuration"); } @@ -397,6 +421,7 @@ static DBusHandlerResult reassociate(DBusConnection *con, DBusMessage *msg) { + return _cmd(con, msg, "REASSOCIATE", "Failed to reassociate"); } @@ -421,7 +446,7 @@ dbus_error_init(&err); if (!dbus_message_get_args(msg, &err, - DBUS_TYPE_STRING, &s, + DBUS_TYPE_STRING, &s, DBUS_TYPE_INT32, &id, DBUS_TYPE_STRING, ¶m, DBUS_TYPE_INVALID)) @@ -477,6 +502,7 @@ DBusHandlerResult wpa_dbus_handler(DBusConnection *con, DBusMessage *msg) { + if (dbus_message_is_method_call(msg, DHCPCD_SERVICE, "Scan")) return scan(con, msg); if (dbus_message_is_method_call(msg, DHCPCD_SERVICE, "ScanResults")) diff -Nru dhcpcd-dbus-0.6.0/wpa.h dhcpcd-dbus-0.6.1/wpa.h --- dhcpcd-dbus-0.6.0/wpa.h 2012-02-02 16:22:44.000000000 -0200 +++ dhcpcd-dbus-0.6.1/wpa.h 2014-07-14 17:56:47.000000000 -0300 @@ -30,7 +30,7 @@ #include "dhcpcd.h" int wpa_close(const char *); -ssize_t wpa_cmd(const char *, const char *, char *, ssize_t); +ssize_t wpa_cmd(const char *, const char *, char *, size_t); int wpa_configure(const struct dhcpcd_config *); #endif