From df7a819fd9b147248d814bc69b883f49446feae9 Mon Sep 17 00:00:00 2001 From: David Schweikert Date: Sun, 29 Jul 2018 08:27:04 +0200 Subject: [PATCH] Allow running fping --help even when raw socket can't be opened, fixes #131 --- CHANGELOG.md | 1 + src/fping.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e164a0e..7641dac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ fping 4.1 (UNRELEASED) - Fix problem when socket fd is 0 (#125, thanks Ramón Novoa!) - Fix running on servers with disabled IPv6 (#118, thanks Simon Matter) +- Allow running "fping -h" or "--help" even when raw socket can't be opened (#131, thanks @teto) fping 4.0 (2017-04-23) ====================== diff --git a/src/fping.c b/src/fping.c index 401cbda..8b9ce25 100644 --- a/src/fping.c +++ b/src/fping.c @@ -352,6 +352,12 @@ int main(int argc, char** argv) HOST_ENTRY* cursor; struct optparse optparse_state; + /* pre-parse -h/--help, so that we also can output help information + * without trying to open the socket, which might fail */ + if(argc == 2 && ( strcmp(argv[1],"-h")==0 || strcmp(argv[1],"--help")==0 )) { + usage(0); + } + socket4 = open_ping_socket_ipv4(ping_data_size); #ifdef IPV6 socket6 = open_ping_socket_ipv6(ping_data_size);