X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Fl_getidentity.c;h=ae4c437935e90e59b3653eeddba5704c52e5b561;hb=831972ed6f8db022dc03f2a26e3c783e355fe635;hp=c37057b717fade32030ace477fdec8e5567827ac;hpb=d2d56f38da01001c92a09afc6b52b5acbd9bc13c;p=fs%2Flustre-release.git diff --git a/lustre/utils/l_getidentity.c b/lustre/utils/l_getidentity.c index c37057b..ae4c437 100644 --- a/lustre/utils/l_getidentity.c +++ b/lustre/utils/l_getidentity.c @@ -1,23 +1,37 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * - * Copyright (C) 2004-2006 Cluster File Systems, Inc. + * GPL HEADER START * - * This file is part of Lustre, http://www.lustre.org. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Lustre is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. * - * Lustre is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). * - * You should have received a copy of the GNU General Public License - * along with Lustre; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * 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. + * + * GPL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Use is subject to license terms. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Sun Microsystems, Inc. */ #include @@ -37,19 +51,18 @@ #include #include #include -#include -#define SETXID_PATHNAME "/etc/lustre/setxid.conf" +#define PERM_PATHNAME "/etc/lustre/perm.conf" /* - * setxid permission file format is like this: + * permission file format is like this: * {nid} {uid} {perms} * * '*' nid means any nid * '*' uid means any uid * the valid values for perms are: - * setuid/setgid/setgrp -- enable corresponding perm - * nosetuid/nosetgid/nosetgrp -- disable corresponding perm + * setuid/setgid/setgrp/rmtacl -- enable corresponding perm + * nosetuid/nosetgid/nosetgrp/normtacl -- disable corresponding perm * they can be listed together, seperated 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, @@ -174,27 +187,31 @@ static inline int match_uid(uid_t uid, const char *str) typedef struct { char *name; __u32 bit; -} setxid_perm_type_t; - -static setxid_perm_type_t setxid_perm_types[] = { - { "setuid", LUSTRE_SETUID_PERM }, - { "setgid", LUSTRE_SETGID_PERM }, - { "setgrp", LUSTRE_SETGRP_PERM }, +} 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 } }; -static setxid_perm_type_t setxid_noperm_types[] = { - { "nosetuid", LUSTRE_SETUID_PERM }, - { "nosetgid", LUSTRE_SETGID_PERM }, - { "nosetgrp", LUSTRE_SETGRP_PERM }, +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 } }; -int parse_setxid_perm(__u32 *perm, __u32 *noperm, char *str) +int parse_perm(__u32 *perm, __u32 *noperm, char *str) { char *start, *end; char name[64]; - setxid_perm_type_t *pt; + perm_type_t *pt; *perm = 0; *noperm = 0; @@ -207,7 +224,7 @@ int parse_setxid_perm(__u32 *perm, __u32 *noperm, char *str) if (start >= end) break; strncpy(name, start, end - start); - for (pt = setxid_perm_types; pt->name; pt++) { + for (pt = perm_types; pt->name; pt++) { if (!strcasecmp(name, pt->name)) { *perm |= pt->bit; break; @@ -215,7 +232,7 @@ int parse_setxid_perm(__u32 *perm, __u32 *noperm, char *str) } if (!pt->name) { - for (pt = setxid_noperm_types; pt->name; pt++) { + for (pt = noperm_types; pt->name; pt++) { if (!strcasecmp(name, pt->name)) { *noperm |= pt->bit; break; @@ -233,16 +250,16 @@ int parse_setxid_perm(__u32 *perm, __u32 *noperm, char *str) return 0; } -int parse_setxid_perm_line(struct identity_downcall_data *data, char *line) +int parse_perm_line(struct identity_downcall_data *data, char *line) { char uid_str[256], nid_str[256], perm_str[256]; lnet_nid_t nid; __u32 perm, noperm; int rc, i; - if (data->idd_nperms >= N_SETXID_PERMS_MAX) { - errlog("setxid permission count %d > max %d\n", - data->idd_nperms, N_SETXID_PERMS_MAX); + if (data->idd_nperms >= N_PERMS_MAX) { + errlog("permission count %d > max %d\n", + data->idd_nperms, N_PERMS_MAX); return -1; } @@ -265,7 +282,7 @@ int parse_setxid_perm_line(struct identity_downcall_data *data, char *line) } } - if (parse_setxid_perm(&perm, &noperm, perm_str)) { + if (parse_perm(&perm, &noperm, perm_str)) { errlog("invalid perm %s\n", perm_str); return -1; } @@ -324,7 +341,7 @@ int parse_setxid_perm_line(struct identity_downcall_data *data, char *line) return 0; } -int get_setxid_perms(FILE *fp, struct identity_downcall_data *data) +int get_perms(FILE *fp, struct identity_downcall_data *data) { char line[1024]; @@ -332,7 +349,7 @@ int get_setxid_perms(FILE *fp, struct identity_downcall_data *data) if (comment_line(line)) continue; - if (parse_setxid_perm_line(data, line)) { + if (parse_perm_line(data, line)) { errlog("parse line %s failed!\n", line); return -1; } @@ -355,14 +372,14 @@ static void show_result(struct identity_downcall_data *data) for (i = 0; i < data->idd_ngroups; i++) printf("%s%u", i > 0 ? "," : "", data->idd_groups[i]); printf("\n"); - printf("setxid permissions:\n" + printf("permissions:\n" " nid\t\t\tperm\n"); for (i = 0; i < data->idd_nperms; i++) { - struct setxid_perm_downcall_data *pdd; + struct perm_downcall_data *pdd; pdd = &data->idd_perms[i]; - printf(" %#llx\t0x%x\n", pdd->pdd_nid, pdd->pdd_perm); + printf(" "LPX64"\t0x%x\n", pdd->pdd_nid, pdd->pdd_perm); } printf("\n"); } @@ -406,13 +423,13 @@ int main(int argc, char **argv) goto downcall; /* read permission database */ - perms_fp = fopen(SETXID_PATHNAME, "r"); + perms_fp = fopen(PERM_PATHNAME, "r"); if (perms_fp) { - get_setxid_perms(perms_fp, data); + get_perms(perms_fp, data); fclose(perms_fp); } else if (errno != ENOENT) { errlog("open %s failed: %s\n", - SETXID_PATHNAME, strerror(errno)); + PERM_PATHNAME, strerror(errno)); } downcall: