Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-126747 / s3/lib/idmap_cache - don't cache Unix account sids #359

Open
wants to merge 1 commit into
base: SCALE-v4-19-stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion source3/lib/idmap_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "../librpc/gen_ndr/idmap.h"
#include "lib/gencache.h"
#include "lib/util/string_wrappers.h"
#include "util_unixsids.h"

/**
* Find a sid2xid mapping
Expand Down Expand Up @@ -281,6 +282,7 @@ void idmap_cache_set_sid2unixid(const struct dom_sid *sid, struct unixid *unix_i
time_t now = time(NULL);
time_t timeout;
fstring key, value;
bool is_implicit_sid = false;

if (!is_null_sid(sid)) {
struct dom_sid_buf sidstr;
Expand All @@ -306,8 +308,15 @@ void idmap_cache_set_sid2unixid(const struct dom_sid *sid, struct unixid *unix_i
? lp_idmap_negative_cache_time()
: lp_idmap_cache_time();
gencache_set(key, value, now + timeout);

if (sid_check_is_in_unix_groups(sid) ||
sid_check_is_in_unix_users(sid)) {
// Avoid setting IDMAP/UID2SID cache entry for local
// users and groups to avoid cache pollution
is_implicit_sid = true;
}
}
if (unix_id->id != -1) {
if ((unix_id->id != -1) && !is_implicit_sid) {
if (is_null_sid(sid)) {
/* negative xid mapping */
fstrcpy(value, "-");
Expand Down
1 change: 1 addition & 0 deletions source3/wscript_build
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ bld.SAMBA3_SUBSYSTEM('samba3core',
lib/idmap_cache.c
lib/namemap_cache.c
lib/util_ea.c
lib/util_unixsids.c
lib/background.c
''',
deps='''
Expand Down