"Martijn Rijkeboer" <mart...@bunix.org> writes: > After quite some discussion here's take 4 of the update of > sysutils/cfengine. This version is based on Stuart's version which was > based on Jiri B's version. > > Notable differences with Stuart's version: > - Remove @sample for failsafe.cf in PLIST: Modern versions of cfengine use > update.cf instead of failsafe.cf (there's an internal failsafe.cf). > - Remove @exec for cfkey in PLIST: The keys are not generated when > installing (as suggested by Stuart), but a remark how to generate them > is added to the README. > - Remove @sample for masterfiles in PLIST: This directory will be created > by cfagent. > - Fix @mode for @sample files: Make configuration files 0600. > - Replace inputs symlink with directory: When /var/cfengine/inputs is a > symlink bootstrapping won't work. > - Remove mysql flavor from FLAVORS: The mysql flavor currently won't build > due to a bug in mysql. > - Patch /var/cfengine/inputs/update.cf: Remove creation of symlinks from > /usr/local/sbin to /var/cfengine/bin/cf-*. > - Update README: Add instructions on how to create key pair and fix > notable changes section. > > Please commit so other people can start testing it. > > Kind regards, > > > Martijn Rijkeboer
Hi, I just started learning cfengine and tested this port. I tried the motd.cf from cfengine samples and it didn't get all the values on OpenBSD. It worked fine on Linux. After checking the code it seems cfengine uses /proc to gather its data which should be patched to use sysctl. I patched the cpu detection bit of the motd example but it still lists my interfaces as "$(interfaces_str)" instead with their name. It gets the interface address though. I haven't found where does it assign the interfaces_str values. Welcome to mandrake.wickedbsd.net! This system is managed by CFEngine. The policy was last updated on Wed Apr 24 19:05:10 2013. The system has 4 cpus. Network interfaces on this system are $(interfaces_str), and the ip-addresses assigned are 10.0.0.3. Here's patch to get the cpu count: $ cat /usr/ports/mystyff/sysutils/cfengine/patches/patch-src_sysinfo_c $OpenBSD$ --- src/sysinfo.c.orig Wed Apr 24 22:22:58 2013 +++ src/sysinfo.c Wed Apr 24 22:26:09 2013 @@ -36,6 +36,12 @@ # include <zone.h> #endif +#if (__OpenBSD__) +#include <sys/param.h> +#include <sys/sysctl.h> +#include <err.h> +#endif + void CalculateDomainName(const char *nodename, const char *dnsname, char *fqname, char *uqname, char *domain); #ifdef LINUX @@ -2100,6 +2106,17 @@ const char *GetWorkDir(void) static void GetCPUInfo() { +#if defined(__OpenBSD) + int mib[2], count; + size_t len; + char buf[CF_BUFSIZE]; + + mib[0] = CTL_HW; + mib[1] = HW_NCPU; + len = sizeof(count); + if (sysctl(mib, 2, &count, &len, NULL, 0) == -1) + err(1, "sysctl"); +#else FILE *fp; char buf[CF_BUFSIZE]; int count = 0; @@ -2123,7 +2140,7 @@ static void GetCPUInfo() fclose(fp); count--; - +#endif if (count < 1) { CfOut(cf_verbose, "", " !! CPU detection makes no sense: got %d\n", count);