This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Cluster Project branch, RHEL5, updated. cmirror_1_1_15-89-g1f8a70a


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Cluster Project".

http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=1f8a70aafaa307b565335652b530e72ace8176a9

The branch, RHEL5 has been updated
       via  1f8a70aafaa307b565335652b530e72ace8176a9 (commit)
      from  4eca59fdacf347d0315eff78487b642e17be2de7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1f8a70aafaa307b565335652b530e72ace8176a9
Author: Marek 'marx' Grac <mgrac@redhat.com>
Date:   Mon May 19 17:28:39 2008 +0200

    [FENCE] Fix #248609: SSH support in Bladecenter fencing (ssh)
    
    Complete ssh support for Bladecenter. You can use password or private key
    (identity_file on STDIN; -k in getopt) to login to system. This patch contains
    complete infrastructure (usable also by other agents).

-----------------------------------------------------------------------

Summary of changes:
 fence/agents/bladecenter/fence_bladecenter.py |    2 +-
 fence/agents/lib/fencing.py.py                |   40 ++++++++++++++++++++-----
 2 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/fence/agents/bladecenter/fence_bladecenter.py b/fence/agents/bladecenter/fence_bladecenter.py
index 6670bcb..ff7ad67 100755
--- a/fence/agents/bladecenter/fence_bladecenter.py
+++ b/fence/agents/bladecenter/fence_bladecenter.py
@@ -64,7 +64,7 @@ def set_power_status(conn, options):
 def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
-			"cmd_prompt", "secure", "port" ]
+			"cmd_prompt", "secure", "port", "identity_file" ]
 
 	options = check_input(device_opt, process_input(device_opt))
 
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 0ddf173..7aa8a0c 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -72,12 +72,16 @@ all_opt = {
 		"order" : 1 },
 	"passwd" : {
 		"getopt" : "p:",
-		"help" : "-p <password>  Login password",
+		"help" : "-p <password>  Login password or passphrase",
 		"order" : 1 },
 	"passwd_script" : {
 		"getopt" : "S:",
 		"help" : "-S <script>    Script to run to retrieve password",
 		"order" : 1 },
+	"identity_file" : {
+		"getopt" : "k:",
+		"help" : "-k <filename>  Identity file (private key) for ssh ",
+		"order" : 1 },
 	"module_name" : {
 		"getopt" : "m:",
 		"help" : "-m <module>    DRAC/MC module name",
@@ -254,11 +258,19 @@ def check_input(device_opt, opt):
 	if 0 == options.has_key("-a"):
 		fail_usage("Failed: You have to enter fence address")
 
-	if 0 == (options.has_key("-p") or options.has_key("-S")):
-		fail_usage("Failed: You have to enter password or password script")
+	if 0 == device_opt.count("identity_file"):
+		if 0 == (options.has_key("-p") or options.has_key("-S")):
+			fail_usage("Failed: You have to enter password or password script")
+	else: 
+		if 0 == (options.has_key("-p") or options.has_key("-S") or options.has_key("-k")):
+			fail_usage("Failed: You have to enter password, password script or identity file")
+
+	if 0 == options.has_key("-x") and 1 == options.has_key("-k"):
+		fail_usage("Failed: You have to use identity file together with ssh connection (-x)")
 
-	if 1 == (options.has_key("-p") and options.has_key("-S")):
-		fail_usage("Failed: You have to enter password or password script")
+	if 1 == options.has_key("-k"):
+		if 0 == os.path.isfile(options["-k"]):
+			fail_usage("Failed: Identity file " + options["-k"] + " does not exist")
 
 	if (0 == options.has_key("-n")) and (device_opt.count("port")):
 		fail_usage("Failed: You have to enter plug number")
@@ -325,14 +337,26 @@ def fence_login(options):
 		re_login = re.compile("(login: )|(Login Name:  )|(username: )|(User Name :)", re.IGNORECASE)
 		re_pass  = re.compile("password", re.IGNORECASE)
 
-		if options.has_key("-x"):
+		if options.has_key("-x") and 0 == options.has_key("-k"):
 			conn = fspawn ('ssh ' + options["-l"] + "@" + options["-a"])
-			result = conn.log_expect(options, [ "ssword: ", "Are you sure you want to continue connecting (yes/no)?" ], LOGIN_TIMEOUT)
+			result = conn.log_expect(options, [ "ssword:", "Are you sure you want to continue connecting (yes/no)?" ], LOGIN_TIMEOUT)
 			if result == 1:
 				conn.sendline("yes")
-				conn.log_expect(options, "ssword: ", SHELL_TIMEOUT)
+				conn.log_expect(options, "ssword:", SHELL_TIMEOUT)
 			conn.sendline(options["-p"])
 			conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+		elif options.has_key("-x") and 1 == options.has_key("-k"):
+			conn = fspawn ('ssh ' + options["-l"] + "@" + options["-a"] + " -i " + options["-k"])
+			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")
+				conn.log_expect(options, [ options["-c"], "Enter passphrase for key '"+options["-k"]+"':"] , SHELL_TIMEOUT)
+			if result != 0:
+				if options.has_key("-p"):
+					conn.sendline(options["-p"])
+					conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+				else:
+					fail_usage("Failed: You have to enter passphrase (-p) for identity file")
 		else:
 			conn = fspawn ('telnet ' + options["-a"])
 			conn.log_expect(options, re_login, LOGIN_TIMEOUT)


hooks/post-receive
--
Cluster Project


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]