/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* apply file permission expression expr to perm
*
* each expression term must match
*
* [ugoa]*[-&+|^=]?[rwxst0-7]*
*
* terms may be combined using ,
*
* if non-null, e points to the first unrecognized char in expr
*/
#include <ast.h>
#include <ls.h>
#include <modex.h>
int
{
register int c;
register int typ;
register int who;
int num;
int op;
int mask;
int masked;
if (perm == -1)
{
perm = 0;
masked = 1;
mask = ~0;
}
else
masked = 0;
for (;;)
{
for (;;)
{
switch (c = *expr++)
{
case 'u':
continue;
case 'g':
continue;
case 'o':
continue;
case 'a':
continue;
default:
if (c >= '0' && c <= '7')
{
if (!who)
c = '=';
}
expr--;
/*FALLTHROUGH*/
case '=':
if (who)
else
perm = 0;
/*FALLTHROUGH*/
case '+':
case '|':
case '-':
case '&':
case '^':
op = c;
for (;;)
{
switch (c = *expr++)
{
case 'r':
continue;
case 'w':
continue;
case 'X':
continue;
/*FALLTHROUGH*/
case 'x':
continue;
case 's':
continue;
case 't':
continue;
case 'l':
{
if (e)
*e = expr - 1;
}
continue;
case '=':
case '+':
case '|':
case '-':
case '&':
case '^':
case ',':
case 0:
if (who)
else
switch (op)
{
case '=':
case '+':
case '|':
case '-':
case '&':
if (!masked)
{
masked = 1;
}
break;
}
switch (op)
{
default:
if (who)
else
perm = 0;
/*FALLTHROUGH*/
case '+':
case '|':
typ = 0;
break;
case '-':
typ = 0;
break;
case '&':
typ = 0;
break;
case '^':
{
/*
* propagate least restrictive to most restrictive
*/
/*
* if any execute then read => execute
*/
{
}
typ = 0;
}
break;
}
switch (c)
{
case '=':
case '+':
case '|':
case '-':
case '&':
case '^':
op = c;
typ = 0;
continue;
}
if (c)
break;
/*FALLTHROUGH*/
default:
if (c < '0' || c > '7')
{
if (e)
*e = expr - 1;
if (typ)
{
if (who)
{
}
}
}
{
num = 0;
}
continue;
}
break;
}
break;
}
break;
}
}
}