KVER(3)

NAME
kver - override system version library

SYNOPSIS
LD_PRELOAD=/usr/pkg/lib/libkver.so uname -a

DESCRIPTION
The kver library provides implementations of sysctl(3) and uname(3) that shadow the real implementation and could be configured to override the information identifying the current system. This is useful for, among other things, building packages in a sandbox/chrooted environment for a different NetBSD release then the system hosting the sandbox.

The library is usually loaded by the run-time link-editor via the LD_PRELOAD hook. The kver(8) utility provides a simple wrapper for convenience.

For each variable that may be overridden, kver first attempts to obtain an override value from an environment variable; if the environment variable is not set then it uses readlink(2) to get the target of a symbolic link, and treats that as the override value; if that also fails, then the variable is not overridden. If none of the variables are overridden, or if an error occurs, then the kver library emits a warning message on the standard error output, and allows the program to run without any overrides.

The following table lists all the variables that may be overridden, giving the environment variable name, the symbolic link name, and a description of the way the value is used.

Environment | Symlink | Description
LIBKVER_OSTYPE | /libkver_ostype |
The operating system type, e.g. "NetBSD". Overrides the sysctl(7) variable kern.ostype. Overrides the result from uname(1) with the -s flag. Overrides the sysname element of the struct utsname result from uname(3).
LIBKVER_OSRELEASE | /libkver_osrelease |
The operating system release, e.g. "6.0_STABLE". Overrides the sysctl(7) variable kern.osrelease. Overrides the result from uname(1) with the -r flag. Overrides the release element of the struct utsname result from uname(3).

This value is also converted to an integer, which is used to override the value of the sysctl(7) variable kern.osrevision.
LIBKVER_MACHINE | /libkver_machine |
The operating hardware platform, e.g. “amd64”. Overrides the sysctl(7) variable hw.machine. Overrides the result from uname(1) with the -m flag. Overrides the machine element of the struct utsname result from uname(3).
LIBKVER_MACHINE_ARCH | /libkver_machine_arch |
The machine processor architecture, e.g. “x86_64”. Overrides the sysctl(7) variable hw.machine_arch. Overrides the result from uname(1) with the -p flag.

EXAMPLES
    env LD_PRELOAD=/lib/libkver.so LIBKVER_OSRELEASE=1.5 uname -r

    ln -s 1.6.2 /libkver_osrelease
    env LD_PRELOAD=/lib/libkver.so uname -r

DIAGNOSTICS

libkver: uname uname(3) failed.

libkver: not configured None of the configurable variables has been overridden.

libkver: sysctl hw.machine_arch sysctl(3) failed to retrieve the value of the hw.machine_arch variable.

libkver: cannot convert osrelease to osrevision: %s The osrelease string could not be converted to an integer for use by the kern.osrevision sysctl(7) variable.

SEE ALSO
ld.so(1), uname(1), sysctl(3), uname(3), kver(8)

AUTHORS
Stoned Elipot <seb@NetBSD.org> Alan Barrett <apb@NetBSD.org>