lib: replace USER_NAME_MAX_LENGTH macro
Replace it by `sysconf(_SC_LOGIN_NAME_MAX)`, which is the maximum username length supported by the kernel. Resolves: https://github.com/shadow-maint/shadow/issues/674 Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
This commit is contained in:
committed by
Serge Hallyn
parent
fb8f44d73f
commit
3b7cc05387
+8
-6
@@ -572,10 +572,11 @@ int main (int argc, char **argv)
|
||||
}
|
||||
#ifdef RLOGIN
|
||||
if (rflg) {
|
||||
size_t max_size = sysconf(_SC_LOGIN_NAME_MAX);
|
||||
assert (NULL == username);
|
||||
username = XMALLOC(USER_NAME_MAX_LENGTH + 1, char);
|
||||
username[USER_NAME_MAX_LENGTH] = '\0';
|
||||
if (do_rlogin (hostname, username, USER_NAME_MAX_LENGTH, term, sizeof term)) {
|
||||
username = XMALLOC(max_size + 1, char);
|
||||
username[max_size] = '\0';
|
||||
if (do_rlogin (hostname, username, max_size, term, sizeof term)) {
|
||||
preauth_flag = true;
|
||||
} else {
|
||||
free (username);
|
||||
@@ -884,14 +885,15 @@ int main (int argc, char **argv)
|
||||
|
||||
failed = false; /* haven't failed authentication yet */
|
||||
if (NULL == username) { /* need to get a login id */
|
||||
size_t max_size = sysconf(_SC_LOGIN_NAME_MAX);
|
||||
if (subroot) {
|
||||
closelog ();
|
||||
exit (1);
|
||||
}
|
||||
preauth_flag = false;
|
||||
username = XMALLOC(USER_NAME_MAX_LENGTH + 1, char);
|
||||
username[USER_NAME_MAX_LENGTH] = '\0';
|
||||
login_prompt (username, USER_NAME_MAX_LENGTH);
|
||||
username = XMALLOC(max_size + 1, char);
|
||||
username[max_size] = '\0';
|
||||
login_prompt (username, max_size);
|
||||
|
||||
if ('\0' == username[0]) {
|
||||
/* Prompt for a new login */
|
||||
|
||||
Reference in New Issue
Block a user