From e2a1090098fd2bcdd37dc1e9870cad46d975761c Mon Sep 17 00:00:00 2001 From: Nathan Kinder Date: Feb 23 2012 21:51:31 +0000 Subject: 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. --- diff --git a/ldap/systools/idsktune.c b/ldap/systools/idsktune.c index a16c27c..e0f485c 100644 --- a/ldap/systools/idsktune.c +++ b/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);