From: Ben Gras Date: Tue, 13 Dec 2005 09:48:29 +0000 (+0000) Subject: seteuid() and setegid() X-Git-Tag: v3.1.2a~473 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/expt.png?a=commitdiff_plain;h=f6e50525979293235ac00c7e5c02e2af4183fc99;p=minix.git seteuid() and setegid() --- diff --git a/commands/simple/df.c b/commands/simple/df.c index ef290c2cc..f1d69e031 100755 --- a/commands/simple/df.c +++ b/commands/simple/df.c @@ -40,9 +40,6 @@ #define v12_super_block super_block #define SUPER_V1 SUPER_MAGIC -/* Only setuid() and setgid(). */ -#define seteuid(uid) setuid(uid) -#define setegid(gid) setgid(gid) #endif #define ISDISK(mode) S_ISBLK(mode) /* || S_ISCHR for raw device??? */ diff --git a/include/minix/callnr.h b/include/minix/callnr.h index cb9891b69..29dbff2d2 100755 --- a/include/minix/callnr.h +++ b/include/minix/callnr.h @@ -1,4 +1,4 @@ -#define NCALLS 91 /* number of system calls allowed */ +#define NCALLS 93 /* number of system calls allowed */ #define EXIT 1 #define FORK 2 @@ -82,3 +82,5 @@ #define GETPRIORITY 88 /* to PM */ #define SETPRIORITY 89 /* to PM */ #define GETTIMEOFDAY 90 /* to PM */ +#define SETEUID 91 /* to PM (and PM -> FS) */ +#define SETEGID 92 /* to PM (and PM -> FS) */ diff --git a/include/unistd.h b/include/unistd.h index c45f94500..2b8d45150 100755 --- a/include/unistd.h +++ b/include/unistd.h @@ -124,9 +124,11 @@ _PROTOTYPE( int pipe, (int _fildes[2]) ); _PROTOTYPE( ssize_t read, (int _fd, void *_buf, size_t _n) ); _PROTOTYPE( int rmdir, (const char *_path) ); _PROTOTYPE( int setgid, (_mnx_Gid_t _gid) ); +_PROTOTYPE( int setegid, (_mnx_Gid_t _gid) ); _PROTOTYPE( int setpgid, (pid_t _pid, pid_t _pgid) ); _PROTOTYPE( pid_t setsid, (void) ); _PROTOTYPE( int setuid, (_mnx_Uid_t _uid) ); +_PROTOTYPE( int seteuid, (_mnx_Uid_t _uid) ); _PROTOTYPE( unsigned int sleep, (unsigned int _seconds) ); _PROTOTYPE( long sysconf, (int _name) ); _PROTOTYPE( pid_t tcgetpgrp, (int _fd) ); diff --git a/lib/posix/_setgid.c b/lib/posix/_setgid.c index 8c12f2f60..66270ad15 100755 --- a/lib/posix/_setgid.c +++ b/lib/posix/_setgid.c @@ -1,5 +1,6 @@ #include #define setgid _setgid +#define setegid _setegid #include PUBLIC int setgid(grp) @@ -10,3 +11,12 @@ gid_t grp; m.m1_i1 = (int) grp; return(_syscall(MM, SETGID, &m)); } + +PUBLIC int setegid(grp) +gid_t grp; +{ + message m; + + m.m1_i1 = (int) grp; + return(_syscall(MM, SETEGID, &m)); +} diff --git a/lib/posix/_setuid.c b/lib/posix/_setuid.c index 3dd3c70fb..5eb9b9be9 100755 --- a/lib/posix/_setuid.c +++ b/lib/posix/_setuid.c @@ -1,5 +1,6 @@ #include #define setuid _setuid +#define seteuid _seteuid #include PUBLIC int setuid(usr) @@ -10,3 +11,12 @@ _mnx_Uid_t usr; m.m1_i1 = usr; return(_syscall(MM, SETUID, &m)); } + +PUBLIC int seteuid(usr) +_mnx_Uid_t usr; +{ + message m; + + m.m1_i1 = usr; + return(_syscall(MM, SETEUID, &m)); +} diff --git a/lib/syscall/setgid.s b/lib/syscall/setgid.s index 12aa77755..03c76ec8f 100755 --- a/lib/syscall/setgid.s +++ b/lib/syscall/setgid.s @@ -1,7 +1,11 @@ .sect .text .extern __setgid .define _setgid +.define _setegid .align 2 _setgid: jmp __setgid + +_setegid: + jmp __setegid diff --git a/lib/syscall/setuid.s b/lib/syscall/setuid.s index 85e87c36a..fb5549f90 100755 --- a/lib/syscall/setuid.s +++ b/lib/syscall/setuid.s @@ -1,7 +1,11 @@ .sect .text .extern __setuid .define _setuid +.define _seteuid .align 2 _setuid: jmp __setuid + +_seteuid: + jmp __seteuid diff --git a/servers/fs/table.c b/servers/fs/table.c index 41dda3c7a..538128bf2 100644 --- a/servers/fs/table.c +++ b/servers/fs/table.c @@ -108,6 +108,8 @@ PUBLIC _PROTOTYPE (int (*call_vec[]), (void) ) = { no_sys, /* 88 = getpriority */ no_sys, /* 89 = setpriority */ no_sys, /* 90 = gettimeofday */ + no_sys, /* 91 = seteuid */ + no_sys, /* 92 = setegid */ }; /* This should not fail with "array size is negative": */ extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1]; diff --git a/servers/pm/getset.c b/servers/pm/getset.c index 20810574b..d59bdb78d 100644 --- a/servers/pm/getset.c +++ b/servers/pm/getset.c @@ -42,21 +42,23 @@ PUBLIC int do_getset() rmp->mp_reply.reply_res3 = mproc[m_in.procnr].mp_pid; break; + case SETEUID: case SETUID: if (rmp->mp_realuid != (uid_t) m_in.usr_id && rmp->mp_effuid != SUPER_USER) return(EPERM); - rmp->mp_realuid = (uid_t) m_in.usr_id; + if(call_nr == SETUID) rmp->mp_realuid = (uid_t) m_in.usr_id; rmp->mp_effuid = (uid_t) m_in.usr_id; tell_fs(SETUID, who, rmp->mp_realuid, rmp->mp_effuid); r = OK; break; + case SETEGID: case SETGID: if (rmp->mp_realgid != (gid_t) m_in.grp_id && rmp->mp_effuid != SUPER_USER) return(EPERM); - rmp->mp_realgid = (gid_t) m_in.grp_id; + if(call_nr == SETGID) rmp->mp_realgid = (gid_t) m_in.grp_id; rmp->mp_effgid = (gid_t) m_in.grp_id; tell_fs(SETGID, who, rmp->mp_realgid, rmp->mp_effgid); r = OK; diff --git a/servers/pm/table.c b/servers/pm/table.c index 6b0aeafdc..53e9630eb 100644 --- a/servers/pm/table.c +++ b/servers/pm/table.c @@ -107,6 +107,8 @@ _PROTOTYPE (int (*call_vec[NCALLS]), (void) ) = { do_getsetpriority, /* 88 = getpriority */ do_getsetpriority, /* 89 = setpriority */ do_time, /* 90 = gettimeofday */ + do_getset, /* 91 = seteuid */ + do_getset /* 92 = setegid */ }; /* This should not fail with "array size is negative": */ extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];