Use sysconf(_SC_SYMLOOP_MAX) instead of MAXSYMLINKS. If sysconf
authorPetter Reinholdtsen <pere@hungry.com>
Tue, 28 Jan 2014 10:13:10 +0000 (10:13 +0000)
committerPetter Reinholdtsen <pere@hungry.com>
Tue, 28 Jan 2014 10:13:10 +0000 (10:13 +0000)
returns an error, fall back to MAXSYMLINKS on platforms that
define it.  Fixes build on Hurd.  Patch from Justus Winter and
Debian.

git-svn-id: svn://svn.sv.gnu.org/sysvinit/sysvinit/trunk@138 456724a4-4300-0410-8514-c89748c515a2

doc/Changelog
src/killall5.c

index 84db0529146cb5cc894bf3b1e863e902b6dc95bf..8c11523e6c439e86a5a4874d64a42318d49e737a 100644 (file)
@@ -67,6 +67,10 @@ sysvinit (2.89dsf) UNRELEASED; urgency=low
   * Define _XOPEN_SOURCE when building to get crypt() from <unistd.h>
     instead of using <crypt.h> in sulogin.c, to get the source building
     with the musl C library.
+  * Use sysconf(_SC_SYMLOOP_MAX) instead of MAXSYMLINKS.  If sysconf
+    returns an error, fall back to MAXSYMLINKS on platforms that
+    define it.  Fixes build on Hurd.  Patch from Justus Winter and
+    Debian.
 
  -- Petter Reinholdtsen <pere@hungry.com>  Sun Apr 11 11:28:55 CEST 2010
 
index 54176c3e9494a0699a5488babb0b7fe886b74310..3bb6f9d7c8cd6738d12b0ae350f98b4695d0d392 100644 (file)
@@ -376,6 +376,19 @@ out:
        return 0;
 }
 
+/*
+ *     Get the maximal number of symlinks to follow.
+ */
+static int maxsymlinks(void)
+{
+       int v = sysconf(_SC_SYMLOOP_MAX);
+#ifdef MAXSYMLINKS
+       if (v == -1)
+               return MAXSYMLINKS;
+#endif
+       return v;
+}
+
 /*
  *     Check path is located on a network based partition.
  */
@@ -383,7 +396,7 @@ int check4nfs(const char * path, char * real)
 {
        char buf[PATH_MAX+1];
        const char *curr;
-       int deep = MAXSYMLINKS;
+       int deep = maxsymlinks();
 
        if (!nlist) return 0;