fix(member-files): preserve the original lookup error in ACL diagnostics
This commit is contained in:
1 parent
cce633b5b0
commit
f66c4e928e
1 file changed
+12
-9
@@ -116,19 +116,22 @@ int member_files_member(struct UTUN_INSTANCE* inst, uint64_t group, uint64_t nod
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_MEDIA, "member_files: membership query failed group=%llu: %s",
|
||||
(unsigned long long)group, sqlite3_errmsg(inst->topo_sqlite_db)); return 0;
|
||||
}
|
||||
int rc = sqlite3_bind_int64(st, 1, (sqlite3_int64)node);
|
||||
if (rc == SQLITE_OK) rc = sqlite3_step(st);
|
||||
char role[16]; const char* tags = (const char*)sqlite3_column_text(st, 0);
|
||||
int storage_role = tags && json_flat_get(tags, "storage", role, sizeof(role)) == 0 && !strcmp(role, "yes");
|
||||
int allowed = rc == SQLITE_ROW && !sqlite3_column_int(st, 1) && !sqlite3_column_int(st, 3) &&
|
||||
(!storage || (storage_role && sqlite3_column_bytes(st, 2) == 64));
|
||||
const char* stage = "bind"; int rc = sqlite3_bind_int64(st, 1, (sqlite3_int64)node);
|
||||
if (rc == SQLITE_OK) { stage = "step"; rc = sqlite3_step(st); }
|
||||
int source = -1, deleted = -1, signature = 0, storage_role = 0, allowed = 0;
|
||||
if (rc == SQLITE_ROW) {
|
||||
char role[16]; const char* tags = (const char*)sqlite3_column_text(st, 0);
|
||||
source = sqlite3_column_int(st, 1); deleted = sqlite3_column_int(st, 3); signature = sqlite3_column_bytes(st, 2);
|
||||
storage_role = tags && json_flat_get(tags, "storage", role, sizeof(role)) == 0 && !strcmp(role, "yes");
|
||||
allowed = !source && !deleted && (!storage || (storage_role && signature == 64));
|
||||
}
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_MEDIA,
|
||||
"member_files: ACL allowed=%d group=%llu node=%llu require_storage=%d row=%d storage=%d source=%d signature=%d deleted=%d",
|
||||
allowed, (unsigned long long)group, (unsigned long long)node, storage, rc == SQLITE_ROW,
|
||||
storage_role, sqlite3_column_int(st, 1), sqlite3_column_bytes(st, 2), sqlite3_column_int(st, 3));
|
||||
storage_role, source, signature, deleted);
|
||||
if (rc != SQLITE_ROW && rc != SQLITE_DONE) DEBUG_ERROR(DEBUG_CATEGORY_MEDIA,
|
||||
"member_files: access check failed group=%llu node=%llu require_storage=%d sqlite_rc=%d: %s",
|
||||
(unsigned long long)group, (unsigned long long)node, storage, rc, sqlite3_errmsg(inst->topo_sqlite_db));
|
||||
"member_files: access check failed group=%llu node=%llu require_storage=%d stage=%s rc=%d (%s): %s",
|
||||
(unsigned long long)group, (unsigned long long)node, storage, stage, rc, sqlite3_errstr(rc), sqlite3_errmsg(inst->topo_sqlite_db));
|
||||
int final = sqlite3_finalize(st);
|
||||
if (final != SQLITE_OK) DEBUG_ERROR(DEBUG_CATEGORY_MEDIA,
|
||||
"member_files: access finalize failed group=%llu node=%llu sqlite_rc=%d: %s",
|
||||
|
||||
Reference in new issue
Block a user