Whamcloud - gitweb
LU-9243 gss: fix GSS struct definition badness
[fs/lustre-release.git] / lustre / utils / gss / gssd.c
index 39d75d8..5f7bb40 100644 (file)
@@ -9,6 +9,8 @@
   Copyright (c) 2002 Marius Aamodt Eriksen <marius@UMICH.EDU>.
   All rights reserved, all wrongs reversed.
 
+  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:
 #include <string.h>
 #include <signal.h>
 #include <errno.h>
+#include <libcfs/util/string.h>
+
 #include "gssd.h"
 #include "err_util.h"
 #include "gss_util.h"
 #include "krb5_util.h"
 #include "lsupport.h"
 
-char pipefs_dir[PATH_MAX] = GSSD_PIPEFS_DIR;
+char *pipefs_dir = GSSD_PIPEFS_DIR;
 char pipefs_nfsdir[PATH_MAX] = GSSD_PIPEFS_DIR;
-char keytabfile[PATH_MAX] = GSSD_DEFAULT_KEYTAB_FILE;
-char ccachedir[PATH_MAX] = GSSD_DEFAULT_CRED_DIR;
+char *keytabfile = GSSD_DEFAULT_KEYTAB_FILE;
+char *ccachedir = GSSD_DEFAULT_CRED_DIR;
 int  use_memcache = 0;
 int  lgssd_mutex_downcall = -1;
 
@@ -105,10 +109,13 @@ void lgssd_fini_mutexs(void)
 
 void lgssd_mutex_get(int semid)
 {
-       struct sembuf   op[1] = { {0, -1, SEM_UNDO} };
-       int             rc;
+       struct sembuf op = {
+               .sem_op = -1,
+               .sem_flag = SEM_UNDO
+       };
+       int rc;
 
-       rc = semop(semid, op, 1);
+       rc = semop(semid, &op, 1);
        if (rc != 0) {
                printerr(0, "exit on mutex_get err %d: %s\n",
                         rc, strerror(errno));
@@ -118,10 +125,12 @@ void lgssd_mutex_get(int semid)
 
 void lgssd_mutex_put(int semid)
 {
-       struct sembuf   op[1] = { {0, 1, 0} };
-       int             rc;
+       struct sembuf op = {
+               .sem_op = 1
+       };
+       int rc;
 
-       rc = semop(semid, op, 1);
+       rc = semop(semid, &op, 1);
        if (rc != 0) {
                printerr(0, "ignore mutex_put err %d: %s\n",
                         rc, strerror(errno));
@@ -160,7 +169,6 @@ sig_hup(int signal)
 {
        /* don't exit on SIGHUP */
        printerr(1, "Received SIGHUP... Ignoring.\n");
-       return;
 }
 
 static void
@@ -192,19 +200,19 @@ main(int argc, char *argv[])
                                verbosity++;
                                break;
                        case 'p':
-                               strlcpy(pipefs_dir, optarg, sizeof(pipefs_dir));
-                               if (pipefs_dir[sizeof(pipefs_dir)-1] != '\0')
-                                       errx(1, "pipefs path name too long");
+                               pipefs_dir = strdup(optarg);
+                               if (!pipe_dir)
+                                       errx(1, "pipefs path name not aquired");
                                break;
                        case 'k':
-                               strlcpy(keytabfile, optarg, sizeof(keytabfile));
-                               if (keytabfile[sizeof(keytabfile)-1] != '\0')
-                                       errx(1, "keytab path name too long");
+                               keytabfile = strdup(optarg);
+                               if (!keytab_file)
+                                       errx(1, "keytab path name not aquired");
                                break;
                        case 'd':
-                               strlcpy(ccachedir, optarg, sizeof(ccachedir));
-                               if (ccachedir[sizeof(ccachedir)-1] != '\0')
-                                       errx(1, "ccachedir path name too long");
+                               ccachedir = strdup(optarg);
+                               if (!ccachedir)
+                                       errx(1, "ccachedir path name not aquired");
                                break;
                        default:
                                usage(argv[0]);
@@ -243,11 +251,6 @@ main(int argc, char *argv[])
        signal(SIGTERM, sig_die);
        signal(SIGHUP, sig_hup);
 
-#if 0
-       /* Determine Kerberos information from the kernel */
-       gssd_obtain_kernel_krb5_info();
-#endif
-
        lgssd_init_mutexs();
 
        printerr(0, "lgssd initialized and ready to serve\n");