linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / fs / lockd / svc.c
index 1bc0676..71a30b4 100644 (file)
 #define LOCKD_BUFSIZE          (1024 + NLMSVC_XDRSIZE)
 #define ALLOWED_SIGS           (sigmask(SIGKILL))
 
-extern struct svc_program      nlmsvc_program;
+static struct svc_program      nlmsvc_program;
+
 struct nlmsvc_binding *                nlmsvc_ops;
+EXPORT_SYMBOL(nlmsvc_ops);
+
 static DECLARE_MUTEX(nlmsvc_sema);
 static unsigned int            nlmsvc_users;
 static pid_t                   nlmsvc_pid;
@@ -175,6 +178,8 @@ lockd(struct svc_rqst *rqstp)
 
        }
 
+       flush_signals(current);
+
        /*
         * Check whether there's a new lockd process before
         * shutting down the hosts and clearing the slot.
@@ -188,7 +193,7 @@ lockd(struct svc_rqst *rqstp)
                printk(KERN_DEBUG
                        "lockd: new process, skipping host shutdown\n");
        wake_up(&lockd_exit);
-               
+
        /* Exit the RPC thread */
        svc_exit_thread(rqstp);
 
@@ -270,6 +275,7 @@ out:
        up(&nlmsvc_sema);
        return error;
 }
+EXPORT_SYMBOL(lockd_up);
 
 /*
  * Decrement the user count and bring down lockd if we're the last.
@@ -311,6 +317,7 @@ lockd_down(void)
 out:
        up(&nlmsvc_sema);
 }
+EXPORT_SYMBOL(lockd_down);
 
 /*
  * Sysctl parameters (same as module parameters, different interface).
@@ -324,7 +331,7 @@ static ctl_table nlm_sysctls[] = {
                .ctl_name       = CTL_UNNUMBERED,
                .procname       = "nlm_grace_period",
                .data           = &nlm_grace_period,
-               .maxlen         = sizeof(int),
+               .maxlen         = sizeof(unsigned long),
                .mode           = 0644,
                .proc_handler   = &proc_doulongvec_minmax,
                .extra1         = (unsigned long *) &nlm_grace_period_min,
@@ -334,7 +341,7 @@ static ctl_table nlm_sysctls[] = {
                .ctl_name       = CTL_UNNUMBERED,
                .procname       = "nlm_timeout",
                .data           = &nlm_timeout,
-               .maxlen         = sizeof(int),
+               .maxlen         = sizeof(unsigned long),
                .mode           = 0644,
                .proc_handler   = &proc_doulongvec_minmax,
                .extra1         = (unsigned long *) &nlm_timeout_min,
@@ -398,6 +405,38 @@ static int param_set_##name(const char *val, struct kernel_param *kp)      \
        return 0;                                                       \
 }
 
+static inline int is_callback(u32 proc)
+{
+       return proc == NLMPROC_GRANTED
+               || proc == NLMPROC_GRANTED_MSG
+               || proc == NLMPROC_TEST_RES
+               || proc == NLMPROC_LOCK_RES
+               || proc == NLMPROC_CANCEL_RES
+               || proc == NLMPROC_UNLOCK_RES
+               || proc == NLMPROC_NSM_NOTIFY;
+}
+
+
+static int lockd_authenticate(struct svc_rqst *rqstp)
+{
+       rqstp->rq_client = NULL;
+       switch (rqstp->rq_authop->flavour) {
+               case RPC_AUTH_NULL:
+               case RPC_AUTH_UNIX:
+                       if (rqstp->rq_proc == 0)
+                               return SVC_OK;
+                       if (is_callback(rqstp->rq_proc)) {
+                               /* Leave it to individual procedures to
+                                * call nlmsvc_lookup_host(rqstp)
+                                */
+                               return SVC_OK;
+                       }
+                       return svc_set_client(rqstp);
+       }
+       return SVC_DENIED;
+}
+
+
 param_set_min_max(port, int, simple_strtol, 0, 65535)
 param_set_min_max(grace_period, unsigned long, simple_strtoul,
                  nlm_grace_period_min, nlm_grace_period_max)
@@ -471,11 +510,12 @@ static struct svc_version *       nlmsvc_version[] = {
 static struct svc_stat         nlmsvc_stats;
 
 #define NLM_NRVERS     (sizeof(nlmsvc_version)/sizeof(nlmsvc_version[0]))
-struct svc_program     nlmsvc_program = {
-       .pg_prog        = NLM_PROGRAM,          /* program number */
-       .pg_nvers       = NLM_NRVERS,           /* number of entries in nlmsvc_version */
-       .pg_vers        = nlmsvc_version,       /* version table */
-       .pg_name        = "lockd",              /* service name */
-       .pg_class       = "nfsd",               /* share authentication with nfsd */
-       .pg_stats       = &nlmsvc_stats,        /* stats table */
+static struct svc_program      nlmsvc_program = {
+       .pg_prog                = NLM_PROGRAM,          /* program number */
+       .pg_nvers               = NLM_NRVERS,           /* number of entries in nlmsvc_version */
+       .pg_vers                = nlmsvc_version,       /* version table */
+       .pg_name                = "lockd",              /* service name */
+       .pg_class               = "nfsd",               /* share authentication with nfsd */
+       .pg_stats               = &nlmsvc_stats,        /* stats table */
+       .pg_authenticate = &lockd_authenticate  /* export authentication */
 };