Hello community, here is the log from the commit of package batctl for openSUSE:Factory checked in at 2017-11-17 10:57:17 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/batctl (Old) and /work/SRC/openSUSE:Factory/.batctl.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "batctl" Fri Nov 17 10:57:17 2017 rev:18 rq:542488 version:2017.3 Changes: -------- --- /work/SRC/openSUSE:Factory/batctl/batctl.changes 2017-01-09 11:00:11.613856951 +0100 +++ /work/SRC/openSUSE:Factory/.batctl.new/batctl.changes 2017-11-17 11:00:54.370741187 +0100 @@ -1,0 +2,8 @@ +Sat Nov 4 21:26:24 UTC 2017 - [email protected] + +- Update to version 2017.3 + * See the following for all changes: + https://www.open-mesh.org/projects/open-mesh/news +- Cleanup with spec-cleaner + +------------------------------------------------------------------- Old: ---- batctl-2016.5.tar.gz New: ---- batctl-2017.3.tar.gz batctl-2017.3.tar.gz.asc batctl.keyring ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ batctl.spec ++++++ --- /var/tmp/diff_new_pack.8lzbgl/_old 2017-11-17 11:00:55.298707225 +0100 +++ /var/tmp/diff_new_pack.8lzbgl/_new 2017-11-17 11:00:55.298707225 +0100 @@ -1,7 +1,7 @@ # # spec file for package batctl # -# Copyright (c) 2017 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -15,20 +15,18 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # -# Upstream First - Policy: -# Never add any patches to this package without the upstream commit id -# in the patch. Any patches added here without a very good reason to make -# an exception will be silently removed with the next version update. Name: batctl +Version: 2017.3 +Release: 0 Summary: B.A.T.M.A.N. advanced control and management tool -Version: 2016.5 -Release: 2 License: GPL-2.0 Group: Productivity/Networking/Other Url: http://www.open-mesh.org/projects/batctl Source0: http://downloads.open-mesh.org/batman/stable/sources/batctl/%{name}-%{version}.tar.gz -BuildRequires: pkg-config +Source1: http://downloads.open-mesh.org/batman/stable/sources/batctl/%{name}-%{version}.tar.gz.asc +Source2: batctl.keyring +BuildRequires: pkgconfig BuildRequires: pkgconfig(libnl-3.0) %description @@ -40,22 +38,21 @@ tcpdump and interfaces to the kernel module settings. %prep -%setup -n %{name}-%{version} +%setup -q %build export CFLAGS='%{optflags}' make %{?_smp_mflags} %install -%{__mkdir_p} $RPM_BUILD_ROOT%{_bindir} -%{__mkdir_p} $RPM_BUILD_ROOT%{_mandir}/man8 -%{__install} -m 644 man/%{name}.8 $RPM_BUILD_ROOT%{_mandir}/man8 -%{__install} -m 755 %{name} $RPM_BUILD_ROOT%{_bindir} +mkdir -p %{buildroot}%{_bindir} +mkdir -p %{buildroot}%{_mandir}/man8 +install -m 644 man/%{name}.8 %{buildroot}%{_mandir}/man8 +install -m 755 %{name} %{buildroot}%{_bindir} %files -%defattr(-,root,root) %doc README %{_bindir}/%{name} -%{_mandir}/man8/%{name}.8.gz +%{_mandir}/man8/%{name}.8%{ext_man} %changelog ++++++ batctl-2016.5.tar.gz -> batctl-2017.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/CHANGELOG new/batctl-2017.3/CHANGELOG --- old/batctl-2016.5/CHANGELOG 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/CHANGELOG 2017-09-28 14:32:10.000000000 +0200 @@ -1,3 +1,31 @@ +batctl 2017.3 + + * bugs squashed: + - Fix error messages on traceroute send failures + + -- Thu, 28 Sep 2017 13:43:18 +0200 + +batctl 2017.2 + + * coding style cleanups and refactoring + + -- Fri, 28 Jul 2017 13:42:03 +0200 + +batctl 2017.1 + + * (no changes) + + -- Tue, 23 May 2017 11:40:21 +0200 + +batctl 2017.0 + + * remove root check for read-only sysfs and rtnl functionality + * coding style cleanups + * bugs squashed: + - fix check for root priviliges when started under modified effective uid + + -- Tue, 28 Feb 2017 17:22:49 +0100 + batctl 2016.5 * reimplement traceroute/ping commands in userspace without debugfs diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/Makefile new/batctl-2017.3/Makefile --- old/batctl-2016.5/Makefile 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/Makefile 2017-09-28 14:32:10.000000000 +0200 @@ -1,7 +1,7 @@ #!/usr/bin/make -f # -*- makefile -*- # -# Copyright (C) 2006-2016 B.A.T.M.A.N. contributors +# Copyright (C) 2006-2017 B.A.T.M.A.N. contributors # # This program is free software; you can redistribute it and/or # modify it under the terms of version 2 of the GNU General Public diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/allocate.h new/batctl-2017.3/allocate.h --- old/batctl-2016.5/allocate.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/allocate.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2017 B.A.T.M.A.N. contributors: * * Marek Lindner <[email protected]> * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/bat-hosts.c new/batctl-2017.3/bat-hosts.c --- old/batctl-2016.5/bat-hosts.c 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/bat-hosts.c 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2017 B.A.T.M.A.N. contributors: * * Andreas Langer <[email protected]>, Marek Lindner <[email protected]> * @@ -128,7 +128,7 @@ if (!bat_host) { if (read_opt & USE_BAT_HOSTS) - fprintf(stderr, "Error - could not allocate memory: %s\n", strerror(errno)); + perror("Error - could not allocate memory"); goto out; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/bat-hosts.h new/batctl-2017.3/bat-hosts.h --- old/batctl-2016.5/bat-hosts.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/bat-hosts.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2017 B.A.T.M.A.N. contributors: * * Marek Lindner <[email protected]> * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/batman_adv.h new/batctl-2017.3/batman_adv.h --- old/batctl-2016.5/batman_adv.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/batman_adv.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 B.A.T.M.A.N. contributors: +/* Copyright (C) 2016-2017 B.A.T.M.A.N. contributors: * * Matthias Schiffer * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/bisect_iv.c new/batctl-2017.3/bisect_iv.c --- old/batctl-2016.5/bisect_iv.c 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/bisect_iv.c 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2017 B.A.T.M.A.N. contributors: * * Marek Lindner <[email protected]> * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/bisect_iv.h new/batctl-2017.3/bisect_iv.h --- old/batctl-2016.5/bisect_iv.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/bisect_iv.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2017 B.A.T.M.A.N. contributors: * * Marek Lindner <[email protected]> * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/debug.c new/batctl-2017.3/debug.c --- old/batctl-2016.5/debug.c 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/debug.c 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2017 B.A.T.M.A.N. contributors: * * Marek Lindner <[email protected]> * @@ -219,6 +219,8 @@ } } + check_root_or_die("batctl"); + if (read_opt & UNICAST_ONLY && read_opt & MULTICAST_ONLY) { fprintf(stderr, "Error - '-u' and '-m' are exclusive options\n"); debug_table_usage(debug_table); @@ -270,6 +272,8 @@ char *debugfs_mnt; FILE *fp; + check_root_or_die("batctl vis_data"); + debugfs_mnt = debugfs_mount(NULL); if (!debugfs_mnt) { fprintf(stderr, "Error - can't mount or find debugfs\n"); @@ -318,6 +322,8 @@ } } + check_root_or_die("batctl log"); + debugfs_mnt = debugfs_mount(NULL); if (!debugfs_mnt) { fprintf(stderr, "Error - can't mount or find debugfs\n"); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/debug.h new/batctl-2017.3/debug.h --- old/batctl-2016.5/debug.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/debug.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2017 B.A.T.M.A.N. contributors: * * Marek Lindner <[email protected]> * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/functions.c new/batctl-2017.3/functions.c --- old/batctl-2016.5/functions.c 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/functions.c 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2017 B.A.T.M.A.N. contributors: * * Andreas Langer <[email protected]>, Marek Lindner <[email protected]> * @@ -59,7 +59,7 @@ #include "debugfs.h" #include "netlink.h" -#define PATH_BUFF_LEN 200 +#define PATH_BUFF_LEN 400 static struct timespec start_time; static char *host_name; @@ -1138,3 +1138,11 @@ get_random_bytes_fallback(buf, buflen); } + +void check_root_or_die(const char *cmd) +{ + if (geteuid() != 0) { + fprintf(stderr, "Error - you must be root to run '%s' !\n", cmd); + exit(EXIT_FAILURE); + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/functions.h new/batctl-2017.3/functions.h --- old/batctl-2016.5/functions.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/functions.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2017 B.A.T.M.A.N. contributors: * * Andreas Langer <[email protected]>, Marek Lindner <[email protected]> * @@ -31,7 +31,7 @@ #define ETH_STR_LEN 17 #define BATMAN_ADV_TAG "batman-adv:" -#define PATH_BUFF_LEN 200 +#define PATH_BUFF_LEN 400 /* return time delta from start to end in milliseconds */ void start_timer(void); @@ -54,6 +54,7 @@ int check_mesh_iface_ownership(char *mesh_iface, char *hard_iface); void get_random_bytes(void *buf, size_t buflen); +void check_root_or_die(const char *cmd); int print_routing_algos(void); extern char *line_ptr; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/genl.h new/batctl-2017.3/genl.h --- old/batctl-2016.5/genl.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/genl.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2017 B.A.T.M.A.N. contributors: * * Marek Lindner <[email protected]> * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/hash.c new/batctl-2017.3/hash.c --- old/batctl-2016.5/hash.c 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/hash.c 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2006-2017 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/hash.h new/batctl-2017.3/hash.h --- old/batctl-2016.5/hash.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/hash.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2006-2017 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/icmp_helper.c new/batctl-2017.3/icmp_helper.c --- old/batctl-2016.5/icmp_helper.c 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/icmp_helper.c 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2017 B.A.T.M.A.N. contributors: * * Marek Lindner <[email protected]>, Simon Wunderlich * @@ -30,6 +30,7 @@ #include <netinet/ether.h> #include <stdbool.h> #include <stdint.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/ioctl.h> @@ -190,7 +191,7 @@ iface->sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (iface->sock < 0) { - fprintf(stderr, "Error - can't create raw socket: %s\n", strerror(errno)); + perror("Error - can't create raw socket"); ret = -errno; goto free_iface; } @@ -201,7 +202,7 @@ ret = ioctl(iface->sock, SIOCGIFINDEX, &req); if (ret < 0) { - fprintf(stderr, "Error - can't create raw socket (SIOCGIFINDEX): %s\n", strerror(errno)); + perror("Error - can't create raw socket (SIOCGIFINDEX)"); ret = -errno; goto close_sock; } @@ -214,7 +215,7 @@ ret = bind(iface->sock, (struct sockaddr *)&sll, sizeof(struct sockaddr_ll)); if (ret < 0) { - fprintf(stderr, "Error - can't bind raw socket: %s\n", strerror(errno)); + perror("Error - can't bind raw socket"); ret = -errno; goto close_sock; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/icmp_helper.h new/batctl-2017.3/icmp_helper.h --- old/batctl-2016.5/icmp_helper.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/icmp_helper.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2017 B.A.T.M.A.N. contributors: * * Andreas Langer <[email protected]>, Marek Lindner <[email protected]> * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/interface.c new/batctl-2017.3/interface.c --- old/batctl-2016.5/interface.c 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/interface.c 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2017 B.A.T.M.A.N. contributors: * * Marek Lindner <[email protected]> * @@ -330,6 +330,8 @@ if (rest_argc == 0) return print_interfaces(mesh_iface); + check_root_or_die("batctl interface"); + if ((strcmp(rest_argv[0], "add") != 0) && (strcmp(rest_argv[0], "a") != 0) && (strcmp(rest_argv[0], "del") != 0) && (strcmp(rest_argv[0], "d") != 0) && (strcmp(rest_argv[0], "create") != 0) && (strcmp(rest_argv[0], "c") != 0) && diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/interface.h new/batctl-2017.3/interface.h --- old/batctl-2016.5/interface.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/interface.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2017 B.A.T.M.A.N. contributors: * * Marek Lindner <[email protected]> * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/ioctl.c new/batctl-2017.3/ioctl.c --- old/batctl-2016.5/ioctl.c 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/ioctl.c 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2012-2017 B.A.T.M.A.N. contributors: * * Marek Lindner <[email protected]> * @@ -35,6 +35,8 @@ #include "ioctl.h" +void check_root_or_die(const char *cmd); + /* code borrowed from ethtool */ static int statistics_custom_get(int fd, struct ifreq *ifr) { @@ -48,7 +50,7 @@ ifr->ifr_data = (void *)&drvinfo; err = ioctl(fd, SIOCETHTOOL, ifr); if (err < 0) { - fprintf(stderr, "Error - can't open driver information: %s\n", strerror(errno)); + perror("Error - can't open driver information"); goto out; } @@ -72,7 +74,7 @@ ifr->ifr_data = (void *)strings; err = ioctl(fd, SIOCETHTOOL, ifr); if (err < 0) { - fprintf(stderr, "Error - can't get stats strings information: %s\n", strerror(errno)); + perror("Error - can't get stats strings information"); goto out; } @@ -81,7 +83,7 @@ ifr->ifr_data = (void *) stats; err = ioctl(fd, SIOCETHTOOL, ifr); if (err < 0) { - fprintf(stderr, "Error - can't get stats information: %s\n", strerror(errno)); + perror("Error - can't get stats information"); goto out; } @@ -110,7 +112,7 @@ fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) { - fprintf(stderr, "Error - can't open socket: %s\n", strerror(errno)); + perror("Error - can't open socket"); goto out; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/ioctl.h new/batctl-2017.3/ioctl.h --- old/batctl-2016.5/ioctl.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/ioctl.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2012-2017 B.A.T.M.A.N. contributors: * * Marek Lindner <[email protected]> * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/list.h new/batctl-2017.3/list.h --- old/batctl-2016.5/list.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/list.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,6 +1,6 @@ /* Minimal Linux-like double-linked list helper functions * - * Copyright (c) 2012-2016, Sven Eckelmann <[email protected]> + * Copyright (c) 2012-2017, Sven Eckelmann <[email protected]> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/main.c new/batctl-2017.3/main.c --- old/batctl-2016.5/main.c 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/main.c 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2017 B.A.T.M.A.N. contributors: * * Andreas Langer <[email protected]>, Marek Lindner <[email protected]> * @@ -134,13 +134,6 @@ exit(EXIT_SUCCESS); } - /* TODO: remove this generic check here and move it into the individual functions */ - /* check if user is root */ - if ((strncmp(argv[1], "bisect", strlen("bisect")) != 0) && ((getuid()) || (getgid()))) { - fprintf(stderr, "Error - you must be root to run '%s' !\n", argv[0]); - exit(EXIT_FAILURE); - } - if ((strcmp(argv[1], "interface") == 0) || (strcmp(argv[1], "if") == 0)) { ret = interface(mesh_iface, argc - 1, argv + 1); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/main.h new/batctl-2017.3/main.h --- old/batctl-2016.5/main.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/main.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2017 B.A.T.M.A.N. contributors: * * Andreas Langer <[email protected]>, Marek Lindner <[email protected]> * @@ -25,7 +25,7 @@ #include <stdint.h> #ifndef SOURCE_VERSION -#define SOURCE_VERSION "2016.5" +#define SOURCE_VERSION "2017.3" #endif #define SOCKET_PATH_FMT "%s/batman_adv/%s/socket" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/netlink.c new/batctl-2017.3/netlink.c --- old/batctl-2016.5/netlink.c 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/netlink.c 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2017 B.A.T.M.A.N. contributors: * * Marek Lindner <[email protected]>, Andrew Lunn <[email protected]> * @@ -1177,11 +1177,12 @@ } /* only parse routing algorithm name */ + last_err = -EINVAL; info_header = netlink_get_info(ifindex, BATADV_CMD_GET_ORIGINATORS, NULL); free(info_header); if (strlen(algo_name_buf) == 0) - return -EOPNOTSUPP; + return last_err; if (!strcmp("BATMAN_IV", algo_name_buf)) header = " Originator last-seen (#/255) Nexthop [outgoingIF]\n"; @@ -1244,11 +1245,12 @@ } /* only parse routing algorithm name */ + last_err = -EINVAL; info_header = netlink_get_info(ifindex, BATADV_CMD_GET_ORIGINATORS, NULL); free(info_header); if (strlen(algo_name_buf) == 0) - return -EOPNOTSUPP; + return last_err; if (!strcmp("BATMAN_IV", algo_name_buf)) header = " Router ( TQ) Next Hop [outgoingIf] Bandwidth\n"; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/netlink.h new/batctl-2017.3/netlink.h --- old/batctl-2016.5/netlink.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/netlink.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2017 B.A.T.M.A.N. contributors: * * Marek Lindner <[email protected]>, Andrew Lunn <[email protected]> * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/packet.h new/batctl-2017.3/packet.h --- old/batctl-2016.5/packet.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/packet.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2016 B.A.T.M.A.N. contributors: +/* Copyright (C) 2007-2017 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/ping.c new/batctl-2017.3/ping.c --- old/batctl-2016.5/ping.c 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/ping.c 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2017 B.A.T.M.A.N. contributors: * * Andreas Langer <[email protected]>, Marek Lindner <[email protected]> * @@ -45,7 +45,7 @@ #include "icmp_helper.h" -char is_aborted = 0; +static volatile sig_atomic_t is_aborted = 0; static void ping_usage(void) @@ -133,6 +133,8 @@ return EXIT_FAILURE; } + check_root_or_die("batctl ping"); + dst_string = argv[found_args]; bat_hosts_init(0); bat_host = bat_hosts_find_by_name(dst_string); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/ping.h new/batctl-2017.3/ping.h --- old/batctl-2016.5/ping.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/ping.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2017 B.A.T.M.A.N. contributors: * * Marek Lindner <[email protected]> * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/sys.c new/batctl-2017.3/sys.c --- old/batctl-2016.5/sys.c 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/sys.c 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2017 B.A.T.M.A.N. contributors: * * Marek Lindner <[email protected]> * @@ -156,6 +156,8 @@ snprintf(path_buff, PATH_BUFF_LEN, SYS_BATIF_PATH_FMT, mesh_iface); if (argc != 1) { + check_root_or_die("batctl loglevel"); + for (i = 1; i < argc; i++) { if (strcmp(argv[i], "none") == 0) { log_level = 0; @@ -268,6 +270,8 @@ goto out; } + check_root_or_die("batctl"); + if (!batctl_settings[setting].params) goto write_file; @@ -380,6 +384,8 @@ goto out; } + check_root_or_die("batctl gw_mode"); + if (strcmp(argv[1], "client") == 0) gw_mode = GW_MODE_CLIENT; else if (strcmp(argv[1], "server") == 0) @@ -449,6 +455,8 @@ } } + check_root_or_die("batctl routing_algo"); + if (argc == 2) { res = write_file(SYS_SELECTED_RA_PATH, "", argv[1], NULL); goto out; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/sys.h new/batctl-2017.3/sys.h --- old/batctl-2016.5/sys.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/sys.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2017 B.A.T.M.A.N. contributors: * * Marek Lindner <[email protected]> * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/tcpdump.c new/batctl-2017.3/tcpdump.c --- old/batctl-2016.5/tcpdump.c 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/tcpdump.c 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2017 B.A.T.M.A.N. contributors: * * Andreas Langer <[email protected]> * @@ -39,6 +39,7 @@ #include <netinet/icmp6.h> #include <netinet/if_ether.h> #include <net/ethernet.h> +#include <signal.h> #include <stddef.h> #include <stdint.h> #include <sys/select.h> @@ -1113,9 +1114,98 @@ parse_eth_hdr(packet_buff, buff_len, read_opt, time_printed); } -int tcpdump(int argc, char **argv) +static struct dump_if *create_dump_interface(char *iface) { + struct dump_if *dump_if; struct ifreq req; + int res; + + dump_if = malloc(sizeof(struct dump_if)); + if (!dump_if) + return NULL; + + memset(dump_if, 0, sizeof(struct dump_if)); + + dump_if->dev = iface; + if (strlen(dump_if->dev) > IFNAMSIZ - 1) { + fprintf(stderr, "Error - interface name too long: %s\n", dump_if->dev); + goto free_dumpif; + } + + dump_if->raw_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); + if (dump_if->raw_sock < 0) { + perror("Error - can't create raw socket"); + goto free_dumpif; + } + + memset(&req, 0, sizeof (struct ifreq)); + strncpy(req.ifr_name, dump_if->dev, IFNAMSIZ); + req.ifr_name[sizeof(req.ifr_name) - 1] = '\0'; + + res = ioctl(dump_if->raw_sock, SIOCGIFHWADDR, &req); + if (res < 0) { + perror("Error - can't create raw socket (SIOCGIFHWADDR)"); + goto close_socket; + } + + dump_if->hw_type = req.ifr_hwaddr.sa_family; + + switch (dump_if->hw_type) { + case ARPHRD_ETHER: + case ARPHRD_IEEE80211_PRISM: + case ARPHRD_IEEE80211_RADIOTAP: + break; + default: + fprintf(stderr, "Error - interface '%s' is of unknown type: %i\n", dump_if->dev, dump_if->hw_type); + goto close_socket; + } + + memset(&req, 0, sizeof (struct ifreq)); + strncpy(req.ifr_name, dump_if->dev, IFNAMSIZ); + req.ifr_name[sizeof(req.ifr_name) - 1] = '\0'; + + res = ioctl(dump_if->raw_sock, SIOCGIFINDEX, &req); + if (res < 0) { + perror("Error - can't create raw socket (SIOCGIFINDEX)"); + goto close_socket; + } + + dump_if->addr.sll_family = AF_PACKET; + dump_if->addr.sll_protocol = htons(ETH_P_ALL); + dump_if->addr.sll_ifindex = req.ifr_ifindex; + + res = bind(dump_if->raw_sock, (struct sockaddr *)&dump_if->addr, sizeof(struct sockaddr_ll)); + if (res < 0) { + perror("Error - can't bind raw socket"); + goto close_socket; + } + + return dump_if; + +close_socket: + close(dump_if->raw_sock); +free_dumpif: + free(dump_if); + + return NULL; +} + +static volatile sig_atomic_t is_aborted = 0; + +static void sig_handler(int sig) +{ + switch (sig) { + case SIGINT: + case SIGTERM: + is_aborted = 1; + break; + default: + break; + } +} + +int tcpdump(int argc, char **argv) +{ struct timeval tv; struct dump_if *dump_if, *dump_if_tmp; struct list_head dump_if_list; @@ -1165,78 +1255,21 @@ return EXIT_FAILURE; } + check_root_or_die("batctl tcpdump"); + bat_hosts_init(read_opt); + signal(SIGINT, sig_handler); + signal(SIGTERM, sig_handler); + /* init interfaces list */ INIT_LIST_HEAD(&dump_if_list); FD_ZERO(&wait_sockets); while (argc > found_args) { - - dump_if = malloc(sizeof(struct dump_if)); - memset(dump_if, 0, sizeof(struct dump_if)); - dump_if->raw_sock = -1; - - dump_if->dev = argv[found_args]; - - if (strlen(dump_if->dev) > IFNAMSIZ - 1) { - fprintf(stderr, "Error - interface name too long: %s\n", dump_if->dev); - goto out; - } - - dump_if->raw_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); - - if (dump_if->raw_sock < 0) { - fprintf(stderr, "Error - can't create raw socket: %s\n", strerror(errno)); - goto out; - } - - memset(&req, 0, sizeof (struct ifreq)); - strncpy(req.ifr_name, dump_if->dev, IFNAMSIZ); - req.ifr_name[sizeof(req.ifr_name) - 1] = '\0'; - - res = ioctl(dump_if->raw_sock, SIOCGIFHWADDR, &req); - if (res < 0) { - fprintf(stderr, "Error - can't create raw socket (SIOCGIFHWADDR): %s\n", strerror(errno)); - close(dump_if->raw_sock); - goto out; - } - - dump_if->hw_type = req.ifr_hwaddr.sa_family; - - switch (dump_if->hw_type) { - case ARPHRD_ETHER: - case ARPHRD_IEEE80211_PRISM: - case ARPHRD_IEEE80211_RADIOTAP: - break; - default: - fprintf(stderr, "Error - interface '%s' is of unknown type: %i\n", dump_if->dev, dump_if->hw_type); - goto out; - } - - memset(&req, 0, sizeof (struct ifreq)); - strncpy(req.ifr_name, dump_if->dev, IFNAMSIZ); - req.ifr_name[sizeof(req.ifr_name) - 1] = '\0'; - - res = ioctl(dump_if->raw_sock, SIOCGIFINDEX, &req); - - if (res < 0) { - fprintf(stderr, "Error - can't create raw socket (SIOCGIFINDEX): %s\n", strerror(errno)); - close(dump_if->raw_sock); + dump_if = create_dump_interface(argv[found_args]); + if (!dump_if) goto out; - } - - dump_if->addr.sll_family = AF_PACKET; - dump_if->addr.sll_protocol = htons(ETH_P_ALL); - dump_if->addr.sll_ifindex = req.ifr_ifindex; - - res = bind(dump_if->raw_sock, (struct sockaddr *)&dump_if->addr, sizeof(struct sockaddr_ll)); - - if (res < 0) { - fprintf(stderr, "Error - can't bind raw socket: %s\n", strerror(errno)); - close(dump_if->raw_sock); - goto out; - } if (dump_if->raw_sock > max_sock) max_sock = dump_if->raw_sock; @@ -1246,7 +1279,7 @@ found_args++; } - while (1) { + while (!is_aborted) { memcpy(&tmp_wait_sockets, &wait_sockets, sizeof(fd_set)); @@ -1259,7 +1292,7 @@ continue; if (res < 0) { - fprintf(stderr, "Error - can't select on raw socket: %s\n", strerror(errno)); + perror("Error - can't select on raw socket"); continue; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/tcpdump.h new/batctl-2017.3/tcpdump.h --- old/batctl-2016.5/tcpdump.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/tcpdump.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2017 B.A.T.M.A.N. contributors: * * Andreas Langer <[email protected]>, Marek Lindner <[email protected]> * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/tp_meter.c new/batctl-2017.3/tp_meter.c --- old/batctl-2016.5/tp_meter.c 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/tp_meter.c 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2013-2017 B.A.T.M.A.N. contributors: * * Antonio Quartulli <[email protected]> * @@ -432,6 +432,8 @@ return EXIT_FAILURE; } + check_root_or_die("batctl throughputmeter"); + dst_string = argv[found_args]; bat_hosts_init(read_opt); bat_host = bat_hosts_find_by_name(dst_string); @@ -498,8 +500,9 @@ break; case BATADV_TP_REASON_CANCEL: printf("CANCEL received: test aborted\n"); - /* fall through and print the partial result */ + /* fall through */ case BATADV_TP_REASON_COMPLETE: + /* print the partial result */ if (result.test_time > 0) { throughput = result.total_bytes * 1000; throughput /= result.test_time; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/tp_meter.h new/batctl-2017.3/tp_meter.h --- old/batctl-2016.5/tp_meter.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/tp_meter.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2013-2017 B.A.T.M.A.N. contributors: * * Antonio Quartulli <[email protected]> * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/traceroute.c new/batctl-2017.3/traceroute.c --- old/batctl-2016.5/traceroute.c 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/traceroute.c 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2017 B.A.T.M.A.N. contributors: * * Andreas Langer <[email protected]>, Marek Lindner <[email protected]> * @@ -94,6 +94,8 @@ return EXIT_FAILURE; } + check_root_or_die("batctl traceroute"); + dst_string = argv[found_args]; bat_hosts_init(read_opt); bat_host = bat_hosts_find_by_name(dst_string); @@ -148,7 +150,7 @@ (struct batadv_icmp_header *)&icmp_packet_out, sizeof(icmp_packet_out)); if (res < 0) { - fprintf(stderr, "Error - can't send icmp packet: %s\n", strerror(res)); + fprintf(stderr, "Error - can't send icmp packet: %s\n", strerror(-res)); continue; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/traceroute.h new/batctl-2017.3/traceroute.h --- old/batctl-2016.5/traceroute.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/traceroute.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2017 B.A.T.M.A.N. contributors: * * Marek Lindner <[email protected]> * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/translate.c new/batctl-2017.3/translate.c --- old/batctl-2016.5/translate.c 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/translate.c 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2017 B.A.T.M.A.N. contributors: * * Andreas Langer <[email protected]>, Marek Lindner <[email protected]> * @@ -46,6 +46,8 @@ return EXIT_FAILURE; } + check_root_or_die("batctl translate"); + dst_string = argv[1]; bat_hosts_init(0); bat_host = bat_hosts_find_by_name(dst_string); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2016.5/translate.h new/batctl-2017.3/translate.h --- old/batctl-2016.5/translate.h 2016-12-15 18:32:21.000000000 +0100 +++ new/batctl-2017.3/translate.h 2017-09-28 14:32:10.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2017 B.A.T.M.A.N. contributors: * * Marek Lindner <[email protected]> *
