Changeset 71


Ignore:
Timestamp:
11/21/08 19:35:31 (3 years ago)
Author:
bruno
Message:

Enforce that expiration date is after current date

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/sshgw/bin/createsshuser

    r70 r71  
    44use strict; 
    55use SSHGWUser; 
     6use Time::localtime qw(localtime); 
     7use Date::Manip; 
    68 
    79my ($username, $groups, $uid, $expire, $fullname, $email, $sshkey, $emailcc) ; 
     
    9698        die "Expiration date format should be YYYY-MM-DD\n" unless $expire =~ /^\d{4}-\d{2}-\d{2}$/ ; 
    9799    } 
     100    my @date = pb_get_date(); 
     101    my $date = strftime("%Y-%m-%d", @date); 
     102    my $flag = Date_Cmp($date,$expire); 
     103    if ($flag >= 0) { 
     104        # expire is earlier 
     105        die "Expiration date ($expire) should be after current date ($date)\n"; 
     106    } 
    98107 
    99108    if (defined $email) { 
     
    113122    return ($username, $fullname, $groups, $expire, $email, $sshkey, $emailcc); 
    114123} 
     124 
     125sub pb_get_date { 
     126    return(localtime->sec(), localtime->min(), localtime->hour(), localtime->mday(), localtime->mon(), localtime->year(), localtime->wday(), localtime->yday(), localtime->isdst()); 
     127} 
Note: See TracChangeset for help on using the changeset viewer.