1 /* krb5/utils.c --- Kerberos 5 GSS-API helper functions.
2 * Copyright (C) 2003-2014 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
gss_krb5_tktlifetime(Shishi_tkt * tkt)29 gss_krb5_tktlifetime (Shishi_tkt * tkt)
30 {
31 time_t now, end;
32
33 if (!tkt)
34 return GSS_C_INDEFINITE;
35
36 if (!shishi_tkt_valid_now_p (tkt))
37 return 0;
38
39 now = time (NULL);
40 end = shishi_tkt_endctime (tkt);
41
42 return end - now;
43 }
44