1 /*
2  * Copyright 2003,2007,2009,2011,2012 Red Hat, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, and the entire permission notice in its entirety,
9  *    including the disclaimer of warranties.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote
14  *    products derived from this software without specific prior
15  *    written permission.
16  *
17  * ALTERNATIVELY, this product may be distributed under the terms of the
18  * GNU Lesser General Public License, in which case the provisions of the
19  * LGPL are required INSTEAD OF the above restrictions.
20  *
21  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
22  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
24  * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef pam_krb5_stash_h
34 #define pam_krb5_stash_h
35 
36 #include "userinfo.h"
37 
38 struct _pam_krb5_ccname_list {
39 	char *name;
40 	int session_specific;
41 	struct _pam_krb5_ccname_list *next;
42 };
43 
44 struct _pam_krb5_stash {
45 	char *key;
46 	krb5_context v5ctx;
47 	int v5attempted, v5result, v5expired, v5external;
48 	struct _pam_krb5_ccname_list *v5ccnames;
49 	krb5_ccache v5ccache, v5armorccache;
50 	int v5setenv;
51 	int v5shm;
52 	pid_t v5shm_owner;
53 	int afspag;
54 };
55 
56 struct _pam_krb5_stash *_pam_krb5_stash_get(pam_handle_t *pamh,
57 					    const char *user,
58 					    struct _pam_krb5_user_info *info,
59 					    struct _pam_krb5_options *options);
60 void _pam_krb5_stash_push(krb5_context ctx, struct _pam_krb5_stash *stash,
61 			  struct _pam_krb5_options *options,
62 			  const char *ccname_template,
63 			  int preserve_existing_ccaches,
64 			  const char *user,
65 			  struct _pam_krb5_user_info *userinfo,
66 			  uid_t uid, gid_t gid);
67 int _pam_krb5_stash_pop(krb5_context ctx, struct _pam_krb5_stash *stash,
68 			struct _pam_krb5_options *options);
69 void _pam_krb5_stash_shm_read(pam_handle_t *pamh,
70 			      const char *partial_key,
71 			      struct _pam_krb5_stash *stash,
72 			      struct _pam_krb5_options *options,
73 			      const char *user,
74 			      struct _pam_krb5_user_info *userinfo);
75 void _pam_krb5_stash_shm_write(pam_handle_t *pamh,
76 			       struct _pam_krb5_stash *stash,
77 			       struct _pam_krb5_options *options,
78 			       const char *user,
79 			       struct _pam_krb5_user_info *userinfo);
80 void _pam_krb5_stash_name(struct _pam_krb5_options *options,
81 			  const char *user, char **name);
82 void _pam_krb5_stash_shm_var_name(struct _pam_krb5_options *options,
83 				  const char *user, char **name);
84 
85 #endif
86