summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaarten Vanraes <alien@mageia.org>2011-10-24 18:05:36 +0000
committerMaarten Vanraes <alien@mageia.org>2011-10-24 18:05:36 +0000
commitb0cae796314f7c0ceda3d44f0fa74e55acd21b8b (patch)
tree0143632fd8b255c90fdb39a4b527f5dfeb81c820
parent8b55d62379d30e5263c28604f229ec376a9fa72e (diff)
downloaddrakx-backup-do-not-use-b0cae796314f7c0ceda3d44f0fa74e55acd21b8b.tar
drakx-backup-do-not-use-b0cae796314f7c0ceda3d44f0fa74e55acd21b8b.tar.gz
drakx-backup-do-not-use-b0cae796314f7c0ceda3d44f0fa74e55acd21b8b.tar.bz2
drakx-backup-do-not-use-b0cae796314f7c0ceda3d44f0fa74e55acd21b8b.tar.xz
drakx-backup-do-not-use-b0cae796314f7c0ceda3d44f0fa74e55acd21b8b.zip
- add screen
- add dropbear - add etc/shells - add script that set password and start ssh server
-rwxr-xr-xrescue/genpasswd10
-rw-r--r--rescue/list.xml10
-rwxr-xr-xrescue/startssh18
-rw-r--r--rescue/tree/etc/fstab1
-rw-r--r--rescue/tree/etc/issue1
-rwxr-xr-xrescue/tree/etc/rc.sysinit8
6 files changed, 46 insertions, 2 deletions
diff --git a/rescue/genpasswd b/rescue/genpasswd
new file mode 100755
index 000000000..328ced265
--- /dev/null
+++ b/rescue/genpasswd
@@ -0,0 +1,10 @@
+#!/usr/bin/perl
+
+system "stty -echo";
+print STDERR "Give a password: ";
+chomp($word = <STDIN>);
+print STDERR "\n";
+system "stty echo";
+
+print crypt($word, join('', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64]));
+print "\n";
diff --git a/rescue/list.xml b/rescue/list.xml
index e94f0c9a2..895a7d315 100644
--- a/rescue/list.xml
+++ b/rescue/list.xml
@@ -65,6 +65,11 @@
btrfs btrfsck btrfs-convert btrfsctl btrfs-debug-tree
btrfs-map-logical btrfs-show btrfs-vol mkfs.btrfs fsck.btrfs
+
+ dropbear dropbearkey
+
+ screen
+
<if ARCH="i.86|x86_64">
mkfs.jfs fsck.jfs jfs_tune
</if>
@@ -247,6 +252,7 @@
termcap
protocols
services
+ shells
ssh/ssh_config
</from>
@@ -322,7 +328,9 @@
</from>
<from dir=".">
<to dir="/usr/sbin">
- diskdrake-resize
+ diskdrake-resize
+ genpasswd
+ startssh
</to>
<to dir="/usr/sbin">
restore-image.sh
diff --git a/rescue/startssh b/rescue/startssh
new file mode 100755
index 000000000..4c48d8291
--- /dev/null
+++ b/rescue/startssh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+passwd=`genpasswd`
+
+if (( $? != 0 )); then
+ reset
+ exit $?
+fi
+
+sed -E -i -e 's/^root:[^:]*:/root:'"$passwd"':/' /etc/passwd
+
+mkdir -p /etc/dropbear
+[[ -f /etc/dropbear/dropbear_dss_host_key ]] || dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key
+[[ -f /etc/dropbear/dropbear_rsa_host_key ]] || dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
+
+echo ""
+echo -n "Starting ssh daemon... "
+dropbear && echo "OK"
diff --git a/rescue/tree/etc/fstab b/rescue/tree/etc/fstab
index fbafb7801..148dcd4b4 100644
--- a/rescue/tree/etc/fstab
+++ b/rescue/tree/etc/fstab
@@ -1,4 +1,5 @@
/dev/ram3 / ext2 defaults 1 1
/dev/fd0 /mnt/floppy auto defaults,noauto 0 0
none /proc proc defaults,noauto,ro 0 0
+devpts /dev/pts devpts defaults,noauto,rw 0 0
/dev/cdrom /mnt/cdrom auto defaults,noauto 0 0
diff --git a/rescue/tree/etc/issue b/rescue/tree/etc/issue
index d4aee6d89..c5a4c7fb8 100644
--- a/rescue/tree/etc/issue
+++ b/rescue/tree/etc/issue
@@ -24,5 +24,6 @@ Use loadkeys to change your keyboard layout (eg: loadkeys fr)
Use modprobe to load modules (eg: modprobe snd-card-fm801)
Use drvinst to install drivers according to detected devices
Use lsparts to list your partitions with types
+Use startssh to start an ssh daemon
Use rescue-gui to go back to the rescue menu
diff --git a/rescue/tree/etc/rc.sysinit b/rescue/tree/etc/rc.sysinit
index e5164dd45..39d7dec6b 100755
--- a/rescue/tree/etc/rc.sysinit
+++ b/rescue/tree/etc/rc.sysinit
@@ -11,14 +11,20 @@ echo -e "\t\t\tWelcome to \\033[1;36mMageia\\033[0;39m Linux"
action "Remounting root filesystem in read-write mode" mount -n -o remount,rw /
ln -s /tmp/stage2/etc/* /etc 2>/dev/null
+# make passwd changable
+rm -f /etc/passwd
+cp /tmp/stage2/etc/passwd /etc/
rm -f /dev ; cp -a /tmp/stage2/dev /dev
-mkdir -p /mnt /var/log
+mkdir -p /mnt /var/log /dev/pts
>/etc/mtab
mount -f /
mount -f /proc
+# mount /dev/pts and link /dev/ptmx so dropbear works
+mount /dev/pts
+ln -s /dev/pts/ptmx /dev/ptmx
# Set the hostname.
action "Setting hostname rescue" hostname rescue