/*
* 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
*/
/*
*/
/*
* Token processing for sysupd; each token function does one
* or more operations. All of them bump the buffer pointer
* to the next token; some of them extract one or more data
* from the token.
*/
#include <locale.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <toktable.h>
#include "sysplugin.h"
#include <audit_plugin.h>
static void anchor_path(char *);
size_t);
static void skip_bytes(parse_context_t *);
static void skip_string(parse_context_t *);
static int xgeneric(parse_context_t *);
/*
* parse_token - process a token in a record to (1) extract data of interest
* if any and (2) point to the next token.
*
* returns 0 if ok. + or - values are of debug value:
*
* returns -1 if the parsing of the token failed.
*
* returns +<previous id> if the token is not found. This value
* is used to help determine where in the record the problem
* occurred. The common failure case is that the parsing of
* token M is incorrect and the buffer pointer ends up pointing
* to garbage. The positive error value of M *may* be the id of
* the incorrectly parsed token.
*/
int
{
char tokenid;
int rc;
#if DEBUG
if (first) {
first = 0;
}
#endif
return (rc);
}
/* here if token id is not in table */
return (prev_tokenid);
}
/* There should not be any file tokens in the middle of a record */
/* ARGSUSED */
int
{
return (-1);
}
/* ARGSUSED */
int
{
return (-1);
}
static void
{
}
/*
* 32bit header
*/
int
{
return (0);
}
int
{
return (0);
}
int
{
return (0);
}
int
{
return (0);
}
/*
* ======================================================
* The following token processing routines return
* 0: if parsed ok
* -1: can't parse and can't determine location of next token
* ======================================================
*/
int
{
short magic_number;
if (magic_number != AUT_TRAILER_MAGIC)
return (-1);
return (0);
}
/*
* Format of arbitrary data token:
* arbitrary data token id &(ctx->adr) char
* how to print adr_char
* basic unit adr_char
* unit count adr_char, specifying number of units of
* data items depends on basic unit
*
*/
int
{
switch (basic_unit) {
case AUR_CHAR: /* same as AUR_BYTE */
break;
case AUR_SHORT:
break;
case AUR_INT32: /* same as AUR_INT */
break;
case AUR_INT64:
break;
default:
return (-1);
/* NOTREACHED */
break;
}
return (0);
}
/*
* Format of opaque token:
* opaque token id adr_char
* size adr_short
* data adr_char, size times
*
*/
int
{
return (0);
}
/*
* Format of return32 value token:
* return value token id adr_char
* error number adr_char
* return value adr_u_int32
*
*/
int
{
char errnum;
return (0);
}
/*
* Format of return64 value token:
* return value token id adr_char
* error number adr_char
* return value adr_u_int64
*
*/
int
{
char errnum;
return (0);
}
/*
* Format of sequence token:
* sequence token id adr_char
* audit_count int32_t
*
*/
int
{
return (0);
}
/*
* Format of text token:
* text token id adr_char
* text adr_string
*/
int
{
return (-1);
}
len--; /* includes EOS */
return (0);
}
/*
* Format of tid token:
* ip token id adr_char
* terminal type adr_char
* terminal type = AU_IPADR:
* remote port: ushort
* local port: ushort
* IP type: int32 -- AU_IPv4 or AU_IPv6
* address: int32 if IPv4, else 4 * int32
*/
int
{
switch (type) {
default:
return (-1); /* other than IP type is not implemented */
case AU_IPADR:
break;
}
return (0);
}
/*
* Format of ip_addr token:
* ip token id adr_char
* address adr_int32
*
*/
int
{
return (0);
}
/*
* Format of ip_addr_ex token:
* ip token id adr_char
* ip type adr_int32
* ip address adr_u_char*type
*
*/
int
{
return (0);
}
/*
* Format of ip token:
* ip header token id adr_char
* version adr_char
* type of service adr_char
* length adr_short
* id adr_u_short
* offset adr_u_short
* ttl adr_char
* protocol adr_char
* checksum adr_u_short
* source address adr_int32
* destination address adr_int32
*
*/
int
{
return (0);
}
/*
* Format of iport token:
* ip port address token id adr_char
* port address adr_short
*
*/
int
{
return (0);
}
/*
* Format of groups token:
* group token id adr_char
* group list adr_int32, 16 times
*
*/
int
{
return (0);
}
/*
* Format of newgroups token:
* group token id adr_char
* number of groups adr_short
* group list adr_int32, "number" times
*
*/
int
{
short int number;
return (0);
}
/*
* Format of argument32 token:
* argument token id adr_char
* argument number adr_char
* argument value adr_int32
* argument description adr_string
*
*/
int
{
return (0);
}
/*
* Format of argument64 token:
* argument token id adr_char
* argument number adr_char
* argument value adr_int64
* argument description adr_string
*
*/
int
{
return (0);
}
/*
* Format of acl token:
* acl token id adr_char
* type adr_u_int32
* value adr_u_int32
* mode adr_u_int32
*/
int
{
return (0);
}
/*
* Format of ace token:
* ace token id adr_char
* id adr_u_int32
* access_mask adr_u_int32
* flags adr_u_short
* type adr_u_short
*/
int
{
return (0);
}
/*
* Format of attribute token: (old pre SunOS 5.7 format)
* attribute token id adr_char
* mode adr_int32 (printed in octal)
* uid adr_int32
* gid adr_int32
* file system id adr_int32
* node id adr_int32
* device adr_int32
*
*/
int
{
return (0);
}
/*
* Format of attribute32 token:
* attribute token id adr_char
* mode adr_int32 (printed in octal)
* uid adr_int32
* gid adr_int32
* file system id adr_int32
* node id adr_int64
* device adr_int32
*
*/
int
{
return (0);
}
/*
* Format of attribute64 token:
* attribute token id adr_char
* mode adr_int32 (printed in octal)
* uid adr_int32
* gid adr_int32
* file system id adr_int32
* node id adr_int64
* device adr_int64
*
*/
int
{
return (0);
}
/*
* Format of command token:
* attribute token id adr_char
* argc adr_short
* argv len adr_short variable amount of argv len
* argv text argv len and text
* .
* .
* .
* envp count adr_short variable amount of envp len
* envp len adr_short and text
* envp text envp len
* .
* .
* .
*
*/
int
{
short cnt;
short i;
for (i = 0; i < cnt; i++)
for (i = 0; i < cnt; i++)
return (0);
}
/*
* Format of exit token:
* attribute token id adr_char
* return value adr_int32
* errno adr_int32
*
*/
int
{
return (0);
}
/*
* Format of exec_args token:
* attribute token id adr_char
* count value adr_int32
* strings null terminated strings
*
*/
int
{
int count, i;
for (i = 1; i <= count; i++) {
}
return (0);
}
/*
* Format of exec_env token:
* attribute token id adr_char
* count value adr_int32
* strings null terminated strings
*
*/
int
{
int count, i;
for (i = 1; i <= count; i++)
return (0);
}
/*
* Format of liaison token:
*/
int
{
return (0);
}
/*
* Format of path token:
* path adr_string
*/
int
{
0);
return (-1);
/*
* anchor the path because collapse_path needs it
*/
}
return (0);
}
/*
* path attr token / AUT_XATPATH
*
* Format of path attr token:
* token id adr_char
* string count adr_int32
* strings adr_string
*
* the sequence of strings is converted to a single string with
* a blank separator replacing the EOS for all but the last
* string.
*/
int
{
int string_cnt, i;
char *p;
for (i = 0; i < string_cnt; i++) {
while (*p++ != '\0') {
continue;
}
}
return (-1);
}
/* fix up: replace each NUL except the last with ' ' */
for (i = 0; i < (string_cnt-1); i++) {
while (*p++ != '\0') {
continue;
}
*(p - 1) = ' ';
}
return (0);
}
/*
* Format of System V IPC permission token:
* System V IPC permission token id adr_char
* uid adr_int32
* gid adr_int32
* cuid adr_int32
* cgid adr_int32
* mode adr_int32
* seq adr_int32
* key adr_int32
*/
int
{
return (0);
}
static void
{
}
/*
* Format of process32 token:
* process token id adr_char
* auid adr_int32
* euid adr_int32
* egid adr_int32
* ruid adr_int32
* rgid adr_int32
* pid adr_int32
* sid adr_int32
* termid adr_int32*2
*
*/
int
{
return (0);
}
/*
* Format of process32_ex token:
* process token id adr_char
* auid adr_int32
* euid adr_int32
* egid adr_int32
* ruid adr_int32
* rgid adr_int32
* pid adr_int32
* sid adr_int32
* termid
* port adr_int32
* type adr_int32
* ip address adr_u_char*type
*
*/
int
{
return (0);
}
/*
* Format of process64 token:
* process token id adr_char
* auid adr_int32
* euid adr_int32
* egid adr_int32
* ruid adr_int32
* rgid adr_int32
* pid adr_int32
* sid adr_int32
* termid adr_int64+adr_int32
*
*/
int
{
return (0);
}
/*
* Format of process64_ex token:
* process token id adr_char
* auid adr_int32
* euid adr_int32
* egid adr_int32
* ruid adr_int32
* rgid adr_int32
* pid adr_int32
* sid adr_int32
* termid
* port adr_int64
* type adr_int32
* ip address adr_u_char*type
*
*/
int
{
return (0);
}
/*
* Format of System V IPC token:
* System V IPC token id adr_char
* System V IPC type adr_char
* object id adr_int32
*
*/
int
{
return (0);
}
/*
* Format of socket token:
* socket_type adrm_short
* remote_port adrm_short
* remote_inaddr adrm_int32
*
*/
int
{
return (0);
}
/*
* Format of socket_ex token:
* socket_domain adrm_short
* socket_type adrm_short
* address_type adrm_short
* local_port adrm_short
* local_inaddr adrm_u_char*address_type
* remote_port adrm_short
* remote_inaddr adrm_u_char*address_type
*
*/
int
{
short ip_size;
sizeof (short) + (ip_size * sizeof (char));
return (0);
}
static void
{
}
/*
* Format of subject32 token:
* subject token id adr_char
* auid adr_int32
* euid adr_int32
* egid adr_int32
* ruid adr_int32
* rgid adr_int32
* pid adr_int32
* sid adr_int32
* termid adr_int32*2
*
*/
int
{
return (0);
}
/*
* Format of subject32_ex token:
* subject token id adr_char
* auid adr_int32
* euid adr_int32
* egid adr_int32
* ruid adr_int32
* rgid adr_int32
* pid adr_int32
* sid adr_int32
* termid
* port adr_int32
* type adr_int32
* ip address adr_u_char*type
*
*/
int
{
return (0);
}
/*
* Format of subject64 token:
* subject token id adr_char
* auid adr_int32
* euid adr_int32
* egid adr_int32
* ruid adr_int32
* rgid adr_int32
* pid adr_int32
* sid adr_int32
* termid adr_int64+adr_int32
*
*/
int
{
return (0);
}
/*
* Format of subject64_ex token:
* subject token id adr_char
* auid adr_int32
* euid adr_int32
* egid adr_int32
* ruid adr_int32
* rgid adr_int32
* pid adr_int32
* sid adr_int32
* termid
* port adr_int64
* type adr_int32
* ip address adr_u_char*type
*
*/
int
{
return (0);
}
int
{
return (0);
}
int
{
return (0);
}
/*
* anchor a path name with a slash
* assume we have enough space
*/
static void
{
*path = '/';
}
/*
* copy path to collapsed path.
* collapsed path does not contain:
* successive slashes
* instances of dot-slash
* instances of dot-dot-slash
* passed path must be anchored with a '/'
*/
static size_t
{
ls++; /* source length including '\0' */
slashseen = 0;
if (s[is] == '\0') {
--id;
}
s[id++] = '\0';
break;
}
/* previous character was a / */
if (slashseen) {
if (s[is] == '/')
continue; /* another slash, ignore it */
} else if (s[is] == '/') {
/* we see a /, just copy it and try again */
slashseen = 1;
s[id++] = '/';
continue;
}
/* /./ seen */
is += 1;
continue;
}
/* XXX/. seen */
if (id > 1)
id--;
continue;
}
/* XXX/.. seen */
is += 1;
if (id > 0)
id--;
;
id++;
continue;
}
/* XXX/../ seen */
is += 2;
if (id > 0)
id--;
;
id++;
continue;
}
;
is--;
}
}
/*
* for tokens with sub-fields that include a length, this
* skips the sub-field.
*/
static void
{
ushort_t c;
}
static void
{
char c;
do {
} while (c != (char)0);
}
/*
* add a byte to specified length so there can be a prefix of
* '/' added (if needed for paths). Another is added for '\0'
*
* if offset is zero, new data overwrites old, if any. Otherwise
* new data is appended to the end.
*/
static void
{
char *bp;
len++; /* in case need to add '/' prefix */
if (*p == NULL) {
perror("audit_sysudp.so");
return;
}
if (offset > 0)
offset--; /* overwrite end of string */
}
/*
* Format of host token:
* host adr_uint32
*/
int
{
return (0);
}
/*
* Format of useofauth token:
* uauth token id adr_char
* uauth adr_string
*
*/
int
{
return (0);
}
/*
* Format of user token:
* user token id adr_char
* uid adr_uid
* username adr_string
*
*/
int
{
return (0);
}
/*
* Format of zonename token:
* zonename token id adr_char
* zonename adr_string
*
*/
int
{
0);
return (0);
}
/*
* Format of fmri token:
* fmri token id adr_char
* fmri adr_string
*/
int
{
return (0);
}
int
{
}
int
{
}
int
{
}
int
{
}
int
{
}
int
{
}
/*
* Format of xgeneric token:
* XID adr_int32
* creator UID adr_int32
*
* Includes: xcolormap, xcursor, xfont, xgc, xpixmap, and xwindow
*/
static int
{
return (0);
}
/*
* Format of xproperty token:
* XID adr_int32
* creator UID adr_int32
* atom string adr_string
*/
int
{
return (0);
}
/*
* Format of xclient token:
* xclient id adr_int32
*/
int
{
return (0);
}
/*
* -----------------------------------------------------------------------
* privilege_token() : Process privilege token and display contents
*
* Format of privilege token:
* privilege token id adr_char
* privilege type adr_string
* privilege adr_string
* -----------------------------------------------------------------------
*/
int
{
return (0);
}
/*
* Format of label token:
* label ID 1 byte
* compartment length 1 byte
* classification 2 bytes
* compartment words <compartment length> * 4 bytes
*/
int
{
char c;
return (0);
}
/*
* Format of useofpriv token:
* priv_type adr_char
* priv_set_t adr_short
* priv_set adr_char*(sizeof (priv_set_t))
*/
int
{
return (0);
}