fence-agents: master - fence: Fix virsh agent and ssh_options in case of ssh private key

Jan Friesse honzaf@fedoraproject.org
Thu Jan 8 10:22:00 GMT 2009


Gitweb:        http://git.fedorahosted.org/git/fence-agents.git?p=fence-agents.git;a=commitdiff;h=c6e55b3eafd591a33ef7ee6ce2a2271988a521ec
Commit:        c6e55b3eafd591a33ef7ee6ce2a2271988a521ec
Parent:        4220491205dd5296581f09a51d84bbcdfaef718b
Author:        Jan Friesse <jfriesse@redhat.com>
AuthorDate:    Thu Jan 8 11:21:29 2009 +0100
Committer:     Jan Friesse <jfriesse@redhat.com>
CommitterDate: Thu Jan 8 11:21:29 2009 +0100

fence: Fix virsh agent and ssh_options in case of ssh private key

Virsh agent should use --noprofile and --norc when invoking bash, because
in other case, all PS1 setting doesn't make any sense.

fencing.py.py library have two branches for invoking ssh command. One
case is without ssh private key and other is with it. Case without
private key process ssh_options agent key, but other branch not.
This patch fixes that and now both branches behave correctly.
---
 fence/agents/lib/fencing.py.py    |    6 +++++-
 fence/agents/virsh/fence_virsh.py |    2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 11e8bca..4393b97 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -559,7 +559,11 @@ def fence_login(options):
 			conn.sendline(options["-p"])
 			conn.log_expect(options, options["-c"], LOGIN_TIMEOUT)
 		elif options.has_key("-x") and 1 == options.has_key("-k"):
-			conn = fspawn('%s %s@%s -i %s' % (SSH_PATH, options["-l"], options["-a"], options["-k"]))
+			command = '%s %s@%s -i %s' % (SSH_PATH, options["-l"], options["-a"], options["-k"])
+			if options.has_key("ssh_options"):
+				command += ' ' + options["ssh_options"]
+			conn = fspawn(command)
+
 			result = conn.log_expect(options, [ options["-c"], "Are you sure you want to continue connecting (yes/no)?", "Enter passphrase for key '"+options["-k"]+"':" ], LOGIN_TIMEOUT)
 			if result == 1:
 				conn.sendline("yes")
diff --git a/fence/agents/virsh/fence_virsh.py b/fence/agents/virsh/fence_virsh.py
index d54478d..bdf4e88 100644
--- a/fence/agents/virsh/fence_virsh.py
+++ b/fence/agents/virsh/fence_virsh.py
@@ -72,7 +72,7 @@ def main():
 
 	options["-x"]=1
 
-	options["ssh_options"]="-t '/bin/bash -c \"PS1=\[EXPECT\]#\  /bin/bash\"'"
+	options["ssh_options"]="-t '/bin/bash -c \"PS1=\[EXPECT\]#\  /bin/bash --noprofile --norc\"'"
 
 	## Operate the fencing device
 	conn = fence_login(options)



More information about the Cluster-cvs mailing list