From: R.E. Wolff Date: Thu, 17 Aug 2017 07:53:25 +0000 (+0200) Subject: Alternative 'skip uid 0 checks on cygwin' to adpoliak's implmentation X-Git-Tag: v0.93~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff337c65ab577115db349b9223bf20e79396bda1;p=thirdparty%2Fmtr.git Alternative 'skip uid 0 checks on cygwin' to adpoliak's implmentation --- diff --git a/configure.ac b/configure.ac index a08ce67..287f139 100644 --- a/configure.ac +++ b/configure.ac @@ -31,6 +31,9 @@ before running ./bootstrap.sh again.]) PKG_PROG_PKG_CONFIG AM_CONDITIONAL([CYGWIN], [test "$host_os" = cygwin]) +AM_COND_IF([CYGWIN], + [AC_DEFINE([USING_CYGWIN], [1], [Building Under Cygwin.])], + []) # Check bytes in types. AC_CHECK_SIZEOF([unsigned char], [1]) diff --git a/ui/curses.c b/ui/curses.c index 7566ad7..74df398 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -235,7 +235,7 @@ int mtr_curses_keyaction( if (f <= 0.0) return ActionNone; - if (getuid() != 0 && f < 1.0) + if (!running_as_root() && (f < 1.0)) return ActionNone; ctl->WaitTime = f; diff --git a/ui/gtk.c b/ui/gtk.c index b05e869..394c143 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -294,8 +294,7 @@ static void Toolbar_fill( /* allow root only to set zero delay */ Adjustment = (GtkAdjustment *) gtk_adjustment_new(ctl->WaitTime, - getuid() == - 0 ? 0.01 : 1.00, + running_as_root() ? 0.01 : 1.00, 999.99, 1.0, 10.0, 0.0); Button = gtk_spin_button_new(Adjustment, 0.5, 2); diff --git a/ui/mtr.c b/ui/mtr.c index 9999246..e95ffb6 100644 --- a/ui/mtr.c +++ b/ui/mtr.c @@ -484,7 +484,7 @@ static void parse_arg( if (ctl->WaitTime <= 0.0) { error(EXIT_FAILURE, 0, "wait time must be positive"); } - if (getuid() != 0 && ctl->WaitTime < 1.0) { + if (!running_as_root() && ctl->WaitTime < 1.0) { error(EXIT_FAILURE, 0, "non-root users cannot request an interval < 1.0 seconds"); } diff --git a/ui/mtr.h b/ui/mtr.h index fdca96b..9d474f8 100644 --- a/ui/mtr.h +++ b/ui/mtr.h @@ -139,4 +139,11 @@ struct mplslen { char labels; /* how many labels did we get? */ }; + +#ifdef USING_CYGWIN +#define running_as_root() 1 +#else +#define running_as_root() (getuid() != 0) +#endif + #endif /* MTR_MTR_H */