audit_path.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 1991-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* @(#)audit_path.c 2.7 92/02/16 SMI; SunOS CMW
* @(#)audit_path.c 4.2.1.2 91/05/08 SMI; BSM Module
*
* This code does the audit path processes. Part of this is still in
* audit.c and will be moved here when time permits.
*
* Note that audit debuging is enabled here. We will turn it off at
* beta shipment.
*/
#include <sys/pathname.h>
#include <c2/audit_kernel.h>
#include <c2/audit_record.h>
#include <sys/sysmacros.h>
/*
* allocate a new auditpath
* newsect = increment sections count,
* charincr = change in strings storage
*/
struct audit_path *
{
struct audit_path *newapp;
int i, alloc_size, oldlen;
alloc_size = sizeof (struct audit_path) +
}
/*
* if this is a new section, set its end
* if this is an extended section, reset its end
*/
/* copy all of the old strings */
return (newapp);
}
/*
* increment audit path reference count
*/
void
{
}
/*
* decrement audit path reference count
*/
void
{
return;
}
int
token_t *m;
{
int i;
if (m == (token_t *)0)
return (0);
i += m->len;
return (i);
}
token_t *
{
au_buff_t *m;
uint_t l;
while (size) {
m = au_get_buff();
m->len = l;
if (head)
else
head = m;
tail = m;
size -= l;
cp += l;
}
return (head);
}
token_t *
au_append_token(chain, m)
token_t *m;
{
return (m);
if (m == (token_t *)0)
return (chain);
;
return (chain);
}
void
{
int id; /* index of where we are in destination string */
int is; /* index of where we are in source string */
int cnt; /* # of levels in audit_path */
int slashseen; /* have we seen a slash */
char *s; /* start of top-level string */
char c;
if (is <= 2)
is = 0; /* catch leading // or ./ */
if ((c = s[is]) == '\0') {
/* that's all folks, we've reached the end of input */
/* remove terminating / */
--id;
}
s[id++] = '\0';
break;
}
if (slashseen) {
/* previous character was a / */
if (c == '/') {
/* another slash, ignore it */
continue;
}
} else if (c == '/') {
/* we see a /, just copy it and try again */
slashseen = 1;
s[id++] = c;
continue;
}
if (c == '.') {
/* XXX/. seen */
if (id > 1)
id--;
continue;
}
if (c == '/') {
/* XXX/./ seen */
is += 1;
continue;
}
/* XXX/.. or XXX/../ seen */
is++;
char *s_attr;
/* .. refers to attributed object */
s_attr = s;
id--;
slashseen = 0;
continue;
}
/* backup over previous component */
if (id > 0)
id--;
id--;
continue;
}
}
/* copy component name and terminating /, if any */
for (;;) {
c = s[is++];
if (c == '\0' || c == '/')
break;
s[id++] = c;
}
/* back up to before terminating '\0' or / */
slashseen = 0;
is -= 2;
}
/* fill empty attribute directory reference */
s[0] = '.';
s[1] = '\0';
id = 2;
}
/* correct end pointer */
}