45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek/*
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek SSSD
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek Kerberos 5 Backend Module -- ccache related utilities
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek Authors:
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek Sumit Bose <sbose@redhat.com>
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek Jakub Hrozek <jhrozek@redhat.com>
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek Copyright (C) 2014 Red Hat
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek This program is free software; you can redistribute it and/or modify
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek it under the terms of the GNU General Public License as published by
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek the Free Software Foundation; either version 3 of the License, or
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek (at your option) any later version.
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek This program is distributed in the hope that it will be useful,
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek but WITHOUT ANY WARRANTY; without even the implied warranty of
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek GNU General Public License for more details.
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek You should have received a copy of the GNU General Public License
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek along with this program. If not, see <http://www.gnu.org/licenses/>.
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek*/
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek#ifndef __KRB5_CCACHE_H__
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek#define __KRB5_CCACHE_H__
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek#include "util/util.h"
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozekstruct tgt_times {
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek time_t authtime;
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek time_t starttime;
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek time_t endtime;
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek time_t renew_till;
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek};
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek
7c5cd2e7711621af9163a41393e88896a91ac33bJakub Hrozekerrno_t sss_krb5_precreate_ccache(const char *ccname, uid_t uid, gid_t gid);
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozekerrno_t sss_krb5_cc_destroy(const char *ccname, uid_t uid, gid_t gid);
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek
2745b0156f12df7a7eb93d57716233243658e4d9Jakub Hrozekerrno_t sss_krb5_check_ccache_princ(krb5_context kctx,
2745b0156f12df7a7eb93d57716233243658e4d9Jakub Hrozek const char *ccname,
2745b0156f12df7a7eb93d57716233243658e4d9Jakub Hrozek krb5_principal user_princ);
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozekerrno_t sss_krb5_cc_verify_ccache(const char *ccname, uid_t uid, gid_t gid,
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek const char *realm, const char *principal);
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozekerrno_t get_ccache_file_data(const char *ccache_file, const char *client_name,
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek struct tgt_times *tgtt);
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozekerrno_t safe_remove_old_ccache_file(const char *old_ccache,
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek const char *new_ccache,
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek uid_t uid, gid_t gid);
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek
802385896dc1c4e7b8bbd40dcfe3cd131f68e696Sumit Bose/**
802385896dc1c4e7b8bbd40dcfe3cd131f68e696Sumit Bose * @brief Copy given ccache into a MEMORY ccache
802385896dc1c4e7b8bbd40dcfe3cd131f68e696Sumit Bose *
802385896dc1c4e7b8bbd40dcfe3cd131f68e696Sumit Bose * @param[in] mem_ctx Talloc memory context the new ccache name should be
802385896dc1c4e7b8bbd40dcfe3cd131f68e696Sumit Bose * allocated on
802385896dc1c4e7b8bbd40dcfe3cd131f68e696Sumit Bose * @param[in] kctx Kerberos context
802385896dc1c4e7b8bbd40dcfe3cd131f68e696Sumit Bose * @param[in] ccache_file Name of existing ccache
802385896dc1c4e7b8bbd40dcfe3cd131f68e696Sumit Bose * @param[out] _mem_name Name of the new MEMORY ccache
802385896dc1c4e7b8bbd40dcfe3cd131f68e696Sumit Bose *
802385896dc1c4e7b8bbd40dcfe3cd131f68e696Sumit Bose * In contrast to MEMORY keytabs MEMORY ccaches can and must be removed
802385896dc1c4e7b8bbd40dcfe3cd131f68e696Sumit Bose * explicitly with krb5_cc_destroy() from the memory. Just calling
802385896dc1c4e7b8bbd40dcfe3cd131f68e696Sumit Bose * krb5_cc_close() will keep the MEMORY ccache in memory even if there are no
802385896dc1c4e7b8bbd40dcfe3cd131f68e696Sumit Bose * open handles for the given MEMORY ccache.
802385896dc1c4e7b8bbd40dcfe3cd131f68e696Sumit Bose */
802385896dc1c4e7b8bbd40dcfe3cd131f68e696Sumit Bosekrb5_error_code copy_ccache_into_memory(TALLOC_CTX *mem_ctx, krb5_context kctx,
802385896dc1c4e7b8bbd40dcfe3cd131f68e696Sumit Bose const char *ccache_file,
802385896dc1c4e7b8bbd40dcfe3cd131f68e696Sumit Bose char **_mem_name);
45aeb924ec3ac448bb8d174a5cc061ed98b147c7Jakub Hrozek#endif /* __KRB5_CCACHE_H__ */