My test case is very simple:
control:
ActionSequence = ( packages )
DefaultPkgMgr = ( freebsd )
FreeBSDInstallCommand = ( "/usr/sbin/pkg_add -r %s" )
packages:
bash action=install
So what I expect this to do is go off and retrieve the latest
version of bash and install it. In fact what happens is that cfagent
segfaults.
Inside FreeBSDPackageCheck():
strncpy(pkgname, package, CF_BUFSIZE - 1);
pkgversion = strrchr(pkgname, '-');
*pkgversion = '\0';
pkgversion += 1;
Debug("FreeBSDPackageCheck(): Requested version %s %s of %s\n",
CMPSENSETEXT[cmp],(version[0] ? version : "ANY"), pkgname);
I don't know very much about FreeBSD packages as I haven't used
FreeBSD in some years and I never used packages very much even then so
I'm not sure what exactly is supposed to be happening here. It
looks like we're trying to support adding packages by version number
or just grabbing "the latest" which is what I want. In any event I
notice that pkgversion is never seen again in the rest of the
function. We simply dereference it and crash because strrchr()
returned 0 and there's nothing TO dereference.
At time of writing the latest version of bash available is 3.2.25
so I'll change my rule viz:
packages:
bash-3.2.25 action=install
This time cfagent doesn't crash but because we ignored the
pkgversion variable the package that pkg_add tries to retrieve from
ftp.freebsd.org is bash-3.2.25.tbz. This fails since the default
location is ftp://ftp.freebsd.org/.../Latest/ and only has bash.tbz.
I suppose this might work if you had your own custom package
repository but out of the box it doesn't. Even if I override the
PACKAGESITE location to ftp://ftp.freebsd.org/.../All/ I would need to
know the exact version number of each package I wanted to install.
After deleting the lines containing pkgversion in
FreeBSDPackageCheck() and FreeBSDPackageList() - three lines near the
top of each function - I was able to run my original rule successfully
and install bash.
_______________________________________________
Bug-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/bug-cfengine