Implement issetugid syscall
Implement issetugid syscall and provide a test. This gets rid of the scary "Unsecure. Implement me" warning during compilation.
This commit is contained in:
+17
-3
@@ -81,16 +81,30 @@ PUBLIC int do_exec_newmem()
|
||||
if (r != OK)
|
||||
panic("do_exec_newmem: sys_datacopy failed: %d", r);
|
||||
|
||||
if((r=vm_exec_newmem(proc_e, &args, sizeof(args), &stack_top, &flags)) == OK) {
|
||||
allow_setuid= 0; /* Do not allow setuid execution */
|
||||
if ((r = vm_exec_newmem(proc_e, &args, sizeof(args), &stack_top,
|
||||
&flags)) == OK) {
|
||||
allow_setuid = 0; /* Do not allow setuid execution */
|
||||
rmp->mp_flags &= ~TAINTED; /* By default not tainted */
|
||||
|
||||
if (rmp->mp_tracer == NO_TRACER) {
|
||||
/* Okay, setuid execution is allowed */
|
||||
allow_setuid= 1;
|
||||
allow_setuid = 1;
|
||||
|
||||
rmp->mp_effuid = args.new_uid;
|
||||
rmp->mp_effgid = args.new_gid;
|
||||
}
|
||||
|
||||
/* A process is considered 'tainted' when it's executing with
|
||||
* setuid or setgid bit set, or when the real{u,g}id doesn't
|
||||
* match the eff{u,g}id, respectively. */
|
||||
if (allow_setuid && args.setugid) {
|
||||
/* Program has setuid and/or setgid bits set */
|
||||
rmp->mp_flags |= TAINTED;
|
||||
} else if (rmp->mp_effuid != rmp->mp_realuid ||
|
||||
rmp->mp_effgid != rmp->mp_realgid) {
|
||||
rmp->mp_flags |= TAINTED;
|
||||
}
|
||||
|
||||
/* System will save command line for debugging, ps(1) output, etc. */
|
||||
strncpy(rmp->mp_name, args.progname, PROC_NAME_LEN-1);
|
||||
rmp->mp_name[PROC_NAME_LEN-1] = '\0';
|
||||
|
||||
@@ -103,7 +103,7 @@ PUBLIC int do_fork()
|
||||
}
|
||||
|
||||
/* Inherit only these flags. In normal fork(), PRIV_PROC is not inherited. */
|
||||
rmc->mp_flags &= (IN_USE|DELAY_CALL);
|
||||
rmc->mp_flags &= (IN_USE|DELAY_CALL|TAINTED);
|
||||
rmc->mp_child_utime = 0; /* reset administration */
|
||||
rmc->mp_child_stime = 0; /* reset administration */
|
||||
rmc->mp_exitstatus = 0;
|
||||
|
||||
+6
-1
@@ -18,7 +18,8 @@
|
||||
*===========================================================================*/
|
||||
PUBLIC int do_get()
|
||||
{
|
||||
/* Handle GETUID, GETGID, GETGROUPS, GETGROUPS_O, GETPID, GETPGRP, GETSID.
|
||||
/* Handle GETUID, GETGID, GETGROUPS, GETGROUPS_O, GETPID, GETPGRP, GETSID,
|
||||
ISSETUGID.
|
||||
*/
|
||||
|
||||
register struct mproc *rmp = mp;
|
||||
@@ -103,6 +104,10 @@ PUBLIC int do_get()
|
||||
r = target->mp_procgrp;
|
||||
break;
|
||||
}
|
||||
case ISSETUGID:
|
||||
r = !!(rmp->mp_flags & TAINTED);
|
||||
break;
|
||||
|
||||
default:
|
||||
r = EINVAL;
|
||||
break;
|
||||
|
||||
@@ -91,5 +91,6 @@ EXTERN struct mproc {
|
||||
#define TRACE_EXIT 0x08000 /* tracer is forcing this process to exit */
|
||||
#define TRACE_ZOMBIE 0x10000 /* waiting for tracer to issue WAIT call */
|
||||
#define DELAY_CALL 0x20000 /* waiting for call before sending signal */
|
||||
#define TAINTED 0x40000 /* process is 'tainted' */
|
||||
|
||||
#define MP_MAGIC 0xC0FFEE0
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ _PROTOTYPE (int (*call_vec[]), (void) ) = {
|
||||
do_procstat, /* 103 = procstat */
|
||||
do_getprocnr, /* 104 = getprocnr */
|
||||
no_sys, /* 105 = unused */
|
||||
no_sys, /* 106 = unused */
|
||||
do_get, /* 106 = issetugid */
|
||||
do_getepinfo_o, /* 107 = getepinfo XXX: old implementation*/
|
||||
do_adddma, /* 108 = adddma */
|
||||
do_deldma, /* 109 = deldma */
|
||||
|
||||
Reference in New Issue
Block a user