sss_nss_ex.c revision 859bddc2bf51dc426a3dc56bd9f365e9c5722b65
54bde50b7d791bd8c3d2a6581f8a4ff26d9f0834Timo Sirainen Extended NSS Responder Interface
54bde50b7d791bd8c3d2a6581f8a4ff26d9f0834Timo Sirainen Sumit Bose <sbose@redhat.com>
54bde50b7d791bd8c3d2a6581f8a4ff26d9f0834Timo Sirainen Copyright (C) 2017 Red Hat
54bde50b7d791bd8c3d2a6581f8a4ff26d9f0834Timo Sirainen This program is free software; you can redistribute it and/or modify
54bde50b7d791bd8c3d2a6581f8a4ff26d9f0834Timo Sirainen it under the terms of the GNU General Public License as published by
54bde50b7d791bd8c3d2a6581f8a4ff26d9f0834Timo Sirainen the Free Software Foundation; either version 3 of the License, or
54bde50b7d791bd8c3d2a6581f8a4ff26d9f0834Timo Sirainen (at your option) any later version.
54bde50b7d791bd8c3d2a6581f8a4ff26d9f0834Timo Sirainen This program is distributed in the hope that it will be useful,
9eedd38c2985596fb692dcca62193379d34c4c5bTimo Sirainen but WITHOUT ANY WARRANTY; without even the implied warranty of
9eedd38c2985596fb692dcca62193379d34c4c5bTimo Sirainen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
54bde50b7d791bd8c3d2a6581f8a4ff26d9f0834Timo Sirainen GNU General Public License for more details.
54bde50b7d791bd8c3d2a6581f8a4ff26d9f0834Timo Sirainen You should have received a copy of the GNU General Public License
54bde50b7d791bd8c3d2a6581f8a4ff26d9f0834Timo Sirainen along with this program. If not, see <http://www.gnu.org/licenses/>.
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen#include "sss_client/idmap/sss_nss_idmap_private.h"
517d1e7142d57299c733b30423e35e7e1f8d01d6Timo Sirainen#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
e80203675151ef9d4f3f850cf02041042eb13096Timo Sirainen return sss_nss_mc_getpwnam(inp->input.name, strlen(inp->input.name),
54bde50b7d791bd8c3d2a6581f8a4ff26d9f0834Timo Sirainen return sss_nss_mc_getgrnam(inp->input.name, strlen(inp->input.name),
54bde50b7d791bd8c3d2a6581f8a4ff26d9f0834Timo Sirainen return sss_nss_mc_initgroups_dyn(inp->input.name,
5e5c6dc798670afe6b717529e0df2c94879fd112Timo Sirainenstatic int check_flags(struct nss_input *inp, uint32_t flags,
5e5c6dc798670afe6b717529e0df2c94879fd112Timo Sirainen bool no_data = false;
54bde50b7d791bd8c3d2a6581f8a4ff26d9f0834Timo Sirainen /* SSS_NSS_EX_FLAG_NO_CACHE and SSS_NSS_EX_FLAG_INVALIDATE_CACHE are
9eedd38c2985596fb692dcca62193379d34c4c5bTimo Sirainen * mutually exclusive */
9eedd38c2985596fb692dcca62193379d34c4c5bTimo Sirainen && (flags & SSS_NSS_EX_FLAG_INVALIDATE_CACHE) != 0) {
49e513d090753ccbf95560b2f3a21f081a5b6c51Timo Sirainen || (flags & SSS_NSS_EX_FLAG_INVALIDATE_CACHE) != 0) {
54bde50b7d791bd8c3d2a6581f8a4ff26d9f0834Timo Sirainen /* Allow empty buffer with SSS_NSS_EX_FLAG_INVALIDATE_CACHE */
54bde50b7d791bd8c3d2a6581f8a4ff26d9f0834Timo Sirainen if ((flags & SSS_NSS_EX_FLAG_INVALIDATE_CACHE) != 0) {
int ret;
int time_left;
int errnop;
size_t c;
bool skip_mc = false;
bool skip_data = false;
if (ret != 0) {
return ret;
switch (ret) {
case ERANGE:
return ERANGE;
case ENOENT:
switch (ret) {
ret = 0;
goto out;
case ERANGE:
goto out;
case ENOENT:
goto out;
if (num_results == 0) {
goto out;
if (skip_data) {
ret = 0;
goto out;
< num_results) {
* sizeof(gid_t));
goto out;
for (c = 0; c < num_results; c++) {
ret = 0;
goto out;
goto out;
case SSS_NSS_GETPWNAM:
case SSS_NSS_GETPWUID:
case SSS_NSS_GETPWNAM_EX:
case SSS_NSS_GETPWUID_EX:
case SSS_NSS_GETGRNAM:
case SSS_NSS_GETGRGID:
case SSS_NSS_GETGRNAM_EX:
case SSS_NSS_GETGRGID_EX:
if (ret != 0) {
goto out;
if (len == 0) {
ret = 0;
goto out;
out:
return ret;
int ret;
return EINVAL;
if (ret != 0) {
return ret;
name_len++;
return ENOMEM;
int ret;
if (ret != 0) {
return ret;
if (ret == 0) {
return ret;
int ret;
if (ret == 0) {
return ret;
int ret;
if (ret != 0) {
return ret;
if (ret == 0) {
return ret;
int ret;
if (ret == 0) {
return ret;
int ret;
long int new_ngroups;
if (ret != 0) {
return ret;
return ENOMEM;
if (ret != 0) {
return ret;
ret = 0;
return ret;