1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>pam_pkcs11: mapper.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li><a href="dirs.html"><span>Directories</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File List</span></a></li>
<li><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
<div class="navpath"><a class="el" href="dir_55f9682142a78e45196901be32452b47.html">src</a> » <a class="el" href="dir_ba07705465e8c8a06fa6b5f205305322.html">mappers</a>
</div>
</div>
<div class="contents">
<h1>mapper.h</h1><a href="mapper_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * PAM-PKCS11 mapping modules</span>
<a name="l00003"></a>00003 <span class="comment"> * Copyright (C) 2005 Juan Antonio Martinez <jonsito@teleline.es></span>
<a name="l00004"></a>00004 <span class="comment"> * pam-pkcs11 is copyright (C) 2003-2004 of Mario Strasser <mast@gmx.net></span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
<a name="l00007"></a>00007 <span class="comment"> * modify it under the terms of the GNU Lesser General Public</span>
<a name="l00008"></a>00008 <span class="comment"> * License as published by the Free Software Foundation; either</span>
<a name="l00009"></a>00009 <span class="comment"> * version 2.1 of the License, or (at your option) any later version.</span>
<a name="l00010"></a>00010 <span class="comment"> *</span>
<a name="l00011"></a>00011 <span class="comment"> * This library is distributed in the hope that it will be useful,</span>
<a name="l00012"></a>00012 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00013"></a>00013 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
<a name="l00014"></a>00014 <span class="comment"> * Lesser General Public License for more details.</span>
<a name="l00015"></a>00015 <span class="comment"> *</span>
<a name="l00016"></a>00016 <span class="comment"> * You should have received a copy of the GNU Lesser General Public</span>
<a name="l00017"></a>00017 <span class="comment"> * License along with this library; if not, write to the Free Software</span>
<a name="l00018"></a>00018 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00019"></a>00019 <span class="comment"> *</span>
<a name="l00020"></a>00020 <span class="comment"> * $Id: mapper.h 358 2008-11-06 14:28:46Z ludovic.rousseau $</span>
<a name="l00021"></a>00021 <span class="comment"> */</span>
<a name="l00022"></a>00022
<a name="l00023"></a>00023 <span class="preprocessor">#ifndef __MAPPER_H_</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#define __MAPPER_H_</span>
<a name="l00025"></a>00025 <span class="preprocessor"></span>
<a name="l00026"></a>00026 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span><span class="preprocessor">#include <config.h></span>
<a name="l00028"></a>00028 <span class="preprocessor">#endif</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span>
<a name="l00030"></a>00030 <span class="preprocessor">#include <sys/types.h></span>
<a name="l00031"></a>00031 <span class="preprocessor">#include <stdlib.h></span>
<a name="l00032"></a>00032 <span class="preprocessor">#include <string.h></span>
<a name="l00033"></a>00033 <span class="preprocessor">#include <pwd.h></span>
<a name="l00034"></a>00034 <span class="preprocessor">#include <../common/cert_st.h></span>
<a name="l00035"></a>00035 <span class="preprocessor">#include "../scconf/scconf.h"</span>
<a name="l00036"></a>00036
<a name="l00040"></a><a class="code" href="structmapper__module__st.html">00040</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structmapper__module__st.html" title="Structure to be filled on mapper module initialization.">mapper_module_st</a> {
<a name="l00042"></a><a class="code" href="structmapper__module__st.html#a8f8f80d37794cde9472343e4487ba3eb">00042</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="structmapper__module__st.html#a8f8f80d37794cde9472343e4487ba3eb" title="mapper name">name</a>;
<a name="l00044"></a><a class="code" href="structmapper__module__st.html#abba81c977d8901de66b169a60d8481e1">00044</a> <a class="code" href="struct__scconf__block.html">scconf_block</a> *<a class="code" href="structmapper__module__st.html#abba81c977d8901de66b169a60d8481e1" title="mapper configuration block">block</a>;
<a name="l00046"></a><a class="code" href="structmapper__module__st.html#ab133ab6f78d4ef8149644d544f8d902c">00046</a> <span class="keywordtype">int</span> <a class="code" href="structmapper__module__st.html#ab133ab6f78d4ef8149644d544f8d902c" title="debug level to set before call entry points">dbg_level</a>;
<a name="l00048"></a><a class="code" href="structmapper__module__st.html#ae376f130b17d169ee51be68077a89ed0">00048</a> <span class="keywordtype">void</span> *<a class="code" href="structmapper__module__st.html#ae376f130b17d169ee51be68077a89ed0" title="pointer to mapper local data">context</a>;
<a name="l00050"></a><a class="code" href="structmapper__module__st.html#a243a6cb3b1ff404e473d431be6cc5880">00050</a> <span class="keywordtype">char</span> **(*entries)(X509 *x509, <span class="keywordtype">void</span> *<a class="code" href="structmapper__module__st.html#ae376f130b17d169ee51be68077a89ed0" title="pointer to mapper local data">context</a>);
<a name="l00052"></a><a class="code" href="structmapper__module__st.html#a45cb3d67c6aae40e79c7e07d830c4478">00052</a> <span class="keywordtype">char</span> *(*finder)(X509 *x509, <span class="keywordtype">void</span> *<a class="code" href="structmapper__module__st.html#ae376f130b17d169ee51be68077a89ed0" title="pointer to mapper local data">context</a>);
<a name="l00054"></a><a class="code" href="structmapper__module__st.html#a182609d9b64f223a3c9973fba94ca0b4">00054</a> int (*<a class="code" href="structmapper__module__st.html#a182609d9b64f223a3c9973fba94ca0b4" title="cert-to-login matcher">matcher</a>)(X509 *x509, <span class="keyword">const</span> <span class="keywordtype">char</span> *login, <span class="keywordtype">void</span> *<a class="code" href="structmapper__module__st.html#ae376f130b17d169ee51be68077a89ed0" title="pointer to mapper local data">context</a>);
<a name="l00056"></a><a class="code" href="structmapper__module__st.html#aa835e787ef360f3f94fc6ff15737e265">00056</a> void (*<a class="code" href="structmapper__module__st.html#aa835e787ef360f3f94fc6ff15737e265" title="module de-initialization">deinit</a>)( <span class="keywordtype">void</span> *<a class="code" href="structmapper__module__st.html#ae376f130b17d169ee51be68077a89ed0" title="pointer to mapper local data">context</a>);
<a name="l00057"></a>00057 } <a class="code" href="structmapper__module__st.html" title="Structure to be filled on mapper module initialization.">mapper_module</a>;
<a name="l00058"></a>00058
<a name="l00063"></a><a class="code" href="structmapfile.html">00063</a> <span class="keyword">struct </span><a class="code" href="structmapfile.html" title="This struct is used in processing map files a map file is a list of &quot;key&quot;...">mapfile</a> {
<a name="l00065"></a><a class="code" href="structmapfile.html#a69ec24fb2d0a5f5e532deb9adaab81d6">00065</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="structmapfile.html#a69ec24fb2d0a5f5e532deb9adaab81d6" title="URL of mapfile.">uri</a>;
<a name="l00067"></a><a class="code" href="structmapfile.html#aff2566f4c366b48d73479bef43ee4d2e">00067</a> <span class="keywordtype">char</span> *<a class="code" href="structmapfile.html#aff2566f4c366b48d73479bef43ee4d2e" title="buffer to content of mapfile">buffer</a>;
<a name="l00069"></a><a class="code" href="structmapfile.html#ae809d5359ac030c60a30a8f0b2294b82">00069</a> <span class="keywordtype">size_t</span> <a class="code" href="structmapfile.html#ae809d5359ac030c60a30a8f0b2294b82" title="lenght of buffer">length</a>;
<a name="l00071"></a><a class="code" href="structmapfile.html#a6c968ee6eb10c4ba386621ba90472862">00071</a> <span class="keywordtype">char</span> *<a class="code" href="structmapfile.html#a6c968ee6eb10c4ba386621ba90472862" title="pointer to last readed entry in buffer">pt</a>;
<a name="l00073"></a><a class="code" href="structmapfile.html#a5892a9181e6a332f84d27aecd41dcd12">00073</a> <span class="keywordtype">char</span> *<a class="code" href="structmapfile.html#a5892a9181e6a332f84d27aecd41dcd12" title="key entry in current buffer">key</a>;
<a name="l00075"></a><a class="code" href="structmapfile.html#a4e9aec275e566b978a3ccb4e043d8c61">00075</a> <span class="keywordtype">char</span> *<a class="code" href="structmapfile.html#a4e9aec275e566b978a3ccb4e043d8c61" title="value assigned to key">value</a>;
<a name="l00076"></a>00076 };
<a name="l00077"></a>00077
<a name="l00078"></a>00078 <span class="comment">/* ------------------------------------------------------- */</span>
<a name="l00079"></a>00079
<a name="l00088"></a>00088 <a class="code" href="structmapper__module__st.html" title="Structure to be filled on mapper module initialization.">mapper_module</a> * <a class="code" href="mapper_8h.html#abd7e377bfc805aeac08054aa5ece69b9" title="Initialize module and mapper_module_st structure.">mapper_module_init</a>(<a class="code" href="struct__scconf__block.html">scconf_block</a> *ctx,<span class="keyword">const</span> <span class="keywordtype">char</span> *mapper_name);
<a name="l00089"></a>00089
<a name="l00090"></a>00090 <span class="comment">/* ------------------------------------------------------- */</span>
<a name="l00091"></a>00091
<a name="l00092"></a>00092 <span class="comment">/*</span>
<a name="l00093"></a>00093 <span class="comment">* mapper.c prototype functions</span>
<a name="l00094"></a>00094 <span class="comment">*/</span>
<a name="l00095"></a>00095 <span class="preprocessor">#ifndef __MAPPER_C_</span>
<a name="l00096"></a><a class="code" href="mapper_8h.html#a13bd5c2569e42f48a17ce7d7acd6607b">00096</a> <span class="preprocessor"></span><span class="preprocessor">#define MAPPER_EXTERN extern</span>
<a name="l00097"></a>00097 <span class="preprocessor"></span><span class="preprocessor">#else</span>
<a name="l00098"></a>00098 <span class="preprocessor"></span><span class="preprocessor">#define MAPPER_EXTERN</span>
<a name="l00099"></a>00099 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00100"></a>00100 <span class="preprocessor"></span>
<a name="l00101"></a>00101 <span class="comment">/* mapfile related functions */</span>
<a name="l00102"></a>00102
<a name="l00108"></a>00108 <a class="code" href="mapper_8h.html#a13bd5c2569e42f48a17ce7d7acd6607b">MAPPER_EXTERN</a> <span class="keyword">struct </span><a class="code" href="structmapfile.html" title="This struct is used in processing map files a map file is a list of &quot;key&quot;...">mapfile</a> *<a class="code" href="mapper_8h.html#aff785dc94718a428e1ef46c35dc2dcfa" title="Initialize a mapper entry table.">set_mapent</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="structmapfile.html#a69ec24fb2d0a5f5e532deb9adaab81d6" title="URL of mapfile.">uri</a>);
<a name="l00109"></a>00109
<a name="l00115"></a>00115 <a class="code" href="mapper_8h.html#a13bd5c2569e42f48a17ce7d7acd6607b">MAPPER_EXTERN</a> <span class="keywordtype">int</span> <a class="code" href="mapper_8h.html#a1478d4be0cc248ad061a36339c9b3daf" title="Retrieve next entry of given map file.">get_mapent</a>(<span class="keyword">struct</span> <a class="code" href="structmapfile.html" title="This struct is used in processing map files a map file is a list of &quot;key&quot;...">mapfile</a> *mfile);
<a name="l00116"></a>00116
<a name="l00121"></a>00121 <a class="code" href="mapper_8h.html#a13bd5c2569e42f48a17ce7d7acd6607b">MAPPER_EXTERN</a> <span class="keywordtype">void</span> <a class="code" href="mapper_8h.html#abab71f0630103ff957b9e5d84a6105c0" title="Release a mapentry structure.">end_mapent</a>(<span class="keyword">struct</span> <a class="code" href="structmapfile.html" title="This struct is used in processing map files a map file is a list of &quot;key&quot;...">mapfile</a> *mfile);
<a name="l00122"></a>00122
<a name="l00130"></a>00130 <a class="code" href="mapper_8h.html#a13bd5c2569e42f48a17ce7d7acd6607b">MAPPER_EXTERN</a> <span class="keywordtype">char</span> *<a class="code" href="mapper_8h.html#a63c4a27f00025978b79902228ddffa4f" title="Try to map &quot;key&quot; to provided mapfile.">mapfile_find</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *file,<span class="keywordtype">char</span> *<a class="code" href="structmapfile.html#a5892a9181e6a332f84d27aecd41dcd12" title="key entry in current buffer">key</a>,<span class="keywordtype">int</span> ignorecase);
<a name="l00131"></a>00131
<a name="l00140"></a>00140 <a class="code" href="mapper_8h.html#a13bd5c2569e42f48a17ce7d7acd6607b">MAPPER_EXTERN</a> <span class="keywordtype">int</span> <a class="code" href="mapper_8h.html#a589ef6dd1c494a11afb251acec024d85" title="Try to match provided key to provided name by mean of a mapfile.">mapfile_match</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *file,<span class="keywordtype">char</span> *<a class="code" href="structmapfile.html#a5892a9181e6a332f84d27aecd41dcd12" title="key entry in current buffer">key</a>,<span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="structmapfile.html#a4e9aec275e566b978a3ccb4e043d8c61" title="value assigned to key">value</a>,<span class="keywordtype">int</span> ignorecase);
<a name="l00141"></a>00141
<a name="l00142"></a>00142 <span class="comment">/* pwent related functions */</span>
<a name="l00143"></a>00143
<a name="l00150"></a>00150 <a class="code" href="mapper_8h.html#a13bd5c2569e42f48a17ce7d7acd6607b">MAPPER_EXTERN</a> <span class="keywordtype">char</span> *<a class="code" href="mapper_8h.html#a11277748d021c9212e7460b90e10749c" title="find the user login that matches pw_name or pw_gecos with provided item">search_pw_entry</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *item, <span class="keywordtype">int</span> ignorecase);
<a name="l00151"></a>00151
<a name="l00159"></a>00159 <a class="code" href="mapper_8h.html#a13bd5c2569e42f48a17ce7d7acd6607b">MAPPER_EXTERN</a> <span class="keywordtype">int</span> <a class="code" href="mapper_8h.html#a21892c500d029efa93208fd716de48c3" title="Test if provided item matches pw_name or pw_gecos of provided password structure...">compare_pw_entry</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *item, <span class="keyword">struct</span> passwd *pw,<span class="keywordtype">int</span> ignorecase);
<a name="l00160"></a>00160
<a name="l00161"></a>00161 <span class="preprocessor">#undef MAPPER_EXTERN</span>
<a name="l00162"></a>00162 <span class="preprocessor"></span>
<a name="l00163"></a>00163 <span class="comment">/* ------------------------------------------------------- */</span>
<a name="l00164"></a>00164
<a name="l00173"></a><a class="code" href="mapper_8h.html#a791f7f44d4bc2b0fb3db279e4f5a8dc0">00173</a> <span class="preprocessor">#define _DEFAULT_MAPPER_FIND_ENTRIES \</span>
<a name="l00174"></a>00174 <span class="preprocessor">static char ** mapper_find_entries(X509 *x509, void *context) { \</span>
<a name="l00175"></a>00175 <span class="preprocessor"> return NULL; \</span>
<a name="l00176"></a>00176 <span class="preprocessor">}</span>
<a name="l00177"></a>00177 <span class="preprocessor"></span>
<a name="l00186"></a><a class="code" href="mapper_8h.html#ac77f111c63b7a5a1c75c81e5937da326">00186</a> <span class="preprocessor">#define _DEFAULT_MAPPER_FIND_USER \</span>
<a name="l00187"></a>00187 <span class="preprocessor">static char * mapper_find_user(X509 *x509,void *context) { \</span>
<a name="l00188"></a>00188 <span class="preprocessor"> if ( !x509 ) return NULL; \</span>
<a name="l00189"></a>00189 <span class="preprocessor"> return "nobody"; \</span>
<a name="l00190"></a>00190 <span class="preprocessor">}</span>
<a name="l00191"></a>00191 <span class="preprocessor"></span>
<a name="l00202"></a><a class="code" href="mapper_8h.html#ac8058aaca72c3f6db063e5128bf8eab1">00202</a> <span class="preprocessor">#define _DEFAULT_MAPPER_MATCH_USER \</span>
<a name="l00203"></a>00203 <span class="preprocessor">static int mapper_match_user(X509 *x509, const char *login, void *context) { \</span>
<a name="l00204"></a>00204 <span class="preprocessor"> char *username= mapper_find_user(x509,context); \</span>
<a name="l00205"></a>00205 <span class="preprocessor"> if (!x509) return -1; \</span>
<a name="l00206"></a>00206 <span class="preprocessor"> if (!login) return -1; \</span>
<a name="l00207"></a>00207 <span class="preprocessor"> if (!username) return 0; </span><span class="comment">/*user not found*/</span> \
<a name="l00208"></a>00208 if ( ! strcmp(login,username) ) return 1; <span class="comment">/* match user */</span> \
<a name="l00209"></a>00209 return 0; <span class="comment">/* no match */</span> \
<a name="l00210"></a>00210 }
<a name="l00211"></a>00211
<a name="l00216"></a><a class="code" href="mapper_8h.html#afc62f3ec1bd2d9427511f13c525fc610">00216</a> <span class="preprocessor">#define _DEFAULT_MAPPER_END \</span>
<a name="l00217"></a>00217 <span class="preprocessor">static void mapper_module_end(void *context) { \</span>
<a name="l00218"></a>00218 <span class="preprocessor"> free(context); \</span>
<a name="l00219"></a>00219 <span class="preprocessor"> return; \</span>
<a name="l00220"></a>00220 <span class="preprocessor">} \</span>
<a name="l00221"></a>00221 <span class="preprocessor"></span>
<a name="l00222"></a>00222 <span class="preprocessor"></span>
<a name="l00229"></a><a class="code" href="mapper_8h.html#adb5e0d438bea160c5f0d35a8cdaf6466">00229</a> <span class="preprocessor">#define _DEFAULT_MAPPER_INIT \</span>
<a name="l00230"></a>00230 <span class="preprocessor">mapper_module* mapper_module_init(scconf_block *blk,const char *name) { \</span>
<a name="l00231"></a>00231 <span class="preprocessor"> mapper_module *pt= malloc(sizeof (mapper_module)); \</span>
<a name="l00232"></a>00232 <span class="preprocessor"> if (!pt) return NULL; \</span>
<a name="l00233"></a>00233 <span class="preprocessor"> pt->name = name; \</span>
<a name="l00234"></a>00234 <span class="preprocessor"> pt->context = NULL; \</span>
<a name="l00235"></a>00235 <span class="preprocessor"> pt->block = blk; \</span>
<a name="l00236"></a>00236 <span class="preprocessor"> pt->dbg_level = get_debug_level(); \</span>
<a name="l00237"></a>00237 <span class="preprocessor"> pt->entries = mapper_find_entries; \</span>
<a name="l00238"></a>00238 <span class="preprocessor"> pt->finder = mapper_find_user; \</span>
<a name="l00239"></a>00239 <span class="preprocessor"> pt->matcher = mapper_match_user; \</span>
<a name="l00240"></a>00240 <span class="preprocessor"> pt->deinit = mapper_module_end; \</span>
<a name="l00241"></a>00241 <span class="preprocessor"> return pt; \</span>
<a name="l00242"></a>00242 <span class="preprocessor">} \</span>
<a name="l00243"></a>00243 <span class="preprocessor"></span>
<a name="l00244"></a>00244 <span class="preprocessor"></span><span class="comment">/* end of mapper.h file */</span>
<a name="l00245"></a>00245 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Sat Jun 12 17:28:15 2010 for pam_pkcs11 by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>
|