uid.c

MudOSa4DGD/mudlib/dgd/lib/sys/efun/uid.c · 1.8 KB

From the archive MudOSa4DGD-30.06.98.tar.gz

Download the archive   « Back to the archive contents

/*
 * 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 id) {
  /* only let us do this for export_uid-style */
  if (AUTO_PRIV() && __euid == 0) {
    __uid = id;
    return 1;
  }
  return 0;
}

/* set euid of this_object() */
nomask int __seteuid(string id) {
  string file;
  file=object_name(this_object());
  /* check if we are allowed to set this euid */
  if ((id == 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(), id))) {
    __euid = id;
    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

Site Stats

Snippets: 1791
Codebases: 571