From: Ari Johnson Date: Wed, 21 Feb 2007 02:00:05 +0000 (+0000) Subject: More fixes to prevent players from setting the 'internal' attribute flag X-Git-Tag: 0.73~146 X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=12c09831b543265c9e469b902b0441bdb33021be;p=cobramush.git More fixes to prevent players from setting the 'internal' attribute flag --- diff --git a/src/atr_tab.c b/src/atr_tab.c index c582d78..0a33fb4 100644 --- a/src/atr_tab.c +++ b/src/atr_tab.c @@ -38,8 +38,32 @@ typedef struct atr_alias { /** Prefix table for standard attribute names */ PTAB ptab_attrib; -/** Attribute flags */ -PRIV attr_privs[] = { +/** Attribute flags for setting */ +PRIV attr_privs_set[] = { + {"no_command", '$', AF_NOPROG, AF_NOPROG}, + {"no_inherit", 'i', AF_PRIVATE, AF_PRIVATE}, + {"private", 'i', AF_PRIVATE, AF_PRIVATE}, + {"no_clone", 'c', AF_NOCOPY, AF_NOCOPY}, + {"privilege", 'w', AF_PRIVILEGE, AF_PRIVILEGE}, + {"visual", 'v', AF_VISUAL, AF_VISUAL}, + {"mortal_dark", 'm', AF_MDARK, AF_MDARK}, + {"hidden", 'm', AF_MDARK, AF_MDARK}, + {"regexp", 'R', AF_REGEXP, AF_REGEXP}, + {"case", 'C', AF_CASE, AF_CASE}, + {"locked", '+', AF_LOCKED, AF_LOCKED}, + {"safe", 'S', AF_SAFE, AF_SAFE}, + {"prefixmatch", '\0', AF_PREFIXMATCH, AF_PREFIXMATCH}, + {"veiled", 'V', AF_VEILED, AF_VEILED}, + {"debug", 'b', AF_DEBUG, AF_DEBUG}, + {"public", 'p', AF_PUBLIC, AF_PUBLIC}, + {"nearby", 'n', AF_NEARBY, AF_NEARBY}, + {"amhear", 'M', AF_MHEAR, AF_MHEAR}, + {"aahear", 'A', AF_AHEAR, AF_AHEAR}, + {NULL, '\0', 0, 0} +}; + +/** Attribute flags for viewing */ +PRIV attr_privs_view[] = { {"no_command", '$', AF_NOPROG, AF_NOPROG}, {"no_inherit", 'i', AF_PRIVATE, AF_PRIVATE}, {"pow_inherit", 't', AF_POWINHERIT, AF_POWINHERIT}, @@ -266,7 +290,7 @@ do_attribute_access(dbref player, char *name, char *perms, int retroactive) return; } if (strcasecmp(perms, "none")) { - flags = string_to_privs(attr_privs, perms, 0); + flags = string_to_privs(attr_privs_set, perms, 0); if (!flags) { notify(player, T("I don't understand those permissions.")); return; @@ -328,7 +352,7 @@ do_attribute_access(dbref player, char *name, char *perms, int retroactive) } notify_format(player, T("%s -- Attribute permissions now: %s"), name, - privs_to_string(attr_privs, flags)); + privs_to_string(attr_privs_view, flags)); } @@ -472,7 +496,8 @@ do_attribute_info(dbref player, char *name) } notify_format(player, "Attribute: %s", ap == catchall ? "Default Attribute" : AL_NAME(ap)); notify_format(player, - " Flags: %s", privs_to_string(attr_privs, AL_FLAGS(ap))); + " Flags: %s", privs_to_string(attr_privs_view, + AL_FLAGS(ap))); notify_format(player, " Creator: %s", unparse_dbref(AL_CREATOR(ap))); /* Now Locks */ if(!(AL_RLock(ap) == TRUE_BOOLEXP)) diff --git a/src/attrib.c b/src/attrib.c index 8863353..212ce50 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -39,7 +39,8 @@ ATTR *catchall; */ StrTree atr_names; /** Table of attribute flags. */ -extern PRIV attr_privs[]; +extern PRIV attr_privs_set[]; +extern PRIV attr_privs_view[]; dbref atr_on_obj = NOTHING; /** A flag to show if we're in the middle of a @wipe (this changes @@ -285,7 +286,7 @@ int string_to_atrflag(dbref player, char const *p) { int f; - f = string_to_privs(attr_privs, p, 0); + f = string_to_privs(attr_privs_set, p, 0); if (!f) return -1; if (!Admin(player) && (f & AF_MDARK)) @@ -311,7 +312,7 @@ string_to_atrflagsets(dbref player, char const *p, int *setbits, int *clrbits) { int f; *setbits = *clrbits = 0; - f = string_to_privsets(attr_privs, p, setbits, clrbits); + f = string_to_privsets(attr_privs_set, p, setbits, clrbits); if (f <= 0) return -1; if (!Prived(player) && ((*setbits & AF_MDARK) || (*clrbits & AF_MDARK))) @@ -330,7 +331,7 @@ string_to_atrflagsets(dbref player, char const *p, int *setbits, int *clrbits) const char * atrflag_to_string(int mask) { - return privs_to_string(attr_privs, mask); + return privs_to_string(attr_privs_view, mask); } /** Utility define for atr_add and can_create_attr */ diff --git a/src/db.c b/src/db.c index 2ddd94b..9322171 100644 --- a/src/db.c +++ b/src/db.c @@ -1285,7 +1285,7 @@ get_list(FILE * f, dbref i) } } -extern PRIV attr_privs[]; +extern PRIV attr_privs_view[]; void db_read_attrs(FILE * f, dbref i, int count) @@ -1306,7 +1306,7 @@ db_read_attrs(FILE * f, dbref i, int count) strcpy(name, tmp); db_read_this_labeled_dbref(f, "owner", &owner); db_read_this_labeled_string(f, "flags", &tmp); - flags = string_to_privs(attr_privs, tmp, 0); + flags = string_to_privs(attr_privs_view, tmp, 0); db_read_this_labeled_number(f, "derefs", &derefs); if(HAS_COBRADBFLAG(indb_flags,DBF_NEW_ATR_LOCK)) { diff --git a/src/fundb.c b/src/fundb.c index 1ff3d5b..65af2d3 100644 --- a/src/fundb.c +++ b/src/fundb.c @@ -32,7 +32,7 @@ #pragma warning( disable : 4761) /* NJG: disable warning re conversion */ #endif -extern PRIV attr_privs[]; +extern PRIV attr_privs_view[]; static lock_type get_locktype(char *str); extern struct db_stat_info *get_stats(dbref owner); static int lattr_helper(dbref player, dbref thing, dbref parent, char const *pattern, @@ -432,7 +432,7 @@ FUNCTION(fun_flags) safe_str("#-1", buff, bp); return; } - safe_str(privs_to_letters(attr_privs, AL_FLAGS(a)), buff, bp); + safe_str(privs_to_letters(attr_privs_view, AL_FLAGS(a)), buff, bp); if (atr_sub_branch(a)) safe_chr('`', buff, bp); } else { @@ -465,7 +465,7 @@ FUNCTION(fun_lflags) safe_str("#-1", buff, bp); return; } - safe_str(privs_to_string(attr_privs, AL_FLAGS(a)), buff, bp); + safe_str(privs_to_string(attr_privs_view, AL_FLAGS(a)), buff, bp); } else { /* Object flags, visible to all */ safe_str(bits_to_string("FLAG", Flags(thing), executor, thing), buff, bp); diff --git a/src/look.c b/src/look.c index 34a79b9..33bf524 100644 --- a/src/look.c +++ b/src/look.c @@ -47,7 +47,7 @@ void decompile_atrs(dbref player, dbref thing, const char *name, const char *pattern, const char *prefix, int skipdef); void decompile_locks(dbref player, dbref thing, const char *name, int skipdef); -extern PRIV attr_privs[]; +extern PRIV attr_privs_view[]; static void look_exits(dbref player, dbref loc, const char *exit_name) @@ -336,7 +336,7 @@ look_helper_veiled(dbref player, dbref thing __attribute__ ((__unused__)), if (EX_PUBLIC_ATTRIBS && !strcmp(AL_NAME(atr), "DESCRIBE") && !strcmp(pattern, "*")) return 0; - strcpy(fbuf, privs_to_letters(attr_privs, AL_FLAGS(atr))); + strcpy(fbuf, privs_to_letters(attr_privs_view, AL_FLAGS(atr))); if (atr_sub_branch(atr)) strcat(fbuf, "`"); if (AF_Veiled(atr)) { @@ -380,7 +380,7 @@ look_helper(dbref player, dbref thing __attribute__ ((__unused__)), if (EX_PUBLIC_ATTRIBS && !strcmp(AL_NAME(atr), "DESCRIBE") && !strcmp(pattern, "*")) return 0; - strcpy(fbuf, privs_to_letters(attr_privs, AL_FLAGS(atr))); + strcpy(fbuf, privs_to_letters(attr_privs_view, AL_FLAGS(atr))); if (atr_sub_branch(atr)) strcat(fbuf, "`"); r = safe_atr_value(atr); @@ -1446,9 +1446,9 @@ decompile_helper(dbref player, dbref thing __attribute__ ((__unused__)), /* Are we different? If so, do as usual */ int npmflags = AL_FLAGS(ptr) & (~AF_PREFIXMATCH); if (AL_FLAGS(atr) != AL_FLAGS(ptr) && AL_FLAGS(atr) != npmflags) - privs = privs_to_string(attr_privs, AL_FLAGS(atr)); + privs = privs_to_string(attr_privs_view, AL_FLAGS(atr)); } else { - privs = privs_to_string(attr_privs, AL_FLAGS(atr)); + privs = privs_to_string(attr_privs_view, AL_FLAGS(atr)); } if (privs && *privs) notify_format(player, "@set %s/%s=%s", dh->name, AL_NAME(atr), privs); diff --git a/src/predicat.c b/src/predicat.c index 9dd3b9b..08f748a 100644 --- a/src/predicat.c +++ b/src/predicat.c @@ -47,7 +47,7 @@ static int grep_helper(dbref player, dbref thing, dbref parent, char const *pattern, ATTR *atr, void *args); void do_grep(dbref player, char *obj, char *lookfor, int flag, int insensitive); int pay_quota(dbref, int); -extern PRIV attr_privs[]; +extern PRIV attr_privs_view[]; /** A generic function to generate a formatted string. The * return value is a statically allocated buffer. @@ -1391,7 +1391,7 @@ grep_helper(dbref player, dbref thing __attribute__ ((__unused__)), notify_format(player, "%s%s [#%d%s]%s %s", ANSI_HILITE, AL_NAME(atr), Owner(AL_CREATOR(atr)), - privs_to_letters(attr_privs, AL_FLAGS(atr)), + privs_to_letters(attr_privs_view, AL_FLAGS(atr)), ANSI_NORMAL, tbuf1); return found; }