*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
*
* GPL HEADER END
*/
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2014, Intel Corporation.
+ * Copyright (c) 2011, 2016, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#include <syslog.h>
#include <libcfs/util/param.h>
-#include <libcfs/util/string.h>
-#include <lnet/nidstr.h>
-#include <lustre/lustre_user.h>
-#include <lustre/lustre_idl.h>
+#include <linux/lnet/nidstr.h>
+#include <linux/lustre/lustre_user.h>
+#include <linux/lustre/lustre_idl.h>
#define PERM_PATHNAME "/etc/lustre/perm.conf"
* '*' nid means any nid
* '*' uid means any uid
* the valid values for perms are:
- * setuid/setgid/setgrp/rmtacl -- enable corresponding perm
- * nosetuid/nosetgid/nosetgrp/normtacl -- disable corresponding perm
+ * setuid/setgid/setgrp -- enable corresponding perm
+ * nosetuid/nosetgid/nosetgrp -- disable corresponding perm
* 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,
static void usage(void)
{
fprintf(stderr,
- "\nusage: %s {mdtname} {uid}\n"
+ "\nusage: %s {-d|mdtname} {uid}\n"
"Normally invoked as an upcall from Lustre, set via:\n"
- "lctl set_param mdt.${mdtname}.identity_upcall={path to upcall}\n",
+ "lctl set_param mdt.${mdtname}.identity_upcall={path to upcall}\n"
+ "\t-d: debug, print values to stdout instead of Lustre\n",
progname);
}
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,
unsigned int ngroups = 0;
int ngroups_tmp;
struct passwd *pw;
- char *pw_name;
- int namelen;
int i;
pw = getpwuid(data->idd_uid);
}
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;
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",
qsort(groups, ngroups, sizeof(*groups), compare_u32);
data->idd_ngroups = ngroups;
- free(pw_name);
free(groups_tmp);
return 0;
}
} perm_type_t;
static perm_type_t perm_types[] = {
- { "setuid", CFS_SETUID_PERM },
- { "setgid", CFS_SETGID_PERM },
- { "setgrp", CFS_SETGRP_PERM },
- { "rmtacl", CFS_RMTACL_PERM },
- { "rmtown", CFS_RMTOWN_PERM },
- { 0 }
+ { "setuid", CFS_SETUID_PERM },
+ { "setgid", CFS_SETGID_PERM },
+ { "setgrp", CFS_SETGRP_PERM },
+ { "rmtacl", 0 },
+ { "rmtown", 0 },
+ { 0 }
};
static perm_type_t noperm_types[] = {
- { "nosetuid", CFS_SETUID_PERM },
- { "nosetgid", CFS_SETGID_PERM },
- { "nosetgrp", CFS_SETGRP_PERM },
- { "normtacl", CFS_RMTACL_PERM },
- { "normtown", CFS_RMTOWN_PERM },
- { 0 }
+ { "nosetuid", CFS_SETUID_PERM },
+ { "nosetgid", CFS_SETGID_PERM },
+ { "nosetgrp", CFS_SETGRP_PERM },
+ { "normtacl", 0 },
+ { "normtown", 0 },
+ { 0 }
};
int parse_perm(__u32 *perm, __u32 *noperm, char *str)
rc = get_perms(data);
downcall:
- if (getenv("L_GETIDENTITY_TEST")) {
- show_result(data);
- rc = 0;
- goto out;
- }
+ if (strcmp(argv[1], "-d") == 0 || getenv("L_GETIDENTITY_TEST")) {
+ show_result(data);
+ rc = 0;
+ goto out;
+ }
rc = cfs_get_param_paths(&path, "mdt/%s/identity_info", argv[1]);
if (rc != 0) {