Whamcloud - gitweb
LU-3289 gss: Add option for loading keys during mount
[fs/lustre-release.git] / lustre / utils / mount_lustre.c
index b247327..7ed9fff 100644 (file)
@@ -114,6 +114,10 @@ void usage(FILE *out)
                "\t\tskip_lfsck: NOT auto resume the paused/crashed LFSCK\n"
                "\t\texclude=<ostname>[:<ostname>] : colon-separated list of "
                "inactive OSTs (e.g. lustre-OST0001)\n"
+#ifdef HAVE_GSS
+               "\t\tskpath=<file|directory>: Path to a file or directory of"
+               "key configuration files to load into the kernel keyring\n"
+#endif
                "\t\tretry=<num>: number of times mount is retried by client\n"
                "\t\tmd_stripe_cache_size=<num>: set the raid stripe cache "
                "size for the underlying raid if present\n");
@@ -277,6 +281,17 @@ int parse_options(struct mount_opts *mop, char *orig_options, int *flagp)
                        /* XXX special check for 'force' option */
                        ++mop->mo_force;
                        printf("force: %d\n", mop->mo_force);
+#ifdef HAVE_GSS
+               } else if (val && strncmp(opt, "skpath=", 7) == 0) {
+                       if (strlen(val) + 1 >= sizeof(mop->mo_skpath)) {
+                               fprintf(stderr,
+                                       "%s: shared key path too long\n",
+                                       progname);
+                               free(options);
+                               return -1;
+                       }
+                       strncpy(mop->mo_skpath, val + 1, strlen(val + 1));
+#endif
                } else if (parse_one_option(opt, flagp) == 0) {
                        /* pass this on as an option */
                        append_option(options, opt);
@@ -629,6 +644,7 @@ int main(int argc, char *const argv[])
        struct mount_opts mop;
        char *options;
        int i, rc, flags;
+       bool client;
 
        progname = strrchr(argv[0], '/');
        progname = progname ? progname + 1 : argv[0];
@@ -687,7 +703,8 @@ int main(int argc, char *const argv[])
                return rc;
        }
 
-       if (strstr(mop.mo_usource, ":/") == NULL) {
+       client = (strstr(mop.mo_usource, ":/") != NULL);
+       if (!client) {
                rc = osd_init();
                if (rc)
                        return rc;
@@ -706,14 +723,26 @@ int main(int argc, char *const argv[])
                printf("mounting device %s at %s, flags=%#x options=%s\n",
                       mop.mo_source, mop.mo_target, flags, options);
 
-       if (strstr(mop.mo_usource, ":/") == NULL &&
-           osd_tune_lustre(mop.mo_source, &mop)) {
+       if (!client && osd_tune_lustre(mop.mo_source, &mop)) {
                if (verbose)
                        fprintf(stderr, "%s: unable to set tunables for %s"
                                        " (may cause reduced IO performance)\n",
                                        argv[0], mop.mo_source);
        }
 
+#ifdef HAVE_GSS
+       if (mop.mo_skpath[0] != '\0') {
+               /* Treat shared key failures as fatal */
+               rc = load_shared_keys(&mop);
+               if (rc) {
+                       fprintf(stderr,
+                               "%s: Error loading shared keys: %s\n",
+                               progname, strerror(rc));
+                       return rc;
+               }
+       }
+#endif
+
        if (!mop.mo_fake) {
                /* flags and target get to lustre_get_sb(), but not
                 * lustre_fill_super().  Lustre ignores the flags, but mount
@@ -833,7 +862,7 @@ int main(int argc, char *const argv[])
        /* mo_usource should be freed, but we can rely on the kernel */
        free(mop.mo_source);
 
-       if (strstr(mop.mo_usource, ":/") == NULL)
+       if (!client)
                osd_fini();
 
        return rc;