]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/rquotad/rquota_svc.c
2000-08-25 Ion Badulescu <ionut@cs.columbia.edu>
[nfs-utils.git] / utils / rquotad / rquota_svc.c
index d402f0b2f952f32a73c2e882977adac2418efc75..f55c192762bf3aab0975994a05896f2f691e94cc 100644 (file)
  */
 #include "config.h"
 
+#ifdef HAVE_TCP_WRAPPER
+#include "tcpwrapper.h"
+#endif
+
 #include <unistd.h>
 #include <rpc/rpc.h>
 #include "rquota.h"
@@ -30,6 +34,7 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <syslog.h>
+#include <signal.h>
 
 #ifdef __STDC__
 #define SIG_PF void(*)(int)
@@ -59,6 +64,15 @@ static void rquotaprog_1(struct svc_req *rqstp, register SVCXPRT *transp)
    xdrproc_t xdr_argument, xdr_result;
    char *(*local)(char *, struct svc_req *);
 
+#ifdef HAVE_TCP_WRAPPER
+   /* remote host authorization check */
+   if (!check_default("rquotad", svc_getcaller(transp),
+                     rqstp->rq_proc, RQUOTAPROG)) {
+         svcerr_auth (transp, AUTH_FAILED);
+         return;
+   }
+#endif
+
    /*
     * Don't bother authentication for NULLPROC.
     */
@@ -125,6 +139,15 @@ static void rquotaprog_2(struct svc_req *rqstp, register SVCXPRT *transp)
    xdrproc_t xdr_argument, xdr_result;
    char *(*local)(char *, struct svc_req *);
 
+#ifdef HAVE_TCP_WRAPPER
+   /* remote host authorization check */
+   if (!check_default("rquotad", svc_getcaller(transp),
+                     rqstp->rq_proc, RQUOTAPROG)) {
+         svcerr_auth (transp, AUTH_FAILED);
+         return;
+   }
+#endif
+
    /*
     * Don't bother authentication for NULLPROC.
     */
@@ -190,6 +213,9 @@ int main(int argc, char **argv)
 
    openlog("rquota", LOG_PID, LOG_DAEMON);
 
+   /* WARNING: the following works on Linux and SysV, but not BSD! */
+   signal(SIGCHLD, SIG_IGN);
+
    transp = svcudp_create(RPC_ANYSOCK);
    if (transp == NULL) {
       syslog(LOG_ERR, "cannot create udp service.");