diff options
author | Sergey Bugaev <bugaevc@gmail.com> | 2021-05-29 18:08:52 +0300 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2022-08-10 22:15:31 +0200 |
commit | 2e3a1e0f028ae5498d96a4a3618a3533e062d2eb (patch) | |
tree | 9db11a0c0e5743069106e83bd2a9d3639dd40e38 | |
parent | ffead1cbcaa1db5db525403043e27d618af8752b (diff) | |
download | hurd-2e3a1e0f028ae5498d96a4a3618a3533e062d2eb.tar.gz hurd-2e3a1e0f028ae5498d96a4a3618a3533e062d2eb.tar.bz2 hurd-2e3a1e0f028ae5498d96a4a3618a3533e062d2eb.zip |
Remove the concept of process owner
Now that it's completely unused.
procinfo.owner is now simply set to the first UID that a process has.
proc_setowner () is kept for compatibility, but now does nothing.
The clients still try to call it, though, for compatibility with older
proc server versions.
-rw-r--r-- | hurd/process.defs | 4 | ||||
-rw-r--r-- | hurd/process_reply.defs | 2 | ||||
-rw-r--r-- | hurd/process_request.defs | 8 | ||||
-rw-r--r-- | libfshelp/exec-reauth.c | 9 | ||||
-rw-r--r-- | libfshelp/start-translator-long.c | 12 | ||||
-rw-r--r-- | proc/info.c | 7 | ||||
-rw-r--r-- | proc/mgt.c | 27 | ||||
-rw-r--r-- | proc/proc.h | 2 | ||||
-rw-r--r-- | utils/login.c | 1 |
9 files changed, 28 insertions, 44 deletions
diff --git a/hurd/process.defs b/hurd/process.defs index 83bf6561..416ec30f 100644 --- a/hurd/process.defs +++ b/hurd/process.defs @@ -122,9 +122,7 @@ routine proc_reassign ( process: process_t; newtask: task_t); -/* Set the owner of the process. The new owner must be within the - current authentication of the caller. If CLEAR is set, then ignore - OWNER and restore the process to unowned status. */ +/* Deprecated; definition kept for compatibility. */ routine proc_setowner ( process: process_t; owner: uid_t; diff --git a/hurd/process_reply.defs b/hurd/process_reply.defs index e37db425..4775c7c6 100644 --- a/hurd/process_reply.defs +++ b/hurd/process_reply.defs @@ -43,7 +43,7 @@ simpleroutine proc_setmsgport_reply ( in oldmsgport: mach_port_t); skip; /* reassign */ -skip; /* setowner */ +skip; /* was setowner */ skip; /* getpids */ skip; /* set_arg_locations */ skip; /* get_arg_locations */ diff --git a/hurd/process_request.defs b/hurd/process_request.defs index 882e8366..295a05bb 100644 --- a/hurd/process_request.defs +++ b/hurd/process_request.defs @@ -124,13 +124,7 @@ simpleroutine proc_reassign_request ( ureplyport reply: reply_port_t; newtask: task_t); -/* Set the owner of the process. The new owner must be within the - current authentication of the caller. */ -simpleroutine proc_setowner_request ( - process: process_t; - ureplyport reply: reply_port_t; - owner: uid_t; - clear: int); +skip; /* Was proc_setowner */ /* Get the process ID and the parent process ID, also find out if we are orphaned. */ diff --git a/libfshelp/exec-reauth.c b/libfshelp/exec-reauth.c index 9b6087c7..7b87d576 100644 --- a/libfshelp/exec-reauth.c +++ b/libfshelp/exec-reauth.c @@ -131,9 +131,12 @@ fshelp_exec_reauth (int suid, uid_t uid, int sgid, gid_t gid, /* Re-authenticate the exec parameters. */ exec_reauth (newauth, _secure, 0, ports, num_ports, fds, num_fds); - proc_setowner (ports[INIT_PORT_PROC], - eff_uids->num > 0 ? eff_uids->ids[0] : 0, - !eff_uids->num); + /* Try proc_setowner () for compatibility with older proc server. */ + err = proc_setowner (ports[INIT_PORT_PROC], + eff_uids->num > 0 ? eff_uids->ids[0] : 0, + !eff_uids->num); + if (err == EOPNOTSUPP) + err = 0; abandon_suid: if (eff_uids) diff --git a/libfshelp/start-translator-long.c b/libfshelp/start-translator-long.c index af893ba2..1bbf310a 100644 --- a/libfshelp/start-translator-long.c +++ b/libfshelp/start-translator-long.c @@ -267,9 +267,15 @@ fshelp_start_translator_long (fshelp_open_fn_t underlying_open_fn, proc_child (proc, task); err = proc_task2proc (proc, task, &ports[INIT_PORT_PROC]); if (!err) - err = proc_setowner (ports[INIT_PORT_PROC], - owner_uid, - owner_uid == (uid_t) -1); + { + /* Try proc_setowner () for compatibility with + older proc server. */ + err = proc_setowner (ports[INIT_PORT_PROC], + owner_uid, + owner_uid == (uid_t) -1); + if (err == EOPNOTSUPP) + err = 0; + } if (deallocate_proc) mach_port_deallocate (mach_task_self (), proc); if (err) diff --git a/proc/info.c b/proc/info.c index ab74fb39..c2d7ad67 100644 --- a/proc/info.c +++ b/proc/info.c @@ -500,6 +500,7 @@ S_proc_getprocinfo (struct proc *callerp, struct proc *tp; task_t task; /* P's task port. */ mach_port_t msgport; /* P's msgport, or MACH_PORT_NULL if none. */ + int owned; /* No need to check CALLERP here; we don't use it. */ @@ -624,6 +625,8 @@ S_proc_getprocinfo (struct proc *callerp, *piarraylen = structsize / sizeof (int); pi = (struct procinfo *) *piarray; + owned = p->p_id && p->p_id->i_nuids; + pi->state = ((p->p_stopped ? PI_STOPPED : 0) | (p->p_exec ? PI_EXECED : 0) @@ -631,12 +634,12 @@ S_proc_getprocinfo (struct proc *callerp, | (!p->p_pgrp->pg_orphcnt ? PI_ORPHAN : 0) | (p->p_msgport == MACH_PORT_NULL ? PI_NOMSG : 0) | (p->p_pgrp->pg_session->s_sid == p->p_pid ? PI_SESSLD : 0) - | (p->p_noowner ? PI_NOTOWNED : 0) + | (owned ? 0 : PI_NOTOWNED) | (!p->p_parentset ? PI_NOPARENT : 0) | (p->p_traced ? PI_TRACED : 0) | (p->p_msgportwait ? PI_GETMSG : 0) | (p->p_loginleader ? PI_LOGINLD : 0)); - pi->owner = p->p_owner; + pi->owner = owned ? p->p_id->i_uids[0] : 0; pi->ppid = p->p_parent->p_pid; pi->pgrp = p->p_pgrp->pg_pgid; pi->session = p->p_pgrp->pg_session->s_sid; @@ -186,9 +186,6 @@ S_proc_child (struct proc *parentp, childp->p_login = parentp->p_login; childp->p_login->l_refcnt++; - childp->p_owner = parentp->p_owner; - childp->p_noowner = parentp->p_noowner; - ids_rele (childp->p_id); ids_ref (parentp->p_id); childp->p_id = parentp->p_id; @@ -432,27 +429,13 @@ S_proc_reauthenticate_reassign (struct proc *p, return err; } -/* Implement proc_setowner as described in <hurd/process.defs>. */ kern_return_t S_proc_setowner (struct proc *p, - uid_t owner, - int clear) + uid_t owner, + int clear) { - if (!p) - return EOPNOTSUPP; - - if (clear) - p->p_noowner = 1; - else - { - if (! check_uid (p, owner)) - return EPERM; - - p->p_owner = owner; - p->p_noowner = 0; - } - - return 0; + /* No longer does anything, kept for compatibility. */ + return EOPNOTSUPP; } /* Implement proc_getpids as described in <hurd/process.defs>. */ @@ -859,8 +842,6 @@ complete_proc (struct proc *p, pid_t pid) p->p_ochild = 0; p->p_parentset = 0; - p->p_noowner = 1; - p->p_pgrp = init_proc->p_pgrp; /* At this point, we do not know the task of the startup process, diff --git a/proc/proc.h b/proc/proc.h index cafcfaff..a83a5090 100644 --- a/proc/proc.h +++ b/proc/proc.h @@ -44,7 +44,6 @@ struct proc task_t p_task; pid_t p_pid; struct login *p_login; - uid_t p_owner; struct ids *p_id; /* Process hierarchy */ @@ -90,7 +89,6 @@ struct proc unsigned int p_deadmsg:1; /* hang on requests for a message port */ unsigned int p_checkmsghangs:1; /* someone is currently hanging on us */ unsigned int p_msgportwait:1; /* blocked in getmsgport */ - unsigned int p_noowner:1; /* has no owner known */ unsigned int p_loginleader:1; /* leader of login collection */ unsigned int p_dead:1; /* process is dead */ unsigned int p_important:1; /* has called proc_mark_important */ diff --git a/utils/login.c b/utils/login.c index 506fdaf2..5fd5afc7 100644 --- a/utils/login.c +++ b/utils/login.c @@ -682,6 +682,7 @@ main(int argc, char *argv[]) } } + /* Try proc_setowner () for compatibility with older proc server. */ if (ugids.eff_uids.num > 0) proc_setowner (proc_server, ugids.eff_uids.ids[0], 0); else |