wok-6.x rev 18689

openssh, openssh-pam: fix post_install() with --root
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Dec 11 00:40:59 2015 +0200 (2015-12-11)
parents b103fbd6b3b8
children f3d35bfb9ab5
files openssh-pam/receipt openssh/receipt openssh/stuff/openssh
line diff
     1.1 --- a/openssh-pam/receipt	Thu Dec 10 21:28:40 2015 +0100
     1.2 +++ b/openssh-pam/receipt	Fri Dec 11 00:40:59 2015 +0200
     1.3 @@ -40,7 +40,7 @@
     1.4  # Rules to gen a SliTaz package suitable for Tazpkg.
     1.5  genpkg_rules()
     1.6  {
     1.7 -	mkdir -p $fs/usr $fs/etc/init.d $fs/etc/ssh 
     1.8 +	mkdir -p $fs/usr $fs/etc/init.d $fs/etc/ssh
     1.9  	cp -a $install/usr/sbin $install/usr/bin $fs/usr
    1.10  	rm -f $fs/usr/sbin/sftp-server
    1.11  	cp -a $install/etc $fs
    1.12 @@ -52,22 +52,23 @@
    1.13  
    1.14  post_install()
    1.15  {
    1.16 -	grep -q ssh $1/etc/inetd.conf || cat >> $1/etc/inetd.conf <<EOT
    1.17 +	grep -q ssh "$1/etc/inetd.conf" || cat >> "$1/etc/inetd.conf" <<EOT
    1.18  #ssh	stream	tcp	nowait	root	sshd	sshd	-i
    1.19  EOT
    1.20  	while read dropbear openssh ; do
    1.21 -		[ -s $1$dropbear ] || continue
    1.22 -		dropbearconvert dropbear openssh $1$dropbear $1$openssh
    1.23 -		dropbearkey -y -f $1$dropbear | grep ssh > $1$openssh.pub
    1.24 -		dropbearkey -y -f $1$dropbear | grep Fingerprint
    1.25 +		[ -s "$1$dropbear" ] || continue
    1.26 +		dropbearconvert dropbear openssh "$1$dropbear" "$1$openssh"
    1.27 +		dropbearkey -y -f "$1$dropbear" | grep ssh > "$1$openssh.pub"
    1.28 +		dropbearkey -y -f "$1$dropbear" | grep Fingerprint
    1.29  	done <<EOT
    1.30  /etc/dropbear/dropbear_rsa_host_key	/etc/ssh/ssh_host_rsa_key
    1.31  /etc/dropbear/dropbear_dss_host_key	/etc/ssh/ssh_host_dsa_key
    1.32  EOT
    1.33 -ssh-keygen -A
    1.34 +
    1.35 +	chroot "$1/" ssh-keygen -A
    1.36  }
    1.37  
    1.38  post_remove()
    1.39  {
    1.40 -	grep -q sshd $1/etc/inetd.conf && sed -i '/sshd/d' $1/etc/inetd.conf
    1.41 +	grep -q sshd "$1/etc/inetd.conf" && sed -i '/sshd/d' "$1/etc/inetd.conf"
    1.42  }
     2.1 --- a/openssh/receipt	Thu Dec 10 21:28:40 2015 +0100
     2.2 +++ b/openssh/receipt	Fri Dec 11 00:40:59 2015 +0200
     2.3 @@ -40,7 +40,7 @@
     2.4  # Rules to gen a SliTaz package suitable for Tazpkg.
     2.5  genpkg_rules()
     2.6  {
     2.7 -	mkdir -p $fs/usr $fs/etc/init.d $fs/etc/ssh 
     2.8 +	mkdir -p $fs/usr $fs/etc/init.d $fs/etc/ssh
     2.9  	cp -a $install/usr/sbin $install/usr/bin $fs/usr
    2.10  	rm -f $fs/usr/sbin/sftp-server
    2.11  	cp -a $install/etc $fs
    2.12 @@ -51,22 +51,23 @@
    2.13  
    2.14  post_install()
    2.15  {
    2.16 -	grep -q ssh $1/etc/inetd.conf || cat >> $1/etc/inetd.conf <<EOT
    2.17 +	grep -q ssh "$1/etc/inetd.conf" || cat >> "$1/etc/inetd.conf" <<EOT
    2.18  #ssh	stream	tcp	nowait	root	sshd	sshd	-i
    2.19  EOT
    2.20  	while read dropbear openssh ; do
    2.21 -		[ -s $1$dropbear ] || continue
    2.22 -		dropbearconvert dropbear openssh $1$dropbear $1$openssh
    2.23 -		dropbearkey -y -f $1$dropbear | grep ssh > $1$openssh.pub
    2.24 -		dropbearkey -y -f $1$dropbear | grep Fingerprint
    2.25 +		[ -s "$1$dropbear" ] || continue
    2.26 +		dropbearconvert dropbear openssh "$1$dropbear" "$1$openssh"
    2.27 +		dropbearkey -y -f "$1$dropbear" | grep ssh > "$1$openssh.pub"
    2.28 +		dropbearkey -y -f "$1$dropbear" | grep Fingerprint
    2.29  	done <<EOT
    2.30  /etc/dropbear/dropbear_rsa_host_key	/etc/ssh/ssh_host_rsa_key
    2.31  /etc/dropbear/dropbear_dss_host_key	/etc/ssh/ssh_host_dsa_key
    2.32  EOT
    2.33 -ssh-keygen -A
    2.34 +
    2.35 +	chroot "$1/" ssh-keygen -A
    2.36  }
    2.37  
    2.38  post_remove()
    2.39  {
    2.40 -	grep -q sshd $1/etc/inetd.conf && sed -i '/sshd/d' $1/etc/inetd.conf
    2.41 +	grep -q sshd "$1/etc/inetd.conf" && sed -i '/sshd/d' "$1/etc/inetd.conf"
    2.42  }
     3.1 --- a/openssh/stuff/openssh	Thu Dec 10 21:28:40 2015 +0100
     3.2 +++ b/openssh/stuff/openssh	Fri Dec 11 00:40:59 2015 +0200
     3.3 @@ -1,5 +1,5 @@
     3.4  #!/bin/sh
     3.5 -# /etc/init.d/openssh : Start, stop and restart OpenSSH server on SliTaz, at 
     3.6 +# /etc/init.d/openssh : Start, stop and restart OpenSSH server on SliTaz, at
     3.7  # boot time or with the command line.
     3.8  #
     3.9  # To start OpenSSH server at boot time, just put openssh in the $RUN_DAEMONS
    3.10 @@ -15,55 +15,55 @@
    3.11  PIDFILE=/var/run/sshd.pid
    3.12  
    3.13  [ -d /var/run/sshd ] || mkdir -p /var/run/sshd
    3.14 +
    3.15  case "$1" in
    3.16 -  start)
    3.17 -    # We need rsa and dsa host key file to start dropbear.
    3.18 -    if [ ! -f /etc/ssh/ssh_host_rsa_key ] ; then
    3.19 -      echo "Generating $NAME rsa key... "
    3.20 -      ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -C '' -N ''
    3.21 -    fi
    3.22 -    if [ ! -f /etc/ssh/ssh_host_dsa_key ] ; then
    3.23 -      echo "Generating $NAME dsa key... "
    3.24 -      ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -C '' -N ''
    3.25 -    fi
    3.26 -    if [ ! -f /etc/ssh/ssh_host_ecdsa_key ] ; then
    3.27 -      echo "Generating $NAME ecdsa key... "
    3.28 -      ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -C '' -N ''
    3.29 -    fi
    3.30 -    if active_pidfile $PIDFILE sshd ; then
    3.31 -      echo "$NAME already running."
    3.32 -      exit 1
    3.33 -    fi
    3.34 -    echo -n "Starting $DESC: $NAME... "
    3.35 -    $DAEMON $OPTIONS
    3.36 -    status
    3.37 -    ;;
    3.38 -  stop)
    3.39 -    if ! active_pidfile $PIDFILE sshd ; then
    3.40 -      echo "$NAME is not running."
    3.41 -      exit 1
    3.42 -    fi
    3.43 -    echo -n "Stopping $DESC: $NAME... "
    3.44 -    kill `cat $PIDFILE`
    3.45 -    status
    3.46 -    ;;
    3.47 -  restart)
    3.48 -    if ! active_pidfile $PIDFILE sshd ; then
    3.49 -      echo "$NAME is not running."
    3.50 -      exit 1
    3.51 -    fi
    3.52 -    echo -n "Restarting $DESC: $NAME... "
    3.53 -    kill `cat $PIDFILE`
    3.54 -    sleep 2
    3.55 -    $DAEMON $OPTIONS
    3.56 -    status
    3.57 -    ;;
    3.58 -  *)
    3.59 -    echo ""
    3.60 -    echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
    3.61 -    echo ""
    3.62 -    exit 1
    3.63 -    ;;
    3.64 +	start)
    3.65 +		# We need rsa and dsa host key file to start dropbear.
    3.66 +		if [ ! -f /etc/ssh/ssh_host_rsa_key ] ; then
    3.67 +			echo "Generating $NAME rsa key... "
    3.68 +			ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -C '' -N ''
    3.69 +		fi
    3.70 +		if [ ! -f /etc/ssh/ssh_host_dsa_key ] ; then
    3.71 +			echo "Generating $NAME dsa key... "
    3.72 +			ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -C '' -N ''
    3.73 +		fi
    3.74 +		if [ ! -f /etc/ssh/ssh_host_ecdsa_key ] ; then
    3.75 +			echo "Generating $NAME ecdsa key... "
    3.76 +			ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -C '' -N ''
    3.77 +		fi
    3.78 +		if active_pidfile $PIDFILE sshd ; then
    3.79 +			echo "$NAME already running."
    3.80 +			exit 1
    3.81 +		fi
    3.82 +		action "Starting $DESC: $NAME... "
    3.83 +		$DAEMON $OPTIONS
    3.84 +		status
    3.85 +		;;
    3.86 +	stop)
    3.87 +		if ! active_pidfile $PIDFILE sshd ; then
    3.88 +			echo "$NAME is not running."
    3.89 +			exit 1
    3.90 +		fi
    3.91 +		action "Stopping $DESC: $NAME... "
    3.92 +		kill $(cat $PIDFILE)
    3.93 +		status
    3.94 +		;;
    3.95 +	restart)
    3.96 +		if ! active_pidfile $PIDFILE sshd ; then
    3.97 +			echo "$NAME is not running."
    3.98 +			exit 1
    3.99 +		fi
   3.100 +		action "Restarting $DESC: $NAME... "
   3.101 +		kill $(cat $PIDFILE)
   3.102 +		sleep 2
   3.103 +		$DAEMON $OPTIONS
   3.104 +		status
   3.105 +		;;
   3.106 +	*)
   3.107 +		emsg "<n><b>Usage:</b> /etc/init.d/$(basename $0) [start|stop|restart]"
   3.108 +		newline
   3.109 +		exit 1
   3.110 +		;;
   3.111  esac
   3.112  
   3.113  exit 0