/*
* user_id.c
*
* Identify all objects with the users that creates/controls them
*
* (C) Frank Schmidt, Jesus@NorseMUD
*
*/
/* user id and effective user id */
private static string uid, euid;
/* get uid and euid of this_object() */
nomask string __getuid() { return uid; }
nomask string __geteuid() { return euid; }
/* set uid of this_object() */
nomask int __setuid(string user) {
/* only let us do this for export_uid-style */
if (AUTO_PRIV() && euid == 0) {
uid = user;
return 1;
}
return 0;
}
/* set euid of this_object() */
nomask int __seteuid(string user) {
string file;
file=object_name(this_object());
/* check if we are allowed to set this euid */
if ((user == DRIVER_UID &&
/* allow DGD-objects to get driver euid */
(file == USER || file == GLOBAL || file == DRIVER)) ||
(file == master() || /* prevent recursion in master object */
/* check master for valid euid */
call_other(master(), __VALID_SETEUID_FUNC, this_object(), user))) {
euid = user;
return 1;
}
return 0;
}
/* define "efun" for getuid(ob) and geteuid(ob) */
static varargs string getuid(object ob) {
if (!ob) return uid;
return ob->__getuid();
}
static varargs string geteuid(object ob) {
if (!ob) return euid;
return ob->__geteuid();
}
#ifdef MUDOS_EXPORT_UID
/* export euid from this_object() to uid of ob */
static varargs int export_uid(object ob) {
if (!ob) return __setuid(euid);
return ob->__setuid(euid);
}
#endif
/* be able to change euid also */
static varargs int seteuid(mixed var1, mixed var2) {
if (!objectp(var1)) return __seteuid(var1);
return var1->__seteuid(var2);
}
#ifndef MUDOS_CREATOR
# ifndef creator
/* creator returns the uid */
static varargs string creator(object ob) {
return getuid(ob);
}
# endif
#endif