/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
%{
#include <aclutils.h>
#include <idmap.h>
#include <errno.h>
#include "acl.tab.h"
#ifdef input
#endif
#ifdef unput
#endif
int grab_string(char *terminators);
static int input();
static void unput(int);
int
yyerror(const char *s)
{
return (0);
}
int
yywrap(void)
{
return (1);
}
extern char *yybuf;
int yybufpos;
/*
* Used for tracking allocated strings while walking through an ACL.
*/
struct yystrings {
char *y_perms; /* permssions from PERM_TOK */
char *y_iflags; /* iflags from INHERIT_TOK */
char *y_idstr; /* string of appened id */
} yystrings;
%}
%e 1500
%p 5000
/*
* TS = type state
* NS = name state
* PS = Permission state
* AIS = Allow/deny/inheritance state
* AS = Allow state (only used when inheritance detected)
* ES = End state
*/
ID [0-9]+
SID S-[^:,\n]+
LOGNAME [^:]+:
INHERIT_STR [fdinFSI-]+
%%
return (ENTRY_TYPE);
}
return (ENTRY_TYPE);
}
return (ENTRY_TYPE);
}
return (ENTRY_TYPE);
}
return (ENTRY_TYPE);
}
return (ENTRY_TYPE);
}
return (ENTRY_TYPE);
}
return (ENTRY_TYPE);
}
return (ENTRY_TYPE);
}
return (ENTRY_TYPE);
}
return (ENTRY_TYPE);
}
return (ENTRY_TYPE);
}
<TS>defaultuser: {
return (ENTRY_TYPE);
}
return (ENTRY_TYPE);
}
<TS>defaultgroup: {
return (ENTRY_TYPE);
}
return (ENTRY_TYPE);
}
<TS>defaultother: {
return (ENTRY_TYPE);
}
<TS>defaultother:: {
return (ENTRY_TYPE);
}
return (ENTRY_TYPE);
}
<TS>defaultmask: {
return (ENTRY_TYPE);
}
<TS>defaultmask:: {
return (ENTRY_TYPE);
}
return (ENTRY_TYPE);
}
<TS>"\n" {
return (NL);
}
<TS>. {
if (grab_string(":,\n") != 0) {
"Failed to retrieve"
" error string.\n"));
return (ERROR);
}
"Invalid ACL entry "
return (ERROR);
}
<NS>: {
return (COLON);
}
return (ERROR);
}
return (IDNAME);
}
<NS>"\n" {
" from ACL specification.\n"));
return (ERROR);
}
<NS>. {
int error;
if (error != 0) {
"name specification.\n"));
} else {
"'%s' not specified correctly.\n"),
}
return (ERROR);
}
return (ACE_PERM);
}
<PS>list_directory/[:/,] {
return (ACE_PERM);
}
<PS>write_data/[:/,] {
return (ACE_PERM);
}
return (ACE_PERM);
}
<PS>append_data/[:/,] {
return (ACE_PERM);
}
<PS>add_subdirectory/[:/,] {
return (ACE_PERM);
}
<PS>read_xattr/[:/,] {
return (ACE_PERM);
}
<PS>write_xattr/[:/,] {
return (ACE_PERM);
}
return (ACE_PERM);
}
<PS>delete_child/[:/,] {
return (ACE_PERM);
}
<PS>read_attributes/[:/,] {
return (ACE_PERM);
}
<PS>write_attributes/[:/,] {
return (ACE_PERM);
}
return (ACE_PERM);
}
return (ACE_PERM);
}
return (ACE_PERM);
}
<PS>write_owner/[:/,] {
return (ACE_PERM);
}
<PS>synchronize/[:/,] {
return (ACE_PERM);
}
return (ACE_PERM);
}
return (ACE_PERM);
}
<PS>modify_set/[:/,] {
return (ACE_PERM);
}
return (ACE_PERM);
}
int c;
c = input();
unput(c);
return (ERROR);
}
/*
* aclent are done after permissions.
*/
if (isdigit(c))
else if (c != ':')
return (PERM_TOK);
}
<PS>"/:" {
"Invalid permission /: specified.\n"));
return (ERROR);
}
<PS>: {
int c;
c = input();
unput(c);
if (isdigit(c))
else
return (COLON);
}
<PS>"/" {
return (SLASH);
}
<PS>"\n" {
"ACL entry is missing "
"permission fields.\n"));
return (ERROR);
}
<PS>"," {
"The ',' is not a valid permission field "
"separator.\nThe comma is used to separate "
"access control entries.\nSee acl(5) for "
"examples of specifying ACL entries.\n"));
return (ERROR);
}
<PS>. {
if (grab_string("/:,\n") != 0) {
"Failed to retrieve"
" error string.\n"));
return (ERROR);
}
"Invalid permission(s) '%s' "
return (ERROR);
}
int c;
c = input();
unput(c);
if (c == ',' || c == '\n')
else
return (ACCESS_TYPE);
}
int c;
c = input();
unput(c);
if (c == ',' || c == '\n')
else
return (ACCESS_TYPE);
}
int c;
c = input();
unput(c);
if (c == ',' || c == '\n')
else
return (ACCESS_TYPE);
}
int c;
c = input();
unput(c);
if (c == ',' || c == '\n')
else
return (ACCESS_TYPE);
}
<AS>: {
"Invalid Access type "
"specified.\nThe field is blank, when"
" it should be either allow or deny.\n"));
return (ERROR);
}
<AS>"\n" {
"ACL access type must be specified.\n"));
return (ERROR);
}
<AS>. {
if (grab_string(":,\n") != 0) {
"Failed to "
"retrieve error "
"string.\n"));
return (ERROR);
}
"Invalid access "
"type '%s' specified.\n"),
} else {
"No access "
}
return (ERROR);
}
int c;
c = input();
unput(c);
if (c == ',' || c == '\n')
else
return (ACCESS_TYPE);
}
int c;
c = input();
unput(c);
if (c == ',' || c == '\n')
else
return (ACCESS_TYPE);
}
int c;
c = input();
unput(c);
if (c == ',' || c == '\n')
else
return (ACCESS_TYPE);
}
int c;
c = input();
unput(c);
if (c == ',' || c == '\n')
else
return (ACCESS_TYPE);
}
<AIS>file_inherit/[:/,] {
return (ACE_INHERIT);
}
<AIS>dir_inherit/[:/,] {
return (ACE_INHERIT);
}
<AIS>no_propagate/[/:,] {
return (ACE_INHERIT);
}
<AIS>inherit_only/[/:,] {
return (ACE_INHERIT);
}
<AIS>successful_access/[/:,] {
return (ACE_INHERIT);
}
<AIS>failed_access/[/:,] {
return (ACE_INHERIT);
}
return (ACE_INHERIT);
}
<AIS>{INHERIT_STR}/[:] {
return (ERROR);
}
return (INHERIT_TOK);
}
<AIS>: {
/*
* Only inheritance fields should hit this.
* of the regexp.
*/
return (COLON);
}
<AIS>"/" {
return (SLASH);
}
<AIS>"\n" {
"Invalid ACL specification."
"\nWas expecting to find"
" access type or inheritance flags.\n"),
return (ERROR);
}
<AIS>"," {
"The ',' is not a valid inheritance field "
"separator.\nThe comma is used to separate "
"access control entries.\nSee acl(5) for "
"examples of specifying ACL entries.\n"));
return (ERROR);
}
<AIS>. {
if (grab_string(":,\n") != 0) {
"Failed to "
"retrieve error "
"string.\n"));
return (ERROR);
}
"Invalid inheritance or"
" access type '%s' specified.\n"),
} else {
"No inheritance or "
"access type specified.\n"),
}
return (ERROR);
}
return (ERROR);
}
return (ID);
}
return (ERROR);
}
return (SID);
}
<US>: {
return (COLON);
}
* Catch specific error to produce
* nice message for users who are trying
* to use old syntax format which had
* inheritance flags as the last field.
*/
"Access type should be final"
" field in ACL specification.\n"));
return (ERROR);
}
<US>. {
if (grab_string(",\n") != 0) {
"Failed to retrieve"
" error string.\n"));
return (ERROR);
}
"Invalid data ':%s' specified"
return (ERROR);
}
<US>"\n" {
"Missing fields in ACL "
"specification.\nWas expecting to find "
return (ERROR);
}
<ES>"," {
return (COMMA);
}
<ES>. {
if (grab_string("/:,\n") != 0) {
"Failed to retrieve error"
" string.\n"));
return (ERROR);
}
"Unrecognized data '%s' found"
return (ERROR);
}
<ES>"\n" {
return (NL);
}
%%
/*
* Pull string up to terminator off of input string.
* used for retrieving illegal data in ACL specification.
*
* The first set of characters is retrieved from yytext.
* subsequent characters are pulled from the input stream,
* until either EOF or one of the requested terminators is scene.
* Result is returned in yylval.str which is malloced.
*/
int
grab_string(char *terminators)
{
int c;
int done = 0;
int cnt;
int alloced;
int error = 0;
char *ptr;
return (1);
}
do {
c = input();
if (c == EOF)
break;
if (c == *ptr) {
done = 1;
break;
}
}
if (done)
break;
alloced + 80);
alloced += 80;
return (1);
}
cnt++;
} while (!done);
return (error);
}
static int
input(void)
{
int c;
if (c == '\0') {
return (EOF);
}
return (c);
}
static void
unput(int c)
{
if (c == '\0') {
return;
}
if (yybufpos > 0) {
--yybufpos;
}
}
/*
* return ACE entry type
*/
int
ace_entry_type(int type)
{
int ret = -1;
switch (type) {
case USER_TOK:
case USER_SID_TOK:
ret = 0;
break;
case GROUP_TOK:
case GROUP_SID_TOK:
break;
case OWNERAT_TOK:
break;
case GROUPAT_TOK:
break;
case EVERYONEAT_TOK:
ret = ACE_EVERYONE;
break;
}
return (ret);
}
/*
* return aclent entry type
*/
int
{
*ret = 0;
switch (type) {
case USER_TOK:
break;
case GROUP_TOK:
break;
case OTHER_TOK:
break;
case MASK_TOK:
break;
case DEFAULT_USER_TOK:
break;
case DEFAULT_GROUP_TOK:
break;
case DEFAULT_MASK_TOK:
*ret = DEF_CLASS_OBJ;
break;
case DEFAULT_OTHER_TOK:
*ret = DEF_OTHER_OBJ;
break;
default:
return (EACL_ENTRY_ERROR);
}
return (0);
}
/*
* convert string into numeric id.
*/
static int
{
char *end;
errno = 0;
return (EACL_INVALID_USER_GROUP);
return (0);
}
/*
*/
int
{
int error = 0;
switch (entry_type) {
case USER_TOK:
case DEFAULT_USER_TOK:
break;
if (pw) {
error = 0;
}
break;
case GROUP_TOK:
case DEFAULT_GROUP_TOK:
break;
if (gr) {
error = 0;
}
break;
case USER_SID_TOK:
break;
case GROUP_SID_TOK:
break;
}
return (error);
}
int
{
return (UID_NOBODY);
else
return (id);
}
/*
* reset beginning state to TS and set character position
* back to zero.
*/
void
yyreset()
{
yybufpos = 0;
}
void
{
}