From a1c40e491d055fbc664ebed6ac1d5fed23fb31f5 Mon Sep 17 00:00:00 2001 From: sgunderson Date: Thu, 17 Aug 2000 21:47:34 +0000 Subject: [PATCH] nr_intperm(): Code cleanup, simplification and optimization. --- nonroot.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/nonroot.c b/nonroot.c index 6280557..18071f8 100644 --- a/nonroot.c +++ b/nonroot.c @@ -167,26 +167,25 @@ int nr_intperm(const uid_t uid, const char * const rightfile, fscanf(rights, "%s %s %d %d\n", this_entry, these_rights, &this_uid, &this_gid); - /* - * a bit (a BIT?) ugly, perhaps (PERHAPS?) - * note: no typo, it's supposed to be a single `=' sign - */ - if ((strcmp(this_entry, entry) == 0 && (rights_assigned = 1)) || - (strcmp(this_entry, ".default") == 0 && - strcmp(this_entry, ".rights") != 0 && - rights_assigned == 0)) { + if (strcmp(this_entry, entry) == 0) rights_assigned = 1; + if (strcmp(this_entry, ".default") == 0) rights_assigned = 2; + + if (rights_assigned != 0) { if (ret_rights != NULL) strcpy(ret_rights, these_rights); - strcpy(check_rights, these_rights); - check_uid = this_uid; - check_gid = this_gid; + strcpy(check_rights, these_rights); + check_uid = this_uid; + check_gid = this_gid; + + /* if we found a `real' (non-default) match, break right away */ if (rights_assigned == 1) break; - rights_assigned = 1; } } - if (rights_assigned == 0) puts("no entry! denying...\n"); - if (rights_assigned == 0) return -1; /* no entry, no access */ + if (rights_assigned == 0) { + puts("no entry! denying...\n"); + return -1; /* no entry, no access */ + } /* if we're only looking for at entry, return OK now */ if (perm == 0) { -- 2.39.2