From 834bcebcaf0ff0c1f764d9d16d5f5bd6f4107fce Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Tue, 28 Jan 2014 10:13:10 +0000 Subject: [PATCH] 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. --- doc/Changelog | 4 ++++ src/killall5.c | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/doc/Changelog b/doc/Changelog index 84db052..8c11523 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -67,6 +67,10 @@ sysvinit (2.89dsf) UNRELEASED; urgency=low * Define _XOPEN_SOURCE when building to get crypt() from instead of using 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 Sun Apr 11 11:28:55 CEST 2010 diff --git a/src/killall5.c b/src/killall5.c index 54176c3..3bb6f9d 100644 --- a/src/killall5.c +++ b/src/killall5.c @@ -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;