2a9af1f71887f02935e2fb6ad5023afba5b6d43eSumit Bose NSS Responder Interface for ID-SID mappings
2a9af1f71887f02935e2fb6ad5023afba5b6d43eSumit Bose Sumit Bose <sbose@redhat.com>
2a9af1f71887f02935e2fb6ad5023afba5b6d43eSumit Bose Copyright (C) 2013 Red Hat
2a9af1f71887f02935e2fb6ad5023afba5b6d43eSumit Bose This program is free software; you can redistribute it and/or modify
2a9af1f71887f02935e2fb6ad5023afba5b6d43eSumit Bose it under the terms of the GNU General Public License as published by
2a9af1f71887f02935e2fb6ad5023afba5b6d43eSumit Bose the Free Software Foundation; either version 3 of the License, or
2a9af1f71887f02935e2fb6ad5023afba5b6d43eSumit Bose (at your option) any later version.
2a9af1f71887f02935e2fb6ad5023afba5b6d43eSumit Bose This program is distributed in the hope that it will be useful,
2a9af1f71887f02935e2fb6ad5023afba5b6d43eSumit Bose but WITHOUT ANY WARRANTY; without even the implied warranty of
2a9af1f71887f02935e2fb6ad5023afba5b6d43eSumit Bose MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2a9af1f71887f02935e2fb6ad5023afba5b6d43eSumit Bose GNU General Public License for more details.
2a9af1f71887f02935e2fb6ad5023afba5b6d43eSumit Bose You should have received a copy of the GNU General Public License
2a9af1f71887f02935e2fb6ad5023afba5b6d43eSumit Bose along with this program. If not, see <http://www.gnu.org/licenses/>.
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Bose#include "sss_client/idmap/sss_nss_idmap_private.h"
440797cba931aa491bf418035f55935943e22b4bSumit Bose for (c = 0; l[c] != NULL; c++) {
440797cba931aa491bf418035f55935943e22b4bSumit Bosestatic int buf_to_name_type_list(uint8_t *buf, size_t buf_len, uint32_t num,
440797cba931aa491bf418035f55935943e22b4bSumit Bose for (c = 0; c < num; c++) {
440797cba931aa491bf418035f55935943e22b4bSumit Bose if (n[c] == NULL) {
0d01e4f6cc21d8ca0e4fafe59c7cbfa1459fa47eSumit Bosestatic int buf_to_kv_list(uint8_t *buf, size_t buf_len,
0d01e4f6cc21d8ca0e4fafe59c7cbfa1459fa47eSumit Bose for (c = 0; c < buf_len; c++) {
0d01e4f6cc21d8ca0e4fafe59c7cbfa1459fa47eSumit Bose list = calloc((count + 1), sizeof(struct sss_nss_kv));
0d01e4f6cc21d8ca0e4fafe59c7cbfa1459fa47eSumit Bose for (c = 0; c < count; c++) {
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Bosestatic int sss_nss_getyyybyxxx(union input inp, enum sss_cli_command cmd,
440797cba931aa491bf418035f55935943e22b4bSumit Bose ret = sss_strnlen(inp.str, 10 * 1024 , &inp_len);
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Bose nret = sss_nss_make_request_timeout(cmd, &rd, time_left, &repbuf, &replen,
a171d77f40aa92e240e91aa4bafe5a392a98b5a2Michal Zidek SAFEALIGN_COPY_UINT32(&num_results, repbuf, NULL);
440797cba931aa491bf418035f55935943e22b4bSumit Bose } else if (num_results > 1 && cmd != SSS_NSS_GETLISTBYCERT) {
a171d77f40aa92e240e91aa4bafe5a392a98b5a2Michal Zidek /* Skip first two 32 bit values (number of results and
a171d77f40aa92e240e91aa4bafe5a392a98b5a2Michal Zidek * reserved padding) */
a171d77f40aa92e240e91aa4bafe5a392a98b5a2Michal Zidek SAFEALIGN_COPY_UINT32(&out->type, repbuf + 2 * sizeof(uint32_t), NULL);
2a9af1f71887f02935e2fb6ad5023afba5b6d43eSumit Bose if (data_len <= 1 || repbuf[replen - 1] != '\0') {
2a9af1f71887f02935e2fb6ad5023afba5b6d43eSumit Bose strncpy(str, (char *) repbuf + DATA_START, data_len);
2a9af1f71887f02935e2fb6ad5023afba5b6d43eSumit Bose SAFEALIGN_COPY_UINT32(&c, repbuf + DATA_START, NULL);
440797cba931aa491bf418035f55935943e22b4bSumit Bose ret = buf_to_name_type_list(repbuf + LIST_START, replen - LIST_START,
0d01e4f6cc21d8ca0e4fafe59c7cbfa1459fa47eSumit Bose ret = buf_to_kv_list(repbuf + DATA_START, data_len, &kv_list);
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Boseint sss_nss_getsidbyname_timeout(const char *fq_name, unsigned int timeout,
2a9af1f71887f02935e2fb6ad5023afba5b6d43eSumit Bose if (sid == NULL || fq_name == NULL || *fq_name == '\0') {
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Bose ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETSIDBYNAME, timeout, &out);
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Boseint sss_nss_getsidbyname(const char *fq_name, char **sid,
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Bose return sss_nss_getsidbyname_timeout(fq_name, NO_TIMEOUT, sid, type);
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Boseint sss_nss_getsidbyid_timeout(uint32_t id, unsigned int timeout,
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Bose ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETSIDBYID, timeout, &out);
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Boseint sss_nss_getsidbyid(uint32_t id, char **sid, enum sss_id_type *type)
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Bose return sss_nss_getsidbyid_timeout(id, NO_TIMEOUT, sid, type);
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Boseint sss_nss_getnamebysid_timeout(const char *sid, unsigned int timeout,
2a9af1f71887f02935e2fb6ad5023afba5b6d43eSumit Bose if (fq_name == NULL || sid == NULL || *sid == '\0') {
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Bose ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETNAMEBYSID, timeout, &out);
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Boseint sss_nss_getnamebysid(const char *sid, char **fq_name,
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Bose return sss_nss_getnamebysid_timeout(sid, NO_TIMEOUT, fq_name, type);
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Boseint sss_nss_getidbysid_timeout(const char *sid, unsigned int timeout,
2a9af1f71887f02935e2fb6ad5023afba5b6d43eSumit Bose if (id == NULL || id_type == NULL || sid == NULL || *sid == '\0') {
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Bose ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETIDBYSID, timeout, &out);
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Boseint sss_nss_getidbysid(const char *sid, uint32_t *id, enum sss_id_type *id_type)
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Bose return sss_nss_getidbysid_timeout(sid, NO_TIMEOUT, id, id_type);
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Boseint sss_nss_getorigbyname_timeout(const char *fq_name, unsigned int timeout,
0d01e4f6cc21d8ca0e4fafe59c7cbfa1459fa47eSumit Bose if (kv_list == NULL || fq_name == NULL || *fq_name == '\0') {
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Bose ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETORIGBYNAME, timeout, &out);
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Boseint sss_nss_getorigbyname(const char *fq_name, struct sss_nss_kv **kv_list,
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Bose return sss_nss_getorigbyname_timeout(fq_name, NO_TIMEOUT, kv_list, type);
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Boseint sss_nss_getnamebycert_timeout(const char *cert, unsigned int timeout,
9c88f837ffacf6548c13825589b327de1a5525f3Sumit Bose if (fq_name == NULL || cert == NULL || *cert == '\0') {
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Bose ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETNAMEBYCERT, timeout, &out);
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Boseint sss_nss_getnamebycert(const char *cert, char **fq_name,
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Bose return sss_nss_getnamebycert_timeout(cert, NO_TIMEOUT, fq_name, type);
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Boseint sss_nss_getlistbycert_timeout(const char *cert, unsigned int timeout,
440797cba931aa491bf418035f55935943e22b4bSumit Bose if (fq_name == NULL || cert == NULL || *cert == '\0') {
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Bose ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETLISTBYCERT, timeout, &out);
e54db68cbb9c12d8a6867f2c7766fb2115ab0997Sumit Boseint sss_nss_getlistbycert(const char *cert, char ***fq_name,