Page MenuHomeFreeBSD

syslogd: Refresh configuration using libcasper
Needs ReviewPublic

Authored by jfree on Aug 15 2023, 4:07 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 20, 1:48 PM
Unknown Object (File)
Apr 13 2024, 11:00 AM
Unknown Object (File)
Apr 12 2024, 12:12 PM
Unknown Object (File)
Apr 10 2024, 12:21 AM
Unknown Object (File)
Apr 9 2024, 6:49 AM
Unknown Object (File)
Apr 9 2024, 1:15 AM
Unknown Object (File)
Apr 8 2024, 6:48 PM
Unknown Object (File)
Mar 27 2024, 10:14 PM

Details

Reviewers
markj
Summary
When a SIGHUP signal is sent to syslogd, the configuration is reparsed,
leading to new resource acquisition.

If syslogd is running in capability mode and a SIGHUP is received, new
resources cannot be acquired. To mitigate this issue, libcasper is used
to parse the configuration.

The libcasper process runs outside of capability mode and is capable of
parsing syslogd's configuration and obtaining new resources. These
resources are then sent to the syslogd process via nvlist.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

jfree requested review of this revision.Aug 15 2023, 4:07 AM

Use logerror() to log errors instead of exiting. This makes debugging significantly easier when something goes wrong during configuration parsing.

Update to avoid rebase conflicts

usr.sbin/syslogd/syslogd_cap_config.c
74

What's the point of having filed_count as an nvlist element? Doesn't nvlist_get_nvlist_array() return the size of the array in filed_count?

130

Per my comment in D41463, we should continue factoring this code out to make it less confusing. In an ideal design, IMO, readconfigfile() would return the nvlist instead of mucking with global variables.

That doesn't need to happen in this revision, it's just a comment about the direction I think we should go.

Don't manually add the filed count to the nvlist. The filed count is fetched when getting the nvlist filed array.

Fix minor mistyping in populate_config(). filed_count should be declared as size_t, not uint64_t.

usr.sbin/syslogd/syslogd_cap_config.c
82

Does the casper service do any validation of the config file path? Doesn't this interface allow syslogd to parse any file as a syslogd configuration file and derive capabilities from it?

Most likely we should handle this by making the configuration service take a limit, set by cap_limit_set(). During initialization, syslogd would limit the service to only /etc/syslog.conf (or whatever is specified by -f). An attempt to parse any other file should be rejected by the casper service.

Create filed nvlist directly from readconfigfile() and address Mark's comments.

usr.sbin/syslogd/syslogd_cap_config.c
82

Does the casper service do any validation of the config file path? Doesn't this interface allow syslogd to parse any file as a syslogd configuration file and derive capabilities from it?

Most likely we should handle this by making the configuration service take a limit, set by cap_limit_set(). During initialization, syslogd would limit the service to only /etc/syslog.conf (or whatever is specified by -f). An attempt to parse any other file should be rejected by the casper service.

I made ConfFile a global variable and did a strcmp() to verify that the passed-in path matched libcasper's original copy.