コード例 #1
0
ファイル: nscd_door.c プロジェクト: AlainODea/illumos-gate
nss_status_t
_nscd_doorcall_sendfd(int fd, int callnum, void *indata, int indlen,
	nss_pheader_t *phdr)
{
	void		*uptr;
	void		*dptr;
	void		*datap;
	size_t		ndata;
	size_t		adata;
	size_t		buflen;
	nss_pheader_t	*phdr_d;
	door_desc_t	desc;
	char		*me = "_nscd_doorcall_sendfd";

	_NSCD_LOG(NSCD_LOG_FRONT_END, NSCD_LOG_LEVEL_DEBUG)
	(me, "processing door call %d (fd = %d)...\n", callnum, fd);

	/* allocate door buffer from the stack */
	NSCD_ALLOC_DOORBUF(callnum, indlen, uptr, buflen);
	dptr = uptr;
	ndata = buflen;
	adata = buflen;
	datap = NSCD_N2N_DOOR_DATA(void, dptr);
	if (indata != NULL)
		(void) memmove(datap, indata, indlen);
	desc.d_attributes = DOOR_DESCRIPTOR;
	desc.d_data.d_desc.d_descriptor = fd;

	send_doorfd(&dptr, &ndata, &adata, &desc);

	phdr_d = (nss_pheader_t *)dptr;
	if (NSCD_STATUS_IS_NOT_OK(phdr_d)) {
		if (phdr != NULL)
			*phdr = *phdr_d;

		_NSCD_LOG(NSCD_LOG_FRONT_END, NSCD_LOG_LEVEL_DEBUG)
		(me, "door call (%d) failed (status = %d, error = %s)\n",
		    callnum, NSCD_GET_STATUS(phdr_d),
		    strerror(NSCD_GET_ERRNO(phdr_d)));
	}

	return (NSCD_GET_STATUS(phdr_d));
}
コード例 #2
0
static void
if_selfcred_return_per_user_door(char *argp, size_t arg_size,
	door_desc_t *dp, int whoami)
{
	nss_pheader_t	*phdr = (nss_pheader_t *)((void *)argp);
	char		*dblist;
	int		door = -1;
	int		rc = 0;
	door_desc_t	desc;
	char		*space;
	int		len;

	/*
	 * check to see if self-cred is configured and
	 * need to return an alternate PUN door
	 */
	if (per_user_is_on == 1) {
		rc = need_per_user_door(argp, whoami,
		    _nscd_get_client_euid(), &dblist);
		if (rc == -1)
			per_user_is_on = 0;
	}
	if (rc <= 0) {
		/*
		 * self-cred not configured, and no error detected,
		 * return to continue the door call processing
		 */
		if (NSCD_STATUS_IS_OK(phdr))
			return;
		else
			/*
			 * configured but error detected,
			 * stop the door call processing
			 */
			(void) door_return(argp, phdr->data_off, NULL, 0);
	}

	/* get the alternate PUN door */
	_nscd_proc_alt_get(argp, &door);
	if (NSCD_GET_STATUS(phdr) != NSS_ALTRETRY) {
		(void) door_return(argp, phdr->data_off, NULL, 0);
	}

	/* return the alternate door descriptor */
	len = strlen(dblist) + 1;
	space = alloca(arg_size + len);
	phdr->data_len = len;
	(void) memcpy(space, phdr, arg_size);
	(void) strncpy((char *)space + arg_size, dblist, len);
	dp = &desc;
	dp->d_attributes = DOOR_DESCRIPTOR;
	dp->d_data.d_desc.d_descriptor = door;
	arg_size += len;
	(void) door_return(space, arg_size, dp, 1);
}
コード例 #3
0
static void
selfcred_fork(
	void		*buf,
	int		doorfd,
	int		cslot,
	uid_t		uid,
	gid_t		gid)
{
	int		ret;
	nscd_fork_t	f;
	nss_pheader_t	*phdr = (nss_pheader_t *)buf;
	char		*me = "selfcred_fork";

	/* if no door fd, do nothing */
	if (doorfd == -1) {
		NSCD_SET_N2N_STATUS(phdr, NSS_NSCD_PRIV, 0,
		    NSCD_SELF_CRED_NO_DOOR);
	}

	_NSCD_LOG(NSCD_LOG_SELF_CRED, NSCD_LOG_LEVEL_DEBUG)
	(me, "sending fork request to door %d for slot %d "
	    "(uid = %d, gid = %d)\n", doorfd, cslot, uid, gid);

	f.slot = cslot;
	f.uid = uid;
	f.gid = gid;

	ret = _nscd_doorcall_fd(doorfd, NSCD_FORK|(_whoami&NSCD_WHOAMI),
	    &f, sizeof (f), NULL, 0, phdr);

	_NSCD_LOG(NSCD_LOG_SELF_CRED, NSCD_LOG_LEVEL_DEBUG)
	(me, "fork request sent to door %d for slot %d (rc = %d)\n",
	    doorfd, cslot, ret);

	if (NSCD_STATUS_IS_NOT_OK(phdr)) {

		_NSCD_LOG(NSCD_LOG_SELF_CRED, NSCD_LOG_LEVEL_DEBUG)
		(me, "fork request sent to door %d for slot %d failed: "
		    "status = %d, errno = %s, nscd status = %d\n", doorfd,
		    cslot, NSCD_GET_STATUS(phdr),
		    strerror(NSCD_GET_ERRNO(phdr)),
		    NSCD_GET_NSCD_STATUS(phdr));

	}
}
コード例 #4
0
ファイル: nscd_door.c プロジェクト: AlainODea/illumos-gate
nss_status_t
_nscd_doorcall_fd(int fd, int callnum, void *indata, int indlen,
	void *outdata, int outdlen, nss_pheader_t *phdr)
{
	void		*uptr;
	void		*dptr;
	void		*datap;
	size_t		ndata;
	size_t		adata;
	size_t		buflen;
	door_arg_t	param;
	int		ret, errnum;
	nss_pheader_t	*phdr_d;
	char		*me = "_nscd_doorcall_fd";

	_NSCD_LOG(NSCD_LOG_FRONT_END, NSCD_LOG_LEVEL_DEBUG)
	(me, "processing door call %d (fd = %d)...\n", callnum, fd);

	/* allocate door buffer from the stack */
	NSCD_ALLOC_DOORBUF(callnum, indlen, uptr, buflen);
	dptr = uptr;
	ndata = buflen;
	adata = buflen;
	datap = NSCD_N2N_DOOR_DATA(void, dptr);
	if (indata != NULL)
		(void) memmove(datap, indata, indlen);

	param.rbuf = (char *)dptr;
	param.rsize = ndata;
	param.data_ptr = (char *)dptr;
	param.data_size = adata;
	param.desc_ptr = NULL;
	param.desc_num = 0;
	ret = door_call(fd, &param);
	if (ret < 0) {
		errnum = errno;
		/*
		 * door call did not get through, return errno
		 * if requested
		 */
		if (phdr != NULL) {
			NSCD_SET_STATUS(phdr, NSS_ERROR, errnum);
		}

		_NSCD_LOG(NSCD_LOG_FRONT_END, NSCD_LOG_LEVEL_DEBUG)
		(me, "door call (%d to %d) did not get through (%s)\n",
		    callnum, fd, strerror(errnum));

		return (NSS_ERROR);
	}
	ndata = param.rsize;
	dptr = (void *)param.data_ptr;

	/*
	 * door call got through, check if operation failed.
	 * if so, return error info if requested
	 */
	phdr_d = (nss_pheader_t *)dptr;
	ret = NSCD_GET_STATUS(phdr_d);
	if (ret != NSS_SUCCESS) {
		if (phdr != NULL) {
			NSCD_COPY_STATUS(phdr, phdr_d);
		}

		_NSCD_LOG(NSCD_LOG_FRONT_END, NSCD_LOG_LEVEL_DEBUG)
		(me, "door call (%d to %d) failed: p_status = %d, "
		    "p_errno = %s, nscd status = %d\n", callnum, fd,
		    ret, strerror(NSCD_GET_ERRNO(phdr_d)),
		    NSCD_GET_NSCD_STATUS(phdr_d));
	} else
		ret = copy_output(outdata, outdlen, phdr_d, phdr);

	/* if new buffer allocated for this door call, free it */
	if (dptr != uptr)
		(void) munmap(dptr, param.rsize);


	return (ret);
}