Hi,
Post by Scott MarkwellI'd like to request that this functionality be added to a future
build, to be configurable at runtime. The issue being is patch
management, where applying a patch across multiple systems remotely
isn't easy under SUSE to do if the patches must be deployed as source
packages.
ok, here we go. You asked for it, you test it :-)
The patch below is against "pristine" 1.1.33, and adds the run-time
option "login-env-ttyprompt-hack yes/no" (default=no) to mgetty.config.
All I can say is "it compiles, and the code looks good", but I have
NOT tested it.
I'd appreciate if you could do a quick test on both variants, and tell
me if it works.
gert
------------- snip --------------
Index: logname.c
===================================================================
RCS file: /u2/cvs/mgetty/logname.c,v
retrieving revision 4.9
retrieving revision 4.11
diff -u -r4.9 -r4.11
--- logname.c 17 Aug 2003 10:38:36 -0000 4.9
+++ logname.c 24 Nov 2005 16:58:32 -0000 4.11
@@ -1,10 +1,20 @@
-#ident "$Id: logname.c,v 4.9 2003/08/17 10:38:36 gert Exp $ Copyright (c) Gert Doering"
+#ident "$Id: logname.c,v 4.11 2005/11/24 16:58:32 gert Exp $ Copyright (c) Gert Doering"
/* logname.c
*
* print 'login:' prompt, handling eventual escape sequence substitutions
*
* read login name, detect incoming PPP frames and FIDO startup sequences
+ *
+ * $Log: logname.c,v $
+ * Revision 4.11 2005/11/24 16:58:32 gert
+ * add extra flag, env_ttyprompt, that replaces #ifdef ENV_TTYPROMPT
+ *
+ * Revision 4.10 2005/04/25 21:09:13 gert
+ * drain tty output before changing CR/LF settings after reading login name
+ * (this was a race condition on very fast machines that lead to confused
+ * tty drivers - and there is no good reason NOT to let the output drain)
+ *
*/
@@ -257,9 +267,11 @@
* If ENV_TTYPROMPT is set, do not read anything
*/
-int getlogname _P6( (prompt, tio, buf, maxsize, max_login_time, do_fido),
+int getlogname _P7( (prompt, tio, buf, maxsize, max_login_time,
+ do_fido, env_ttyprompt),
char * prompt, TIO * tio, char * buf,
- int maxsize, int max_login_time, boolean do_fido )
+ int maxsize, int max_login_time,
+ boolean do_fido, boolean env_ttyprompt )
{
int i, r;
char ch;
@@ -278,15 +290,16 @@
final_prompt = ln_escape_prompt( prompt );
-#ifdef ENV_TTYPROMPT
- printf( "\r\n%s", final_prompt );
- tio_mode_sane( tio, FALSE );
- tio_map_cr( tio, TRUE );
- tio_set( STDIN, tio );
- buf[0] = 0;
- set_env_var( "TTYPROMPT", final_prompt );
- return 0;
-#else /* !ENV_TTYPROMPT */
+ if ( env_ttyprompt )
+ {
+ printf( "\r\n%s", final_prompt );
+ tio_mode_sane( tio, FALSE );
+ tio_map_cr( tio, TRUE );
+ tio_set( STDIN, tio );
+ buf[0] = 0;
+ set_env_var( "TTYPROMPT", final_prompt );
+ return 0;
+ }
if ( max_login_time > 0 )
{
@@ -577,9 +590,9 @@
lprintf( L_NOISE, "input finished with '\\r', setting ICRNL ONLCR" );
}
+ tio_drain_output( STDIN ); /* make sure CR+LF has been sent */
tio_set( STDIN, tio );
if ( i == 0 ) return -1;
else return 0;
-#endif /* !ENV_TTYPROMPT */
}
Index: mgetty.c
===================================================================
RCS file: /u2/cvs/mgetty/mgetty.c,v
retrieving revision 4.36
retrieving revision 4.38
diff -u -r4.36 -r4.38
--- mgetty.c 17 Nov 2003 19:08:20 -0000 4.36
+++ mgetty.c 24 Nov 2005 16:58:50 -0000 4.38
@@ -1,4 +1,4 @@
-#ident "$Id: mgetty.c,v 4.36 2003/11/17 19:08:20 gert Exp $ Copyright (c) Gert Doering"
+#ident "$Id: mgetty.c,v 4.38 2005/11/24 16:58:50 gert Exp $ Copyright (c) Gert Doering"
/* mgetty.c
*
@@ -68,7 +68,7 @@
/* logname.c */
int getlogname _PROTO(( char * prompt, TIO * termio,
char * buf, int maxsize, int max_login_time,
- boolean do_fido ));
+ boolean do_fido, boolean env_ttyprompt ));
/* conf_mg.c */
void exit_usage _PROTO((int num));
@@ -1035,7 +1035,7 @@
if ( getlogname( c_string(login_prompt), &tio, buf, sizeof(buf),
c_bool(blocking)? 0: c_int(login_time),
- c_bool(do_send_emsi) ) == -1 )
+ c_bool(do_send_emsi), c_bool(env_ttyprompt) ) == -1 )
{
continue;
}
@@ -1046,9 +1046,7 @@
/* dreadful hack for Linux, set TERM if desired */
if ( c_isset(termtype) )
{
- char * t = malloc( 6 + strlen( c_string(termtype)) );
- if ( t != NULL )
- { sprintf( t, "TERM=%s", c_string(termtype) ); putenv(t); }
+ set_env_var( "TERM", c_string(termtype) );
}
/* catch "standard question #29" (DCD low -> /bin/login gets stuck) */
Index: conf_mg.c
===================================================================
RCS file: /u2/cvs/mgetty/conf_mg.c,v
retrieving revision 4.15
retrieving revision 4.16
diff -u -r4.15 -r4.16
--- conf_mg.c 27 Jan 2001 16:22:37 -0000 4.15
+++ conf_mg.c 24 Nov 2005 16:57:58 -0000 4.16
@@ -1,4 +1,4 @@
-#ident "$Id: conf_mg.c,v 4.15 2001/01/27 16:22:37 gert Exp $ Copyright (c) Gert Doering"
+#ident "$Id: conf_mg.c,v 4.16 2005/11/24 16:57:58 gert Exp $ Copyright (c) Gert Doering"
/* conf_mg.c
*
@@ -106,6 +106,7 @@
{ "login-time", {0}, CT_INT, C_EMPTY },
#endif
{ "fido-send-emsi", {TRUE}, CT_BOOL, C_PRESET },
+ { "login-env-ttyprompt-hack", {FALSE}, CT_BOOL, C_PRESET },
#ifdef LOGIN_CFG_FILE
{ "login-conf-file", {(p_int) LOGIN_CFG_FILE}, CT_STRING, C_PRESET },
Index: conf_mg.h
===================================================================
RCS file: /u2/cvs/mgetty/conf_mg.h,v
retrieving revision 4.10
retrieving revision 4.11
diff -u -r4.10 -r4.11
--- conf_mg.h 5 Jan 2001 18:03:58 -0000 4.10
+++ conf_mg.h 24 Nov 2005 16:57:58 -0000 4.11
@@ -1,4 +1,4 @@
-#ident "$Id: conf_mg.h,v 4.10 2001/01/05 18:03:58 gert Exp $ Copyright (c) 1994 Gert Doering"
+#ident "$Id: conf_mg.h,v 4.11 2005/11/24 16:57:58 gert Exp $ Copyright (c) 1994 Gert Doering"
/* all (dynamic) mgetty configuration is contained in this structure.
* It is initialized and loaded in conf_mg.c and accessed from mgetty.c
@@ -47,6 +47,7 @@
login_prompt,
login_time, /* max. time to log in */
do_send_emsi, /* send EMSI_REQ string */
+ env_ttyprompt, /* suppress login prompt */
login_config, /* login.config file name */
station_id, /* local fax station ID */
--
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany ***@greenie.muc.de
fax: +49-89-35655025 ***@net.informatik.tu-muenchen.de
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de