X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Fl_getidentity.c;h=ff7bb26ab827a4020f3f8c29b88fa6da8c04a507;hb=5b468e20ecc0b77460444393d1bb41867d99899d;hp=16460791e7f0afea875f9c9becd5b3bae13643ff;hpb=d92bd22523aa9bb1cdb91ded3d46fb180f68a93c;p=fs%2Flustre-release.git diff --git a/lustre/utils/l_getidentity.c b/lustre/utils/l_getidentity.c index 1646079..ff7bb26 100644 --- a/lustre/utils/l_getidentity.c +++ b/lustre/utils/l_getidentity.c @@ -46,10 +46,9 @@ #include #include -#include #include -#include -#include +#include +#include #define PERM_PATHNAME "/etc/lustre/perm.conf" @@ -87,15 +86,15 @@ static int compare_u32(const void *v1, const void *v2) static void errlog(const char *fmt, ...) { - va_list args; + va_list args; - openlog(progname, LOG_PERROR | LOG_PID, LOG_AUTHPRIV); + openlog(progname, LOG_PERROR | LOG_PID, LOG_AUTHPRIV); - va_start(args, fmt); - vsyslog(LOG_NOTICE, fmt, args); - va_end(args); + va_start(args, fmt); + vsyslog(LOG_WARNING, fmt, args); + va_end(args); - closelog(); + closelog(); } int get_groups_local(struct identity_downcall_data *data, @@ -105,8 +104,6 @@ int get_groups_local(struct identity_downcall_data *data, unsigned int ngroups = 0; int ngroups_tmp; struct passwd *pw; - char *pw_name; - int namelen; int i; pw = getpwuid(data->idd_uid); @@ -117,25 +114,13 @@ int get_groups_local(struct identity_downcall_data *data, } data->idd_gid = pw->pw_gid; - namelen = sysconf(_SC_LOGIN_NAME_MAX); - if (namelen < _POSIX_LOGIN_NAME_MAX) - namelen = _POSIX_LOGIN_NAME_MAX; - - pw_name = malloc(namelen); - if (!pw_name) { - errlog("malloc error\n"); - data->idd_err = errno; - return -1; - } - strlcpy(pw_name, pw->pw_name, namelen); groups = data->idd_groups; /* Allocate array of size maxgroups instead of handling two * consecutive and potentially racy getgrouplist() calls. */ groups_tmp = malloc(maxgroups * sizeof(gid_t)); if (groups_tmp == NULL) { - free(pw_name); data->idd_err = errno ? errno : ENOMEM; errlog("malloc error=%u\n",data->idd_err); return -1; @@ -144,7 +129,6 @@ int get_groups_local(struct identity_downcall_data *data, ngroups_tmp = maxgroups; if (getgrouplist(pw->pw_name, pw->pw_gid, groups_tmp, &ngroups_tmp) < 0) { - free(pw_name); free(groups_tmp); data->idd_err = errno ? errno : EIDRM; errlog("getgrouplist() error for uid %u: error=%u\n", @@ -161,7 +145,6 @@ int get_groups_local(struct identity_downcall_data *data, qsort(groups, ngroups, sizeof(*groups), compare_u32); data->idd_ngroups = ngroups; - free(pw_name); free(groups_tmp); return 0; }