cifs_idmap_sss.c revision 6469f42ca80bb9b955875d590485b0d9366491df
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor Benjamin Franzke <benjaminfranzke@googlemail.com>
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor Copyright (C) 2013 Benjamin Franzke
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor This program is free software; you can redistribute it and/or modify
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc it under the terms of the GNU General Public License as published by
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor the Free Software Foundation; either version 3 of the License, or
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor (at your option) any later version.
2e545ce2450a9953665f701bb05350f0d3f26275nd This program is distributed in the hope that it will be useful,
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen but WITHOUT ANY WARRANTY; without even the implied warranty of
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor GNU General Public License for more details.
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor You should have received a copy of the GNU General Public License
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen along with this program. If not, see <http://www.gnu.org/licenses/>.
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor/* TODO: Support well known SIDs as in samba's
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor/* TODO: Support of [all] samba's Unix SIDs:
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor * Users: S-1-22-1-%UID
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor * Groups: S-1-22-2-%GID
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor#define debug(...) do { } while(0)
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor const char **errmsg;
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor } while (0);
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzorint cifs_idmap_init_plugin(void **handle, const char **errmsg)
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor/* Test with `getcifsacl file` on client. */
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzorint cifs_idmap_sid_to_str(void *handle, const struct cifs_sid *csid,
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor iderr = sss_idmap_bin_sid_to_sid(ctx->idmap, (const uint8_t *) csid,
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor if (err != 0) {
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor /* FIXME: Map Samba Unix SIDs? (sid->id and use getpwuid)? */
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzorstatic int sid_to_cifs_sid(struct sssd_ctx *ctx, const char *sid,
4aa603e6448b99f9371397d439795c91a93637eand return -1;
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor/* Test with setcifsacl -a */
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzorint cifs_idmap_str_to_sid(void *handle, const char *name,
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor if (err != 0) {
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor /* Might be a raw string representation of SID,
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor * try converting that before returning an error. */
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzorstatic int samba_unix_sid_to_id(const char *sid, struct cifs_uxid *cuxid)
4aa603e6448b99f9371397d439795c91a93637eand return -1;
cae0359c9286c8e34cbccd15eee2da90562c1ee2sf return -1;
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzorstatic int sss_sid_to_id(struct sssd_ctx *ctx, const char *sid,
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor err = sss_nss_getidbysid(sid, (uint32_t *)&cuxid->id.uid, &id_type);
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor if (err != 0) {
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor * cifs_idmap_sids_to_ids - convert struct cifs_sids to struct cifs_uxids
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor * usecase: mount.cifs -o sec=krb5,multiuser,cifsacl,nounix
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor * test: ls -n on mounted share
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzorint cifs_idmap_sids_to_ids(void *handle, const struct cifs_sid *csid,
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor for (i = 0; i < num; ++i) {
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor err = sss_idmap_bin_sid_to_sid(ctx->idmap, (const uint8_t *) &csid[i],
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor debug("setting uid of %s to %d", sid, cuxid[i].id.uid);
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzorint cifs_idmap_ids_to_sids(void *handle, const struct cifs_uxid *cuxid,
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor for (i = 0; i < num; ++i) {
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor err = sss_nss_getsidbyid((uint32_t)cuxid[i].id.uid, &sid, &id_type);
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor if (err != 0) {
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor /* FIXME: would it be safe to map *any* uid/gids unknown by sssd to
cc8190433d13f5e9de618c5d7f10c824c0c1919cgryzor * SAMBA's UNIX SIDs? */