#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <sys/types.h>
#include <pkgstrct.h>
#include <locale.h>
#include <libintl.h>
#include <pkglib.h>
#include "install.h"
#include "libinst.h"
#include "libadm.h"
#include "messages.h"
extern int warnflag;
static int finalck_warning(struct cfent *ept, int attrchg, int contchg);
static int finalck_error(struct cfent *ept, int attrchg, int contchg);
int
finalck(struct cfent *ept, int attrchg, int contchg, boolean_t a_warning)
{
int errflg;
if (a_warning) {
errflg = finalck_warning(ept, attrchg, contchg);
} else {
errflg = finalck_error(ept, attrchg, contchg);
}
echoDebug(DBG_FINALCK_EXIT, errflg, ept->ftype,
ept->path ? ept->path : "");
return (errflg);
}
static int
finalck_error(struct cfent *ept, int attrchg, int contchg)
{
int errflg = 0;
echoDebug(DBG_FINALCK_ERROR, attrchg, contchg, ept->ftype,
ept->path ? ept->path : "");
if (attrchg || contchg) {
int n;
n = averify(1, &ept->ftype, ept->path, &ept->ainfo);
echoDebug(DBG_FINALCK_ERROR_AVERIFY, n);
if (n != 0) {
logerr(ERR_FINALCK_ATTR, ept->path);
logerr(getErrbufAddr());
errflg++;
warnflag++;
if (n == VE_EXIST)
return (1);
}
}
if (contchg && strchr("fev", ept->ftype)) {
int n;
if (contchg < 0) {
ept->cinfo.modtime = BADCONT;
ept->cinfo.size = BADCONT;
ept->cinfo.cksum = BADCONT;
}
n = cverify(1, &ept->ftype, ept->path, &ept->cinfo, 1);
echoDebug(DBG_FINALCK_ERROR_CVERIFY, n);
if (n != 0) {
logerr(ERR_FINALCK_CONT, ept->path);
logerr(getErrbufAddr());
errflg++;
warnflag++;
}
}
return (errflg);
}
static int
finalck_warning(struct cfent *ept, int attrchg, int contchg)
{
int errflg = 0;
echoDebug(DBG_FINALCK_WARNING, attrchg, contchg, ept->ftype,
ept->path ? ept->path : "");
if (attrchg || contchg) {
int n;
n = averify(1, &ept->ftype, ept->path, &ept->ainfo);
echoDebug(DBG_FINALCK_WARNING_AVERIFY, n);
if (n != 0) {
logerr(WRN_FINALCK_ATTR, ept->path);
logerr(getErrbufAddr());
errflg++;
if (n == VE_EXIST) {
return (1);
}
}
}
if (contchg && strchr("fev", ept->ftype)) {
int n;
if (contchg < 0) {
ept->cinfo.modtime = BADCONT;
ept->cinfo.size = BADCONT;
ept->cinfo.cksum = BADCONT;
}
n = cverify(1, &ept->ftype, ept->path, &ept->cinfo, 1);
echoDebug(DBG_FINALCK_WARNING_CVERIFY, n);
if (n != 0) {
logerr(WRN_FINALCK_CONT, ept->path);
logerr(getErrbufAddr());
}
errflg++;
}
return (errflg);
}