diff --git a/lib/chkname.c b/lib/chkname.c index 98f791706..bee2e6bd7 100644 --- a/lib/chkname.c +++ b/lib/chkname.c @@ -2,7 +2,7 @@ // SPDX-FileCopyrightText: 1996-2000, Marek Michałkiewicz // SPDX-FileCopyrightText: 2001-2005, Tomasz Kłoczko // SPDX-FileCopyrightText: 2005-2008, Nicolas François -// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar +// SPDX-FileCopyrightText: 2023-2025, Alejandro Colomar // SPDX-License-Identifier: BSD-3-Clause @@ -27,8 +27,6 @@ #include #include #include -#include -#include #include #include "defines.h" @@ -36,6 +34,11 @@ #include "string/strcmp/streq.h" +#ifndef LOGIN_NAME_MAX +# define LOGIN_NAME_MAX 256 +#endif + + int allow_bad_names = false; @@ -44,12 +47,11 @@ login_name_max_size(void) { long conf; - errno = 0; conf = sysconf(_SC_LOGIN_NAME_MAX); - if (conf == -1 && errno != 0) + if (conf == -1) return LOGIN_NAME_MAX; - return MIN(conf, PTRDIFF_MAX); + return conf; }