Branch data Line data Source code
1 : : /* krb5/utils.c --- Kerberos 5 GSS-API helper functions.
2 : : * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Simon Josefsson
3 : : *
4 : : * This file is part of the Generic Security Service (GSS).
5 : : *
6 : : * GSS is free software; you can redistribute it and/or modify it
7 : : * under the terms of the GNU General Public License as published by
8 : : * the Free Software Foundation; either version 3 of the License, or
9 : : * (at your option) any later version.
10 : : *
11 : : * GSS is distributed in the hope that it will be useful, but WITHOUT
12 : : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 : : * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 : : * License for more details.
15 : : *
16 : : * You should have received a copy of the GNU General Public License
17 : : * along with GSS; if not, see http://www.gnu.org/licenses or write to
18 : : * the Free Software Foundation, Inc., 51 Franklin Street, Fifth
19 : : * Floor, Boston, MA 02110-1301, USA.
20 : : *
21 : : */
22 : :
23 : : /* Get specification. */
24 : : #include "k5internal.h"
25 : :
26 : : /* Return number of seconds left of ticket lifetime, or 0 if ticket
27 : : has expired, or GSS_C_INDEFINITE if ticket is NULL. */
28 : : OM_uint32
29 : 1 : gss_krb5_tktlifetime (Shishi_tkt * tkt)
30 : : {
31 : : time_t now, end;
32 : :
33 [ - + ]: 1 : if (!tkt)
34 : 0 : return GSS_C_INDEFINITE;
35 : :
36 [ - + ]: 1 : if (!shishi_tkt_valid_now_p (tkt))
37 : 0 : return 0;
38 : :
39 : 1 : now = time (NULL);
40 : 1 : end = shishi_tkt_endctime (tkt);
41 : :
42 : 1 : return end - now;
43 : : }
|