* getfacl.c (usage): Standardize usage output. Change return type to
static void. (print_version): New function. (longopts): Added longopts for all options. (main): Accommodate new help and version options.
This commit is contained in:
parent
b2f338e9a9
commit
82d178a405
|
@ -1,3 +1,11 @@
|
||||||
|
2002-05-23 Joshua Daniel Franklin <joshuadfranklin@yahoo.com>
|
||||||
|
|
||||||
|
* getfacl.c (usage): Standardize usage output. Change return type to
|
||||||
|
static void.
|
||||||
|
(print_version): New function.
|
||||||
|
(longopts): Added longopts for all options.
|
||||||
|
(main): Accommodate new help and version options.
|
||||||
|
|
||||||
2002-05-22 Joshua Daniel Franklin <joshuadfranklin@yahoo.com>
|
2002-05-22 Joshua Daniel Franklin <joshuadfranklin@yahoo.com>
|
||||||
|
|
||||||
* mount.cc (version) New global variable.
|
* mount.cc (version) New global variable.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* getfacl.c
|
/* getfacl.c
|
||||||
|
|
||||||
Copyright 2000, 2001 Red Hat Inc.
|
Copyright 2000, 2001, 2002 Red Hat Inc.
|
||||||
|
|
||||||
Written by Corinna Vinschen <vinschen@redhat.com>
|
Written by Corinna Vinschen <vinschen@redhat.com>
|
||||||
|
|
||||||
|
@ -20,6 +20,9 @@ details. */
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
static const char version[] = "$Revision$";
|
||||||
|
static char *prog_name;
|
||||||
|
|
||||||
char *
|
char *
|
||||||
permstr (mode_t perm)
|
permstr (mode_t perm)
|
||||||
{
|
{
|
||||||
|
@ -58,68 +61,84 @@ groupname (gid_t gid)
|
||||||
return gbuf;
|
return gbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define pn(txt) fprintf (fp, txt "\n", name)
|
static void
|
||||||
#define p(txt) fprintf (fp, txt "\n")
|
usage (FILE * stream)
|
||||||
|
|
||||||
int
|
|
||||||
usage (const char *name, int help)
|
|
||||||
{
|
{
|
||||||
FILE *fp = help ? stdout : stderr;
|
fprintf (stream, "Usage: %s [-adn] FILE [FILE2...]\n"
|
||||||
|
"Display file and directory access control lists (ACLs).\n"
|
||||||
pn ("usage: %s [-adn] file...");
|
"\n"
|
||||||
if (!help)
|
" -a, --all display the filename, the owner, the group, and\n"
|
||||||
pn ("Try `%s --help' for more information.");
|
" the ACL of the file\n"
|
||||||
else
|
" -d, --dir display the filename, the owner, the group, and\n"
|
||||||
|
" the default ACL of the directory, if it exists\n"
|
||||||
|
" -h, --help output usage information and exit\n"
|
||||||
|
" -n, --noname display user and group IDs instead of names\n"
|
||||||
|
" -v, --version output version information and exit\n"
|
||||||
|
"\n"
|
||||||
|
"When multiple files are specified on the command line, a blank\n"
|
||||||
|
"line separates the ACLs for each file.\n", prog_name);
|
||||||
|
if (stream == stdout)
|
||||||
{
|
{
|
||||||
p ("");
|
fprintf (stream, ""
|
||||||
p ("Display file and directory access control lists (ACLs).");
|
"For each argument that is a regular file, special file or\n"
|
||||||
p ("");
|
"directory, getfacl displays the owner, the group, and the ACL.\n"
|
||||||
p ("For each argument that is a regular file, special file or");
|
"For directories getfacl displays additionally the default ACL.\n"
|
||||||
p ("directory, getfacl displays the owner, the group, and the ACL.");
|
"\n"
|
||||||
p ("For directories getfacl displays additionally the default ACL.");
|
"With no options specified, getfacl displays the filename, the\n"
|
||||||
p ("");
|
"owner, the group, and both the ACL and the default ACL, if it\n"
|
||||||
p ("With no options specified, getfacl displays the filename, the");
|
"exists.\n"
|
||||||
p ("owner, the group, and both the ACL and the default ACL, if it");
|
"\n"
|
||||||
p ("exists.");
|
"The format for ACL output is as follows:\n"
|
||||||
p ("");
|
" # file: filename\n"
|
||||||
p ("The following options are supported:");
|
" # owner: name or uid\n"
|
||||||
p ("");
|
" # group: name or uid\n"
|
||||||
p ("-a Display the filename, the owner, the group, and the ACL");
|
" user::perm\n"
|
||||||
p (" of the file.");
|
" user:name or uid:perm\n"
|
||||||
p ("");
|
" group::perm\n"
|
||||||
p ("-d Display the filename, the owner, the group, and the default");
|
" group:name or gid:perm\n"
|
||||||
p (" ACL of the directory, if it exists.");
|
" mask:perm\n"
|
||||||
p ("");
|
" other:perm\n"
|
||||||
p ("-n Display user and group IDs instead of names.");
|
" default:user::perm\n"
|
||||||
p ("");
|
" default:user:name or uid:perm\n"
|
||||||
p ("The format for ACL output is as follows:");
|
" default:group::perm\n"
|
||||||
p (" # file: filename");
|
" default:group:name or gid:perm\n"
|
||||||
p (" # owner: name or uid");
|
" default:mask:perm\n"
|
||||||
p (" # group: name or uid");
|
" default:other:perm\n"
|
||||||
p (" user::perm");
|
"\n");
|
||||||
p (" user:name or uid:perm");
|
|
||||||
p (" group::perm");
|
|
||||||
p (" group:name or gid:perm");
|
|
||||||
p (" mask:perm");
|
|
||||||
p (" other:perm");
|
|
||||||
p (" default:user::perm");
|
|
||||||
p (" default:user:name or uid:perm");
|
|
||||||
p (" default:group::perm");
|
|
||||||
p (" default:group:name or gid:perm");
|
|
||||||
p (" default:mask:perm");
|
|
||||||
p (" default:other:perm");
|
|
||||||
p ("");
|
|
||||||
p ("When multiple files are specified on the command line, a blank");
|
|
||||||
p ("line separates the ACLs for each file.");
|
|
||||||
}
|
}
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct option longopts[] = {
|
struct option longopts[] = {
|
||||||
|
{"all", no_argument, NULL, 'a'},
|
||||||
|
{"dir", no_argument, NULL, 'd'},
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
|
{"noname", no_argument, NULL, 'n'},
|
||||||
|
{"version", no_argument, NULL, 'v'},
|
||||||
{0, no_argument, NULL, 0}
|
{0, no_argument, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_version ()
|
||||||
|
{
|
||||||
|
const char *v = strchr (version, ':');
|
||||||
|
int len;
|
||||||
|
if (!v)
|
||||||
|
{
|
||||||
|
v = "?";
|
||||||
|
len = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
v += 2;
|
||||||
|
len = strchr (v, ' ') - v;
|
||||||
|
}
|
||||||
|
printf ("\
|
||||||
|
getfacl (cygwin) %.*s\n\
|
||||||
|
ACL Utility\n\
|
||||||
|
Copyright (c) 2000, 2001, 2002 Red Hat, Inc.\n\
|
||||||
|
Compiled on %s", len, v, __DATE__);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
@ -132,7 +151,15 @@ main (int argc, char **argv)
|
||||||
struct stat st;
|
struct stat st;
|
||||||
aclent_t acls[MAX_ACL_ENTRIES];
|
aclent_t acls[MAX_ACL_ENTRIES];
|
||||||
|
|
||||||
while ((c = getopt_long (argc, argv, "adn", longopts, NULL)) != EOF)
|
prog_name = strrchr (argv[0], '/');
|
||||||
|
if (prog_name == NULL)
|
||||||
|
prog_name = strrchr (argv[0], '\\');
|
||||||
|
if (prog_name == NULL)
|
||||||
|
prog_name = argv[0];
|
||||||
|
else
|
||||||
|
prog_name++;
|
||||||
|
|
||||||
|
while ((c = getopt_long (argc, argv, "adhnv", longopts, NULL)) != EOF)
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 'a':
|
case 'a':
|
||||||
|
@ -141,16 +168,24 @@ main (int argc, char **argv)
|
||||||
case 'd':
|
case 'd':
|
||||||
dopt = 1;
|
dopt = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'h':
|
||||||
|
usage (stdout);
|
||||||
|
return 0;
|
||||||
case 'n':
|
case 'n':
|
||||||
nopt = 1;
|
nopt = 1;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'v':
|
||||||
return usage (argv[0], 1);
|
print_version ();
|
||||||
|
return 0;
|
||||||
default:
|
default:
|
||||||
return usage (argv[0], 0);
|
usage (stderr);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
if (optind > argc - 1)
|
if (optind > argc - 1)
|
||||||
return usage (argv[0], 0);
|
{
|
||||||
|
usage (stderr);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
while ((c = optind++) < argc)
|
while ((c = optind++) < argc)
|
||||||
{
|
{
|
||||||
if (stat (argv[c], &st))
|
if (stat (argv[c], &st))
|
||||||
|
|
Loading…
Reference in New Issue