Date: Sat, 8 Jan 2005 02:13:24 -0500 From: Craig Rodrigues <rodrigc@crodrigues.org> To: Kris Kennaway <kris@obsecurity.org> Cc: freebsd-ports@freebsd.org Subject: Hack to sysctl kern.osreldate, for ports cluster Message-ID: <20050108071324.GA32371@crodrigues.org>
next in thread | raw e-mail | index | archive | help
Hi, On http://pointyhat.freebsd.org/errorlogs/ it states that sysctl should not be used to determine the version of FreeBSD, and that uname(1) or the OSVERSION variable should be used instead. While a valid thing to do, this is another detail for port maintainers to keep track of. What do you think of this hack to sysctl, which cats /usr/include/sys/param.h to get the value of kern.osreldate, instead of going to the true kernel sysctl variable? --- sbin/sysctl/sysctl.c.orig Sat Jan 8 01:34:41 2005 +++ sbin/sysctl/sysctl.c Sat Jan 8 01:57:13 2005 @@ -568,8 +568,14 @@ printf("%d", *(int *)p); else printf("%d.%dC", (*(int *)p - 2732) / 10, (*(int *)p - 2732) % 10); - } else - printf(hflag ? "%'d" : "%d", *(int *)p); + } else { +#ifdef PORTS_HACK + if (strcmp("kern.osreldate", name ) == 0) { + system("awk '/^#define __FreeBSD_version/ { print $3 }' /usr/include/sys/param.h"); + } else +#endif /* PORTS_HACK */ + printf(hflag ? "%'d" : "%d", *(int *)p); + } val = " "; len -= sizeof(int); p += sizeof(int); -- Craig Rodrigues rodrigc@crodrigues.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050108071324.GA32371>