Overview of pkg-lib-bsd.inc

Public Function Summary

Public functions are intended to be called by the code that imports this library.

Name Summary
patchlevelcmp
portver

Public Function Details

patchlevelcmp

Named Parameters

patchlevel
rel

Code

function patchlevelcmp(rel, patchlevel) {
    kbrel = get_kb_item("ssh/login/freebsdrel");
    if(kbrel !=rel) return(0);
    kbpatchlevel = int(get_kb_item("ssh/login/freebsdpatchlevel"));
    if(kbpatchlevel<int(patchlevel)) {
	return(-1);
    } else if(kbpatchlevel>int(patchlevel)) {
	return(1);
    } else {
	return(0);
    }
}


		
top

portver

Named Parameters

pkg

Code

function portver(pkg) {
    pkgs = get_kb_item("ssh/login/freebsdpkg");
    if(!pkgs) return(NULL);
    narrowed = egrep(pattern:"^" + pkg + "-[0-9]", string:pkgs);
    if (!narrowed) return(NULL);

    # Package was installed
    __pkg_match = TRUE;

    list = split(narrowed, sep:'\n', keep:0);
    foreach package (list) {
	pat = string("^",pkg,"-([^ -]+) (.*)$");
	matches = eregmatch(pattern:pat, string:package);
	if(!isnull(matches)) {
	    return(matches[1]);
	}
    }
    return(NULL);
}

# Function to verify if a given patch level is outdated, and if so, to

		
top