Browse Source

ticket 304 - Fix kernel version checking in dsktune

The kernel version cehcking in dsktune is incorrect.  It takes each
version element and checks it separately, without factoring in the
check for the previous version element.  This causes checks like
3.2.5 > 2.4.7 to be evaluated as false.

This fix factors in the previous version element comparison, which
ensures that the version is evaluated correctly as a whole.
Nathan Kinder 13 years ago
parent
commit
e2a1090098
1 changed files with 21 additions and 12 deletions
  1. 21 12
      ldap/systools/idsktune.c

+ 21 - 12
ldap/systools/idsktune.c

@@ -44,7 +44,7 @@
 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  *    Don't forget to update build_date when the patch sets are updated. 
  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
-static char *build_date = "10-AUGUST-2007";
+static char *build_date = "23-FEBRUARY-2012";
 
 #if defined(__FreeBSD__) || defined(__bsdi)
 #define IDDS_BSD_INCLUDE 1
@@ -1112,6 +1112,9 @@ linux_check_release(void)
   FILE *fp;
   char osl[128];
   char *cmd = strdup("/bin/uname -r");
+  int major = 0;
+  int minor = 0;
+  int revision = 0;
 
   if (cmd == NULL) {
     printf("ERROR: Unable to allocate memory\n");
@@ -1139,20 +1142,26 @@ linux_check_release(void)
 	printf("DEBUG  : %s\n",osl);
   }
 
-  if (atoi(strtok(osl, ".")) < 2) {
-	printf("ERROR: We support kernel version 2.4.7 and higher.\n\n");
-	flag_os_bad = 1;
-	goto done;
-  }
-  if (atoi(strtok(NULL, ".")) < 4) {
-	printf("ERROR: We support kernel version 2.4.7 and higher.\n\n");
-	flag_os_bad = 1;
-	goto done;
-  }
-  if (atoi(strtok(NULL, "-")) < 7) {
+  major = atoi(strtok(osl, "."));
+  minor = atoi(strtok(NULL, "."));
+  revision = atoi(strtok(NULL, "-"));
+
+  if (major < 2) {
 	printf("ERROR: We support kernel version 2.4.7 and higher.\n\n");
 	flag_os_bad = 1;
 	goto done;
+  } else if (major == 2) {
+	if (minor < 4) {
+		printf("ERROR: We support kernel version 2.4.7 and higher.\n\n");
+		flag_os_bad = 1;
+		goto done;
+	} else if (minor == 4) {
+		if (revision < 7) {
+			printf("ERROR: We support kernel version 2.4.7 and higher.\n\n");
+			flag_os_bad = 1;
+			goto done;
+		}
+	}
   }
 done:
   if (cmd) free(cmd);