2 * ID Mapping Plugin interface for cifs-utils
3 * Copyright (C) 2012 Jeff Layton (jlayton@samba.org)
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #endif /* HAVE_CONFIG_H */
26 #include <sys/types.h>
28 #include "cifsidmap.h"
29 #include "idmap_plugin.h"
31 const char *plugin_errmsg;
35 resolve_symbol(const char *symbol_name)
40 symbol = dlsym(plugin, symbol_name);
42 plugin_errmsg = dlerror();
47 * open the plugin. Note that we leave it open over the life of the
48 * program. It gets closed on exit.
56 plugin = dlopen(IDMAP_PLUGIN_PATH, RTLD_LAZY);
58 plugin_errmsg = dlerror();
66 init_plugin(void **handle)
69 int (*init)(void **, const char **);
75 init = resolve_symbol("cifs_idmap_init_plugin");
77 plugin_errmsg = "cifs_idmap_init_plugin not implemented";
80 return (*init)(handle, &plugin_errmsg);
84 exit_plugin(void *handle)
88 exit = resolve_symbol("cifs_idmap_exit_plugin");
94 sid_to_str(void *handle, const struct cifs_sid *sid, char **name)
96 int (*entry)(void *, const struct cifs_sid *, char **);
98 *(void **)(&entry) = resolve_symbol("cifs_idmap_sid_to_str");
100 plugin_errmsg = "cifs_idmap_sid_to_str not implemented";
104 return (*entry)(handle, sid, name);
108 str_to_sid(void *handle, const char *name, struct cifs_sid *sid)
110 int (*entry)(void *, const char *, struct cifs_sid *);
112 *(void **)(&entry) = resolve_symbol("cifs_idmap_str_to_sid");
114 plugin_errmsg = "cifs_idmap_str_to_sid not implemented";
118 return (*entry)(handle, name, sid);
122 sids_to_ids(void *handle, const struct cifs_sid *sid, const size_t num,
123 struct cifs_uxid *cuxid)
125 int (*entry)(void *handle, const struct cifs_sid *sids,
126 const size_t num, struct cifs_uxid *cuxid);
128 *(void **)(&entry) = resolve_symbol("cifs_idmap_sids_to_ids");
130 plugin_errmsg = "cifs_idmap_sids_to_ids not implemented";
134 return (*entry)(handle, sid, num, cuxid);
138 ids_to_sids(void *handle, const struct cifs_uxid *cuxid, const size_t num,
139 struct cifs_sid *sid)
141 int (*entry)(void *handle, const struct cifs_uxid *cuxid,
142 const size_t num, struct cifs_sid *sid);
144 *(void **)(&entry) = resolve_symbol("cifs_idmap_ids_to_sids");
146 plugin_errmsg = "cifs_idmap_ids_to_sids not implemented";
150 return (*entry)(handle, cuxid, num, sid);