From d385685a92668241d8c802f33f2e5497d9a7ea5a Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Fri, 12 Aug 2016 16:43:33 +0800 Subject: [PATCH] LU-8813 utils: l_getidentity compatibility Allow the new l_getidentity tool to parse old perm.conf which may contains old 'rmtacl', 'rmtown'. These configurations are obsolete, will be ignored directly, not error. This patch also introduces new '-d' option to debug l_getidentity. Signed-off-by: Fan Yong Change-Id: Id0c54d0c24f551e93af80a0ab461870aa5037f84 Reviewed-on: http://review.whamcloud.com/23667 Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Andrew Perepechko Reviewed-by: Oleg Drokin --- lustre/utils/l_getidentity.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/lustre/utils/l_getidentity.c b/lustre/utils/l_getidentity.c index 6d09231..11cc89d 100644 --- a/lustre/utils/l_getidentity.c +++ b/lustre/utils/l_getidentity.c @@ -60,8 +60,8 @@ * '*' 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, @@ -73,9 +73,10 @@ static char *progname; 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); } @@ -196,17 +197,21 @@ typedef struct { } perm_type_t; static perm_type_t perm_types[] = { - { "setuid", CFS_SETUID_PERM }, - { "setgid", CFS_SETGID_PERM }, - { "setgrp", CFS_SETGRP_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 }, - { 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) @@ -461,11 +466,11 @@ int main(int argc, char **argv) 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) { -- 1.8.3.1