Skip to content

Commit abdf9a2

Browse files
committed
Return correct return code on access error.
Signed-off-by: Mike Ponomarenko <mponomarenko@bloomberg.net>
1 parent 991d8c7 commit abdf9a2

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

db/comdb2.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ int64_t gbl_num_auth_allowed = 0;
238238
int64_t gbl_num_auth_denied = 0;
239239
int gbl_allow_old_authn = 0;
240240
int gbl_uses_externalauth = 0;
241+
int gbl_uses_simpleauth = 0;
241242
int gbl_uses_externalauth_connect = 0;
242243
int gbl_externalauth_warn = 0;
243244
int gbl_identity_cache_max = 500;

db/comdb2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,7 @@ extern int gbl_allow_old_authn;
16451645
extern int gbl_uses_password;
16461646
extern int gbl_unauth_tag_access;
16471647
extern int gbl_uses_externalauth;
1648+
extern int gbl_uses_simpleauth;
16481649
extern int gbl_uses_externalauth_connect;
16491650
extern int gbl_externalauth_warn;
16501651
extern int gbl_identity_cache_max;

db/db_access.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,12 +410,15 @@ int access_control_check_write(struct ireq *iq, tran_type *trans, int *bdberr)
410410
int rc = 0;
411411

412412
if (gbl_uses_externalauth && iq->authdata && externalComdb2AuthenticateUserRead) {
413-
return externalComdb2AuthenticateUserWrite(iq->authdata, iq->usedb->tablename, iq->corigin);
413+
rc = externalComdb2AuthenticateUserWrite(iq->authdata, iq->usedb->tablename, iq->corigin);
414+
if (rc)
415+
rc = ERR_ACCESS;
416+
return rc;
414417
}
415418

416419
rc = check_tag_access(iq);
417420
if (rc)
418-
return rc;
421+
return ERR_ACCESS;
419422

420423
return 0;
421424
}
@@ -425,12 +428,15 @@ int access_control_check_read(struct ireq *iq, tran_type *trans, int *bdberr)
425428
int rc = 0;
426429

427430
if (gbl_uses_externalauth && iq->authdata && externalComdb2AuthenticateUserRead && iq->usedb) {
428-
return externalComdb2AuthenticateUserRead(iq->authdata, iq->usedb->tablename, iq->corigin);
431+
rc = externalComdb2AuthenticateUserRead(iq->authdata, iq->usedb->tablename, iq->corigin);
432+
if (rc)
433+
rc = ERR_ACCESS;
434+
return rc;
429435
}
430436

431437
rc = check_tag_access(iq);
432438
if (rc)
433-
return rc;
439+
return ERR_ACCESS;
434440

435441
return 0;
436442
}

db/db_tunables.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2586,4 +2586,6 @@ REGISTER_TUNABLE("prefer_non_blocking_coherency_check",
25862586
REGISTER_TUNABLE("new_connection_grace_ms", "Time (in ms) before new connection is eligible for eviction (Default: 100ms)",
25872587
TUNABLE_INTEGER, &gbl_new_connection_grace_ms, INTERNAL, NULL, NULL, NULL, NULL);
25882588
REGISTER_TUNABLE("accept_headroom", "", TUNABLE_INTEGER, &gbl_accept_headroom, INTERNAL, NULL, NULL, NULL, NULL);
2589+
REGISTER_TUNABLE("simpleauth", NULL, TUNABLE_BOOLEAN, &gbl_uses_simpleauth, NOARG | READEARLY, NULL, NULL, NULL, NULL);
2590+
25892591
#endif /* _DB_TUNABLES_H */

db/sql.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,16 @@ enum {
391391
enum WriteResponsesEnum { RESPONSE_TYPES };
392392
#undef XRESPONSE
393393

394+
inline static char *xresponse_type_str(int c)
395+
{
396+
#define XRESPONSE(x) \
397+
if (c == x) \
398+
return #x;
399+
RESPONSE_TYPES
400+
#undef XRESPONSE
401+
return "???";
402+
}
403+
394404
/* read response */
395405
enum {
396406
RESPONSE_PING_PONG,

0 commit comments

Comments
 (0)