1226031Sstas/* 2226031Sstas * Copyright (c) 2009 Kungliga Tekniska H�gskolan 3226031Sstas * (Royal Institute of Technology, Stockholm, Sweden). 4226031Sstas * All rights reserved. 5226031Sstas * 6226031Sstas * Portions Copyright (c) 2009 Apple Inc. All rights reserved. 7226031Sstas * 8226031Sstas * Redistribution and use in source and binary forms, with or without 9226031Sstas * modification, are permitted provided that the following conditions 10226031Sstas * are met: 11226031Sstas * 12226031Sstas * 1. Redistributions of source code must retain the above copyright 13226031Sstas * notice, this list of conditions and the following disclaimer. 14226031Sstas * 15226031Sstas * 2. Redistributions in binary form must reproduce the above copyright 16226031Sstas * notice, this list of conditions and the following disclaimer in the 17226031Sstas * documentation and/or other materials provided with the distribution. 18226031Sstas * 19226031Sstas * 3. Neither the name of the Institute nor the names of its contributors 20226031Sstas * may be used to endorse or promote products derived from this software 21226031Sstas * without specific prior written permission. 22226031Sstas * 23226031Sstas * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 24226031Sstas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25226031Sstas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26226031Sstas * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 27226031Sstas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28226031Sstas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29226031Sstas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30226031Sstas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31226031Sstas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32226031Sstas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33226031Sstas * SUCH DAMAGE. 34226031Sstas */ 35226031Sstas 36226031Sstas#include "kcm_locl.h" 37226031Sstas 38226031Sstas#if 0 39226031Sstas#include <bsm/audit_session.h> 40226031Sstas#endif 41226031Sstas 42226031Sstasvoid 43226031Sstaskcm_session_add(pid_t session_id) 44226031Sstas{ 45226031Sstas kcm_log(1, "monitor session: %d\n", session_id); 46226031Sstas} 47226031Sstas 48226031Sstasvoid 49226031Sstaskcm_session_setup_handler(void) 50226031Sstas{ 51226031Sstas#if 0 52226031Sstas au_sdev_handle_t *h; 53226031Sstas dispatch_queue_t bgq; 54226031Sstas 55226031Sstas h = au_sdev_open(AU_SDEVF_ALLSESSIONS); 56226031Sstas if (h == NULL) 57226031Sstas return; 58226031Sstas 59226031Sstas bgq = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0); 60226031Sstas 61226031Sstas dispatch_async(bgq, ^{ 62226031Sstas for (;;) { 63226031Sstas auditinfo_addr_t aio; 64226031Sstas int event; 65226031Sstas 66226031Sstas if (au_sdev_read_aia(h, &event, &aio) != 0) 67226031Sstas continue; 68226031Sstas 69226031Sstas /* 70226031Sstas * Ignore everything but END. This should relly be 71226031Sstas * CLOSE but since that is delayed until the credential 72226031Sstas * is reused, we can't do that 73226031Sstas * */ 74226031Sstas if (event != AUE_SESSION_END) 75226031Sstas continue; 76226031Sstas 77226031Sstas dispatch_async(dispatch_get_main_queue(), ^{ 78226031Sstas kcm_cache_remove_session(aio.ai_asid); 79226031Sstas }); 80226031Sstas } 81226031Sstas }); 82226031Sstas#endif 83226031Sstas} 84