Whamcloud - gitweb
LU-9679 general: add missing spaces to folded strings.
[fs/lustre-release.git] / lustre / utils / gss / svcgssd_proc.c
index 5ae4213..f2e94fc 100644 (file)
@@ -1,39 +1,36 @@
 /*
-  svc_in_gssd_proc.c
-
-  Copyright (c) 2000 The Regents of the University of Michigan.
-  All rights reserved.
-
-  Copyright (c) 2002 Bruce Fields <bfields@UMICH.EDU>
-
-  Copyright (c) 2014, Intel Corporation.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-  2. Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the distribution.
-  3. Neither the name of the University nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
-  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
-  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-  DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-*/
+ * svc_in_gssd_proc.c
+ *
+ * Copyright (c) 2000 The Regents of the University of Michigan.
+ * All rights reserved.
+ *
+ * Copyright (c) 2002 Bruce Fields <bfields@UMICH.EDU>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
 
 #include <sys/param.h>
 #include <sys/stat.h>
@@ -51,7 +48,6 @@
 #endif
 
 #include <stdbool.h>
-#include <lnet/nidstr.h>
 
 #include "svcgssd.h"
 #include "gss_util.h"
@@ -61,7 +57,6 @@
 #include "lsupport.h"
 #include "gss_oids.h"
 #include "sk_utils.h"
-#include <lustre/lustre_idl.h>
 
 #define SVCGSSD_CONTEXT_CHANNEL "/proc/net/rpc/auth.sptlrpc.context/channel"
 #define SVCGSSD_INIT_CHANNEL    "/proc/net/rpc/auth.sptlrpc.init/channel"
@@ -118,7 +113,7 @@ do_svc_downcall(gss_buffer_desc *out_handle, struct svc_cred *cred,
        }
        qword_printhex(f, out_handle->value, out_handle->length);
        /* XXX are types OK for the rest of this? */
-       qword_printint(f, 3600); /* an hour should be sufficient */
+       qword_printint(f, time(NULL) + 3600);   /* 1 hour should be ok */
        qword_printint(f, cred->cr_remote);
        qword_printint(f, cred->cr_usr_root);
        qword_printint(f, cred->cr_usr_mds);
@@ -157,7 +152,7 @@ send_response(FILE *f, gss_buffer_desc *in_handle, gss_buffer_desc *in_token,
        printerr(2, "sending reply\n");
        qword_addhex(&bp, &blen, in_handle->value, in_handle->length);
        qword_addhex(&bp, &blen, in_token->value, in_token->length);
-       qword_addint(&bp, &blen, 3600); /* an hour should be sufficient */
+       qword_addint(&bp, &blen, time(NULL) + 3600);   /* 1 hour should be ok */
        qword_adduint(&bp, &blen, maj_stat);
        qword_adduint(&bp, &blen, min_stat);
        qword_addhex(&bp, &blen, out_handle->value, out_handle->length);
@@ -232,17 +227,17 @@ get_ids(gss_name_t client_name, gss_OID mech, struct svc_cred *cred,
        else
                cred->cr_mapped_uid = -1;
 
-        realm = strchr(sname, '@');
+       realm = strchr(sname, '@');
        if (realm) {
-                *realm++ = '\0';
+               *realm++ = '\0';
        } else {
                printerr(0, "ERROR: %s has no realm name\n", sname);
                goto out_free;
        }
 
-        host = strchr(sname, '/');
-        if (host)
-                *host++ = '\0';
+       host = strchr(sname, '/');
+       if (host)
+               *host++ = '\0';
 
        if (strcmp(sname, GSSD_SERVICE_MGS) == 0) {
                printerr(0, "forbid %s as a user name\n", sname);
@@ -348,8 +343,8 @@ out_free:
                printerr(1, "%s: authenticated %s%s%s@%s from %016llx\n",
                         lustre_svc_name[lustre_svc], sname,
                         host ? "/" : "", host ? host : "", realm, nid);
-        free(sname);
-        return res;
+       free(sname);
+       return res;
 }
 
 typedef struct gss_union_ctx_id_t {
@@ -746,32 +741,49 @@ int handle_channel_request(FILE *f)
        switch (lustre_mech) {
        case LGSS_MECH_KRB5:
                if (!krb_enabled) {
-                       printerr(1, "WARNING: Request for kerberos but service "
-                                "support not enabled\n");
+                       static time_t next_krb;
+
+                       if (time(NULL) > next_krb) {
+                               printerr(1, "warning: Request for kerberos but "
+                                        "service support not enabled\n");
+                               next_krb = time(NULL) + 3600;
+                       }
                        goto ignore;
                }
                snd.mech = &krb5oid;
                break;
        case LGSS_MECH_NULL:
                if (!null_enabled) {
-                       printerr(1, "WARNING: Request for gssnull but service "
-                                "support not enabled\n");
+                       static time_t next_null;
+
+                       if (time(NULL) > next_null) {
+                               printerr(1, "warning: Request for gssnull but "
+                                        "service support not enabled\n");
+                               next_null = time(NULL) + 3600;
+                       }
                        goto ignore;
                }
                snd.mech = &nulloid;
                break;
        case LGSS_MECH_SK:
-#ifdef HAVE_OPENSSL_SSK
                if (!sk_enabled) {
-                       printerr(1, "WARNING: Request for sk but service "
-                                "support not enabled\n");
+                       static time_t next_ssk;
+
+                       if (time(NULL) > next_ssk) {
+                               printerr(1, "warning: Request for SSK but "
+                                        "service support not %s\n",
+#ifdef HAVE_OPENSSL_SSK
+                                        "enabled"
+#else
+                                        "included"
+#endif
+                                       );
+                               next_ssk = time(NULL) + 3600;
+                       }
+
                        goto ignore;
                }
                snd.mech = &skoid;
-#else
-               printerr(1, "ERROR: Request for sk but service "
-                        "support not enabled\n");
-#endif
                break;
        default:
                printerr(0, "WARNING: invalid mechanism recevied: %d\n",
@@ -824,8 +836,9 @@ int handle_channel_request(FILE *f)
        else if (lustre_mech == LGSS_MECH_NULL)
                rc = handle_null(&snd);
        else
-               printerr(0, "WARNING: Received or request for"
-                        "subflavor that is not enabled: %d\n", lustre_mech);
+               printerr(0,
+                        "WARNING: Received or request for subflavor that is not enabled: %d\n",
+                        lustre_mech);
 
 out_err:
        /* Failures send a null token */