Hello, Zdenek,

I addressed your comments. Please, review.
I put the changes into separate files this time.

In configure.ac I made default option values for all interfaces. So, there should be no way some of them may be uninitialized.

Also, I re-arranged such that ipmishell is automatically disabled if there are no its prerequisites.

In lib_picmg.c I corrected formatting and check all string to integer conversions for errors.

Regards,
Dmitry

18.04.2013 13:42, Zdenek Styblik пишет:
On Thu, Apr 18, 2013 at 7:49 AM, Dmitry Bazhenov <dim...@pigeonpoint.com> wrote:
Hello, all,


Hi,

The attached patch fixes several compile and run-time bugs in the current
ipmitool TOB:
     o lib/ipmi_sel.c
       - zero data before making request to avoid reading of uninitialized data

This looks ok.

     o lib/ipmi_mc.c
       - do not print AUX info, if IPMC return 12-byte Get Device ID

*shrug*

response
     o lib/ipmi_picmg.c
       - add support for hexadecimal and octal formats for the command-line

NACK. Yes, you're adding support for hex and oct, but it doesn't fix
possibility of over/under-flow. Please, add this to ID#3528310 and it
will get fixed along. Thanks!
If you're willing to take it further, please, write a generic function
to validate whether FRU ID is within acceptable range and use
apropriate str2* functions to convert string to integer. Such thing
would be "appreciated".

parameters
     o configure.in
        - fixed build for the newer autotool releases

I guess ACK.

        - do not override OS-default values for IMB, OPEN and LIPMI
interfaces
          if the corresponding enable/disable arguments are not provided in
the command-line

NACK. Have you actually tested results of this patch? The way I see
it, fix is to create _os (defaults) variables and then:
``if test "x$xenable_intf_open" = "xyes" || test
"x$xenable_intf_open_os" = "xyes"; then''

I'll do the patch, eventually, if nobody else does it sooner(faster?).

Regards,
Z.



Please, review.

Regards,
Dmitry


------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Ipmitool-devel mailing list
Ipmitool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel

diff -Nurp ipmitool.sav/lib/ipmi_mc.c ipmitool.cvs/lib/ipmi_mc.c
--- ipmitool.sav/lib/ipmi_mc.c	2013-04-18 11:26:47 +0600
+++ ipmitool.cvs/lib/ipmi_mc.c	2013-04-17 22:57:52 +0600
@@ -448,13 +448,15 @@ ipmi_mc_get_deviceid(struct ipmi_intf * 
 			printf("    %s\n", ipm_dev_adtl_dev_support[i]);
 		}
 	}
-	printf("Aux Firmware Rev Info     : \n");
-	/* These values could be looked-up by vendor if documented,
-	 * so we put them on individual lines for better treatment later
-	 */
-	printf("    0x%02x\n    0x%02x\n    0x%02x\n    0x%02x\n",
-		devid->aux_fw_rev[0], devid->aux_fw_rev[1],
-		devid->aux_fw_rev[2], devid->aux_fw_rev[3]);
+	if (rsp->data_len == sizeof(*devid)) {
+		printf("Aux Firmware Rev Info     : \n");
+		/* These values could be looked-up by vendor if documented,
+		 * so we put them on individual lines for better treatment later
+		 */
+		printf("    0x%02x\n    0x%02x\n    0x%02x\n    0x%02x\n",
+			devid->aux_fw_rev[0], devid->aux_fw_rev[1],
+			devid->aux_fw_rev[2], devid->aux_fw_rev[3]);
+	}
 	return 0;
 }
 
diff -Nurp ipmitool.sav/lib/ipmi_sel.c ipmitool.cvs/lib/ipmi_sel.c
--- ipmitool.sav/lib/ipmi_sel.c	2013-04-18 11:26:47 +0600
+++ ipmitool.cvs/lib/ipmi_sel.c	2013-04-17 22:57:52 +0600
@@ -329,6 +329,7 @@ ipmi_sel_add_entry(struct ipmi_intf * in
 	struct ipmi_rs * rsp;
 	struct ipmi_rq req;
 
+	memset(&req, 0, sizeof(req));
 	req.msg.netfn = IPMI_NETFN_STORAGE;
 	req.msg.cmd = IPMI_CMD_ADD_SEL_ENTRY;
 	req.msg.data = (unsigned char *)rec;
diff -Nurp ipmitool.sav/lib/ipmi_picmg.c ipmitool.cvs/lib/ipmi_picmg.c
--- ipmitool.sav/lib/ipmi_picmg.c	2013-04-18 11:26:47 +0600
+++ ipmitool.cvs/lib/ipmi_picmg.c	2013-04-19 11:23:55 +0600
@@ -145,8 +145,9 @@ ipmi_picmg_getaddr(struct ipmi_intf * in
 	msg_data[0] = 0;   /* picmg identifier */
 	msg_data[1] = 0;   /* default fru id */
 
-	if(argc > 0) {
-		msg_data[1] = strtoul(argv[0], NULL,0);   /* FRU ID */
+	if(argc > 0 && str2uchar(argv[0], &msg_data[1])) {	/* FRU ID */
+		lprintf(LOG_ERR, "Invalid FRU ID specified");
+		return -1;
 	}
 
 	rsp = intf->sendrecv(intf, &req);
@@ -233,24 +234,24 @@ ipmi_picmg_properties(struct ipmi_intf *
 	{
 		printf("PICMG identifier	: 0x%02x\n", rsp->data[0]);
 		printf("PICMG Ext. Version : %i.%i\n",	 rsp->data[1]&0x0f,
-															 (rsp->data[1]&0xf0) >> 4);
+			(rsp->data[1]&0xf0) >> 4);
 		printf("Max FRU Device ID	: 0x%02x\n", rsp->data[2]);
 		printf("FRU Device ID		: 0x%02x\n", rsp->data[3]);
 	}
 
-   /* We cache the major extension version ...
-      to know how to format some commands */
+	 /* We cache the major extension version ...
+	      to know how to format some commands */
 	PicmgExtMajorVersion = rsp->data[1]&0x0f;
 
 	if( PicmgExtMajorVersion == PICMG_CPCI_MAJOR_VERSION  ) { 
 		PicmgCardType = PICMG_CARD_TYPE_CPCI;
-   }
+	}
 	else if(  PicmgExtMajorVersion == PICMG_ATCA_MAJOR_VERSION) {
 		PicmgCardType = PICMG_CARD_TYPE_ATCA;
-   }
+	}
 	else if(  PicmgExtMajorVersion == PICMG_AMC_MAJOR_VERSION) {
 		PicmgCardType = PICMG_CARD_TYPE_AMC;
-   }
+	}
     
 	return 0;
 }
@@ -274,8 +275,11 @@ ipmi_picmg_fru_activation(struct ipmi_in
 	req.msg.data     = (unsigned char*) &cmd;
 	req.msg.data_len = 3;
 
-	cmd.picmg_id  = 0;						/* PICMG identifier */
-	cmd.fru_id    = (unsigned char) atoi(argv[0]);			/* FRU ID	*/
+	cmd.picmg_id  = 0;					/* PICMG identifier */
+	if (str2uchar(argv[0], &cmd.fru_id)) {			/* FRU ID	*/
+		lprintf(LOG_ERR, "Invalid FRU ID specified");
+		return -1;
+	}
 	cmd.fru_state = state;
 
 	rsp = intf->sendrecv(intf, &req);
@@ -306,9 +310,11 @@ ipmi_picmg_fru_activation_policy_get(str
 	req.msg.data     = msg_data;
 	req.msg.data_len = 2;
 
-	msg_data[0] = 0;								/* PICMG identifier */
-	msg_data[1] = (unsigned char) atoi(argv[0]);	/* FRU ID			*/
-
+	msg_data[0] = 0;			/* PICMG identifier */
+	if (str2uchar(argv[0], &msg_data[1])) {	/* FRU ID	*/
+		lprintf(LOG_ERR, "Invalid FRU ID specified");
+		return -1;
+	}
 
 	rsp = intf->sendrecv(intf, &req);
 
@@ -344,10 +350,19 @@ ipmi_picmg_fru_activation_policy_set(str
 	req.msg.data     = msg_data;
 	req.msg.data_len = 4;
 
-	msg_data[0] = 0;								            /* PICMG identifier */
-	msg_data[1] = (unsigned char) atoi(argv[0]);	      /* FRU ID */
-	msg_data[2] = (unsigned char) atoi(argv[1])& 0x03; /* FRU act policy mask  */
-	msg_data[3] = (unsigned char) atoi(argv[2])& 0x03; /* FRU act policy set bits */
+	msg_data[0] = 0;		            /* PICMG identifier */
+	if (str2uchar(argv[0], &msg_data[1])) {	      /* FRU ID */
+		lprintf(LOG_ERR, "Invalid FRU ID specified");
+		return -1;
+	}
+	if (str2uchar(argv[1], &msg_data[2]) || msg_data[2] > 3) { /* FRU act policy mask  */
+		lprintf(LOG_ERR, "Invalid policy mask specified");
+		return -1;
+	}
+	if (str2uchar(argv[2], &msg_data[3]) || msg_data[3] > 3) { /* FRU act policy set bits */
+		lprintf(LOG_ERR, "Invalid policy set bits specified");
+		return -1;
+	}
 
 	rsp = intf->sendrecv(intf, &req);
 
@@ -754,9 +769,11 @@ ipmi_picmg_get_led_properties(struct ipm
 	req.msg.data  = msg_data;
 	req.msg.data_len = 2;
 
-	msg_data[0] = 0x00;									/* PICMG identifier */
-	msg_data[1] = atoi(argv[0]);						/* FRU-ID */
-
+	msg_data[0] = 0x00;				/* PICMG identifier */
+	if (str2uchar(argv[0], &msg_data[1])) {		/* FRU-ID */
+		lprintf(LOG_ERR, "Invalid FRU ID specified");
+		return -1;
+	}
 	rsp = intf->sendrecv(intf, &req);
 
 	if (!rsp) {
@@ -792,10 +809,15 @@ ipmi_picmg_get_led_capabilities(struct i
 	req.msg.data  = msg_data;
 	req.msg.data_len = 3;
 
-	msg_data[0] = 0x00;									/* PICMG identifier */
-	msg_data[1] = atoi(argv[0]);						/* FRU-ID */
-	msg_data[2] = atoi(argv[1]);						/* LED-ID */
-
+	msg_data[0] = 0x00;				/* PICMG identifier */
+	if (str2uchar(argv[0], &msg_data[1])) {		/* FRU-ID */
+		lprintf(LOG_ERR, "Invalid FRU ID specified");
+		return -1;
+	}
+	if (str2uchar(argv[1], &msg_data[2])) {		/* LED-ID */
+		lprintf(LOG_ERR, "Invalid LED ID specified");
+		return -1;
+	}
 
 	rsp = intf->sendrecv(intf, &req);
 
@@ -840,10 +862,15 @@ ipmi_picmg_get_led_state(struct ipmi_int
 	req.msg.data  = msg_data;
 	req.msg.data_len = 3;
 
-	msg_data[0] = 0x00;									/* PICMG identifier */
-	msg_data[1] = atoi(argv[0]);						/* FRU-ID */
-	msg_data[2] = atoi(argv[1]);						/* LED-ID */
-
+	msg_data[0] = 0x00;				/* PICMG identifier */
+	if (str2uchar(argv[0], &msg_data[1])) {		/* FRU-ID */
+		lprintf(LOG_ERR, "Invalid FRU ID specified");
+		return -1;
+	}
+	if (str2uchar(argv[1], &msg_data[2])) {		/* LED-ID */
+		lprintf(LOG_ERR, "Invalid LED ID specified");
+		return -1;
+	}
 
 	rsp = intf->sendrecv(intf, &req);
 
@@ -922,12 +949,27 @@ ipmi_picmg_set_led_state(struct ipmi_int
 	req.msg.data  = msg_data;
 	req.msg.data_len = 6;
 
-	msg_data[0] = 0x00;									/* PICMG identifier */
-	msg_data[1] = atoi(argv[0]);						/* FRU-ID			  */
-	msg_data[2] = atoi(argv[1]);						/* LED-ID			  */
-	msg_data[3] = atoi(argv[2]);						/* LED function	  */
-	msg_data[4] = atoi(argv[3]);						/* LED on duration  */
-	msg_data[5] = atoi(argv[4]);						/* LED color		  */
+	msg_data[0] = 0x00;					/* PICMG identifier	*/
+	if (str2uchar(argv[0], &msg_data[1])) {			/* FRU-ID		*/
+		lprintf(LOG_ERR, "Invalid FRU ID specified");
+		return -1;
+	}
+	if (str2uchar(argv[1], &msg_data[2])) {			/* LED-ID		*/
+		lprintf(LOG_ERR, "Invalid LED ID specified");
+		return -1;
+	}
+	if (str2uchar(argv[2], &msg_data[3])) {			/* LED function		*/
+		lprintf(LOG_ERR, "Invalid LED function specified");
+		return -1;
+	}
+	if (str2uchar(argv[3], &msg_data[4])) {			/* LED on duration	*/
+		lprintf(LOG_ERR, "Invalid LED on duration specified");
+		return -1;
+	}
+	if (str2uchar(argv[4], &msg_data[5])) {			/* LED color		*/
+		lprintf(LOG_ERR, "Invalid LED color specified");
+		return -1;
+	}
 
 	rsp = intf->sendrecv(intf, &req);
 
@@ -961,10 +1003,15 @@ ipmi_picmg_get_power_level(struct ipmi_i
 	req.msg.data  = msg_data;
 	req.msg.data_len = 3;
 
-	msg_data[0] = 0x00;									/* PICMG identifier */
-	msg_data[1] = atoi(argv[0]);						/* FRU-ID			  */
-	msg_data[2] = atoi(argv[1]);						/* Power type		  */
-
+	msg_data[0] = 0x00;					/* PICMG identifier */
+	if (str2uchar(argv[0], &msg_data[1])) {			/* FRU-ID			  */
+		lprintf(LOG_ERR, "Invalid FRU ID specified");
+		return -1;
+	}
+	if (str2uchar(argv[1], &msg_data[2])) {			/* Power type		  */
+		lprintf(LOG_ERR, "Invalid power type specified");
+		return -1;
+	}
 
 	rsp = intf->sendrecv(intf, &req);
 
@@ -1006,9 +1053,18 @@ ipmi_picmg_set_power_level(struct ipmi_i
 	req.msg.data_len = 4;
 
 	msg_data[0] = 0x00;					/* PICMG identifier	 */
-	msg_data[1] = atoi(argv[0]);				/* FRU-ID		 */
-	msg_data[2] = atoi(argv[1]);				/* power level		 */
-	msg_data[3] = atoi(argv[2]);				/* present to desired */
+	if (str2uchar(argv[0], &msg_data[1])) {			/* FRU-ID			  */
+		lprintf(LOG_ERR, "Invalid FRU ID specified");
+		return -1;
+	}
+	if (str2uchar(argv[1], &msg_data[2])) {			/* power level		 */
+		lprintf(LOG_ERR, "Invalid power level specified");
+		return -1;
+	}
+	if (str2uchar(argv[2], &msg_data[3])) {			/* present to desired */
+		lprintf(LOG_ERR, "Invalid present to desired field specified");
+		return -1;
+	}
 
 	rsp = intf->sendrecv(intf, &req);
 
@@ -1095,8 +1151,14 @@ ipmi_picmg_fru_control(struct ipmi_intf 
 	req.msg.data_len = 3;
 
 	msg_data[0] = 0x00;					/* PICMG identifier */
-	msg_data[1] = atoi(argv[0]);				/* FRU-ID	  */
-	msg_data[2] = atoi(argv[1]);				/* control option  */
+	if (str2uchar(argv[0], &msg_data[1])) {			/* FRU-ID	  */
+		lprintf(LOG_ERR, "Invalid FRU ID specified");
+		return -1;
+	}
+	if (str2uchar(argv[0], &msg_data[2])) {			/* control option  */
+		lprintf(LOG_ERR, "Invalid control option specified");
+		return -1;
+	}
 
 	printf("FRU Device Id: %d FRU Control Option: %s\n", msg_data[1],  \
 				val2str( msg_data[2], picmg_frucontrol_vals));
@@ -1112,15 +1174,12 @@ ipmi_picmg_fru_control(struct ipmi_intf 
 		lprintf(LOG_ERR, "frucontrol failed with CC code 0x%02x", rsp->ccode);
 		return -1;
 	} else {
-      printf("frucontrol: ok\n");
+		printf("frucontrol: ok\n");
 	}
 
-
-
 	return 0;
 }
 
-
 int
 ipmi_picmg_clk_get(struct ipmi_intf * intf, int clk_id,int clk_res,int mode)
 {
@@ -1143,9 +1202,9 @@ ipmi_picmg_clk_get(struct ipmi_intf * in
 
 	if(clk_res == -1 || PicmgCardType != PICMG_CARD_TYPE_ATCA ){
 		req.msg.data_len = 2;	/* for amc only channel */
-	}else{
+	} else {
 		req.msg.data_len = 3;	/* for carrier channel and device */
-      msg_data[2] = clk_res;
+		msg_data[2] = clk_res;
 	}
 
 	rsp = intf->sendrecv(intf, &req);
@@ -1164,35 +1223,24 @@ ipmi_picmg_clk_get(struct ipmi_intf * in
 		enabled	 = (rsp->data[1]&0x8)!=0;
 		direction = (rsp->data[1]&0x4)!=0;
 
-		if
-		( 
-			mode == PICMG_EKEY_MODE_QUERY
- 			||
- 			mode == PICMG_EKEY_MODE_PRINT_ALL
- 			||
- 			(
- 				mode == PICMG_EKEY_MODE_PRINT_DISABLED
- 				&&
- 				enabled == 0
- 			)
- 			||
- 			(
- 				mode == PICMG_EKEY_MODE_PRINT_ENABLED
- 				&&
- 				enabled == 1
-         )	
-		) {
+		if ( mode == PICMG_EKEY_MODE_QUERY
+ 			|| mode == PICMG_EKEY_MODE_PRINT_ALL
+ 			|| ( mode == PICMG_EKEY_MODE_PRINT_DISABLED
+ 				&& enabled == 0 )
+ 			|| ( mode == PICMG_EKEY_MODE_PRINT_ENABLED
+ 				&& enabled == 1 ) ) {
 			if( PicmgCardType != PICMG_CARD_TYPE_AMC ) {
 				printf("CLK resource id   : %3d [ %s ]\n", clk_res ,
 					oemval2str( ((clk_res>>6)&0x03), (clk_res&0x0F),
-														picmg_clk_resource_vals));				
+					picmg_clk_resource_vals));				
 			} else {
 				printf("CLK resource id   : N/A [ AMC Module ]\n");
 				clk_res = 0x40; /* Set */
 			} 
-         printf("CLK id            : %3d [ %s ]\n", clk_id,
-					oemval2str( ((clk_res>>6)&0x03), clk_id ,
-														picmg_clk_id_vals));				
+
+		         printf("CLK id            : %3d [ %s ]\n", clk_id,
+				oemval2str( ((clk_res>>6)&0x03), clk_id ,
+				picmg_clk_id_vals));				
 
 
 			printf("CLK setting       : 0x%02x\n", rsp->data[1]);
@@ -1200,27 +1248,26 @@ ipmi_picmg_clk_get(struct ipmi_intf * in
 			printf(" - direction: %s\n", (direction)?"Source":"Receiver");
 			printf(" - PLL ctrl:  0x%x\n", rsp->data[1]&0x3);
 
-		   if(enabled){
-		      unsigned long freq = 0;
-		      freq = (  rsp->data[5] <<  0
-		              | rsp->data[6] <<  8
-		              | rsp->data[7] << 16
-		              | rsp->data[8] << 24 );
-		      printf("  - Index:  %3d\n", rsp->data[2]);
-		      printf("  - Family: %3d [ %s ] \n", rsp->data[3], 
-						val2str( rsp->data[3], picmg_clk_family_vals));
-		      printf("  - AccLVL: %3d [ %s ] \n", rsp->data[4], 
-						oemval2str( rsp->data[3], rsp->data[4],
-											picmg_clk_accuracy_vals));
+			if (enabled) {
+				unsigned long freq = 0;
+				freq = (  rsp->data[5] <<  0
+					| rsp->data[6] <<  8
+					| rsp->data[7] << 16
+					| rsp->data[8] << 24 );
+				printf("  - Index:  %3d\n", rsp->data[2]);
+				printf("  - Family: %3d [ %s ] \n", rsp->data[3], 
+					val2str( rsp->data[3], picmg_clk_family_vals));
+				printf("  - AccLVL: %3d [ %s ] \n", rsp->data[4], 
+					oemval2str( rsp->data[3], rsp->data[4],
+					picmg_clk_accuracy_vals));
 		
-		      printf("  - Freq:   %ld\n", freq);
-		   }
+				printf("  - Freq:   %ld\n", freq);
+			}
 		}
 	}
 	return 0;
 }
 
-
 int
 ipmi_picmg_clk_set(struct ipmi_intf * intf, int argc, char ** argv)
 {
@@ -1250,28 +1297,24 @@ ipmi_picmg_clk_set(struct ipmi_intf * in
 	msg_data[9] = (freq >>24)& 0xFF;		/* freq					 */
 
 	req.msg.data_len = 10;
-   if( PicmgCardType == PICMG_CARD_TYPE_ATCA  )
-   {
-      if( argc > 7)
-      {
-         req.msg.data_len = 11;
-         msg_data[10] = strtoul(argv[6], NULL,0);	/* resource id			 */
-      }
-      else
-      {
-         lprintf(LOG_ERR, "Missing resource id for atca board.");
-         return -1;
-      }
-   }
+	if( PicmgCardType == PICMG_CARD_TYPE_ATCA ) {
+		if( argc > 7) {
+			req.msg.data_len = 11;
+			msg_data[10] = strtoul(argv[6], NULL,0);	/* resource id			 */
+		} else {
+			lprintf(LOG_ERR, "Missing resource id for atca board.");
+			return -1;
+		}
+	}
 
 #if 1
-printf("## ID:      %d\n", msg_data[1]);
-printf("## index:   %d\n", msg_data[2]);
-printf("## setting: 0x%02x\n", msg_data[3]);
-printf("## family:  %d\n", msg_data[4]);
-printf("## acc:     %d\n", msg_data[5]);
-printf("## freq:    %ld\n", freq );
-printf("## res:     %d\n", msg_data[10]);
+	printf("## ID:      %d\n", msg_data[1]);
+	printf("## index:   %d\n", msg_data[2]);
+	printf("## setting: 0x%02x\n", msg_data[3]);
+	printf("## family:  %d\n", msg_data[4]);
+	printf("## acc:     %d\n", msg_data[5]);
+	printf("## freq:    %ld\n", freq );
+	printf("## res:     %d\n", msg_data[10]);
 #endif
 
 	rsp = intf->sendrecv(intf, &req);
@@ -1289,8 +1332,6 @@ printf("## res:     %d\n", msg_data[10])
 	return 0;
 }
 
-
-
 int
 ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
 {
diff -Nurp ipmitool.sav/configure.in ipmitool.cvs/configure.in
--- ipmitool.sav/configure.in	2013-04-18 11:26:47 +0600
+++ ipmitool.cvs/configure.in	2013-04-19 12:08:37 +0600
@@ -51,7 +51,16 @@ if test "x$exec_prefix" = "xNONE"; then
 	exec_prefix="$prefix"
 fi
 
+dnl
+dnl set default option values
+dnl
+
+xenable_intf_bmc=no
+xenable_intf_imb=yes
+xenable_intf_open=yes
+xenable_intf_lipmi=yes
 xenable_all_options=yes
+xenable_ipmishell=yes
 
 dnl set some things so we build with GNU tools on Solaris
 case "$host_os" in
@@ -76,7 +85,6 @@ solaris*)
 	xenable_intf_open=no
 	xenable_intf_lipmi=no
 	xenable_intf_bmc=no
-	xenable_ipmishell=no
 	;;
 *darwin*|aix*)
 	# disable the linux and solaris-specific interfaces
@@ -89,7 +97,6 @@ solaris*)
 *freebsd*)
 	xenable_intf_imb=no
 	xenable_intf_lipmi=no
-	xenable_intf_bmc=no
 	;;
 *netbsd*)
 	xenable_intf_imb=no
@@ -209,11 +216,18 @@ AC_ARG_WITH([kerneldir],
 
 AH_TEMPLATE([HAVE_LINUX_COMPILER_H], [])
 AC_MSG_CHECKING([for linux/compiler.h])
-AC_PREPROC_IFELSE([#include <linux/compiler.h>],
-	[AC_DEFINE(HAVE_LINUX_COMPILER_H, [1],
+
+m4_version_prereq([2.68],
+	[AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <linux/compiler.h>]])],
+		[AC_DEFINE(HAVE_LINUX_COMPILER_H, [1],
+			[Define to 1 if you have the <linux/compiler.h> header file.])
+		AC_MSG_RESULT([yes])],
+		[AC_MSG_RESULT([no])])],
+	[AC_PREPROC_IFELSE([#include <linux/compiler.h>],
+		[AC_DEFINE(HAVE_LINUX_COMPILER_H, [1],
 		[Define to 1 if you have the <linux/compiler.h> header file.])
-	AC_MSG_RESULT([yes])],
-	[AC_MSG_RESULT([no])])
+		AC_MSG_RESULT([yes])],
+		[AC_MSG_RESULT([no])])])
 
 CPPFLAGS=$ORIG_CPPFLAGS
 AC_SUBST(CPPFLAGS)
@@ -379,7 +393,7 @@ AC_ARG_ENABLE([intf-open],
 	[AC_HELP_STRING([--enable-intf-open],
 			[enable Linux OpenIPMI interface [default=auto]])],
 	[xenable_intf_open=$enableval],
-	[xenable_intf_open=yes])
+	[])
 if test "x$xenable_intf_open" = "xstatic" || test "x$xenable_intf_open" = "xplugin"; then
 	xenable_intf_open=yes
 fi
@@ -422,7 +436,7 @@ AC_ARG_ENABLE([intf-imb],
 	[AC_HELP_STRING([--enable-intf-imb],
 			[enable Intel IMB driver interface [default=auto]])],
 	[xenable_intf_imb=$enableval],
-	[xenable_intf_imb=yes])
+	[])
 if test "x$xenable_intf_imb" = "xstatic" || test "x$xenable_intf_imb" = "xplugin"; then
 	xenable_intf_imb=yes
 fi
@@ -439,7 +453,7 @@ AC_ARG_ENABLE([intf-lipmi],
 	[AC_HELP_STRING([--enable-intf-lipmi],
 			[enable Solaris 9 x86 IPMI interface [default=no]])],
 	[xenable_intf_lipmi=$enableval],
-	[xenable_intf_lipmi=no])
+	[])
 if test "x$xenable_intf_lipmi" = "xstatic" || test "x$xenable_intf_lipmi" = "xplugin"; then
 	xenable_intf_lipmi=yes
 fi
@@ -472,12 +486,21 @@ fi
 
 AC_SUBST(IPMITOOL_INTF_LIB)
 
+if test "x$xenable_ipmishell" = "xyes"; then
+	AC_SEARCH_LIBS([tgetent], [tinfo ncurses curses readline termcap])
+	AC_SEARCH_LIBS([initscr], [ncurses curses], [have_curses=yes])
+	AC_SEARCH_LIBS([readline], [readline edit], [have_readline=yes])
+	if test "x$have_curses" != "xyes" || test "x$have_readline" != "xyes"; then
+		xenable_ipmishell=no
+	fi
+fi
+
 dnl check for readline library to enable ipmi shell
 AC_ARG_ENABLE([ipmishell],
 	[AC_HELP_STRING([--enable-ipmishell],
 			[enable IPMI shell interface [default=yes]])],
 	[xenable_ipmishell=$enableval],
-	[xenable_ipmishell=yes])
+	[])
 if test "x$xenable_ipmishell" = "xyes"; then
 	AC_SEARCH_LIBS([tgetent], [tinfo ncurses curses readline termcap])
 	AC_SEARCH_LIBS([initscr], [ncurses curses], [have_curses=yes])
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Ipmitool-devel mailing list
Ipmitool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel

Reply via email to