auth/keyfs: use ulong for time

front
cinap_lenrek 2017-01-26 22:09:44 +01:00
parent 8ea917d119
commit c6b2ad583e
2 changed files with 11 additions and 11 deletions

View File

@ -62,7 +62,7 @@ struct User {
int ref; int ref;
char removed; char removed;
uchar warnings; uchar warnings;
long purgatory; /* time purgatory ends */ ulong purgatory; /* time purgatory ends */
ulong uniq; ulong uniq;
User *link; User *link;
}; };
@ -463,9 +463,9 @@ Read(Fid *f)
case Qsecret: case Qsecret:
if(f->user->status != Sok) if(f->user->status != Sok)
return "user disabled"; return "user disabled";
if(f->user->purgatory > time(0)) if(f->user->purgatory > (ulong)time(0))
return "user in purgatory"; return "user in purgatory";
if(f->user->expire != 0 && f->user->expire < time(0)) if(f->user->expire != 0 && f->user->expire < (ulong)time(0))
return "user expired"; return "user expired";
m = 0; m = 0;
switch(f->qtype){ switch(f->qtype){
@ -500,7 +500,7 @@ Read(Fid *f)
thdr.count = n; thdr.count = n;
return 0; return 0;
case Qstatus: case Qstatus:
if(f->user->status == Sok && f->user->expire && f->user->expire < time(0)) if(f->user->status == Sok && f->user->expire && f->user->expire < (ulong)time(0))
sprint(data, "expired\n"); sprint(data, "expired\n");
else else
sprint(data, "%s\n", status[f->user->status]); sprint(data, "%s\n", status[f->user->status]);
@ -592,11 +592,11 @@ Write(Fid *f)
else else
f->user->bad++; f->user->bad++;
if(f->user->bad && ((f->user->bad)%MAXBAD) == 0) if(f->user->bad && ((f->user->bad)%MAXBAD) == 0)
f->user->purgatory = time(0) + f->user->bad; f->user->purgatory = (ulong)time(0) + f->user->bad;
return 0; return 0;
case Qwarnings: case Qwarnings:
data[n] = '\0'; data[n] = '\0';
f->user->warnings = strtoul(data, 0, 10); f->user->warnings = strtoul(data, nil, 10);
thdr.count = n; thdr.count = n;
break; break;
case Qroot: case Qroot:
@ -1033,10 +1033,10 @@ io(int in, int out)
{ {
char *err; char *err;
int n; int n;
long now, lastwarning; ulong now, lastwarning;
/* after restart, let the system settle for 5 mins before warning */ /* after restart, let the system settle for 5 mins before warning */
lastwarning = time(0) - 24*60*60 + 5*60; lastwarning = (ulong)time(0) - 24*60*60 + 5*60;
while((n = read9pmsg(in, mdata, messagesize)) != 0){ while((n = read9pmsg(in, mdata, messagesize)) != 0){
if(n < 0) if(n < 0)
@ -1064,7 +1064,7 @@ io(int in, int out)
error("mount write"); error("mount write");
now = time(0); now = time(0);
if(warnarg && (now - lastwarning > 24*60*60)){ if(warnarg && (long)(now - lastwarning) > 24*60*60){
syslog(0, "auth", "keyfs starting warnings: %lux %lux", syslog(0, "auth", "keyfs starting warnings: %lux %lux",
now, lastwarning); now, lastwarning);
warning(); warning();
@ -1077,7 +1077,7 @@ int
newkeys(void) newkeys(void)
{ {
Dir *d; Dir *d;
static long ftime; static ulong ftime;
d = dirstat(userkeys); d = dirstat(userkeys);
if(d == nil) if(d == nil)

View File

@ -49,7 +49,7 @@ getexpiration(char *db, char *u)
if(buf[0]){ if(buf[0]){
if(strncmp(buf, "never", 5)){ if(strncmp(buf, "never", 5)){
secs = atoi(buf); secs = strtoul(buf, nil, 10);
memmove(&date, localtime(secs), sizeof(date)); memmove(&date, localtime(secs), sizeof(date));
sprint(buf, "%4.4d%2.2d%2.2d", date.year+1900, date.mon+1, date.mday); sprint(buf, "%4.4d%2.2d%2.2d", date.year+1900, date.mon+1, date.mday);
} else } else