1139804Simp/* 21541Srgrimes * Copyright (c) 1995 - 1999, 2003 Kungliga Tekniska H��gskolan 31541Srgrimes * (Royal Institute of Technology, Stockholm, Sweden). 41541Srgrimes * All rights reserved. 51541Srgrimes * 61541Srgrimes * Redistribution and use in source and binary forms, with or without 71541Srgrimes * modification, are permitted provided that the following conditions 81541Srgrimes * are met: 91541Srgrimes * 101541Srgrimes * 1. Redistributions of source code must retain the above copyright 111541Srgrimes * notice, this list of conditions and the following disclaimer. 121541Srgrimes * 131541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer in the 151541Srgrimes * documentation and/or other materials provided with the distribution. 161541Srgrimes * 171541Srgrimes * 3. Neither the name of the Institute nor the names of its contributors 181541Srgrimes * may be used to endorse or promote products derived from this software 191541Srgrimes * without specific prior written permission. 201541Srgrimes * 211541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 221541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 241541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 251541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 291541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 301541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311541Srgrimes * SUCH DAMAGE. 321541Srgrimes */ 331541Srgrimes 341541Srgrimes#include "ftpd_locl.h" 351541Srgrimes 361541SrgrimesRCSID("$Id$"); 37116182Sobrien 38116182Sobrien#if defined(KRB5) 39116182Sobrien 4013203Swollmanint do_destroy_tickets = 1; 41101127Srwatsonchar *k5ccname; 42144613Sjeff 4313203Swollman#endif 441541Srgrimes 452112Swollman#ifdef KRB5 4669664Speter 4776166Smarkmstatic void 48101127Srwatsondest_cc(void) 4989316Salfred{ 501541Srgrimes krb5_context context; 511541Srgrimes krb5_error_code ret; 521541Srgrimes krb5_ccache id; 531541Srgrimes 541541Srgrimes ret = krb5_init_context(&context); 55141471Sjhb if (ret == 0) { 56144613Sjeff if (k5ccname) 571541Srgrimes ret = krb5_cc_resolve(context, k5ccname, &id); 581541Srgrimes else 591541Srgrimes ret = krb5_cc_default (context, &id); 601541Srgrimes if (ret) 61155334Srwatson krb5_free_context(context); 62155334Srwatson } 6392751Sjeff if (ret == 0) { 6432011Sbde krb5_cc_destroy(context, id); 65155168Sjeff krb5_free_context (context); 66138345Sphk } 67138345Sphk} 681541Srgrimes#endif 6969664Speter 7069664Speter#if defined(KRB5) 7192751Sjeff 7269664Speter/* 7369664Speter * Only destroy if we created the tickets 7469664Speter */ 7569664Speter 7692654Sjeffvoid 7792654Sjeffcond_kdestroy(void) 7869664Speter{ 7969664Speter if (do_destroy_tickets) { 8069664Speter#if KRB5 8169664Speter dest_cc(); 82144613Sjeff#endif 83144613Sjeff do_destroy_tickets = 0; 84144613Sjeff } 85144613Sjeff afsunlog(); 86144613Sjeff} 87144613Sjeff 88144613Sjeffvoid 89144613Sjeffkdestroy(void) 9069664Speter{ 911541Srgrimes#if KRB5 921541Srgrimes dest_cc(); 931541Srgrimes#endif 941541Srgrimes afsunlog(); 951541Srgrimes reply(200, "Tickets destroyed"); 961541Srgrimes} 971541Srgrimes 981541Srgrimes 991541Srgrimesvoid 1001541Srgrimesafslog(const char *cell, int quiet) 1011541Srgrimes{ 1021541Srgrimes if(k_hasafs()) { 1031541Srgrimes#ifdef KRB5 1041541Srgrimes krb5_context context; 1051541Srgrimes krb5_error_code ret; 1061541Srgrimes krb5_ccache id; 1071541Srgrimes 1081541Srgrimes ret = krb5_init_context(&context); 1091541Srgrimes if (ret == 0) { 1101541Srgrimes if (k5ccname) 1111541Srgrimes ret = krb5_cc_resolve(context, k5ccname, &id); 1121541Srgrimes else 1131541Srgrimes ret = krb5_cc_default(context, &id); 1141541Srgrimes if (ret) 1151541Srgrimes krb5_free_context(context); 1161541Srgrimes } 1171541Srgrimes if (ret == 0) { 1181541Srgrimes krb5_afslog(context, id, cell, 0); 1191541Srgrimes krb5_cc_close (context, id); 1201541Srgrimes krb5_free_context (context); 12183366Sjulian } 12283366Sjulian#endif 123140714Sjeff if (!quiet) 1241541Srgrimes reply(200, "afslog done"); 125150164Scsjp } else { 126150164Scsjp if (!quiet) 12791419Sjhb reply(200, "no AFS present"); 12883366Sjulian } 12942408Seivind} 13042453Seivind 13142408Seivindvoid 13242453Seivindafsunlog(void) 133144613Sjeff{ 134144613Sjeff if(k_hasafs()) 13583366Sjulian k_unlog(); 1361541Srgrimes} 1371541Srgrimes 1381541Srgrimes#else 1391541Srgrimesint ftpd_afslog_placeholder; 1401541Srgrimes#endif /* KRB5 */ 1411541Srgrimes