/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#ifndef lint
#endif
/*
* getfacl [-ad] file ...
* This command displays discretionary information for a file or files.
* display format:
* # file: filename
* # owner: uid
* # group: gid
* user::perm
* user:uid:perm
* group::perm
* group:gid:perm
* mask:perm
* other:perm
* default:user::perm
* default:user:uid:perm
* default:group::perm
* default:group:gid:perm
* default:mask:perm
* default:other:perm
*/
#include <stdlib.h>
#include <stdio.h>
#include <pwd.h>
#include <grp.h>
#include <locale.h>
#include <errno.h>
static char *display(int);
static void usage();
int
{
int c;
int aflag = 0;
int dflag = 0;
int errflag = 0;
int savecnt;
int aclcnt;
int mask;
char *permp;
(void) textdomain(TEXT_DOMAIN);
if (argc < 2)
usage();
switch (c) {
case 'a':
aflag++;
break;
case 'd':
dflag++;
break;
case '?':
errflag++;
break;
}
}
if (errflag)
usage();
usage();
register char *filep;
/* Get ACL info of the files */
errno = 0;
gettext("File system doesn't support "
"aclent_t style ACL's.\n"
"See acl(5) for more information on "
"Solaris ACL support.\n"));
exit(2);
}
exit(2);
}
if (aclcnt < MIN_ACL_ENTRIES) {
gettext("%d: acl count too small from %s\n"),
exit(2);
}
== NULL) {
gettext("Insufficient memory\n"));
exit(1);
}
errno = 0;
exit(2);
}
/* display ACL: assume it is sorted. */
(void) printf("# owner: %s\n",
(void) printf("# group: %s\n",
}
case USER:
if (!dflag) {
(void) printf("user:%s:%s\t\t",
(void) printf(
"#effective:%s\n", permp);
}
break;
case USER_OBJ:
if (!dflag) {
/* no need to display uid */
}
break;
case GROUP:
if (!dflag) {
(void) printf("group:%s:%s\t\t",
(void) printf(
"#effective:%s\n", permp);
}
break;
case GROUP_OBJ:
if (!dflag) {
(void) printf(
"#effective:%s\n", permp);
}
break;
case CLASS_OBJ:
if (!dflag) {
}
break;
case OTHER_OBJ:
if (!dflag) {
}
break;
case DEF_USER:
if (!aflag) {
(void) printf("default:user:%s:%s\n",
}
break;
case DEF_USER_OBJ:
if (!aflag) {
(void) printf("default:user::%s\n",
permp);
}
break;
case DEF_GROUP:
if (!aflag) {
(void) printf("default:group:%s:%s\n",
}
break;
case DEF_GROUP_OBJ:
if (!aflag) {
(void) printf("default:group::%s\n",
permp);
}
break;
case DEF_CLASS_OBJ:
if (!aflag) {
(void) printf("default:mask:%s\n",
permp);
}
break;
case DEF_OTHER_OBJ:
if (!aflag) {
(void) printf("default:other:%s\n",
permp);
}
break;
default:
gettext("unrecognized entry\n"));
break;
}
}
}
return (0);
}
static char *
{
char *buf;
exit(1);
}
if (perm & 4)
buf[0] = 'r';
else
buf[0] = '-';
if (perm & 2)
else
if (perm & 1)
else
return (buf);
}
static char *
{
/* could not get passwd information: display uid instead */
return (uidp);
} else
}
static char *
{
/* could not get group information: display gid instead */
return (gidp);
} else
}
static void
usage()
{
gettext("usage: getfacl [-ad] file ... \n"));
exit(1);
}