Whamcloud - gitweb
LU-6245 utils: remove libcfs.h from lustre utilities code
[fs/lustre-release.git] / lustre / utils / l_getidentity.c
index 8e718a5..46bd22c 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, Intel Corporation.
+ * Copyright (c) 2011, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -48,7 +48,8 @@
 #include <libgen.h>
 #include <syslog.h>
 
-#include <libcfs/libcfs.h>
+#include <libcfs/util/string.h>
+#include <lnet/nidstr.h>
 #include <lustre/lustre_user.h>
 #include <lustre/lustre_idl.h>
 
@@ -63,7 +64,7 @@
  * the valid values for perms are:
  * setuid/setgid/setgrp/rmtacl           -- enable corresponding perm
  * nosetuid/nosetgid/nosetgrp/normtacl   -- disable corresponding perm
- * they can be listed together, seperated by ',',
+ * they can be listed together, separated by ',',
  * when perm and noperm are in the same line (item), noperm is preferential,
  * when they are in different lines (items), the latter is preferential,
  * '*' nid is as default perm, and is not preferential.
@@ -262,9 +263,12 @@ int parse_perm(__u32 *perm, __u32 *noperm, char *str)
         return 0;
 }
 
-int parse_perm_line(struct identity_downcall_data *data, char *line)
+static int
+parse_perm_line(struct identity_downcall_data *data, char *line, size_t size)
 {
-        char uid_str[256], nid_str[256], perm_str[256];
+       char uid_str[size];
+       char nid_str[size];
+       char perm_str[size];
         lnet_nid_t nid;
         __u32 perm, noperm;
         int rc, i;
@@ -275,7 +279,7 @@ int parse_perm_line(struct identity_downcall_data *data, char *line)
                 return -1;
         }
 
-        rc = sscanf(line, "%s %s %s", nid_str, uid_str, perm_str);
+       rc = sscanf(line, "%s %s %s", nid_str, uid_str, perm_str);
         if (rc != 3) {
                 errlog("can't parse line %s\n", line);
                 return -1;
@@ -355,8 +359,8 @@ int parse_perm_line(struct identity_downcall_data *data, char *line)
 
 int get_perms(struct identity_downcall_data *data)
 {
-        FILE *fp;
-        char line[1024];
+       FILE *fp;
+       char line[PATH_MAX];
 
         fp = fopen(PERM_PATHNAME, "r");
         if (fp == NULL) {
@@ -370,11 +374,11 @@ int get_perms(struct identity_downcall_data *data)
                 }
         }
 
-        while (fgets(line, 1024, fp)) {
+       while (fgets(line, sizeof(line), fp)) {
                 if (comment_line(line))
                         continue;
 
-                if (parse_perm_line(data, line)) {
+               if (parse_perm_line(data, line, sizeof(line))) {
                         errlog("parse line %s failed!\n", line);
                         data->idd_err = EINVAL;
                         fclose(fp);