From e5cf14ba043f29b8b81440e6c32cf6f1cc91851c Mon Sep 17 00:00:00 2001 From: Hartmut Reuter Date: Tue, 6 Oct 2009 09:10:45 +0200 Subject: [PATCH] New option '-cmd' for 'fs listacl' prints 'fs setacl' commands necessary to create the current ACLs. This is useful for backup scripts using TSM (or others) to save the ACLs into a file to allow for later restore. Reviewed-on: http://gerrit.openafs.org/556 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/venus/fs.c | 86 +++++++++++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 33 deletions(-) diff --git a/src/venus/fs.c b/src/venus/fs.c index 85f44f7ac..96ce3491d 100644 --- a/src/venus/fs.c +++ b/src/venus/fs.c @@ -1150,42 +1150,61 @@ ListACLCmd(struct cmd_syndesc *as, void *arock) continue; } ta = ParseAcl(space); - switch (ta->dfs) { - case 0: - printf("Access list for %s is\n", ti->data); - break; - case 1: - printf("DFS access list for %s is\n", ti->data); - break; - case 2: - printf("DFS initial directory access list of %s is\n", ti->data); - break; - case 3: - printf("DFS initial file access list of %s is\n", ti->data); - break; - } - if (ta->dfs) { - printf(" Default cell = %s\n", ta->cell); - } - if (ta->nplus > 0) { - if (!ta->dfs) - printf("Normal rights:\n"); - for (te = ta->pluslist; te; te = te->next) { - printf(" %s ", te->name); - PRights(te->rights, ta->dfs); - printf("\n"); + if (as->parms[3].items) { /* -cmd */ + printf("fs setacl -dir %s -acl ", ti->data); + if (ta->nplus > 0) { + for (te = ta->pluslist; te; te = te->next) { + printf(" %s ", te->name); + PRights(te->rights, ta->dfs); + } + } + printf("\n"); + if (ta->nminus > 0) { + printf("fs setacl -dir %s -acl ", ti->data); + for (te = ta->minuslist; te; te = te->next) { + printf(" %s ", te->name); + PRights(te->rights, ta->dfs); + } + printf(" -negative\n"); + } + } else { + switch (ta->dfs) { + case 0: + printf("Access list for %s is\n", ti->data); + break; + case 1: + printf("DFS access list for %s is\n", ti->data); + break; + case 2: + printf("DFS initial directory access list of %s is\n", ti->data); + break; + case 3: + printf("DFS initial file access list of %s is\n", ti->data); + break; } - } - if (ta->nminus > 0) { - printf("Negative rights:\n"); - for (te = ta->minuslist; te; te = te->next) { - printf(" %s ", te->name); - PRights(te->rights, ta->dfs); - printf("\n"); + if (ta->dfs) { + printf(" Default cell = %s\n", ta->cell); + } + if (ta->nplus > 0) { + if (!ta->dfs) + printf("Normal rights:\n"); + for (te = ta->pluslist; te; te = te->next) { + printf(" %s ", te->name); + PRights(te->rights, ta->dfs); + printf("\n"); + } } + if (ta->nminus > 0) { + printf("Negative rights:\n"); + for (te = ta->minuslist; te; te = te->next) { + printf(" %s ", te->name); + PRights(te->rights, ta->dfs); + printf("\n"); + } + } + if (ti->next) + printf("\n"); } - if (ti->next) - printf("\n"); ZapAcl(ta); } return error; @@ -3527,6 +3546,7 @@ main(int argc, char **argv) parm_listacl_id = ts->nParms; cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl"); cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl"); + cmd_AddParm(ts, "-cmd", CMD_FLAG, CMD_OPTIONAL, "output as 'fs setacl' command"); cmd_CreateAlias(ts, "la"); ts = cmd_CreateSyntax("getcalleraccess", GetCallerAccess, NULL, -- 2.39.5