Skip to content

Commit 8a1ca01

Browse files
author
Chiradeep Vittal
committed
Bug 8199: insert generated private key where it is expected
1 parent daa8439 commit 8a1ca01

3 files changed

Lines changed: 21 additions & 8 deletions

File tree

scripts/vm/hypervisor/xenserver/xenserver56/patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ vmops=..,0755,/etc/xapi.d/plugins
1515
vmopsSnapshot=..,0755,/etc/xapi.d/plugins
1616
hostvmstats.py=..,0755,/opt/xensource/sm
1717
systemvm.iso=../../../../../vms,0644,/opt/xensource/packages/iso
18-
id_rsa.cloud=..,0600,/root/.ssh
18+
id_rsa.cloud=../../../systemvm,0600,/root/.ssh
1919
network_info.sh=..,0755,/opt/xensource/bin
2020
setupxenserver.sh=..,0755,/opt/xensource/bin
2121
make_migratable.sh=..,0755,/opt/xensource/bin

scripts/vm/hypervisor/xenserver/xenserver56fp1/patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ovstunnel=..,0755,/etc/xapi.d/plugins
1717
vmopsSnapshot=..,0755,/etc/xapi.d/plugins
1818
hostvmstats.py=..,0755,/opt/xensource/sm
1919
systemvm.iso=../../../../../vms,0644,/opt/xensource/packages/iso
20-
id_rsa.cloud=..,0600,/root/.ssh
20+
id_rsa.cloud=../../../systemvm,0600,/root/.ssh
2121
network_info.sh=..,0755,/opt/xensource/bin
2222
setupxenserver.sh=..,0755,/opt/xensource/bin
2323
make_migratable.sh=..,0755,/opt/xensource/bin

scripts/vm/systemvm/injectkeys.sh

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
2-
3-
# $1 = new key
2+
# Copies keys that enable SSH communication with system vms
3+
# $1 = new public key
4+
# $2 = new private key
45

56
#set -x
67

@@ -10,7 +11,7 @@ MOUNTPATH=/mnt/cloud/systemvm
1011
TMPDIR=${TMP}/cloud/systemvm
1112

1213

13-
inject() {
14+
inject_into_iso() {
1415
local isofile=${SYSTEMVM_PATCH_DIR}/$1
1516
local newpubkey=$2
1617
local backup=${isofile}.bak
@@ -36,16 +37,28 @@ inject() {
3637
rm -rf $TMPDIR
3738
}
3839

40+
copy_priv_key() {
41+
local newprivkey=$1
42+
cp -fb $newprivkey $(dirname $0)/id_rsa.cloud && chmod 0600 $(dirname $0)/id_rsa.cloud
43+
return $?
44+
}
45+
3946
mkdir -p $MOUNTPATH
4047

41-
[ $# -ne 1 ] && echo "Usage: $(basename $0) <new keyfile>" && exit 3
48+
[ $# -ne 2 ] && echo "Usage: $(basename $0) <new public key file> <new private key file>" && exit 3
4249
newpubkey=$1
50+
newprivkey=$2
4351
[ ! -f $newpubkey ] && echo "$(basename $0): Could not open $newpubkey" && exit 3
52+
[ ! -f $newprivkey ] && echo "$(basename $0): Could not open $newprivkey" && exit 3
4453
[ $EUID -ne 0 ] && echo "$(basename $0): You have to be root to run this script" && exit 3
4554

4655
command -v mkisofs > /dev/null || (echo "$(basename $0): mkisofs not found, please install or ensure PATH is accurate" ; exit 4)
4756

48-
inject systemvm.iso $newpubkey
49-
#inject systemvm-premium.iso $newpubkey
57+
inject_into_iso systemvm.iso $newpubkey
58+
#inject_into_iso systemvm-premium.iso $newpubkey
59+
60+
[ $? -ne 0 ] && exit 5
61+
62+
copy_priv_key $newprivkey
5063

5164
exit $?

0 commit comments

Comments
 (0)