]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
Alternative 'skip uid 0 checks on cygwin' to adpoliak's implmentation
authorR.E. Wolff <R.E.Wolff@BitWizard.nl>
Thu, 17 Aug 2017 07:53:25 +0000 (09:53 +0200)
committerR.E. Wolff <R.E.Wolff@BitWizard.nl>
Thu, 17 Aug 2017 07:53:25 +0000 (09:53 +0200)
configure.ac
ui/curses.c
ui/gtk.c
ui/mtr.c
ui/mtr.h

index a08ce6722e7152a8a63f0ca889f92f968bae26bd..287f139e409ead131a2087f49b5dfd56501c0cc7 100644 (file)
@@ -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])
index 7566ad7f8444c782e17a195e61dd8fc73b8672f0..74df3980fa87f916df981d2941bcd688d6ddcbcc 100644 (file)
@@ -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;
 
index b05e8695ab7eebb104ae096c02ee043e7dc5b820..394c143d60585716e0af42a4a678a5b5f53c0b8a 100644 (file)
--- 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);
index 99992463dfd50e17f39a4eec76ad2bc26056e557..e95ffb6c9f59256a8031bfdc49c92bfb82a3ba78 100644 (file)
--- 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");
             }
index fdca96ba24d57c4d1b51dd7224ecd8ae5047166a..9d474f8cbabfba2364266992c0cc1ea89f6c12f1 100644 (file)
--- 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 */