Add support for -L(logical) and -P(physical) option in nfs4_getfacl.
Subsystems (2)
PATCH 1/1 Add support for -L(logical) and -P(physical) option in nfs4_getfacl.
Signed-off-by Kenneth D'souza <[email protected]>
--- man/man1/nfs4_getfacl.1 | 18 +++++++++++++- nfs4_getfacl/nfs4_getfacl.c | 47 +++++++++++++++++++++++++++++++++---- 2 files changed, 59 insertions(+), 6 deletions(-)
man/man1/nfs4_getfacl.1 +17 -1
@@ -8,7 +8,7 @@ .SH NAME nfs4_getfacl \- get NFSv4 file/directory access control lists .SH SYNOPSIS -.B nfs4_getfacl [-HR] +.B nfs4_getfacl [-HRLP] file ... .SH DESCRIPTION .B nfs4_getfacl
@@ -28,6 +28,22 @@ flag is specified, .B nfs4_getfacl will list the NFSv4 ACLs of all files and directories recursively. +If the +.BR -L / --logical +flag is specified, +.B nfs4_getfacl +will follow symbolic links to directories. The default behavior is to follow +symbolic link arguments, and skip symbolic links encountered in subdirectories. +Only effective in combination with -R. + +If the +.BR -P / --physical +flag is specified, +.B nfs4_getfacl +will not follow symbolic links to directories. This also skips symbolic link +arguments. +Only effective in combination with -R. + The output format for an NFSv4 file ACL, e.g., is: .RS .nf
nfs4_getfacl/nfs4_getfacl.c +42 -5
96 lines not on this page · raw message
Signature · 1 line
2.17.2
Ping ?
Quoted 152 lines · Kenneth D'souza
Signed-off-by Kenneth D'souza <[email protected]>--- man/man1/nfs4_getfacl.1 | 18 +++++++++++++- nfs4_getfacl/nfs4_getfacl.c | 47 +++++++++++++++++++++++++++++++++---- 2 files changed, 59 insertions(+), 6 deletions(-)man/man1/nfs4_getfacl.1 +17
-1@@ -8,7 +8,7 @@ .SH NAME nfs4_getfacl \- get NFSv4 file/directory access control lists .SH SYNOPSIS -.B nfs4_getfacl [-HR] +.B nfs4_getfacl [-HRLP] file ... .SH DESCRIPTION .B nfs4_getfacl@@ -28,6 +28,22 @@ flag is specified, .B nfs4_getfacl will list the NFSv4 ACLs of all files and directories recursively. +If the +.BR -L / --logical +flag is specified, +.B nfs4_getfacl +will follow symbolic links to directories. The default behavior is to follow +symbolic link arguments, and skip symbolic links encountered in subdirectories. +Only effective in combination with -R. + +If the +.BR -P / --physical +flag is specified, +.B nfs4_getfacl +will not follow symbolic links to directories. This also skips symbolic link +arguments. +Only effective in combination with -R. + The output format for an NFSv4 file ACL, e.g., is: .RS .nfnfs4_getfacl/nfs4_getfacl.c +42
-6@@ -46,9 +46,19 @@ static void usage(int);static void more_help ();static char *execname;static void print_acl_from_path (); +static int walk_type =0 ; +static void logical ();static int recursive (const char *fpath,const struct stat *sb,int tflag,struct FTW *ftwbuf) { +if ((tflag ==FTW_SL ) && (walk_type ==2 )) +return 0 ; + +if ((tflag ==FTW_SL ) && (walk_type ==1 )) { +logical (fpath); +return 0 ; + } +print_acl_from_path (fpath);return 0 ; }@@ -56,14 +66,16 @@ static int recursive(const char *fpath, const struct stat *sb, int tflag, structstatic struct option long_options[] = { {"more-help" ,0 ,0 ,'H' }, {"help" ,0 ,0 ,'h' }, - {"recursive" ,0 ,0 ,'R' }, + {"recursive" ,0 ,0 ,'R' }, + {"logical" ,0 ,0 ,'L' }, + {"physical" ,0 ,0 ,'P' }, {NULL ,0 ,0 ,0 , }, };int main (int argc,char **argv) {int opt, res =1 ; -int do_recursive =0 ; +int flag, do_recursive =0 ; execname =basename (argv[0 ]);@@ -73,7 +85,7 @@ int main(int argc, char **argv) goto out; } -while ((opt =getopt_long (argc, argv,"HR?h" , long_options,NULL )) !=-1 ) { +while ((opt =getopt_long (argc, argv,"HR?hLP" , long_options,NULL )) !=-1 ) {switch (opt) {case 'H' :more_help ();@@ -84,6 +96,22 @@ int main(int argc, char **argv) do_recursive =1 ;break ; +case 'L' : +if (walk_type !=0 ) { +fprintf (stderr,"More than one walk type specified\n" ); + goto out; + } + walk_type =1 ;/* Follow all symbolic links */ +break ; + +case 'P' : +if (walk_type !=0 ) { +fprintf (stderr,"More than one walk type specified\n" ); + goto out; + } + walk_type =2 ;/* Skip all symbolic links */ +break ; +default :usage (1 ); res =0 ;@@ -99,7 +127,10 @@ int main(int argc, char **argv)for (; optind < argc; optind++) {if (do_recursive) { -if (nftw (argv[optind], recursive,20 ,0 ) ==-1 ) +if (walk_type ==2 || walk_type ==1 ) + flag =FTW_PHYS ; + +if (nftw (argv[optind], recursive,20 , flag) ==-1 )printf ("Invalid filename: %s\n" , argv[optind]); }else @@ -121,11 +152,17 @@ static void print_acl_from_path(const char *fpath) } } +static void logical (const char *fpath) +{ +if (nftw (fpath, recursive,20 ,0 ) ==-1 ) +printf ("Invalid filename: %s\n" , fpath); +} +static void usage (int label) {if (label)fprintf (stderr,"%s %s -- get NFSv4 file or directory access control lists.\n" , execname,VERSION ); -fprintf (stderr,"Usage: %s [-R] file ...\n -H, --more-help\tdisplay ACL format information\n -?, -h, --help\tdisplay this help text\n -R --recursive\trecurse into subdirectories\n" , execname); +fprintf (stderr,"Usage: %s [-RPL] file ...\n -H, --more-help\tdisplay ACL format information\n -?, -h, --help\tdisplay this help text\n -R, --recursive\trecurse into subdirectories\n -L, --logical\t\tlogical walk, follow symbolic links\n -P, --physical\tphysical walk, do not follow symbolic links\n" , execname); }static void more_help () --2.17.2