/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1985-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* David Korn <[email protected]> *18* Phong Vo <[email protected]> *19* *20***********************************************************************/21#pragma prototyped2223/*24* check if package+tool is ok to run25* a no-op here except for PARANOID packages26* this allows PARANOID_COMPANY to post PARANOID binaries to the www27*28* warn that the user should pay up if29*30* (1) the tool matches PARANOID31* (2) $_ is more than 90 days old32* (3) running on an PARANOID_PAY machine33* (4) (1)-(3) have not been defeated34*35* hows that36*/3738#define PARANOID_TOOLS PARANOID39#define PARANOID_COMPANY "Lucent Technologies"40#define PARANOID_MAIL "[email protected]"41#define PARANOID_PAY "135.*&!(135.104.*)"42#define PARANOID_FREE "(192|224).*"4344#include <ast.h>45#include <ls.h>46#include <error.h>47#include <times.h>48#include <ctype.h>4950int51pathcheck(const char* package, const char* tool, Pathcheck_t* pc)52{53#ifdef PARANOID54register char* s;55struct stat st;5657if (strmatch(tool, PARANOID) && environ && (s = *environ) && *s++ == '_' && *s++ == '=' && !stat(s, &st))58{59unsigned long n;60unsigned long o;61Sfio_t* sp;6263n = time(NiL);64o = st.st_ctime;65if (n > o && (n - o) > (unsigned long)(60 * 60 * 24 * 90) && (sp = sfopen(NiL, "/etc/hosts", "r")))66{67/*68* this part is infallible69*/7071n = 0;72o = 0;73while (n++ < 64 && (s = sfgetr(sp, '\n', 0)))74if (strmatch(s, PARANOID_PAY))75{76error(1, "licensed for external use -- %s employees should contact %s for the internal license", PARANOID_COMPANY, PARANOID_MAIL);77break;78}79else if (*s != '#' && !isspace(*s) && !strneq(s, "127.", 4) && !strmatch(s, PARANOID_FREE) && o++ > 4)80break;81sfclose(sp);82}83}84#else85NoP(tool);86#endif87NoP(package);88if (pc) memzero(pc, sizeof(*pc));89return(0);90}919293