/*
* 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
*/
/*
*/
#include <assert.h>
#include <libintl.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <strings.h>
#include <unistd.h>
#include <errno.h>
#include <exacct.h>
#include <fcntl.h>
#include <priv.h>
#include "utils.h"
static char *pname;
/*PRINTFLIKE1*/
void
{
}
/*PRINTFLIKE1*/
void
{
/* close the libdladm handle if it was opened */
if (dld_handle != NULL)
}
char *
{
if (p == NULL)
p = arg0;
else
p++;
pname = p;
return (pname);
}
/*
* Return the localized name of an accounting type.
*/
const char *
{
switch (type) {
case AC_PROC:
return (gettext("process"));
case AC_FLOW:
return (gettext("flow"));
case AC_TASK:
return (gettext("task"));
case AC_NET:
return (gettext("net"));
default:
}
/* NOTREACHED */
return (NULL);
}
/*
* Open an accounting file. The filename specified must be an absolute
* pathname and the existing contents of the file (if any) must be of the
* requested type. Needs euid 0 to open the root-owned accounting file.
* file_dac_write is required to create a new file in a directory not owned
* already asserted by caller.
*/
int
{
int rc;
int err;
if (file[0] != '/') {
return (-1);
}
ac_type_name(type));
return (-1);
}
return (-1);
}
/*
* The file is already open as an accounting file somewhere.
* If the file we're trying to open is the same as we have
* currently open then we're ok.
*/
rc = 0;
}
/*
* euid 0, egid 0 and the file_dac_write privilege are no longer
* required; give them up permanently.
*/
if (rc == 0)
return (0);
return (-1);
}
/*
* Verify that the file contents (if any) are extended accounting records
* of the desired type.
*/
{
int err;
if (seteuid(0) == -1)
return (B_FALSE);
if (err == -1)
return (B_FALSE);
/*
* EXR_EOF indicates there are no non-header objects
* in the file. It can't be determined that this
* file is or is not the proper type of extended
* accounting file, which isn't necessarily an error.
* Since it is a proper (albeit empty) extended
* accounting file, it matches any desired type.
*
* if ea_previous_object() failed for any other reason
* than EXR_EOF, the file must be corrupt.
*/
return (B_FALSE);
}
} else {
/*
* A non-header object exists. Insist that it be
* either a process, task, flow or net accounting
* record, the same type as is desired.
* xxx-venu:check 101 merge for EXD_GROUP_NET_*
*/
(c == EXD_GROUP_NET_LINK_DESC ||
c == EXD_GROUP_NET_FLOW_DESC ||
c == EXD_GROUP_NET_LINK_STATS ||
c == EXD_GROUP_NET_FLOW_STATS) &&
return (B_FALSE);
}
}
}
return (B_TRUE);
}