Bug 32288

Summary: [sysinstall] After install: /etc/rc complains if crypto is not installed
Product: Base System Reporter: Ernst de Haan <znerd>
Component: binAssignee: freebsd-qa (Nobody) <qa>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.4-STABLE   
Hardware: Any   
OS: Any   

Description Ernst de Haan freebsd_committer freebsd_triage 2001-11-26 10:40:01 UTC
Just installed 4.4-R on a laptop. I only selected bin, compat4 and a few
others, but I did *not* select crypto. Now when I first started the machine
(actually the reboot after the install) I get the following message:

   Starting final network daemons: creating ssh RSA host key
   /etc/rc: /usr/bin/ssh-keygen: not found
    creating ssh DSA host key
   /etc/rc: /usr/bin/ssh-keygen: not found
   .

Seems to me that this is not very clean.

How-To-Repeat: Install 4.4-R, choose "Custom", select only bin, man, compat4 and ports.
Let the install program restart and watch the messages at boot time.
Comment 1 des 2001-11-26 14:54:32 UTC
Ernst de Haan <znerd@freebsd.org> writes:
>    Starting final network daemons: creating ssh RSA host key
>    /etc/rc: /usr/bin/ssh-keygen: not found
>     creating ssh DSA host key
>    /etc/rc: /usr/bin/ssh-keygen: not found
>    .

This is because sysinstall sets sshd_enable to YES.  It should
probably set it to NO when crypto is not installed.  In addition,
rc.network should check for the existence and executability of
ssh-keygen, which should probably be parametrized.

DES
-- 
Dag-Erling Smorgrav - des@ofug.org
Comment 2 Makoto Matsushita 2001-11-26 17:23:37 UTC
des>  This is because sysinstall sets sshd_enable to YES.  It should
des>  probably set it to NO when crypto is not installed.

sysinstall sets sshd_enable to YES if you

1) select 'Medium' in security profile
2) enable sshd in "Networking Services" menu

I suppose PR originator do 1), is it true?

des>  In addition, rc.network should check for the existence and
des>  executability of ssh-keygen, which should probably be
des>  parametrized.

In /etc/rc, sshd starts only if sshd_enable=YES *and* /usr/bin/sshd
exists as a executable file.  IMHO, tweaking /etc/rc.network is only
required for fixing this.

-- -
Makoto `MAR' Matsushita
Comment 3 Makoto Matsushita 2001-11-27 15:57:36 UTC
des>  In addition, rc.network should check for the existence and
des>  executability of ssh-keygen, which should probably be
des>  parametrized.

How about this patch?  Logic is changed to:

	if ${sshd_enable} is YES
		if ${ssh_keygen_program} is not executable
			ssh_keygen_enable=NO
		if ${ssh_keygen_enable} is YES
			(create keys as before)

ssh_keygen_enable is set to "YES", and ssh_keygen_program is set to
"/usr/bin/ssh-keygen" to keep the behavior of current rc.network.
If a user doesn't install 'crypto' distribution, /usr/bin/ssh-keygen
is not available so ssh_keygen_enable turn to 'NO'.

BTW, I don't like this patch, the ssh-keygen line is too long...

-- -
Makoto `MAR' Matsushita

Index: rc.network
===================================================================
RCS file: /home/ncvs/src/etc/rc.network,v
retrieving revision 1.115
diff -u -r1.115 rc.network
--- rc.network	24 Nov 2001 23:41:32 -0000	1.115
+++ rc.network	27 Nov 2001 15:48:52 -0000
@@ -814,14 +814,21 @@
 
 	case ${sshd_enable} in
 	[Yy][Ee][Ss])
-		if [ ! -f /etc/ssh/ssh_host_key ]; then
-			echo ' creating ssh RSA host key';
-			/usr/bin/ssh-keygen -N "" -f /etc/ssh/ssh_host_key
-		fi
-		if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then
-			echo ' creating ssh DSA host key';
-			/usr/bin/ssh-keygen -d -N "" -f /etc/ssh/ssh_host_dsa_key
+		if [ ! -x ${ssh_keygen_program:-/usr/bin/ssh-keygen} ]; then
+			ssh_keygen_enable="NO"
 		fi
+		case ${ssh_keygen_enable} in
+		[Yy][Ee][Ss])
+			if [ ! -f /etc/ssh/ssh_host_key ]; then
+				echo ' creating ssh RSA host key';
+				${ssh_keygen_program:-/usr/bin/ssh-keygen} -N "" -f /etc/ssh/ssh_host_key
+			fi
+			if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then
+				echo ' creating ssh DSA host key';
+				${ssh_keygen_program:-/usr/bin/ssh-keygen} -d -N "" -f /etc/ssh/ssh_host_dsa_key
+			fi
+			;;
+		esac
 		;;
 	esac
 
Index: defaults/rc.conf
===================================================================
RCS file: /home/ncvs/src/etc/defaults/rc.conf,v
retrieving revision 1.132
diff -u -r1.132 rc.conf
--- defaults/rc.conf	24 Nov 2001 16:12:03 -0000	1.132
+++ defaults/rc.conf	27 Nov 2001 15:48:53 -0000
@@ -153,6 +153,8 @@
 sshd_enable="NO"                # Enable sshd
 sshd_program="/usr/sbin/sshd"	# path to sshd, if you want a different one.
 sshd_flags=""                   # Additional flags for sshd.
+ssh_keygen_enable="YES"		# Create sshd host keys if not exist.
+ssh_keygen_program="/usr/bin/ssh-keygen" # Create sshd host keys if not exist.
 
 ### Network daemon (NFS) Need all portmap_enable="YES" ###
 amd_enable="NO"			# Run amd service with $amd_flags (or NO).
Comment 4 Murray Stokely freebsd_committer freebsd_triage 2001-12-10 11:24:48 UTC
This patch looks good to me, please commit it.  This will also close
PR 31458

   - Murray
Comment 5 DougB 2002-02-08 03:02:00 UTC
Please do NOT commit this patch. It attempts to solve a problem created
by sysinstall with an otherwise useless hack in rc. The real fix is to
make sure that sysintall adjusts rc.conf when crypto is not installed.
Comment 6 Kris Kennaway freebsd_committer freebsd_triage 2003-07-19 00:05:48 UTC
Responsible Changed
From-To: freebsd-bugs->qa

Assign to qa group
Comment 7 Ceri Davies freebsd_committer freebsd_triage 2005-12-30 00:24:15 UTC
State Changed
From-To: open->closed

It hasn't been possible to do an installation with crypto since revision 
1.357 of src/usr.sbin/sysinstall/install.c, which I am taking as a 
pretty good indication that this isn't getting fixed now.