Пример #1
0
/*
 * Purpose:	Test whether a specified lock would be granted if requested
 * Returns:	nlm_granted (or error code)
 * Notes:
 */
nlm4_testres *
nlm4_test_4_svc(nlm4_testargs *arg, struct svc_req *rqstp)
{
	static nlm4_testres result;
	struct nlm4_holder *holder;

	if (debug_level)
		log_from_addr("nlm4_test", rqstp);

	holder = testlock(&arg->alock, LOCK_V4);

	/*
	 * Copy the cookie from the argument into the result.  Note that this
	 * is slightly hazardous, as the structure contains a pointer to a
	 * malloc()ed buffer that will get freed by the caller.  However, the
	 * main function transmits the result before freeing the argument
	 * so it is in fact safe.
	 */
	result.cookie = arg->cookie;
	if (holder == NULL) {
		result.stat.stat = nlm4_granted;
	} else {
		result.stat.stat = nlm4_denied;
		memcpy(&result.stat.nlm4_testrply_u.holder, holder,
		    sizeof(struct nlm4_holder));
	}
	return &result;
}
Пример #2
0
/*
 * Purpose:	Accept result from earlier nlm_test_msg() call
 * Returns:	Nothing
 */
void *
nlm_test_res_1_svc(nlm_testres *arg, struct svc_req *rqstp)
{
	if (debug_level)
		log_from_addr("nlm_test_res", rqstp);
	return (NULL);
}
Пример #3
0
/*
 * Purpose:	Accept result from earlier nlm_granted_msg() call
 * Returns:	Nothing
 */
void *
/*ARGSUSED*/
nlm_granted_res_1_svc(nlm_res *arg, struct svc_req *rqstp)
{
	if (debug_level)
		log_from_addr("nlm_granted_res", rqstp);
	return NULL;
}
Пример #4
0
/*
 * Purpose:	Accept result from earlier nlm_test_msg() call
 * Returns:	Nothing
 */
void *
/*ARGSUSED*/
nlm4_test_res_4_svc(nlm4_testres *arg, struct svc_req *rqstp)
{
	if (debug_level)
		log_from_addr("nlm4_test_res", rqstp);
	return NULL;
}
Пример #5
0
/*
 * Purpose:	Accept result from earlier nlm_test_msg() call
 * Returns:	Nothing
 */
void *
nlm_test_res_1_svc(nlm_testres *arg, struct svc_req *rqstp)
{
	if (debug_level)
		log_from_addr("nlm_test_res", rqstp);
	(void)lock_answer(-1, &arg->cookie, arg->stat.stat, 
		&arg->stat.nlm_testrply_u.holder.svid, NLM_VERS);
	return (NULL);
}
Пример #6
0
/*
 * Purpose:	Accept result from earlier nlm_lock_msg() call
 * Returns:	Nothing
 */
void *
nlm_lock_res_1_svc(nlm_res *arg, struct svc_req *rqstp)
{
	if (debug_level)
		log_from_addr("nlm_lock_res", rqstp);

	(void)lock_answer(-1, &arg->cookie, arg->stat.stat, NULL, NLM_VERS);

	return (NULL);
}
Пример #7
0
/*
 * Purpose:	Release all locks held by a named client
 * Returns:	Nothing
 * Notes:	Potential denial of service security problem here - the
 *		locks to be released are specified by a host name, independent
 *		of the address from which the request has arrived.
 *		Should probably be rejected if the named host has been
 *		using monitored locks.
 */
void *
/*ARGSUSED*/
nlm_free_all_3_svc(nlm_notify *arg, struct svc_req *rqstp)
{
	static char dummy;

	if (debug_level)
		log_from_addr("nlm_free_all", rqstp);
	return &dummy;
}
Пример #8
0
/*
 * Purpose:	Release a DOS-style lock
 * Returns:	nlm_granted, unless in grace period
 * Notes:
 */
nlm_shareres *
nlm_unshare_3_svc(nlm_shareargs *arg, struct svc_req *rqstp)
{
	static nlm_shareres result;

	if (debug_level)
		log_from_addr("nlm_unshare", rqstp);

	result.cookie = arg->cookie;
	result.stat = nlm_granted;
	result.sequence = 1234356;	/* X/Open says this field is ignored? */
	return &result;
}
Пример #9
0
/*
 * Purpose:	non-monitored version of nlm_lock()
 * Returns:	as for nlm_lock()
 * Notes:	These locks are in the same style as the standard nlm_lock,
 *		but the rpc.statd should not be called to establish a
 *		monitor for the client machine, since that machine is
 *		declared not to be running a rpc.statd, and so would not
 *		respond to the statd protocol.
 */
nlm_res *
nlm_nm_lock_3_svc(nlm_lockargs *arg, struct svc_req *rqstp)
{
	static nlm_res result;

	if (debug_level)
		log_from_addr("nlm_nm_lock", rqstp);

	/* copy cookie from arg to result.  See comment in nlm_test_1() */
	result.cookie = arg->cookie;
	result.stat.stat = nlm_granted;
	return &result;
}
Пример #10
0
/*
 * Purpose:	Release an existing lock
 * Returns:	Always granted, unless during grace period
 * Notes:	"no such lock" error condition is ignored, as the
 *		protocol uses unreliable UDP datagrams, and may well
 *		re-try an unlock that has already succeeded.
 */
nlm4_res *
nlm4_unlock_4_svc(nlm4_unlockargs *arg, struct svc_req *rqstp)
{
	static nlm4_res result;

	if (debug_level)
		log_from_addr("nlm4_unlock", rqstp);

	result.stat.stat = unlock(&arg->alock, LOCK_V4);
	result.cookie = arg->cookie;

	return &result;
}
Пример #11
0
void *
nlm4_granted_msg_4_svc(nlm4_testargs *arg, struct svc_req *rqstp)
{
	static nlm4_res result;

	if (debug_level)
		log_from_addr("nlm4_granted_msg", rqstp);

	result.cookie = arg->cookie;
	result.stat.stat = nlm4_granted;
	transmit4_result(NLM4_GRANTED_RES, &result, svc_getcaller(rqstp->rq_xprt));
	return NULL;
}
Пример #12
0
void *
nlm_granted_msg_1_svc(nlm_testargs *arg, struct svc_req *rqstp)
{
	static nlm_res res;

	if (debug_level)
		log_from_addr("nlm_granted_msg", rqstp);

	res.cookie = arg->cookie;
	res.stat.stat = nlm_granted;
	transmit_result(NLM_GRANTED_RES, &res,
	    (struct sockaddr *)svc_getcaller(rqstp->rq_xprt));
	return (NULL);
}
Пример #13
0
/*
 * Purposes:	Establish a lock
 * Returns:	granted, denied or blocked
 * Notes:	*** grace period support missing
 */
nlm4_res *
nlm4_lock_4_svc(nlm4_lockargs *arg, struct svc_req *rqstp)
{
	static nlm4_res result;

	if (debug_level)
		log_from_addr("nlm4_lock", rqstp);

	/* copy cookie from arg to result.  See comment in nlm_test_4() */
	result.cookie = arg->cookie;

	result.stat.stat = getlock(arg, rqstp, LOCK_MON | LOCK_V4);
	return &result;
}
Пример #14
0
void *
nlm4_unlock_msg_4_svc(nlm4_unlockargs *arg, struct svc_req *rqstp)
{
	static nlm4_res result;

	if (debug_level)
		log_from_addr("nlm4_unlock_msg", rqstp);

	result.stat.stat = unlock(&arg->alock, LOCK_V4);
	result.cookie = arg->cookie;

	transmit4_result(NLM4_UNLOCK_RES, &result, svc_getcaller(rqstp->rq_xprt));
	return NULL;
}
Пример #15
0
void *
nlm_test_msg_1_svc(nlm_testargs *arg, struct svc_req *rqstp)
{
	nlm_testres result;
	static char dummy;
	struct sockaddr_in *addr;
	CLIENT *cli;
	int success;
	struct timeval timeo;
	struct nlm4_lock arg4;
	struct nlm4_holder *holder;

	nlmtonlm4(&arg->alock, &arg4);

	if (debug_level)
		log_from_addr("nlm_test_msg", rqstp);

	holder = testlock(&arg4, 0);

	result.cookie = arg->cookie;
	if (holder == NULL) {
		result.stat.stat = nlm_granted;
	} else {
		result.stat.stat = nlm_denied;
		memcpy(&result.stat.nlm_testrply_u.holder, holder,
		    sizeof(struct nlm_holder));
		result.stat.nlm_testrply_u.holder.l_offset =
		    (unsigned int)holder->l_offset;
		result.stat.nlm_testrply_u.holder.l_len =
		    (unsigned int)holder->l_len;
	}

	/*
	 * nlm_test has different result type to the other operations, so
	 * can't use transmit_result() in this case
	 */
	addr = svc_getcaller(rqstp->rq_xprt);
	if ((cli = get_client(addr, NLM_VERS)) != NULL) {
		/* No timeout - not expecting response */
		timerclear(&timeo);

		success = clnt_call(cli, NLM_TEST_RES, xdr_nlm_testres,
		    &result, xdr_void, &dummy, timeo);

		if (debug_level > 2)
			syslog(LOG_DEBUG, "clnt_call returns %d", success);
	}
	return NULL;
}
Пример #16
0
void *
nlm_granted_msg_1_svc(nlm_testargs *arg, struct svc_req *rqstp)
{
	static nlm_res res;

	if (debug_level)
		log_from_addr("nlm_granted_msg", rqstp);

	res.cookie = arg->cookie;
	res.stat.stat = lock_answer(arg->alock.svid, &arg->cookie,
		nlm_granted, NULL, NLM_VERS) == 0 ?
		nlm_granted : nlm_denied;

	transmit_result(NLM_GRANTED_RES, &res, getrpcaddr(rqstp));
	return (NULL);
}
Пример #17
0
/*
 * Purpose:	Release an existing lock
 * Returns:	Always granted, unless during grace period
 * Notes:	"no such lock" error condition is ignored, as the
 *		protocol uses unreliable UDP datagrams, and may well
 *		re-try an unlock that has already succeeded.
 */
nlm_res *
nlm_unlock_1_svc(nlm_unlockargs *arg, struct svc_req *rqstp)
{
	static nlm_res result;
	struct nlm4_lock arg4;

	nlmtonlm4(&arg->alock, &arg4);

	if (debug_level)
		log_from_addr("nlm_unlock", rqstp);

	result.stat.stat = unlock(&arg4, 0);
	result.cookie = arg->cookie;

	return &result;
}
Пример #18
0
void *
nlm_unlock_msg_1_svc(nlm_unlockargs *arg, struct svc_req *rqstp)
{
	static nlm_res result;
	struct nlm4_lock arg4;

	nlmtonlm4(&arg->alock, &arg4);

	if (debug_level)
		log_from_addr("nlm_unlock_msg", rqstp);

	result.stat.stat = unlock(&arg4, 0);
	result.cookie = arg->cookie;

	transmit_result(NLM_UNLOCK_RES, &result, svc_getcaller(rqstp->rq_xprt));
	return NULL;
}
Пример #19
0
void *
nlm_unlock_msg_1_svc(nlm_unlockargs *arg, struct svc_req *rqstp)
{
	static nlm_res res;
	struct nlm4_lock arg4;

	nlmtonlm4(&arg->alock, &arg4);

	if (debug_level)
		log_from_addr("nlm_unlock_msg", rqstp);

	res.stat.stat = unlock(&arg4, 0);
	res.cookie = arg->cookie;

	transmit_result(NLM_UNLOCK_RES, &res, getrpcaddr(rqstp));
	return (NULL);
}
Пример #20
0
/*
 * Purpose:	Receive notification that formerly blocked lock now granted
 * Returns:	always success ('granted')
 * Notes:
 */
nlm_res *
nlm_granted_1_svc(nlm_testargs *arg, struct svc_req *rqstp)
{
	static nlm_res res;

	if (debug_level)
		log_from_addr("nlm_granted", rqstp);

	res.stat.stat = lock_answer(arg->alock.svid, &arg->cookie,
		nlm_granted, NULL, NLM_VERS) == 0 ?
		nlm_granted : nlm_denied;

	/* copy cookie from arg to result.  See comment in nlm_test_1() */
	res.cookie = arg->cookie;

	return (&res);
}
Пример #21
0
void *
nlm4_cancel_msg_4_svc(nlm4_cancargs *arg, struct svc_req *rqstp)
{
	static nlm4_res result;

	if (debug_level)
		log_from_addr("nlm4_cancel_msg", rqstp);

	result.cookie = arg->cookie;
	/*
	 * Since at present we never return 'nlm_blocked', there can never be
	 * a lock to cancel, so this call always fails.
	 */
	result.stat.stat = unlock(&arg->alock, LOCK_CANCEL | LOCK_V4);
	transmit4_result(NLM4_CANCEL_RES, &result, svc_getcaller(rqstp->rq_xprt));

	return NULL;
}
Пример #22
0
/*
 * Purpose:	Cancel a blocked lock request
 * Returns:	granted or denied
 * Notes:
 */
nlm4_res *
nlm4_cancel_4_svc(nlm4_cancargs *arg, struct svc_req *rqstp)
{
	static nlm4_res result;

	if (debug_level)
		log_from_addr("nlm4_cancel", rqstp);

	/* copy cookie from arg to result.  See comment in nlm_test_1() */
	result.cookie = arg->cookie;

	/*
	 * Since at present we never return 'nlm_blocked', there can never be
	 * a lock to cancel, so this call always fails.
	 */
	result.stat.stat = unlock(&arg->alock, LOCK_CANCEL);
	return &result;
}
Пример #23
0
void *
nlm_cancel_msg_1_svc(nlm_cancargs *arg, struct svc_req *rqstp)
{
	static nlm_res res;
	struct nlm4_lock arg4;

	nlmtonlm4(&arg->alock, &arg4);

	if (debug_level)
		log_from_addr("nlm_cancel_msg", rqstp);

	res.cookie = arg->cookie;
	/*
	 * Since at present we never return 'nlm_blocked', there can never be
	 * a lock to cancel, so this call always fails.
	 */
	res.stat.stat = unlock(&arg4, LOCK_CANCEL);
	transmit_result(NLM_CANCEL_RES, &res, getrpcaddr(rqstp));
	return (NULL);
}
Пример #24
0
/*
 * Purposes:	Establish a lock
 * Returns:	granted, denied or blocked
 * Notes:	*** grace period support missing
 */
nlm_res *
nlm_lock_1_svc(nlm_lockargs *arg, struct svc_req *rqstp)
{
	static nlm_res result;
	struct nlm4_lockargs arg4;
	nlmtonlm4(&arg->alock, &arg4.alock);
	arg4.cookie = arg->cookie;
	arg4.block = arg->block;
	arg4.exclusive = arg->exclusive;
	arg4.reclaim = arg->reclaim;
	arg4.state = arg->state;

	if (debug_level)
		log_from_addr("nlm_lock", rqstp);

	/* copy cookie from arg to result.  See comment in nlm_test_1() */
	result.cookie = arg->cookie;

	result.stat.stat = getlock(&arg4, rqstp, LOCK_MON);
	return &result;
}
Пример #25
0
void *
nlm_lock_msg_1_svc(nlm_lockargs *arg, struct svc_req *rqstp)
{
	static nlm_res result;
	struct nlm4_lockargs arg4;

	nlmtonlm4(&arg->alock, &arg4.alock);
	arg4.cookie = arg->cookie;
	arg4.block = arg->block;
	arg4.exclusive = arg->exclusive;
	arg4.reclaim = arg->reclaim;
	arg4.state = arg->state;

	if (debug_level)
		log_from_addr("nlm_lock_msg", rqstp);

	result.cookie = arg->cookie;
	result.stat.stat = getlock(&arg4, rqstp, LOCK_ASYNC | LOCK_MON);
	transmit_result(NLM_LOCK_RES, &result, svc_getcaller(rqstp->rq_xprt));

	return NULL;
}