Dynamic configuration in system.conf for boot system services.
This commit is contained in:
@@ -113,12 +113,13 @@ PUBLIC int main(void)
|
||||
}
|
||||
/* Priviliges for the root system process. */
|
||||
else if(isrootsysn(proc_nr)) {
|
||||
priv(rp)->s_flags= RSYS_F; /* privilege flags */
|
||||
priv(rp)->s_trap_mask= RSYS_T; /* allowed traps */
|
||||
ipc_to_m = RSYS_M; /* allowed targets */
|
||||
kcalls = RSYS_KC; /* allowed kernel calls */
|
||||
priv(rp)->s_sig_mgr = RSYS_SM; /* signal manager */
|
||||
priv(rp)->s_bak_sig_mgr = NONE; /* backup signal manager */
|
||||
priv(rp)->s_flags= RSYS_F; /* privilege flags */
|
||||
priv(rp)->s_trap_mask= SRV_T; /* allowed traps */
|
||||
ipc_to_m = SRV_M; /* allowed targets */
|
||||
kcalls = SRV_KC; /* allowed kernel calls */
|
||||
priv(rp)->s_sig_mgr = SRV_SM; /* signal manager */
|
||||
rp->p_priority = SRV_Q; /* priority queue */
|
||||
rp->p_quantum_size_ms = SRV_QT; /* quantum size */
|
||||
rp->p_priority = SRV_Q; /* priority queue */
|
||||
rp->p_quantum_size_ms = SRV_QT; /* quantum size */
|
||||
}
|
||||
|
||||
@@ -60,11 +60,6 @@ struct priv {
|
||||
/* Guard word for task stacks. */
|
||||
#define STACK_GUARD ((reg_t) (sizeof(reg_t) == 2 ? 0xBEEF : 0xDEADBEEF))
|
||||
|
||||
/* Static privilege id definitions. */
|
||||
#define NR_STATIC_PRIV_IDS NR_BOOT_PROCS
|
||||
#define is_static_priv_id(id) (id >= 0 && id < NR_STATIC_PRIV_IDS)
|
||||
#define static_priv_id(n) (NR_TASKS + (n))
|
||||
|
||||
/* Magic system structure table addresses. */
|
||||
#define BEG_PRIV_ADDR (&priv[0])
|
||||
#define END_PRIV_ADDR (&priv[NR_SYS_PROCS])
|
||||
@@ -82,10 +77,6 @@ struct priv {
|
||||
|
||||
#define may_send_to(rp, nr) (get_sys_bit(priv(rp)->s_ipc_to, nr_to_id(nr)))
|
||||
|
||||
/* Privilege management shorthands. */
|
||||
#define spi_to(n) (1 << (static_priv_id(n)))
|
||||
#define unset_usr_to(m) ((m) & ~(1 << USER_PRIV_ID))
|
||||
|
||||
/* The system structures table and pointers to individual table slots. The
|
||||
* pointers allow faster access because now a process entry can be found by
|
||||
* indexing the psys_addr array, while accessing an element i requires a
|
||||
@@ -94,15 +85,6 @@ struct priv {
|
||||
EXTERN struct priv priv[NR_SYS_PROCS]; /* system properties table */
|
||||
EXTERN struct priv *ppriv_addr[NR_SYS_PROCS]; /* direct slot pointers */
|
||||
|
||||
/* Unprivileged user processes all share the privilege structure of the
|
||||
* root user process.
|
||||
* This id must be fixed because it is used to check send mask entries.
|
||||
*/
|
||||
#define USER_PRIV_ID static_priv_id(ROOT_USR_PROC_NR)
|
||||
/* Specifies a null privilege id.
|
||||
*/
|
||||
#define NULL_PRIV_ID (-1)
|
||||
|
||||
/* Make sure the system can boot. The following sanity check verifies that
|
||||
* the system privileges table is large enough for the number of processes
|
||||
* in the boot image.
|
||||
@@ -111,41 +93,4 @@ EXTERN struct priv *ppriv_addr[NR_SYS_PROCS]; /* direct slot pointers */
|
||||
#error NR_SYS_PROCS must be larger than NR_BOOT_PROCS
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Privileges masks used by the kernel.
|
||||
*/
|
||||
#define IDL_F (SYS_PROC | BILLABLE) /* idle task is not preemptible as we
|
||||
* don't want it to interfere with the
|
||||
* timer tick interrupt handler code.
|
||||
* Unlike other processes idle task is
|
||||
* handled in a special way and is
|
||||
* preempted always if timer tick occurs
|
||||
* and there is another runnable process
|
||||
*/
|
||||
#define TSK_F (SYS_PROC) /* other kernel tasks */
|
||||
#define RSYS_F (SYS_PROC | PREEMPTIBLE | ROOT_SYS_PROC) /* root sys proc */
|
||||
#define DEF_SYS_F (RSYS_F | DYN_PRIV_ID) /* default sys proc */
|
||||
|
||||
/* allowed traps */
|
||||
#define CSK_T (1 << RECEIVE) /* clock and system */
|
||||
#define TSK_T 0 /* other kernel tasks */
|
||||
#define RSYS_T (~0) /* root system proc */
|
||||
#define DEF_SYS_T RSYS_T /* default sys proc */
|
||||
|
||||
/* allowed targets */
|
||||
#define TSK_M 0 /* all kernel tasks */
|
||||
#define RSYS_M (~0) /* root system proc */
|
||||
#define DEF_SYS_M unset_usr_to(RSYS_M) /* default sys proc */
|
||||
|
||||
/* allowed kernel calls */
|
||||
#define NO_C 0 /* no calls allowed */
|
||||
#define ALL_C 1 /* all calls allowed */
|
||||
#define TSK_KC NO_C /* all kernel tasks */
|
||||
#define RSYS_KC ALL_C /* root system proc */
|
||||
#define DEF_SYS_KC RSYS_KC /* default sys proc */
|
||||
|
||||
/* signal manager */
|
||||
#define RSYS_SM SELF /* root system proc */
|
||||
#define DEF_SYS_SM ROOT_SYS_PROC_NR /* default sys proc */
|
||||
|
||||
#endif /* PRIV_H */
|
||||
|
||||
@@ -117,17 +117,17 @@ PUBLIC int do_privctl(struct proc * caller, message * m_ptr)
|
||||
priv(rp)->s_asynsize= 0;
|
||||
|
||||
/* Set defaults for privilege bitmaps. */
|
||||
priv(rp)->s_flags= DEF_SYS_F; /* privilege flags */
|
||||
priv(rp)->s_trap_mask= DEF_SYS_T; /* allowed traps */
|
||||
ipc_to_m = DEF_SYS_M; /* allowed targets */
|
||||
priv(rp)->s_flags= DSRV_F; /* privilege flags */
|
||||
priv(rp)->s_trap_mask= DSRV_T; /* allowed traps */
|
||||
ipc_to_m = DSRV_M; /* allowed targets */
|
||||
fill_sendto_mask(rp, ipc_to_m);
|
||||
kcalls = DEF_SYS_KC; /* allowed kernel calls */
|
||||
kcalls = DSRV_KC; /* allowed kernel calls */
|
||||
for(i = 0; i < SYS_CALL_MASK_SIZE; i++) {
|
||||
priv(rp)->s_k_call_mask[i] = (kcalls == NO_C ? 0 : (~0));
|
||||
}
|
||||
|
||||
/* Set the default signal managers. */
|
||||
priv(rp)->s_sig_mgr = DEF_SYS_SM;
|
||||
priv(rp)->s_sig_mgr = DSRV_SM;
|
||||
priv(rp)->s_bak_sig_mgr = NONE;
|
||||
|
||||
/* Set defaults for resources: no I/O resources, no memory resources,
|
||||
@@ -354,9 +354,25 @@ PRIVATE int update_priv(struct proc *rp, struct priv *priv)
|
||||
priv(rp)->s_trap_mask = priv->s_trap_mask;
|
||||
|
||||
/* Copy target mask. */
|
||||
#if PRIV_DEBUG
|
||||
printf("do_privctl: Setting ipc target mask for %d:");
|
||||
for (i=0; i < NR_SYS_PROCS; i += BITCHUNK_BITS) {
|
||||
printf(" %04x", get_sys_bits(priv->s_ipc_to, i));
|
||||
}
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
memcpy(&ipc_to_m, &priv->s_ipc_to, sizeof(ipc_to_m));
|
||||
fill_sendto_mask(rp, ipc_to_m);
|
||||
|
||||
#if PRIV_DEBUG
|
||||
printf("do_privctl: Set ipc target mask for %d:");
|
||||
for (i=0; i < NR_SYS_PROCS; i += BITCHUNK_BITS) {
|
||||
printf(" %04x", get_sys_bits(priv(rp)->s_ipc_to, i));
|
||||
}
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
/* Copy kernel call mask. */
|
||||
memcpy(priv(rp)->s_k_call_mask, priv->s_k_call_mask,
|
||||
sizeof(priv(rp)->s_k_call_mask));
|
||||
|
||||
Reference in New Issue
Block a user