Seems like logins can be as long as 32 characters, according to utmp (/usr/include/bits/utmp.h)
Also just include screen.h in comm.c so we don't have to include os.h (After changes it needed to know MAXLOGINLEN so just do what was mentioned in comment few lines below) Also bug 21653 Amadeusz
>From 119aea7e5b9d3827e0e6922e95397bf29a9e184f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amadeusz=20S=C5=82awi=C5=84ski?= <am...@asmblr.net> Date: Sat, 15 Sep 2012 15:38:14 +0200 Subject: [PATCH 3/3] Allow screen to run for users with long logins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Seems like logins can be as long as 32 characters Also just include screen.h in comm.c so we don't have to include os.h Signed-off-by: Amadeusz Sławiński <am...@asmblr.net> --- src/acls.c | 2 +- src/acls.h | 2 +- src/comm.c | 5 +---- src/os.h | 5 +++++ src/screen.c | 4 ++-- src/screen.h | 6 +++--- src/socket.c | 2 +- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/acls.c b/src/acls.c index 2f8c809..178d7ba 100644 --- a/src/acls.c +++ b/src/acls.c @@ -182,7 +182,7 @@ struct acluser **up; #endif (*up)->u_Esc = DefaultEsc; (*up)->u_MetaEsc = DefaultMetaEsc; - strncpy((*up)->u_name, name, 20); + strncpy((*up)->u_name, name, MAXLOGINLEN); (*up)->u_password = NULL; if (pass) (*up)->u_password = SaveStr(pass); diff --git a/src/acls.h b/src/acls.h index 907e953..42c7c18 100644 --- a/src/acls.h +++ b/src/acls.h @@ -78,7 +78,7 @@ struct plop typedef struct acluser { struct acluser *u_next; /* continue the main user list */ - char u_name[20+1]; /* login name how he showed up */ + char u_name[MAXLOGINLEN + 1]; /* login name how he showed up */ char *u_password; /* his password (may be NullStr). */ int u_checkpassword; /* nonzero if this u_password is valid */ int u_detachwin; /* the window where he last detached */ diff --git a/src/comm.c b/src/comm.c index 5f4af8a..928f1ac 100644 --- a/src/comm.c +++ b/src/comm.c @@ -36,10 +36,7 @@ */ #include "config.h" -#include "acls.h" -#include "comm.h" - -#define bcopy :-( /* or include screen.h here */ +#include "screen.h" /* Must be in alpha order ! */ diff --git a/src/os.h b/src/os.h index f1d849c..c7b1592 100644 --- a/src/os.h +++ b/src/os.h @@ -311,6 +311,11 @@ extern int errno; # define LOGINDEFAULT 1 #endif +#if defined(UT_NAMESIZE) && !defined(MAXLOGINLEN) +# define MAXLOGINLEN UT_NAMESIZE +#else +# define MAXLOGINLEN 3 +#endif /***************************************************************** * file stuff diff --git a/src/screen.c b/src/screen.c index 6e19732..aacacf6 100644 --- a/src/screen.c +++ b/src/screen.c @@ -978,10 +978,10 @@ char **av; if (home == 0 || *home == '\0') home = ppp->pw_dir; - if (strlen(LoginName) > 20) + if (strlen(LoginName) > MAXLOGINLEN) Panic(0, "LoginName too long - sorry."); #ifdef MULTIUSER - if (multi && strlen(multi) > 20) + if (multi && strlen(multi) > MAXLOGINLEN) Panic(0, "Screen owner name too long - sorry."); #endif if (strlen(home) > MAXPATHLEN - 25) diff --git a/src/screen.h b/src/screen.h index ea35aa1..dd3047a 100644 --- a/src/screen.h +++ b/src/screen.h @@ -207,7 +207,7 @@ struct msg create; struct { - char auser[20 + 1]; /* username */ + char auser[MAXLOGINLEN + 1]; /* username */ int apid; /* pid of frontend */ int adaptflag; /* adapt window size? */ int lines, columns; /* display size */ @@ -221,13 +221,13 @@ struct msg attach; struct { - char duser[20 + 1]; /* username */ + char duser[MAXLOGINLEN + 1]; /* username */ int dpid; /* pid of frontend */ } detach; struct { - char auser[20 + 1]; /* username */ + char auser[MAXLOGINLEN + 1]; /* username */ int nargs; char cmd[MAXPATHLEN]; /* command */ int apid; /* pid of frontend */ diff --git a/src/socket.c b/src/socket.c index a7755a4..711c709 100644 --- a/src/socket.c +++ b/src/socket.c @@ -1528,7 +1528,7 @@ static void PasswordProcessInput __P((char *, int)); struct pwdata { int l; - char buf[20 + 1]; + char buf[MAXLOGINLEN + 1]; struct msg m; }; -- 1.7.12