From ambrisko@whistle.com  Sat Nov 25 13:45:07 2000
Return-Path: <ambrisko@whistle.com>
Received: from alpo.whistle.com (s206m1.whistle.com [207.76.206.1])
	by hub.freebsd.org (Postfix) with ESMTP id 19DC137B479
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 25 Nov 2000 13:45:07 -0800 (PST)
Received: from whistle.com (crab.whistle.com [207.76.205.112])
	by alpo.whistle.com (8.9.1a/8.9.1) with ESMTP id NAA85209
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 25 Nov 2000 13:42:57 -0800 (PST)
Received: (from ambrisko@localhost)
	by whistle.com (8.9.3/8.9.1) id NAA40712;
	Sat, 25 Nov 2000 13:42:10 -0800 (PST)
	(envelope-from ambrisko)
Message-Id: <200011252142.NAA40712@whistle.com>
Date: Sat, 25 Nov 2000 13:42:10 -0800 (PST)
From: Doug Ambrisko <ambrisko@whistle.com>
Reply-To: ambrisko@whistle.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: If installing on a serial console, enable getty on ttyd0.
X-Send-Pr-Version: 3.2

>Number:         23098
>Category:       bin
>Synopsis:       sysinstall(8): [patch] if installing on a serial console, enable getty on ttyd0.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    brucec
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Nov 25 13:50:00 PST 2000
>Closed-Date:    Sat Aug 07 13:45:54 UTC 2010
>Last-Modified:  Sat Aug 07 13:45:54 UTC 2010
>Originator:     Doug Ambrisko
>Release:        FreeBSD 4.2-RELEASE i386
>Organization:
Whistle
>Environment:


>Description:

If you do an install via the serial port, Sysinstall correctly updates 
loader.conf so the kernel messages come up on the console.  However,
it should also enable a getty on the serial port as well so you can
login to that port.  This patch does that by changing "off" to "on " 
for ttyd0.  Note I do not disable getty on ttyvX.  It's probably fairly
easy for the admin to just login as root on the serial port and
disable getty on ttyvX if by chance no display or keyboard device is 
available to address that issue.

This should make life a little easier for serial installations.

>How-To-Repeat:

>Fix:


Index: install.c
===================================================================
RCS file: /cvs/freebsd/src/release/sysinstall/install.c,v
retrieving revision 1.268.2.15
diff -c -r1.268.2.15 install.c
*** install.c	2000/10/31 21:33:23	1.268.2.15
--- install.c	2000/11/25 21:31:10
***************
*** 744,749 ****
--- 744,752 ----
      int i;
      FILE *fp;
      int kstat = 1;
+     FILE  *orig, *new;
+     char buf[1024];
+     char *pos;
  
      /* All of this is done only as init, just to be safe */
      if (RunningAsInit) {
***************
*** 780,787 ****
  			   "boot from the hard disk, I'm afraid!");
  		return DITEM_FAILURE;
  	    }
  	}
! 	
  	/* BOGON #1: Resurrect /dev after bin distribution screws it up */
  	dialog_clear_norefresh();
  	msgNotify("Remaking all devices.. Please wait!");
--- 783,815 ----
  			   "boot from the hard disk, I'm afraid!");
  		return DITEM_FAILURE;
  	    }
+ 
+ 	    /* Fixup /etc/ttys to start a getty on the serial port.
+ 	       This way after a serial installation you can login via
+ 	       the serial port */
+ 	       
+ 	    if (!OnVTY){
+ 	         if (((orig=fopen("/etc/ttys","r")) != NULL) &&
+ 		     ((new=fopen("/etc/ttys.tmp","w")) != NULL)) {
+ 		     while (fgets(buf,sizeof(buf),orig)){
+ 		         if (strstr(buf,"ttyd0")){
+ 		             if ((pos=strstr(buf,"off"))){
+ 			         *pos++='o';
+ 			         *pos++='n';
+ 			         *pos++=' ';
+ 			     }
+ 			 }
+ 			 fputs(buf,new);
+ 		     }
+ 		     fclose(orig);
+ 		     fclose(new);
+ 		     
+ 		     rename("/etc/ttys.tmp","/etc/ttys");
+ 		     unlink("/etc/ttys.tmp");
+ 		 }
+ 	    }
  	}
! 
  	/* BOGON #1: Resurrect /dev after bin distribution screws it up */
  	dialog_clear_norefresh();
  	msgNotify("Remaking all devices.. Please wait!");

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->murray 
Responsible-Changed-By: murray 
Responsible-Changed-When: Fri Aug 31 11:12:21 PDT 2001 
Responsible-Changed-Why:  
Looks like a good idea.  I will work on this. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=23098 
Responsible-Changed-From-To: murray->ambrisko 
Responsible-Changed-By: murray 
Responsible-Changed-When: Tue Jan 1 00:30:41 PST 2002 
Responsible-Changed-Why:  
I think this is a good idea Doug, I hope you can commit this. ;) 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=23098 
Responsible-Changed-From-To: ambrisko->freebsd-qa 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat Jul 23 04:38:01 GMT 2005 
Responsible-Changed-Why:  
Reasssign to current maintainers of sysinstall after a long period 
of inactivity on this PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=23098 
Responsible-Changed-From-To: freebsd-bugs->brucec 
Responsible-Changed-By: brucec 
Responsible-Changed-When: Fri Apr 30 18:54:03 UTC 2010 
Responsible-Changed-Why:  
Take. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=23098 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/23098: commit references a PR
Date: Wed, 23 Jun 2010 14:12:16 +0000 (UTC)

 Author: brucec
 Date: Wed Jun 23 14:11:34 2010
 New Revision: 209467
 URL: http://svn.freebsd.org/changeset/base/209467
 
 Log:
   When installing on a machine which doesn't have a VGA card installed, enable
   a getty on the serial port so that it's possible to login when the system is
   rebooted.
   
   PR: bin/23098
   Submitted by: Doug Ambrisko <ambrisko at whistle.com>
   Reviewed by: randi
   Approved by: rrs (mentor)
   MFC after: 1 month
 
 Modified:
   head/usr.sbin/sysinstall/install.c
 
 Modified: head/usr.sbin/sysinstall/install.c
 ==============================================================================
 --- head/usr.sbin/sysinstall/install.c	Wed Jun 23 14:06:05 2010	(r209466)
 +++ head/usr.sbin/sysinstall/install.c	Wed Jun 23 14:11:34 2010	(r209467)
 @@ -877,6 +877,9 @@ installConfigure(void)
  int
  installFixupBase(dialogMenuItem *self)
  {
 +	FILE *orig, *new;
 +	char buf[1024];
 +	char *pos;
  #if defined(__i386__) || defined(__amd64__)
      FILE *fp;
  #endif
 @@ -895,6 +898,32 @@ installFixupBase(dialogMenuItem *self)
  	    fclose(fp);
  	}
  #endif
 +
 +	/* Fixup /etc/ttys to start a getty on the serial port.
 +	  This way after a serial installation you can login via
 +	  the serial port */
 +
 +	if (!OnVTY){
 +	    if (((orig=fopen("/etc/ttys","r")) != NULL) &&
 +		((new=fopen("/etc/ttys.tmp","w")) != NULL)) {
 +		while (fgets(buf,sizeof(buf),orig)){
 +		    if (strstr(buf,"ttyu0")){
 +			if ((pos=strstr(buf,"off"))){
 +			    *pos++='o';
 +			    *pos++='n';
 +			    *pos++=' ';
 +			}
 +		    }
 +		    fputs(buf,new);
 +		}
 +		fclose(orig);
 +		fclose(new);
 +
 +		rename("/etc/ttys.tmp","/etc/ttys");
 +		unlink("/etc/ttys.tmp");
 +	    }
 +	}
 +
  	
  	/* BOGON #2: We leave /etc in a bad state */
  	chmod("/etc", 0755);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched  
State-Changed-By: brucec 
State-Changed-When: Wed Jun 23 14:32:41 UTC 2010 
State-Changed-Why:  
Fixed in HEAD. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=23098 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/23098: commit references a PR
Date: Sat,  7 Aug 2010 12:41:30 +0000 (UTC)

 Author: brucec
 Date: Sat Aug  7 12:41:12 2010
 New Revision: 211009
 URL: http://svn.freebsd.org/changeset/base/211009
 
 Log:
   MFC r209467:
   
   When installing on a machine which doesn't have a VGA card installed, enable
   a getty on the serial port so that it's possible to login when the system is
   rebooted.
   
   PR: bin/23098
   Submitted by: Doug Ambrisko <ambrisko at whistle.com>
   Approved by: rrs (mentor)
 
 Modified:
   stable/8/usr.sbin/sysinstall/install.c
 Directory Properties:
   stable/8/usr.sbin/sysinstall/   (props changed)
 
 Modified: stable/8/usr.sbin/sysinstall/install.c
 ==============================================================================
 --- stable/8/usr.sbin/sysinstall/install.c	Sat Aug  7 12:21:29 2010	(r211008)
 +++ stable/8/usr.sbin/sysinstall/install.c	Sat Aug  7 12:41:12 2010	(r211009)
 @@ -875,6 +875,9 @@ installConfigure(void)
  int
  installFixupBase(dialogMenuItem *self)
  {
 +    FILE *orig, *new;
 +    char buf[1024];
 +    char *pos;
      FILE *fp;
  #ifdef __ia64__
      const char *efi_mntpt;
 @@ -891,6 +894,32 @@ installFixupBase(dialogMenuItem *self)
  	    fclose(fp);
  	}
  #endif
 +
 +	/* Fixup /etc/ttys to start a getty on the serial port.
 +	  This way after a serial installation you can login via
 +	  the serial port */
 +
 +	if (!OnVTY){
 +	    if (((orig=fopen("/etc/ttys","r")) != NULL) &&
 +		((new=fopen("/etc/ttys.tmp","w")) != NULL)) {
 +		while (fgets(buf,sizeof(buf),orig)){
 +		    if (strstr(buf,"ttyu0")){
 +			if ((pos=strstr(buf,"off"))){
 +			    *pos++='o';
 +			    *pos++='n';
 +			    *pos++=' ';
 +			}
 +		    }
 +		    fputs(buf,new);
 +		}
 +		fclose(orig);
 +		fclose(new);
 +
 +		rename("/etc/ttys.tmp","/etc/ttys");
 +		unlink("/etc/ttys.tmp");
 +	    }
 +	}
 +
  	
  	/* BOGON #2: We leave /etc in a bad state */
  	chmod("/etc", 0755);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/23098: commit references a PR
Date: Sat,  7 Aug 2010 12:47:10 +0000 (UTC)

 Author: brucec
 Date: Sat Aug  7 12:46:49 2010
 New Revision: 211010
 URL: http://svn.freebsd.org/changeset/base/211010
 
 Log:
   MFC r209467:
   
   When installing on a machine which doesn't have a VGA card installed, enable
   a getty on the serial port so that it's possible to login when the system is
   rebooted.
   
   PR: bin/23098
   Submitted by: Doug Ambrisko <ambrisko at whistle.com>
   Approved by: rrs (mentor)
 
 Modified:
   stable/7/usr.sbin/sysinstall/install.c
 Directory Properties:
   stable/7/usr.sbin/sysinstall/   (props changed)
 
 Modified: stable/7/usr.sbin/sysinstall/install.c
 ==============================================================================
 --- stable/7/usr.sbin/sysinstall/install.c	Sat Aug  7 12:41:12 2010	(r211009)
 +++ stable/7/usr.sbin/sysinstall/install.c	Sat Aug  7 12:46:49 2010	(r211010)
 @@ -839,6 +839,9 @@ installConfigure(void)
  int
  installFixupBase(dialogMenuItem *self)
  {
 +    FILE *orig, *new;
 +    char buf[1024];
 +    char *pos;
      FILE *fp;
  #ifdef __ia64__
      const char *efi_mntpt;
 @@ -855,6 +858,32 @@ installFixupBase(dialogMenuItem *self)
  	    fclose(fp);
  	}
  #endif
 +
 +	/* Fixup /etc/ttys to start a getty on the serial port.
 +	  This way after a serial installation you can login via
 +	  the serial port */
 +
 +	if (!OnVTY){
 +	    if (((orig=fopen("/etc/ttys","r")) != NULL) &&
 +		((new=fopen("/etc/ttys.tmp","w")) != NULL)) {
 +		while (fgets(buf,sizeof(buf),orig)){
 +		    if (strstr(buf,"ttyd0")){
 +			if ((pos=strstr(buf,"off"))){
 +			    *pos++='o';
 +			    *pos++='n';
 +			    *pos++=' ';
 +			}
 +		    }
 +		    fputs(buf,new);
 +		}
 +		fclose(orig);
 +		fclose(new);
 +
 +		rename("/etc/ttys.tmp","/etc/ttys");
 +		unlink("/etc/ttys.tmp");
 +	    }
 +	}
 +
  	
  	/* BOGON #2: We leave /etc in a bad state */
  	chmod("/etc", 0755);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed  
State-Changed-By: brucec 
State-Changed-When: Sat Aug 7 13:45:25 UTC 2010 
State-Changed-Why:  
Fix has been merged to stable/7 and stable/8. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=23098 
>Unformatted:
