1N/A/***********************************************************************
1N/A* *
1N/A* This software is part of the ast package *
1N/A* Copyright (c) 1985-2011 AT&T Intellectual Property *
1N/A* and is licensed under the *
1N/A* Common Public License, Version 1.0 *
1N/A* by AT&T Intellectual Property *
1N/A* *
1N/A* A copy of the License is available at *
1N/A* http://www.opensource.org/licenses/cpl1.0.txt *
1N/A* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
1N/A* *
1N/A* Information and Software Systems Research *
1N/A* AT&T Research *
1N/A* Florham Park NJ *
1N/A* *
1N/A* Glenn Fowler <gsf@research.att.com> *
1N/A* David Korn <dgk@research.att.com> *
1N/A* Phong Vo <kpv@research.att.com> *
1N/A* *
1N/A***********************************************************************/
1N/A#pragma prototyped
1N/A
1N/A/*
1N/A * check if package+tool is ok to run
1N/A * a no-op here except for PARANOID packages
1N/A * this allows PARANOID_COMPANY to post PARANOID binaries to the www
1N/A *
1N/A * warn that the user should pay up if
1N/A *
1N/A * (1) the tool matches PARANOID
1N/A * (2) $_ is more than 90 days old
1N/A * (3) running on an PARANOID_PAY machine
1N/A * (4) (1)-(3) have not been defeated
1N/A *
1N/A * hows that
1N/A */
1N/A
1N/A#define PARANOID_TOOLS PARANOID
1N/A#define PARANOID_COMPANY "Lucent Technologies"
1N/A#define PARANOID_MAIL "stc@lucent.com"
1N/A#define PARANOID_PAY "135.*&!(135.104.*)"
1N/A#define PARANOID_FREE "(192|224).*"
1N/A
1N/A#include <ast.h>
1N/A#include <ls.h>
1N/A#include <error.h>
1N/A#include <times.h>
1N/A#include <ctype.h>
1N/A
1N/Aint
1N/Apathcheck(const char* package, const char* tool, Pathcheck_t* pc)
1N/A{
1N/A#ifdef PARANOID
1N/A register char* s;
1N/A struct stat st;
1N/A
1N/A if (strmatch(tool, PARANOID) && environ && (s = *environ) && *s++ == '_' && *s++ == '=' && !stat(s, &st))
1N/A {
1N/A unsigned long n;
1N/A unsigned long o;
1N/A Sfio_t* sp;
1N/A
1N/A n = time(NiL);
1N/A o = st.st_ctime;
1N/A if (n > o && (n - o) > (unsigned long)(60 * 60 * 24 * 90) && (sp = sfopen(NiL, "/etc/hosts", "r")))
1N/A {
1N/A /*
1N/A * this part is infallible
1N/A */
1N/A
1N/A n = 0;
1N/A o = 0;
1N/A while (n++ < 64 && (s = sfgetr(sp, '\n', 0)))
1N/A if (strmatch(s, PARANOID_PAY))
1N/A {
1N/A error(1, "licensed for external use -- %s employees should contact %s for the internal license", PARANOID_COMPANY, PARANOID_MAIL);
1N/A break;
1N/A }
1N/A else if (*s != '#' && !isspace(*s) && !strneq(s, "127.", 4) && !strmatch(s, PARANOID_FREE) && o++ > 4)
1N/A break;
1N/A sfclose(sp);
1N/A }
1N/A }
1N/A#else
1N/A NoP(tool);
1N/A#endif
1N/A NoP(package);
1N/A if (pc) memzero(pc, sizeof(*pc));
1N/A return(0);
1N/A}