Esempio n. 1
0
/* killold probably isn't necessary, but there's no sense in clearing the old
 * alias hint if it's going to get overwritten by the caller anyway. */
int
rotate_alias(dbref target, int killold) {
    char *oldalias = NULL;
    PropPtr pptr;
    int valid;

    sprintf(abuf, ALIASDIR_LAST "%d", (int) target);
    pptr = get_property(0, abuf);
    if (pptr) {
        if ((valid = PropType(pptr) == PROP_STRTYP)) {
            oldalias = strdup(PropDataUNCStr(pptr));
        }
        if (killold || !valid) {
            /* kill the old 'last' hint if we were asked to, or if it's bogus */
            remove_property(0, abuf);
        }
        if (oldalias) {
            /* kill the old alias. */
            sprintf(abuf, ALIASDIR_CUR "%s", oldalias);
            remove_property(0, abuf);
            free(oldalias);
            return 1;
        }
    }

    return 0;
}
Esempio n. 2
0
int
safeputprop(dbref obj, dbref perms, char *buf, char *val, int mesgtyp)
{
	char *ptr;

	if (!buf)
		return 0;
	while (*buf == PROPDIR_DELIMITER)
		buf++;
	if (!*buf)
		return 0;

	/* disallow CR's and :'s in prop names. */
	for (ptr = buf; *ptr; ptr++)
		if (*ptr == '\r' || *ptr == PROP_DELIMITER)
			return 0;

	if (Prop_System(buf))
		return 0;
	
	if (!(mesgtyp & MPI_ISBLESSED)) {
		if (Prop_Hidden(buf))
			return 0;
		if (Prop_SeeOnly(buf))
			return 0;
		if (string_prefix(buf, "_msgmacs/"))
			return 0;
	}
	if (val == NULL) {
		remove_property(obj, buf, 0);
	} else {
		add_property(obj, buf, val, 0);
	}
	return 1;
}
Esempio n. 3
0
dbref
lookup_alias(const char *name, int checkname)
{
    dbref alias;
    PropPtr pptr;

    /* It's important to make sure that an alias lookup based on the name of an
     * existing target never succeeds. This should *only* be possible if an
     * admin manually set the prop on #0 (via @propset or a program), but things
     * can get pretty weird fast if cases of this behavior slip through.
     *
     * Most callers to this function will have already attempted to match the
     * exact target name, and this can be skipped. 'checkname' is used to signal
     * whether or not it's safe to skip this check.
     */
    if (checkname &&
        find_hash(name, player_list, PLAYER_HASH_SIZE) != NULL) {
        return NOTHING;
    }

    sprintf(abuf, ALIASDIR_CUR "%s", name);
    if (*name != '\0' &&
        (pptr = get_property(0, abuf)) &&
        PropType(pptr) == PROP_REFTYP) {
        alias = PropDataRef(pptr);
        if (Typeof(alias) == TYPE_PLAYER) {
            return alias;
        } else {
            /* bogus prop, kill it */
            remove_property(0, abuf); 
        }
    }
    
    return NOTHING;
}
Esempio n. 4
0
int
safeputprop(dbref obj, dbref perms, char *buf, char *val)
{
    char *ptr;
    if (!buf) return 0;
    while (*buf == PROPDIR_DELIMITER) buf++;
    if (!*buf) return 0;
    if (tp_db_readonly) return 0;

    /* disallow CR's and :'s in prop names. */
    for (ptr = buf; *ptr; ptr++)
        if (*ptr == '\r' || *ptr == PROP_DELIMITER) return 0;

    if (!Archperms(perms)) {
        if (Prop_Hidden(buf)) return 0;
    }
    if (!Wizperms(perms)) {
        if (Prop_SeeOnly(buf)) return 0;
    }
    if (!val) {
        remove_property(obj, buf);
    } else {
	add_property(obj, buf, val, 0);
    }
    return 1;
}
Esempio n. 5
0
bool node::set_property_inst(const char *key, property_def::valtype vt,
			     const char *value) {
	properties::iterator k = m_properties.find(key);

	if (k == m_properties.end()) {
		property_def *prop =
			instantiate_property(key, vt, 0,
					     property_def::REMOVABLE);
		if (!prop)
			return false;
		if (!prop->set_value(value)) {
			remove_property(key);
			return false;
		} else {
			propagate_property_changed(this, key);
		}

		return true;
	}

	if (!k->second.is_property() || k->second.is_readonly())
		return false;

	if (k->second.set_value(value)) {
		propagate_property_changed(this, key);
		return true;
	}

	return false;
}
Esempio n. 6
0
void
PortImpl::set_context(Context::ID c)
{
	const Ingen::Shared::LV2URIMap& uris = _bufs.uris();
	_context = c;
	switch (c) {
	case Context::AUDIO:
		remove_property(uris.ctx_context, uris.wildcard);
		break;
	case Context::MESSAGE:
		set_property(uris.ctx_context, uris.ctx_MessageContext);
		break;
	}
}
Esempio n. 7
0
void
clear_alias(dbref target, const char *alias) {
    if (target) {
        rotate_alias(target, 1);
        return;
    }
    if (alias) {
        sprintf(abuf, ALIASDIR_CUR "%s", alias);
        remove_property(0, abuf);
        return;
    }

    /* should not be reached */
    return;
}
Esempio n. 8
0
void
prim_remove_prop(PRIM_PROTOTYPE)
{
	CHECKOP(2);
	oper1 = POP();
	oper2 = POP();
	if (oper1->type != PROG_STRING)
		abort_interp("Non-string argument (2)");
	if (!valid_object(oper2))
		abort_interp("Non-object argument (1)");

	CHECKREMOTE(oper2->data.objref);

	strncpy(buf, DoNullInd(oper1->data.string), BUFFER_LEN);
	buf[BUFFER_LEN - 1] = '\0';

	{
		int	len = strlen(buf);
		char*	ptr = buf + len;

		while((--len >= 0) && (*--ptr == PROPDIR_DELIMITER))
			*ptr = '\0';
	}

	if (!*buf)
		abort_interp("Can't remove root propdir (2)");

	if (!prop_write_perms(ProgUID, oper2->data.objref, buf, mlev))
		abort_interp("Permission denied.");

	remove_property(oper2->data.objref, buf);

#ifdef LOG_PROPS
	log2file("props.log", "#%d (%d) REMOVEPROP: o=%d n=\"%s\"",
		program, pc->line, oper2->data.objref, buf);
#endif

	ts_modifyobject(oper2->data.objref);

	CLEAR(oper1);
	CLEAR(oper2);
}
Esempio n. 9
0
void
do_password(dbref player, const char *old, const char *newobj)
{
    if(Guest(player)) {
        anotify(player, CFAIL NOGUEST_MESG);
        return;
    }

    if ((!DBFETCH(player)->sp.player.password) ||
            (!*DBFETCH(player)->sp.player.password) ||
            strcmp(old, DBFETCH(player)->sp.player.password)
       ) {
        anotify(player, CFAIL "Sorry.");
    } else if (!ok_password(newobj)) {
        anotify(player, CFAIL "Bad new password.");
    } else {
        free((void *) DBFETCH(player)->sp.player.password);
        DBSTORE(player, sp.player.password, alloc_string(newobj));
        ts_modifyobject(player);
        remove_property(player, PROP_PW);
        anotify(player, CSUCC "Password changed.");
    }
}
Esempio n. 10
0
void
remove_proplist_item(dbref player, PropPtr p, int allp)
{
    const char *ptr;

    /* if( tp_db_readonly ) return; *//* Why did we remove this? */

    if (!p)
        return;
    ptr = PropName(p);
    if (!allp) {
        if (Prop_SeeOnly(ptr))
            return;
        if (Prop_Hidden(ptr))
            return;

        if (ptr[0] == '_' && ptr[1] == '\0')
            return;
        if (PropFlags(p) & PROP_SYSPERMS)
            return;
    }
    /* notify(player, ptr); *//* Why did we put this here? */
    remove_property(player, ptr);
}