Rework of runtime interface (#1498)
Some checks failed
CodeQL / Analyze (push) Has been cancelled
mkdocs / deploy (push) Has been cancelled

Also have special error handling for when branches are invalid and
ENOENT would be returned for getattr and readdir so users understand
what is going on and the runtime interface can still be used to fix
the problem.
This commit is contained in:
trapexit 2025-07-21 18:18:59 -05:00 • committed by GitHub
parent e87867cd2a
commit 2b500f194a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 3376 additions and 822 deletions

View file

@ -16,6 +16,8 @@
#include "gidcache.hpp"
#include "syslog.hpp"
#include <grp.h>
#include <pwd.h>
#include <stdlib.h>
@ -130,27 +132,47 @@ GIDCache::initgroups(const uid_t uid_,
void
GIDCache::invalidate_all()
{
size_t size;
size = _records.size();
_records.visit_all([](auto &x)
{
x.second.last_update = 0;
});
SysLog::info("gid cache invalidated, {} entries",size);
}
void
GIDCache::clear_all()
{
size_t size;
size = _records.size();
_records.clear();
SysLog::info("gid cache cleared, {} entries",size);
}
void
GIDCache::clear_unused()
{
int erased = 0;
time_t now = ::time(NULL);
auto erase_func =
[=](auto &x)
[now,&erased](auto &x)
{
return ((now - x.second.last_update) > GIDCache::remove_timeout);
bool should_erase;
time_t time_delta;
time_delta = (now - x.second.last_update);
should_erase = (time_delta > GIDCache::remove_timeout);
erased += should_erase;
return should_erase;
};
_records.erase_if(erase_func);
SysLog::info("cleared {} unused gid cache entries",erased);
}