Ejemplo n.º 1
0
const afs_ucred_t *
afs_osi_proc2cred(afs_proc_t * pr)
{
	afs_ucred_t *rv = NULL;
	static afs_ucred_t cr;

	if (pr == NULL) {
		return NULL;
	}

	if ((pr->state == TASK_RUNNING) || (pr->state == TASK_INTERRUPTIBLE)
		|| (pr->state == TASK_UNINTERRUPTIBLE)
		|| (pr->state == TASK_STOPPED)) {

		/* This is dangerous. If anyone ever crfree's the cred that's
		* returned from here, we'll go boom, because it's statically
		* allocated. */

		cr.cr_ref = 1;
		afs_set_cr_uid(&cr, task_uid(pr));

		cr.cr_ngroups = pr->ngroups;
		memcpy(cr.cr_groups, pr->groups, NGROUPS * sizeof(gid_t));

		rv = &cr;
	}

	return rv;
}
Ejemplo n.º 2
0
const afs_ucred_t *
afs_osi_proc2cred(afs_proc_t * pr)
{
    afs_ucred_t *rv = NULL;
    static afs_ucred_t cr;

    if (pr == NULL) {
	return NULL;
    }

    if ((pr->state == TASK_RUNNING) || (pr->state == TASK_INTERRUPTIBLE)
	|| (pr->state == TASK_UNINTERRUPTIBLE)
	|| (pr->state == TASK_STOPPED)) {
	/* This is dangerous. If anyone ever crfree's the cred that's
	 * returned from here, we'll go boom, because it's statically
	 * allocated. */
	atomic_set(&cr.cr_ref, 1);
	afs_set_cr_uid(&cr, task_uid(pr));
#if defined(AFS_LINUX26_ENV)
#if defined(STRUCT_TASK_STRUCT_HAS_CRED)
	get_group_info(pr->cred->group_info);
	set_cr_group_info(&cr, pr->cred->group_info);
#else
	get_group_info(pr->group_info);
	set_cr_group_info(&cr, pr->group_info);
#endif
#else
	cr.cr_ngroups = pr->ngroups;
	memcpy(cr.cr_groups, pr->groups, NGROUPS * sizeof(gid_t));
#endif
	rv = &cr;
    }

    return rv;
}
Ejemplo n.º 3
0
/* Copy one credential structure to another, being careful about references */
static inline void
afs_copy_creds(cred_t *to_cred, const cred_t *from_cred) {
    afs_set_cr_uid(to_cred, afs_cr_uid(from_cred));
    afs_set_cr_gid(to_cred, afs_cr_gid(from_cred));
    afs_set_cr_ruid(to_cred, afs_cr_ruid(from_cred));
    afs_set_cr_rgid(to_cred, afs_cr_rgid(from_cred));
    get_group_info(afs_cr_group_info(from_cred));
    afs_set_cr_group_info(to_cred, afs_cr_group_info(from_cred));
}
Ejemplo n.º 4
0
/* Return a duplicate of the cred. */
cred_t *
crdup(cred_t * cr)
{
    cred_t *tmp = crget();
#if defined(STRUCT_TASK_STRUCT_HAS_CRED)
    afs_copy_creds(tmp, cr);
#else
    afs_set_cr_uid(tmp, afs_cr_uid(cr));
    afs_set_cr_ruid(tmp, afs_cr_ruid(cr));
    afs_set_cr_gid(tmp, afs_cr_gid(cr));
    afs_set_cr_rgid(tmp, afs_cr_rgid(cr));

    get_group_info(afs_cr_group_info(cr));
    afs_set_cr_group_info(tmp, afs_cr_group_info(cr));
#endif
    return tmp;
}
Ejemplo n.º 5
0
cred_t *
crref(void)
{
#if defined(STRUCT_TASK_STRUCT_HAS_CRED)
    return (cred_t *)get_current_cred();
#else
    cred_t *cr = crget();

    afs_set_cr_uid(cr, current_fsuid());
    afs_set_cr_ruid(cr, current_uid());
    afs_set_cr_gid(cr, current_fsgid());
    afs_set_cr_rgid(cr, current_gid());

    task_lock(current);
    get_group_info(current_group_info());
    afs_set_cr_group_info(cr, current_group_info());
    task_unlock(current);

    return cr;
#endif
}