DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T a

⟦409d198e0⟧ TextFile

    Length: 6314 (0x18aa)
    Types: TextFile
    Names: »auth_logs.c«

Derivation

└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
    └─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z« 
        └─⟦e5a54fb17⟧ 
            └─⟦this⟧ »pp-5.0/Src/submit/auth_logs.c« 

TextFile

/* auth_logs.c: Prints out the authorisation logging info */

# ifndef lint
static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Src/submit/RCS/auth_logs.c,v 5.0 90/09/20 16:22:36 pp Exp Locker: pp $";
# endif

/*
 * $Header: /cs/research/pp/hubris/pp-beta/Src/submit/RCS/auth_logs.c,v 5.0 90/09/20 16:22:36 pp Exp Locker: pp $
 *
 * $Log:	auth_logs.c,v $
 * Revision 5.0  90/09/20  16:22:36  pp
 * rcsforce : 5.0 public release
 * 
 */



#include "util.h"
#include "q.h"
#include <isode/cmd_srch.h>


#define gval(x)                 ((x -> ad_type) == AD_X400_TYPE ? \
                                        (x -> ad_r400adr) : (x -> ad_r822adr))

/* -- externals -- */
extern CMD_TABLE	authtbl_statmsgs[];
extern CHAN             *ch_inbound;
extern ADDR             *ad_originator;
extern ADDR             *ad_recip;
extern char             *msg_unique;
extern char             *mgt_inhost;
extern int		auth_loglev;
extern long             msg_size;


/* -- local routines -- */
void			auth_log();
static int		auth_isdr();
static int		auth_isgood();
static void		gen_auth_logs();
static void		gen_auth_notok();
static void		gen_auth_ok();
static void		gen_auth_stats();
static void		gen_auth_warn();
static void		wr2statfile();
static void		wrdr2statfile();
static void		wrmsg2statfile();




/* -------------------  Begin  Routines  ------------------------------------ */




void auth_log()
{
        ADDR    *ad;

        PP_TRACE (("auth_log()"));

        for (ad = ad_recip; ad; ad = ad->ad_next)
                gen_auth_logs (ad);
}




/* ----------------------------- Logging ------------------------------------ */





static void gen_auth_logs (ad)
ADDR   *ad;
{
	LIST_RCHAN	*lp;
	int		retval = NOTOK;

	PP_TRACE (("gen_auth_logs(%s)", gval(ad)));

	for (lp = ad -> ad_outchan; lp != NULLIST_RCHAN; lp = lp -> li_next)
		if ((retval = auth_isgood (lp)) == OK)
			break; 

	gen_auth_stats (ad, retval);  	
	gen_auth_warn (ad, retval);
}




static void gen_auth_stats (ad, result)
ADDR	*ad;
int     result;
{

	PP_TRACE (("gen_auth_stats '%d' '%s'", result, gval (ad)));

	switch (result) {
	case OK: 
		gen_auth_ok (ad);
		break;
	default:
		gen_auth_notok (ad);
		break;
	}
}




static void gen_auth_ok (ad)
ADDR		*ad;
{
	LIST_RCHAN	*lp = ad -> ad_outchan;

	PP_TRACE (("gen_auth_ok '%s'", gval (ad)));

	switch (auth_loglev) {
	default:
	case AUTH_LOGLEVEL_LOW:
	case AUTH_LOGLEVEL_MEDIUM:
		for (; lp != NULLIST_RCHAN; lp = lp -> li_next)
			if (auth_isgood (lp) == OK) {
				wr2statfile (ad, lp);
				break;
			}
		return;

	case AUTH_LOGLEVEL_HIGH:
		for (; lp != NULLIST_RCHAN; lp = lp -> li_next)
			wr2statfile (ad, lp);
		return;
	}
}





static void gen_auth_notok (ad)
ADDR		*ad;
{
	LIST_RCHAN	*lp = ad -> ad_outchan;

	PP_TRACE (("gen_auth_notok '%s'", gval (ad)));

	switch (auth_loglev) {
	default:
	case AUTH_LOGLEVEL_LOW:
		if (lp != NULLIST_RCHAN)
			wr2statfile (ad, lp);	
		return;

	case AUTH_LOGLEVEL_MEDIUM:
	case AUTH_LOGLEVEL_HIGH:
		for (; lp != NULLIST_RCHAN; lp = lp -> li_next)
			wr2statfile (ad, lp);
		return;
	}
}




static int auth_isgood (lp)
LIST_RCHAN	*lp;
{
	if (lp == NULLIST_RCHAN)
		return FALSE; 

	switch (lp -> li_auth -> status) {
	case AUTH_OK:
	case AUTH_DR_OK:
	case AUTH_FAILED_TEST: 
		return OK;
	default:
		return NOTOK;
	}
}




static int auth_isdr (lp)
LIST_RCHAN	*lp;
{
	if (lp == NULLIST_RCHAN)
		return FALSE; 

	switch (lp -> li_auth -> status) {
	case AUTH_DR_OK:
	case AUTH_DR_FAILED:
		return OK;
	}
	return NOTOK;
}




static void wr2statfile (ad, lp)
ADDR		*ad;
LIST_RCHAN	*lp;
{

	if (auth_isdr (lp) == OK)
		wrdr2statfile (ad, lp);
	else 
		wrmsg2statfile (ad, lp);
}




static void wrmsg2statfile (ad, lp)
ADDR		*ad;
LIST_RCHAN	*lp;
{
	char	sdl, rdl;   /* -- log delimiters -- */
	AUTH	*au = lp -> li_auth;
	char	*cp;

	PP_TRACE (("submit/wrmsg2statfile ('%s')", au -> reason));


	/* -- choose "best" delimitiers for sender and recipient -- */

	if (index (gval (ad_originator), '"') == NULLCP)
		sdl = '"';
	else if (index (gval (ad_originator), '\'') == NULLCP)
		sdl = '\'';
	else
		sdl = '`';


	if (index (gval (ad), '"') == NULL)
		rdl = '"';
	else if (index (gval (ad), '\'') == NULL)
		rdl = '\'';
	else
		rdl = '`';


	cp = rcmd_srch (au -> status, authtbl_statmsgs);

	if (cp == NULLCP)
		cp = rcmd_srch (AUTH_FAILED, authtbl_statmsgs);


	PP_STAT (("%s %s %s -> %s size=%ld sender=%c%s%c \"%s\" recip=%c%s%c \"%s\" \"%s\"",
		cp,
		msg_unique,
		ch_inbound -> ch_name,
		au -> chan -> li_chan -> ch_name,
		msg_size,
		sdl, gval (ad_originator), sdl,
		mgt_inhost,
		rdl, gval (ad), rdl,
		au -> mta -> li_mta,
		au -> reason
		));
}




static void wrdr2statfile (ad, lp)
ADDR		*ad;
LIST_RCHAN	*lp;
{
	char	sdl;   /* -- log delimiters -- */
	AUTH	*au = lp -> li_auth;
	char	*cp;

	PP_TRACE (("submit/wrdr2statfile ('%s')", au -> reason));


	/* -- choose "best" delimitiers for sender and recipient -- */

	if (index (gval (ad_originator), '"') == NULLCP)
		sdl = '"';
	else if (index (gval (ad_originator), '\'') == NULLCP)
		sdl = '\'';
	else
		sdl = '`';


	cp = rcmd_srch (au -> status, authtbl_statmsgs);

	if (cp == NULLCP)
		cp = rcmd_srch (AUTH_DR_FAILED, authtbl_statmsgs);


	PP_STAT (("%s %s %s size=%ld recip=%c%s%c \"%s\"",
		cp,
		msg_unique,
		ch_inbound -> ch_name,
		msg_size,
		sdl, gval (ad_originator), sdl,
		mgt_inhost
		));
}




static void gen_auth_warn (ad, result)
ADDR	*ad;
int     result;
{
	int		found_s = FALSE, 
			found_r = FALSE;
	LIST_RCHAN 	*lp = ad -> ad_outchan;

	/* --- *** ---
	Not implemented yet -  instead generateis PP_OPER
	log messages to indicate what would have happened
	--- *** --- */


	if (result == OK)	return;

	for (; lp != NULLIST_RCHAN; lp = lp -> li_next) {

		if (lp -> li_auth -> chan -> warnsender) {
			if (found_s == FALSE) { 
				PP_OPER (NULLCP, ("%s '%s' %s '%s'",
 					"Warning message to sender",
					gval (ad_originator), 
					"(not generated) : file", 
					lp -> li_auth -> chan -> warnsender));
				found_s = TRUE;
			}
		}			

		if (lp -> li_auth -> chan -> warnrecipient) {
			if (found_r == FALSE) {
				PP_OPER (NULLCP, ("%s '%s' %s '%s'",
 					"Warning message to recipient",
					gval (ad_originator), 
					"(not generated) : file", 
					lp -> li_auth -> chan -> warnsender));
				found_r = TRUE;
			}
		}
	}

}