mirror of
https://github.com/troglobit/finit.git
synced 2026-11-30 21:18:22 +00:00
Fix #211: drop hard-coded getty limit of 32 characters for usernames
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
495c8c9eac
commit
950ca953f5
1 file changed
+15
-1
+15
-1
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <limits.h> /* LOGIN_NAME_MAX */
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -33,6 +34,7 @@
|
|||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <sys/ttydefaults.h> /* Not included by default in musl libc */
|
#include <sys/ttydefaults.h> /* Not included by default in musl libc */
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
#include <unistd.h> /* sysconf() */
|
||||||
|
|
||||||
#include "finit.h"
|
#include "finit.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
@@ -42,6 +44,12 @@
|
|||||||
#define _PATH_LOGIN "/bin/login"
|
#define _PATH_LOGIN "/bin/login"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef LOGIN_NAME_MIN
|
||||||
|
#define LOGIN_NAME_MIN 64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static long logname_len = 32; /* useradd(1) limit at 32 chars */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read one character from stdin.
|
* Read one character from stdin.
|
||||||
*/
|
*/
|
||||||
@@ -197,7 +205,7 @@ static int do_login(char *name)
|
|||||||
static int getty(char *tty, speed_t speed, char *term, char *user)
|
static int getty(char *tty, speed_t speed, char *term, char *user)
|
||||||
{
|
{
|
||||||
const char cln[] = "\r\e[K\n";
|
const char cln[] = "\r\e[K\n";
|
||||||
char name[33]; /* useradd(1) limit at 32 chars */
|
char name[logname_len + 1]; /* +1 for NUL termination */
|
||||||
pid_t sid;
|
pid_t sid;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -263,6 +271,12 @@ int main(int argc, char *argv[])
|
|||||||
if (optind < argc)
|
if (optind < argc)
|
||||||
term = argv[optind++];
|
term = argv[optind++];
|
||||||
|
|
||||||
|
logname_len = sysconf(_SC_LOGIN_NAME_MAX);
|
||||||
|
if (logname_len == -1i)
|
||||||
|
logname_len = LOGIN_NAME_MAX;
|
||||||
|
if (logname_len < LOGIN_NAME_MIN)
|
||||||
|
logname_len = LOGIN_NAME_MIN;
|
||||||
|
|
||||||
return getty(tty, atoi(speed), term, NULL);
|
return getty(tty, atoi(speed), term, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user