Preventing date rollback

Mike Stefanik/78125 mike at bria.AIX
Mon Dec 31 12:21:28 AEST 1990


In article <RICHARD.90Dec3143525 at dataspan.dataspan.UUCP>, richard at dataspan.dataspan.UUCP (Richard "Tiger" Melville) writes:
> Many of the software products our company sells rely on a licence file which
> specifies the duration of time the software is licensed for.  The software
> then refuses to run when the period has expired.  
[deleted]
> Is there a reliable way to test if the date on a machine has been rolled
> back ?  (System files which have modified dates in the future might do the
> trick.)  As portable a solution as possible is desirable, although we mainly
> run SunOs 4.0.

One method that I have used in the past was to declare a static string with
some unique contents in the code (ie: static char *fubar = "UGGA000000000000")
and then write the code so that it is self-modifying.  I simply had the
program determine from whence it came, opened itself, and searched for that
string.  Obviously the "0000000000" part is the date ala time().  Look at the
current time, and if the current time is less than what was in your magic
cookie, you know they rolled the clock back.  If all is ok, then simply update
that string with the current time.  Just make sure that that you lock the
image when you are doing this.

The above is preferable over using inode information such as access time,
because that can easily be fudged.

Hope that helps.
-----------------------------------------------------------------------------
Michael Stefanik, Systems Engineer (JOAT), Briareus Corporation
UUCP: ...!uunet!bria!mike
"If it was hard to code, it should be harder to use!"



More information about the Comp.unix.programmer mailing list