Package: lessdisks
Version: 0.5.3cvs.20040906-10
Followup-For: Bug #289759

having tested -10, i've found it to more-or-less work alright, other
than the broken known_hosts generation.

so, here's two patches- one is a patch against source, and the other is
a patch against lessdisks-keycopy after 104_improved_keycopy.diff has
already been applied.

changes:
  generates functional known_hosts file
  uses /etc/ssh/ssh_known_hosts instead of /root/.ssh/known_hosts
  use $() instead of `` to be more consistant with other lessdisks code
    (some old lessdisks code still uses ``)
  add closing > to email address

enjoy.

live well,
  vagrant


-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i586)
Kernel: Linux 2.6.8-1-386
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages lessdisks depends on:
ii  adduser             3.59                 Add and remove users and groups
ii  binutils            2.15-5               The GNU assembler, linker and bina
ii  coreutils [shelluti 5.2.1-2              The GNU core utilities
ii  debconf             1.4.30.11            Debian configuration management sy
ii  debootstrap         0.2.45               Bootstrap a basic Debian system
ii  lessdisks-easydialo 0.5.3cvs.20040906-10 flexible diskless (x)terminal syst
ii  nfs-kernel-server [ 1:1.0.6-3.1          Kernel NFS server support
ii  shellutils          5.2.1-2              The GNU shell programming utilitie
ii  wget                1.9.1-8              retrieves files from the web

-- debconf information excluded
diff -ruN lessdisks-0.5.3cvs.20040906.orig/install/usr-sbin/lessdisks-keycopy 
lessdisks-0.5.3cvs.20040906/install/usr-sbin/lessdisks-keycopy
--- lessdisks-0.5.3cvs.20040906.orig/install/usr-sbin/lessdisks-keycopy 
2004-04-30 07:05:28.000000000 -0700
+++ lessdisks-0.5.3cvs.20040906/install/usr-sbin/lessdisks-keycopy      
2005-01-19 09:27:12.000000000 -0800
@@ -5,6 +5,20 @@
 # copyright 2004 [EMAIL PROTECTED], distributed under the terms of the
 # GNU General Public License version 2 or any later version.
 
+# Rewrite 2005 Jonas Smedegaard <[EMAIL PROTECTED]>:
+#   * Preserve existing keys
+#   * Quote all vars
+#   * Set modes on SSH dir only if creating it
+#   * Sanity checks on getting keys
+#   * Inject only existing keys
+
+# Re-rewrite 2005 Vagrant Cascadian <[EMAIL PROTECTED]>:
+#   * generate proper known_hosts file
+#   * use /etc/ssh/ssh_known_hosts instead of /root/.ssh/known_hosts
+#   * use $() instead of ``
+
+set -e
+
 if [ -r /etc/lessdisks-install.conf ]; then
   . /etc/lessdisks-install.conf
 fi 
@@ -18,21 +32,28 @@
   exit 2
 fi
 
-tempfile=$(tempfile)
+workdir="$lessdisks_path/etc/ssh"
+known_hosts="$workdir/ssh_known_hosts"
+thishost="$(hostname)"
 
-if [ -z "$tempfile" ]; then
-  echo "no tempfile set... arg!"
-  exit 1
+if [ ! -d "$workdir" ]; then
+       mkdir -p "$workdir"
 fi
 
-for name in xapp disk $(hostname); do
-  for type in rsa dsa; do
-    echo "$name" $(cat /etc/ssh/ssh_host_$type\_key.pub) >> $tempfile
-  done
+for type in rsa dsa; do
+
+       pubkey="$(cat /etc/ssh/ssh_host_${type}_key.pub | tail -n 1 | awk '{ 
print $1" "$2}')"
+       pubkey_type="$(echo $pubkey | awk '{print $1}')"
+       if [ -n "$pubkey" ]; then
+               # Make sure there's at least one line for perl to parse
+               echo "# dummy line" >> "$known_hosts"
+
+               for name in xapp disk $thishost; do
+                       perl -ni -e "\$n++; \
+                               print \"$name $pubkey\n\" if \$n==1; \
+                               print && next unless /^($name\s$pubkey_type|# 
dummy line)/i;" "$known_hosts"
+               done
+       fi
 done
 
-mkdir -p $lessdisks_path/root/.ssh
-cd $lessdisks_path/root/.ssh
-chmod og-rwx .
-cp $tempfile known_hosts
 exit $?
--- lessdisks-keycopy   2005-01-19 09:55:45.000000000 -0800
+++ lessdisks-keycopy.new       2005-01-19 09:55:36.000000000 -0800
@@ -5,13 +5,18 @@
 # copyright 2004 [EMAIL PROTECTED], distributed under the terms of the
 # GNU General Public License version 2 or any later version.
 
-# Rewrite 2005 Jonas Smedegaard <[EMAIL PROTECTED]:
+# Rewrite 2005 Jonas Smedegaard <[EMAIL PROTECTED]>:
 #   * Preserve existing keys
 #   * Quote all vars
 #   * Set modes on SSH dir only if creating it
 #   * Sanity checks on getting keys
 #   * Inject only existing keys
 
+# Re-rewrite 2005 Vagrant Cascadian <[EMAIL PROTECTED]>:
+#   * generate proper known_hosts file
+#   * use /etc/ssh/ssh_known_hosts instead of /root/.ssh/known_hosts
+#   * use $() instead of ``
+
 set -e
 
 if [ -r /etc/lessdisks-install.conf ]; then
@@ -27,26 +32,26 @@
   exit 2
 fi
 
-workdir="$lessdisks_path/root/.ssh"
-thishost="`hostname`"
+workdir="$lessdisks_path/etc/ssh"
+known_hosts="$workdir/ssh_known_hosts"
+thishost="$(hostname)"
 
 if [ ! -d "$workdir" ]; then
        mkdir -p "$workdir"
-       chmod og-rwx "$workdir"
 fi
 
 for type in rsa dsa; do
 
-       pubkey="`cat /etc/ssh/ssh_host_${type}_key.pub | tail -n 1 | awk '{ 
print $1 }'`"
-
+       pubkey="$(cat /etc/ssh/ssh_host_${type}_key.pub | tail -n 1 | awk '{ 
print $1" "$2}')"
+       pubkey_type="$(echo $pubkey | awk '{print $1}')"
        if [ -n "$pubkey" ]; then
                # Make sure there's at least one line for perl to parse
-               echo "# dummy line" >> "$workdir/known_hosts"
+               echo "# dummy line" >> "$known_hosts"
 
                for name in xapp disk $thishost; do
                        perl -ni -e "\$n++; \
-                               print \"$type $name $pubkey\n\" if \$n==1; \
-                               print && next unless /^((rsa|dsa)\s$name\s|# 
dummy line)/i;" "$workdir/known_hosts"
+                               print \"$name $pubkey\n\" if \$n==1; \
+                               print && next unless /^($name\s$pubkey_type|# 
dummy line)/i;" "$known_hosts"
                done
        fi
 done

Attachment: signature.asc
Description: Digital signature

Reply via email to