Path: blob/main/crypto/heimdal/appl/ftp/ftpd/kauth.c
34890 views
/*1* Copyright (c) 1995 - 1999, 2003 Kungliga Tekniska Högskolan2* (Royal Institute of Technology, Stockholm, Sweden).3* All rights reserved.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8*9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11*12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* 3. Neither the name of the Institute nor the names of its contributors17* may be used to endorse or promote products derived from this software18* without specific prior written permission.19*20* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND21* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE22* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE23* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE24* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL25* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS26* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)27* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT28* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY29* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF30* SUCH DAMAGE.31*/3233#include "ftpd_locl.h"3435RCSID("$Id$");3637#if defined(KRB5)3839int do_destroy_tickets = 1;40char *k5ccname;4142#endif4344#ifdef KRB54546static void47dest_cc(void)48{49krb5_context context;50krb5_error_code ret;51krb5_ccache id;5253ret = krb5_init_context(&context);54if (ret == 0) {55if (k5ccname)56ret = krb5_cc_resolve(context, k5ccname, &id);57else58ret = krb5_cc_default (context, &id);59if (ret)60krb5_free_context(context);61}62if (ret == 0) {63krb5_cc_destroy(context, id);64krb5_free_context (context);65}66}67#endif6869#if defined(KRB5)7071/*72* Only destroy if we created the tickets73*/7475void76cond_kdestroy(void)77{78if (do_destroy_tickets) {79#if KRB580dest_cc();81#endif82do_destroy_tickets = 0;83}84afsunlog();85}8687void88kdestroy(void)89{90#if KRB591dest_cc();92#endif93afsunlog();94reply(200, "Tickets destroyed");95}969798void99afslog(const char *cell, int quiet)100{101if(k_hasafs()) {102#ifdef KRB5103krb5_context context;104krb5_error_code ret;105krb5_ccache id;106107ret = krb5_init_context(&context);108if (ret == 0) {109if (k5ccname)110ret = krb5_cc_resolve(context, k5ccname, &id);111else112ret = krb5_cc_default(context, &id);113if (ret)114krb5_free_context(context);115}116if (ret == 0) {117krb5_afslog(context, id, cell, 0);118krb5_cc_close (context, id);119krb5_free_context (context);120}121#endif122if (!quiet)123reply(200, "afslog done");124} else {125if (!quiet)126reply(200, "no AFS present");127}128}129130void131afsunlog(void)132{133if(k_hasafs())134k_unlog();135}136137#else138int ftpd_afslog_placeholder;139#endif /* KRB5 */140141142