Message type for PM_GROUPS

Change-Id: I9e3b784143dd0294a8aad27e3cc588e5b57dabfc
This commit is contained in:
Lionel Sambuc 2014-05-13 14:14:49 +02:00
parent 865f761364
commit c3629bba0b
5 changed files with 18 additions and 14 deletions

View file

@ -103,10 +103,6 @@
/* Field names for the setsid(2) call. */ /* Field names for the setsid(2) call. */
#define PM_GETSID_PID m1_i1 /* pid_t */ #define PM_GETSID_PID m1_i1 /* pid_t */
/* Field names for the setgroups(2)/setgroups(2) calls. */
#define PM_GROUPS_NUM m1_i1 /* int */
#define PM_GROUPS_PTR m1_p1 /* gid_t * */
/* Field names for the getmcontext(2)/setmcontext(2) calls. */ /* Field names for the getmcontext(2)/setmcontext(2) calls. */
#define PM_MCONTEXT_CTX m1_p1 /* mcontext_t * */ #define PM_MCONTEXT_CTX m1_p1 /* mcontext_t * */

View file

@ -145,6 +145,14 @@ typedef struct {
} mess_sigcalls; } mess_sigcalls;
_ASSERT_MSG_SIZE(mess_sigcalls); _ASSERT_MSG_SIZE(mess_sigcalls);
typedef struct {
int num;
vir_bytes ptr; /* gid_t * */
uint8_t padding[48];
} mess_lc_pm_groups;
_ASSERT_MSG_SIZE(mess_lc_pm_groups);
typedef struct { typedef struct {
int which; int which;
vir_bytes value; /* const struct itimerval * */ vir_bytes value; /* const struct itimerval * */
@ -1000,6 +1008,7 @@ typedef struct {
mess_fs_vfs_readsuper m_fs_vfs_readsuper; mess_fs_vfs_readsuper m_fs_vfs_readsuper;
mess_fs_vfs_readwrite m_fs_vfs_readwrite; mess_fs_vfs_readwrite m_fs_vfs_readwrite;
mess_lc_pm_groups m_lc_pm_groups;
mess_lc_pm_itimer m_lc_pm_itimer; mess_lc_pm_itimer m_lc_pm_itimer;
mess_lc_pm_priority m_lc_pm_priority; mess_lc_pm_priority m_lc_pm_priority;
mess_lc_pm_ptrace m_lc_pm_ptrace; mess_lc_pm_ptrace m_lc_pm_ptrace;

View file

@ -14,8 +14,8 @@ int getgroups(int ngroups, gid_t *arr)
message m; message m;
memset(&m, 0, sizeof(m)); memset(&m, 0, sizeof(m));
m.PM_GROUPS_NUM = ngroups; m.m_lc_pm_groups.num = ngroups;
m.PM_GROUPS_PTR = (char *) arr; m.m_lc_pm_groups.ptr = (vir_bytes)arr;
return(_syscall(PM_PROC_NR, PM_GETGROUPS, &m)); return(_syscall(PM_PROC_NR, PM_GETGROUPS, &m));
} }

View file

@ -10,8 +10,8 @@ int setgroups(int ngroups, const gid_t *gidset)
message m; message m;
memset(&m, 0, sizeof(m)); memset(&m, 0, sizeof(m));
m.PM_GROUPS_PTR = (char *) __UNCONST(gidset); m.m_lc_pm_groups.ptr = (vir_bytes)gidset;
m.PM_GROUPS_NUM = ngroups; m.m_lc_pm_groups.num = ngroups;
return(_syscall(PM_PROC_NR, PM_SETGROUPS, &m)); return(_syscall(PM_PROC_NR, PM_SETGROUPS, &m));
} }

View file

@ -26,7 +26,7 @@ int do_get()
switch(call_nr) { switch(call_nr) {
case PM_GETGROUPS: case PM_GETGROUPS:
ngroups = m_in.PM_GROUPS_NUM; ngroups = m_in.m_lc_pm_groups.num;
if (ngroups > NGROUPS_MAX || ngroups < 0) if (ngroups > NGROUPS_MAX || ngroups < 0)
return(EINVAL); return(EINVAL);
@ -40,8 +40,7 @@ int do_get()
return(EINVAL); return(EINVAL);
r = sys_datacopy(SELF, (vir_bytes) rmp->mp_sgroups, who_e, r = sys_datacopy(SELF, (vir_bytes) rmp->mp_sgroups, who_e,
(vir_bytes) m_in.PM_GROUPS_PTR, m_in.m_lc_pm_groups.ptr, ngroups * sizeof(gid_t));
ngroups * sizeof(gid_t));
if (r != OK) if (r != OK)
return(r); return(r);
@ -140,15 +139,15 @@ int do_set()
if (rmp->mp_effuid != SUPER_USER) if (rmp->mp_effuid != SUPER_USER)
return(EPERM); return(EPERM);
ngroups = m_in.PM_GROUPS_NUM; ngroups = m_in.m_lc_pm_groups.num;
if (ngroups > NGROUPS_MAX || ngroups < 0) if (ngroups > NGROUPS_MAX || ngroups < 0)
return(EINVAL); return(EINVAL);
if (ngroups > 0 && m_in.PM_GROUPS_PTR == NULL) if (ngroups > 0 && m_in.m_lc_pm_groups.ptr == 0)
return(EFAULT); return(EFAULT);
r = sys_datacopy(who_e, (vir_bytes) m_in.PM_GROUPS_PTR, SELF, r = sys_datacopy(who_e, m_in.m_lc_pm_groups.ptr, SELF,
(vir_bytes) rmp->mp_sgroups, (vir_bytes) rmp->mp_sgroups,
ngroups * sizeof(gid_t)); ngroups * sizeof(gid_t));
if (r != OK) if (r != OK)