Bug 186251 - authpf(8) always fails with "error removing stale rulesets" on 10.0-RELEASE
Summary: authpf(8) always fails with "error removing stale rulesets" on 10.0-RELEASE
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 10.0-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-pf (Nobody)
Depends on:
Reported: 2014-01-29 18:20 UTC by thomas
Modified: 2020-11-17 16:41 UTC (History)
1 user (show)

See Also:

patch for authpf.c (565 bytes, patch)
2020-11-17 16:37 UTC, Per Andersson
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description thomas 2014-01-29 18:20:01 UTC
After upgrading from 9.1 to 10.0-RELEASE, authpf does not work anymore. The SSH session is immediately terminated after login and the syslog contains the following error message "error removing stale rulesets" (apparently something in remove_stale_rulesets() goes wrong):

root@freebsd:/var/log # tail -n 3 all.log 
Jan 29 16:30:13 freebsd sshd[1035]: Accepted keyboard-interactive/pam for test from port 52213 ssh2
Jan 29 16:30:13 freebsd authpf[1039]: error removing stale rulesets
Jan 29 16:30:13 freebsd sshd[1038]: Received disconnect from 11: disconnected by user

How-To-Repeat: I can reproduce the problem on a freshly installed system with the following minimal config (the same config works on both 9.1 and 9.2):

echo 'pf_enable="YES"' >> /etc/rc.conf
touch /etc/pf.conf
/etc/rc.d/pf start

mkdir /etc/authpf
touch /etc/authpf/authpf.conf
touch /etc/authpf/authpf.rules
mount -t fdescfs null /dev/fd

<create user "test">
echo /usr/sbin/authpf >> /etc/shells
chsh -s authpf test

<login as user "test" via SSH>
Comment 1 thomas 2014-10-13 14:58:12 UTC
I just checked: The problem still exists on the 10.1-RC2.
Comment 2 Eitan Adler freebsd_committer freebsd_triage 2018-05-28 19:49:08 UTC
batch change:

For bugs that match the following
-  Status Is In progress 
- Untouched since 2018-01-01.
- Affects Base System OR Documentation


Reset to open status.

I did a quick pass but if you are getting this email it might be worthwhile to double check to see if this bug ought to be closed.
Comment 3 Per Andersson 2020-11-17 16:37:37 UTC
Created attachment 219771 [details]
patch for authpf.c
Comment 4 Per Andersson 2020-11-17 16:41:57 UTC
We also ran into this, I think the attached patch will solve the problem.

I looks like the return value from ioctl DIOCGETRULESETS (and DIOCGETRULESET) changed in r240233.

Should update manpage for pf also