blob: 1318b8d44a1dcf7986ecee24e26f91eccdfb6be9 [file] [log] [blame]
Zesstra7b2fbe72017-06-17 19:05:06 +02001/* This sefun is to provide a replacement for the efun seteuid().
2 * Feel free to add it to your mudlibs, if you have much code relying on that.
3 */
4
5#if ! __EFUN_DEFINED__(seteuid)
6
7#include <configuration.h>
8
9int seteuid(string str)
10{
Zesstraddddbf72021-05-14 16:52:16 +020011 object|lwobject ob = efun::previous_object();
12 if(objectp(ob))
Zesstra7b2fbe72017-06-17 19:05:06 +020013 {
Zesstraddddbf72021-05-14 16:52:16 +020014 if (!str)
15 {
16 efun::configure_object(ob, OC_EUID, 0);
17 return 1;
18 }
19
20 if (efun::call_direct(__MASTER_OBJECT__, "valid_seteuid", ob, str) != 1)
21 return 0;
22
23 efun::configure_object(ob, OC_EUID, str);
Zesstra7b2fbe72017-06-17 19:05:06 +020024 return 1;
25 }
Zesstraddddbf72021-05-14 16:52:16 +020026 else if (lwobjectp(ob))
27 {
28 if (!str)
29 {
30 efun::configure_lwobject(ob, LC_EUID, 0);
31 return 1;
32 }
Zesstra7b2fbe72017-06-17 19:05:06 +020033
Zesstraddddbf72021-05-14 16:52:16 +020034 if (efun::call_direct(__MASTER_OBJECT__, "privilege_violation",
35 "configure_lwobject", ob, ob, LC_EUID, str) != 1)
36 return 0;
Zesstra7b2fbe72017-06-17 19:05:06 +020037
Zesstraddddbf72021-05-14 16:52:16 +020038 efun::configure_lwobject(ob, LC_EUID, str);
39 return 1;
40
41 }
42 return 0;
Zesstra7b2fbe72017-06-17 19:05:06 +020043}
44
45#endif