Why Short-Circuit Instead of Remove

The removal guide disables the daemon and deletes the database. This is clean and thorough, but it has a consequence: any application that calls agev_get_age_bracket() or connects to /var/run/aged/aged.sock will receive a connection error instead of a response.

If MidnightBSD's mport package manager or other system tools begin querying the aged socket as part of normal operation, a missing daemon may cause errors, warnings, or refused operations. The short-circuit approach avoids this: the socket exists, the protocol is honored, and every query receives a valid response meaning "age unknown."

Approach 1: Socket-Level Stub

Replace the aged daemon with a minimal listener that accepts connections on the same socket and always responds with -1,-1 (unknown).

Using socat

The simplest approach uses socat to listen on the Unix socket and return the "unknown" response to every connection:

# Stop the real daemon
service aged stop
sysrc aged_enable="NO"

# Start a stub listener
socat UNIX-LISTEN:/var/run/aged/aged.sock,fork \
  EXEC:'echo "-1,-1"'

This is suitable for testing. For a persistent setup, wrap it in an rc script (see below).

As an rc Service

Create /usr/local/etc/rc.d/aged_stub:

#!/bin/sh
#
# PROVIDE: aged_stub
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

name="aged_stub"
rcvar="aged_stub_enable"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
pidfile="/var/run/aged/aged_stub.pid"

aged_stub_start() {
    mkdir -p /var/run/aged
    /usr/bin/daemon -p ${pidfile} \
        /usr/local/bin/socat \
        UNIX-LISTEN:/var/run/aged/aged.sock,fork \
        EXEC:'echo "-1,-1"'
}

aged_stub_stop() {
    if [ -f ${pidfile} ]; then
        kill $(cat ${pidfile})
        rm -f ${pidfile}
        rm -f /var/run/aged/aged.sock
    fi
}

load_rc_config $name
run_rc_command "$1"

Enable it:

chmod +x /usr/local/etc/rc.d/aged_stub
sysrc aged_stub_enable="YES"
service aged_stub start

Ensure aged is disabled

The real daemon and the stub cannot both bind to /var/run/aged/aged.sock. Disable aged before starting the stub:

sysrc aged_enable="NO"
service aged stop

Approach 2: Library-Level Shim

Intercept the agev(3) library calls with LD_PRELOAD so applications never reach the socket at all. This works regardless of whether the daemon is running.

The Shim

Create agev_shim.c:

#include <sys/types.h>

int agev_get_age_bracket(uid_t uid, int *lower, int *upper) {
    *lower = -1;
    *upper = -1;
    return 0;
}

int agev_set_age(uid_t uid, int age) {
    return 0;
}

int agev_set_dob(uid_t uid, const char *dob) {
    return 0;
}

Compile and install:

cc -shared -fPIC -o /usr/local/lib/agev_shim.so agev_shim.c

Use for a single application:

LD_PRELOAD=/usr/local/lib/agev_shim.so some_application

Use system-wide by setting LD_PRELOAD in the login environment:

# Add to /etc/profile (sh/bash) or /etc/csh.login (csh/tcsh):
export LD_PRELOAD=/usr/local/lib/agev_shim.so

The library shim is the most thorough approach. Applications receive valid "unknown" responses without any network call. The daemon can be completely removed (per the removal guide) and the shim handles any residual library calls.

Approach 3: rc.conf Swap

The simplest method: disable the real daemon, optionally run the socket stub. No library interposition, no recompilation:

# Disable the real daemon
sysrc aged_enable="NO"

# Optionally enable the stub (Approach 1)
sysrc aged_stub_enable="YES"

# Reboot or restart services
service aged stop
service aged_stub start

This is appropriate if no applications on your system call agev_get_age_bracket() directly. The socket stub handles anything that connects to the Unix socket. Applications that use the C library will get connection errors (or shim results if you combine with Approach 2).

Which Approach to Use

Socket stub — Use when applications connect to the aged socket directly. Handles the daemon protocol. Simple to deploy. Requires socat.
Library shim — Use when applications call agev(3) functions. Intercepts at the library level before any socket connection. Most thorough. Works even with the daemon fully removed.
Both — Use both for complete coverage. The library shim handles compiled applications; the socket stub handles anything that opens the socket directly (scripts, tools, custom code).

The Point

The aged daemon asks a question. The stub answers: "I don't know." Every time, for every user. The socket is live, the protocol is honored, the answer is nothing.