[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] cluster/fence/agents/ipmilan ipmilan.c



CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	rmccabe sourceware org	2007-09-24 21:56:43

Modified files:
	fence/agents/ipmilan: ipmilan.c 

Log message:
	Backport the agent from RHEL5.1 to fix bz205638

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/ipmilan/ipmilan.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1.2.8&r2=1.1.2.9

--- cluster/fence/agents/ipmilan/ipmilan.c	2007/02/13 19:38:33	1.1.2.8
+++ cluster/fence/agents/ipmilan/ipmilan.c	2007/09/24 21:56:43	1.1.2.9
@@ -30,9 +30,9 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <signal.h>
-#include <limits.h>
 #include <string.h>
 #include <errno.h>
+#include <limits.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
 #include <libintl.h>
@@ -92,6 +92,7 @@
 	pid_t i_pid;
 	int i_config;
 	int i_verbose;
+	int i_lanplus;
 };
 
 
@@ -176,8 +177,13 @@
 	int x;
 
 	/* Store path */
-	snprintf(cmd, sizeof(cmd), "%s -I lan -H %s", ipmi->i_ipmitool,
-		 ipmi->i_host);
+	if (ipmi->i_lanplus) {
+		snprintf(cmd, sizeof(cmd), "%s -I lanplus -H %s", 
+				ipmi->i_ipmitool, ipmi->i_host);
+	} else {
+		snprintf(cmd, sizeof(cmd), "%s -I lan -H %s", ipmi->i_ipmitool,
+				ipmi->i_host);
+	}
 
 	if (ipmi->i_user) {
 		snprintf(arg, sizeof(arg), " -U %s", ipmi->i_user);
@@ -460,7 +466,7 @@
  */
 static struct ipmi *
 ipmi_init(struct ipmi *i, char *host, char *authtype,
-	  char *user, char *password, int verbose)
+	  char *user, char *password, int lanplus, int verbose)
 {
 	const char *p;
 
@@ -530,6 +536,7 @@
 	i->i_pid = -1;
 	i->i_id = IPMIID;
 	i->i_verbose = verbose;
+	i->i_lanplus = lanplus;
 
 	return i;
 }
@@ -574,7 +581,7 @@
 	}
 
 	memset((void *)i, 0, sizeof(*i));
-	ipmi_init(i, NULL, NULL, NULL, NULL, 0);
+	ipmi_init(i, NULL, NULL, NULL, NULL, 0, 0);
 	return i;
 }
 
@@ -658,6 +665,7 @@
 	char *end = NULL;
 	struct ipmi *i;
 	size_t len;
+	int lanplus = 0;
 
 	if (!ISIPMI(s))
 		return S_OOPS;
@@ -672,6 +680,10 @@
 	if (user) {
 		*user = 0;
 		user++;
+		if (*user && *user == '+') {
+			lanplus = 1;
+			user++;
+		}
 	}
 
 	/* No separator or end of string reached */
@@ -703,7 +715,7 @@
 		user = NULL;
 
 	/* IPMI auth type not supported on RHEL3 */
-	i = ipmi_init(i, host, NULL, user, passwd, 0);
+	i = ipmi_init(i, host, NULL, user, passwd, lanplus, 0);
 	if (!i)
 		return S_OOPS;
 	i->i_config = 1;
@@ -809,7 +821,7 @@
 		  char *pwd_script, size_t pwd_script_len,
 		  char *user, size_t userlen,
 		  char *op, size_t oplen,
-		  int *verbose)
+		  int *lanplus, int *verbose)
 {
 	char in[256];
 	int line = 0;
@@ -856,20 +868,21 @@
 				strncpy(passwd, val, pwlen);
 			else
 				passwd[0] = 0;
+
 		} else if (!strcasecmp(name, "passwd_script")) {
-			if (val) {     
+			if (val) {
 				strncpy(pwd_script, val, pwd_script_len);
 				pwd_script[pwd_script_len - 1] = '\0';
 			} else
 				pwd_script[0] = '\0';
-		} else if (!strcasecmp(name, "user") ||
-			   !strcasecmp(name, "login")) {
+		} else if (!strcasecmp(name, "user") || !strcasecmp(name, "login")) {
 			/* username */
 			if (val)
 				strncpy(user, val, userlen);
 			else
 				user[0] = 0;
-
+		} else if (!strcasecmp(name, "lanplus")) {
+			(*lanplus) = 1;
 		} else if (!strcasecmp(name, "option") ||
 			   !strcasecmp(name, "operation") ||
 			   !strcasecmp(name, "action")) {
@@ -877,11 +890,6 @@
 				strncpy(op, val, oplen);
 			else
 				op[0] = 0;
-		} else {
-			fprintf(stderr,
-				"parse error: illegal name on line %d\n",
-				line);
-			return 1;
 		}
 	}
 
@@ -908,6 +916,7 @@
 printf("   -i <ipaddr>    IPMI Lan IP to talk to (deprecated, use -i)\n");
 printf("   -p <password>  Password (if required) to control power on\n"
        "                  IPMI device\n");
+printf("   -P             Use Lanplus\n");
 printf("   -S <path>      Script to retrieve password (if required)\n");
 printf("   -l <login>     Username/Login (if required) to control power\n"
        "                  on IPMI device\n");
@@ -921,6 +930,7 @@
 printf("   ipaddr=<#>            Same as -a\n");
 printf("   passwd=<pass>         Same as -p\n");
 printf("   passwd_script=<path>  Same as -S\n");
+printf("   lanplus               Same as -P\n");
 printf("   login=<login>         Same as -u\n");
 printf("   option=<op>           Same as -o\n");
 printf("   operation=<op>        Same as -o\n");
@@ -940,7 +950,8 @@
 	char passwd[64];
 	char user[64];
 	char op[64];
-	char pwd_script[PATH_MAX];
+	char pwd_script[PATH_MAX] = { 0, };
+	int lanplus=0;
 	int verbose=0;
 	char *pname = basename(argv[0]);
 	struct ipmi *i;
@@ -948,7 +959,6 @@
 	memset(ip, 0, sizeof(ip));
 	memset(authtype, 0, sizeof(authtype));
 	memset(passwd, 0, sizeof(passwd));
-	memset(pwd_script, 0, sizeof(pwd_script));
 	memset(user, 0, sizeof(user));
 	memset(op, 0, sizeof(op));
 
@@ -956,7 +966,7 @@
 		/*
 		   Parse command line options if any were specified
 		 */
-		while ((opt = getopt(argc, argv, "A:a:i:l:p:S:o:vV?hH")) != EOF) {
+		while ((opt = getopt(argc, argv, "A:a:i:l:p:S:Po:vV?hH")) != EOF) {
 			switch(opt) {
 			case 'A':
 				/* Auth type */
@@ -975,8 +985,10 @@
 				/* password */
 				strncpy(passwd, optarg, sizeof(passwd));
 				break;
+			case 'P':
+				lanplus = 1;
+				break;
 			case 'S':
-				/* password script */
 				strncpy(pwd_script, optarg, sizeof(pwd_script));
 				pwd_script[sizeof(pwd_script) - 1] = '\0';
 				break;
@@ -1007,7 +1019,7 @@
 				      passwd, sizeof(passwd),
 					  pwd_script, sizeof(pwd_script),
 				      user, sizeof(user),
-				      op, sizeof(op), &verbose) != 0)
+				      op, sizeof(op), &lanplus, &verbose) != 0)
 			return 1;
 	}
 
@@ -1057,7 +1069,7 @@
 
 
 	/* Ok, set up the IPMI struct */
-	i = ipmi_init(NULL, ip, authtype, user, passwd, verbose);
+	i = ipmi_init(NULL, ip, authtype, user, passwd, lanplus, verbose);
 	if (!i)
 		fail_exit("Failed to initialize\n");
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]