extern int _rpcfdtype;
extern int _rpcsvcdirty;
+static inline struct sockaddr_in *nfs_getrpccaller_in(SVCXPRT *xprt)
+{
+ return (struct sockaddr_in *)svc_getcaller(xprt);
+}
+
+static inline struct sockaddr *nfs_getrpccaller(SVCXPRT *xprt)
+{
+ return (struct sockaddr *)svc_getcaller(xprt);
+}
#endif /* RPCMISC_H */
{
union mountd_arguments argument;
union mountd_results result;
-
#ifdef HAVE_TCP_WRAPPER
+ struct sockaddr_in *sin = nfs_getrpccaller_in(transp);
+
/* remote host authorization check */
- if (!check_default("mountd", svc_getcaller(transp),
- rqstp->rq_proc, MOUNTPROG)) {
+ if (sin->sin_family == AF_INET &&
+ !check_default("mountd", sin, rqstp->rq_proc, MOUNTPROG)) {
svcerr_auth (transp, AUTH_FAILED);
return;
}
bool_t
mount_dump_1_svc(struct svc_req *rqstp, void *argp, mountlist *res)
{
- struct sockaddr_in *addr =
- (struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt);
+ struct sockaddr_in *addr = nfs_getrpccaller_in(rqstp->rq_xprt);
xlog(D_CALL, "dump request from %s.", inet_ntoa(addr->sin_addr));
*res = mountlist_list();
bool_t
mount_umnt_1_svc(struct svc_req *rqstp, dirpath *argp, void *resp)
{
- struct sockaddr_in *sin
- = (struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt);
+ struct sockaddr_in *sin = nfs_getrpccaller_in(rqstp->rq_xprt);
nfs_export *exp;
char *p = *argp;
char rpath[MAXPATHLEN+1];
/* Reload /etc/xtab if necessary */
auth_reload();
- mountlist_del_all((struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt));
+ mountlist_del_all(nfs_getrpccaller_in(rqstp->rq_xprt));
return 1;
}
bool_t
mount_export_1_svc(struct svc_req *rqstp, void *argp, exports *resp)
{
- struct sockaddr_in *addr =
- (struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt);
+ struct sockaddr_in *addr = nfs_getrpccaller_in(rqstp->rq_xprt);
xlog(D_CALL, "export request from %s.", inet_ntoa(addr->sin_addr));
*resp = get_exportlist();
bool_t
mount_exportall_1_svc(struct svc_req *rqstp, void *argp, exports *resp)
{
- struct sockaddr_in *addr =
- (struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt);
+ struct sockaddr_in *addr = nfs_getrpccaller_in(rqstp->rq_xprt);
xlog(D_CALL, "exportall request from %s.", inet_ntoa(addr->sin_addr));
*resp = get_exportlist();
bool_t
mount_pathconf_2_svc(struct svc_req *rqstp, dirpath *path, ppathcnf *res)
{
- struct sockaddr_in *sin
- = (struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt);
+ struct sockaddr_in *sin = nfs_getrpccaller_in(rqstp->rq_xprt);
struct stat stb;
nfs_export *exp;
char rpath[MAXPATHLEN+1];
get_rootfh(struct svc_req *rqstp, dirpath *path, nfs_export **expret,
mountstat3 *error, int v3)
{
- struct sockaddr_in *sin =
- (struct sockaddr_in *) svc_getcaller(rqstp->rq_xprt);
+ struct sockaddr_in *sin = nfs_getrpccaller_in(rqstp->rq_xprt);
struct stat stb, estb;
nfs_export *exp;
struct nfs_fh_len *fh;
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+
+#include <arpa/inet.h>
+
+#include "rpcmisc.h"
#include "misc.h"
#include "statd.h"
#include "notlist.h"
-#include <arpa/inet.h>
/* Callback notify list. */
/* notify_list *cbnl = NULL; ... never used */
{
notify_list *lp, *call;
static char *result = NULL;
- char *ip_addr = xstrdup(inet_ntoa(svc_getcaller(rqstp->rq_xprt)
- ->sin_addr));
+ struct sockaddr_in *sin = nfs_getrpccaller_in(rqstp->rq_xprt);
+ char *ip_addr = xstrdup(inet_ntoa(sin->sin_addr));
dprintf(N_DEBUG, "Received SM_NOTIFY from %s, state: %d",
argp->mon_name, argp->state);
#include <errno.h>
#include <arpa/inet.h>
#include <dirent.h>
+
+#include "rpcmisc.h"
#include "misc.h"
#include "statd.h"
#include "notlist.h"
static int
caller_is_localhost(struct svc_req *rqstp)
{
+ struct sockaddr_in *sin = nfs_getrpccaller_in(rqstp->rq_xprt);
struct in_addr caller;
- caller = svc_getcaller(rqstp->rq_xprt)->sin_addr;
+ caller = sin->sin_addr;
if (caller.s_addr != htonl(INADDR_LOOPBACK)) {
note(N_WARNING,
"Call to statd from non-local host %s",
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+
#include <arpa/inet.h>
+#include "rpcmisc.h"
#include "statd.h"
#include "notlist.h"
void *
sm_simu_crash_1_svc (void *argp, struct svc_req *rqstp)
{
+ struct sockaddr_in *sin = nfs_getrpccaller_in(rqstp->rq_xprt);
static char *result = NULL;
struct in_addr caller;
- caller = svc_getcaller(rqstp->rq_xprt)->sin_addr;
+ if (sin->sin_family != AF_INET) {
+ note(N_WARNING, "Call to statd from non-AF_INET address");
+ goto failure;
+ }
+
+ caller = sin->sin_addr;
if (caller.s_addr != htonl(INADDR_LOOPBACK)) {
note(N_WARNING, "Call to statd from non-local host %s",
inet_ntoa(caller));
goto failure;
}
- if (ntohs(svc_getcaller(rqstp->rq_xprt)->sin_port) >= 1024) {
+ if (ntohs(sin->sin_port) >= 1024) {
note(N_WARNING, "Call to statd-simu-crash from unprivileged port");
goto failure;
}
static void
sm_prog_1_wrapper (struct svc_req *rqstp, register SVCXPRT *transp)
{
+ struct sockaddr_in *sin = nfs_getrpccaller_in(transp);
+
/* remote host authorization check */
- if (!check_default("statd", svc_getcaller(transp),
- rqstp->rq_proc, SM_PROG)) {
+ if (sin->sin_family == AF_INET &&
+ !check_default("statd", sin, rqstp->rq_proc, SM_PROG)) {
svcerr_auth (transp, AUTH_FAILED);
return;
}