Files
pmb 84fc383137 docs(freebsd): capture stdout to /var/log/fingerd.log via daemon -o
Without -o the daemon(8) wrapper redirects stdout to /dev/null, so
the printf-based logging is invisible on BSD.
2026-05-16 21:42:09 -07:00

103 lines
2.1 KiB
Markdown

# Running finger on FreeBSD
Tested on FreeBSD 15.0-RELEASE using clang 19, meson, and ninja inside a Bastille thin jail.
## Dependencies
```sh
pkg install git meson ninja pkgconf boost-all googletest
```
## Build
```sh
git clone https://github.com/waffle2k/finger /usr/local/src/finger
cd /usr/local/src/finger
meson setup builddir
meson compile -C builddir
meson install -C builddir
```
`meson install` places the binary at `/usr/local/bin/finger`.
## Plan Files
Create one file per username under `/var/finger/users/`. The file contents are returned when that user is fingered.
```sh
mkdir -p /var/finger/users
echo "Out to lunch." > /var/finger/users/pete
```
Test locally:
```sh
printf 'pete\r\n' | nc -w 2 127.0.0.1 79
```
## RC Service
Create `/usr/local/etc/rc.d/fingerd`:
```sh
#!/bin/sh
# PROVIDE: fingerd
# REQUIRE: NETWORKING
# KEYWORD: shutdown
. /etc/rc.subr
name="fingerd"
rcvar="fingerd_enable"
command="/usr/sbin/daemon"
command_args="-f -p /var/run/fingerd.pid -o /var/log/fingerd.log /usr/local/bin/finger"
pidfile="/var/run/fingerd.pid"
# procname must be the full path so rc.subr can match it against ps output
procname="/usr/local/bin/finger"
load_rc_config $name
: ${fingerd_enable:=NO}
run_rc_command "$1"
```
```sh
chmod +x /usr/local/etc/rc.d/fingerd
```
Enable at boot and start:
```sh
sysrc fingerd_enable=YES
service fingerd start
```
## Bastille Jail Setup (optional)
If running inside a Bastille thin jail, bind-mount the plan files directory from the host so they can be managed without entering the jail.
Host fstab (`/usr/local/bastille/jails/finger/fstab`):
```
/srv/finger/users /usr/local/bastille/jails/finger/root/var/finger/users nullfs rw 0 0
```
To redirect external port 79 into the jail, add to `/usr/local/bastille/jails/finger/rdr.conf`:
```
dual re0 any any tcp 79 79
```
pf will apply this as:
```
rdr pass on re0 inet proto tcp from any to any port = finger -> <jail-ip> port 79
```
Rebuild after source changes:
```sh
bastille cmd finger sh -c 'cd /usr/local/src/finger && meson compile -C builddir && meson install -C builddir'
```