proxy_id.c revision d7dc57bcc2468bee756bcd568daee0644e5b888d
/*
SSSD
Authors:
Stephen Gallagher <sgallagh@redhat.com>
Copyright (C) 2010 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* =Getpwnam-wrapper======================================================*/
struct proxy_id_ctx *ctx,
struct sss_domain_info *dom,
const char *name)
{
enum nss_status status;
char *buffer;
int ret;
if (!tmpctx) {
return ENOMEM;
}
if (!pwd) {
goto done;
}
if (!buffer) {
goto done;
}
/* FIXME: should we move this call outside the transaction to keep the
* transaction as short as possible ? */
switch (status) {
case NSS_STATUS_NOTFOUND:
if (ret) {
goto done;
}
break;
case NSS_STATUS_SUCCESS:
/* uid=0 or gid=0 are invalid values */
/* also check that the id is in the valid range for this domain */
if (ret) {
goto done;
}
break;
}
if (ret) {
goto done;
}
break;
case NSS_STATUS_UNAVAIL:
/* "remote" backend unavailable. Enter offline mode */
goto done;
default:
goto done;
}
done:
if (ret) {
}
return ret;
}
{
" deleting!\n", name));
if (!dn) {
return ENOMEM;
}
}
/* =Getpwuid-wrapper======================================================*/
struct proxy_id_ctx *ctx,
struct sss_domain_info *dom,
{
enum nss_status status;
char *buffer;
bool del_user = false;
int ret;
if (!tmpctx) {
return ENOMEM;
}
if (!pwd) {
return ret;
}
if (!buffer) {
return ret;
}
switch (status) {
case NSS_STATUS_NOTFOUND:
del_user = true;
break;
case NSS_STATUS_SUCCESS:
/* uid=0 or gid=0 are invalid values */
/* also check that the id is in the valid range for this domain */
del_user = true;
break;
}
if (ret) {
goto done;
}
break;
case NSS_STATUS_UNAVAIL:
/* "remote" backend unavailable. Enter offline mode */
goto done;
default:
goto done;
}
if (del_user) {
" deleting!\n", uid));
if (ret) {
goto done;
}
}
done:
if (ret) {
}
return ret;
}
/* =Getpwent-wrapper======================================================*/
struct proxy_id_ctx *ctx,
struct sss_domain_info *dom)
{
bool in_transaction = false;
enum nss_status status;
char *buffer;
char *newbuf;
int ret;
if (!tmpctx) {
return ENOMEM;
}
if (!pwd) {
goto done;
}
if (!buffer) {
goto done;
}
if (ret) {
goto done;
}
in_transaction = true;
if (status != NSS_STATUS_SUCCESS) {
goto done;
}
/* always zero out the pwd structure */
/* get entry */
switch (status) {
case NSS_STATUS_TRYAGAIN:
/* buffer too small ? */
if (buflen < MAX_BUF_SIZE) {
buflen *= 2;
}
if (buflen > MAX_BUF_SIZE) {
}
if (!newbuf) {
goto done;
}
goto again;
case NSS_STATUS_NOTFOUND:
/* we are done here */
in_transaction = false;
break;
case NSS_STATUS_SUCCESS:
/* uid=0 or gid=0 are invalid values */
/* also check that the id is in the valid range for this domain */
goto again; /* skip */
}
if (ret) {
/* Do not fail completely on errors.
* Just report the failure to save and go on */
}
goto again; /* next */
case NSS_STATUS_UNAVAIL:
/* "remote" backend unavailable. Enter offline mode */
break;
default:
break;
}
done:
if (in_transaction) {
}
return ret;
}
/* =Getgrnam-wrapper======================================================*/
do { \
if (debug_level >= level) { \
} else { \
int i = 0; \
/* count */ \
i++; \
} \
} \
} \
} while(0)
struct proxy_id_ctx *ctx,
struct sss_domain_info *dom,
const char *name)
{
enum nss_status status;
char *buffer;
char *newbuf;
bool delete_group = false;
struct sysdb_attrs *members;
int ret;
if (!tmpctx) {
return ENOMEM;
}
if (!grp) {
return ret;
}
if (!buffer) {
return ret;
}
/* FIXME: should we move this call outside the transaction to keep the
* transaction as short as possible ? */
/* always zero out the grp structure */
switch (status) {
case NSS_STATUS_TRYAGAIN:
/* buffer too small ? */
if (buflen < MAX_BUF_SIZE) {
buflen *= 2;
}
if (buflen > MAX_BUF_SIZE) {
}
if (!newbuf) {
goto done;
}
goto again;
case NSS_STATUS_NOTFOUND:
delete_group = true;
break;
case NSS_STATUS_SUCCESS:
/* gid=0 is an invalid value */
/* also check that the id is in the valid range for this domain */
name));
delete_group = true;
break;
}
if (!members) {
goto done;
}
if (ret) {
goto done;
}
} else {
}
if (ret) {
goto done;
}
break;
case NSS_STATUS_UNAVAIL:
/* "remote" backend unavailable. Enter offline mode */
goto done;
default:
goto done;
}
if (delete_group) {
" deleting!\n", name));
if (!dn) {
goto done;
}
if (ret) {
goto done;
}
}
done:
if (ret) {
}
return ret;
}
/* =Getgrgid-wrapper======================================================*/
struct proxy_id_ctx *ctx,
struct sss_domain_info *dom,
{
enum nss_status status;
char *buffer;
char *newbuf;
bool delete_group = false;
struct sysdb_attrs *members;
int ret;
if (!tmpctx) {
return ENOMEM;
}
if (!grp) {
return ret;
}
if (!buffer) {
return ret;
}
/* always zero out the group structure */
switch (status) {
case NSS_STATUS_TRYAGAIN:
/* buffer too small ? */
if (buflen < MAX_BUF_SIZE) {
buflen *= 2;
}
if (buflen > MAX_BUF_SIZE) {
}
if (!newbuf) {
goto done;
}
goto again;
case NSS_STATUS_NOTFOUND:
delete_group = true;
break;
case NSS_STATUS_SUCCESS:
/* gid=0 is an invalid value */
/* also check that the id is in the valid range for this domain */
delete_group = true;
break;
}
if (!members) {
goto done;
}
if (ret) {
goto done;
}
} else {
}
if (ret) {
goto done;
}
break;
case NSS_STATUS_UNAVAIL:
/* "remote" backend unavailable. Enter offline mode */
goto done;
default:
goto done;
}
if (delete_group) {
" deleting!\n", gid));
if (ret) {
goto done;
}
}
done:
if (ret) {
}
return ret;
}
/* =Getgrent-wrapper======================================================*/
struct proxy_id_ctx *ctx,
struct sss_domain_info *dom)
{
bool in_transaction = false;
enum nss_status status;
char *buffer;
struct sysdb_attrs *members;
char *newbuf;
int ret;
if (!tmpctx) {
return ENOMEM;
}
if (!grp) {
goto done;
}
if (!buffer) {
goto done;
}
if (ret) {
goto done;
}
in_transaction = true;
if (status != NSS_STATUS_SUCCESS) {
goto done;
}
/* always zero out the grp structure */
/* get entry */
switch (status) {
case NSS_STATUS_TRYAGAIN:
/* buffer too small ? */
if (buflen < MAX_BUF_SIZE) {
buflen *= 2;
}
if (buflen > MAX_BUF_SIZE) {
}
if (!newbuf) {
goto done;
}
goto again;
case NSS_STATUS_NOTFOUND:
/* we are done here */
in_transaction = false;
break;
case NSS_STATUS_SUCCESS:
/* gid=0 is an invalid value */
/* also check that the id is in the valid range for this domain */
goto again; /* skip */
}
if (!members) {
goto done;
}
if (ret) {
goto done;
}
} else {
}
if (ret) {
/* Do not fail completely on errors.
* Just report the failure to save and go on */
}
goto again; /* next */
case NSS_STATUS_UNAVAIL:
/* "remote" backend unavailable. Enter offline mode */
break;
default:
break;
}
done:
if (in_transaction) {
}
return ret;
}
/* =Initgroups-wrapper====================================================*/
struct proxy_id_ctx *ctx,
struct sss_domain_info *dom,
struct proxy_id_ctx *ctx,
struct sss_domain_info *dom,
const char *name)
{
bool in_transaction = false;
enum nss_status status;
char *buffer;
int ret;
if (!tmpctx) {
return ENOMEM;
}
if (!pwd) {
goto done;
}
if (!buffer) {
goto done;
}
if (ret) {
goto done;
}
in_transaction = true;
/* FIXME: should we move this call outside the transaction to keep the
* transaction as short as possible ? */
switch (status) {
case NSS_STATUS_NOTFOUND:
if (ret) {
goto done;
}
break;
case NSS_STATUS_SUCCESS:
/* uid=0 or gid=0 are invalid values */
/* also check that the id is in the valid range for this domain */
name));
break;
}
if (ret) {
goto done;
}
in_transaction = true;
}
break;
case NSS_STATUS_UNAVAIL:
/* "remote" backend unavailable. Enter offline mode */
break;
default:
break;
}
done:
if (in_transaction) {
}
return ret;
}
struct proxy_id_ctx *ctx,
struct sss_domain_info *dom,
{
enum nss_status status;
long int limit;
long int size;
long int num;
long int num_gids;
int ret;
int i;
num_gids = 0;
limit = 4096;
num = 4096;
if (!gids) {
return ENOMEM;
}
/* FIXME: should we move this call outside the transaction to keep the
* transaction as short as possible ? */
switch (status) {
case NSS_STATUS_TRYAGAIN:
/* buffer too small ? */
if (size < MAX_BUF_SIZE) {
num *= 2;
}
if (size > MAX_BUF_SIZE) {
size = MAX_BUF_SIZE;
}
if (!gids) {
return ENOMEM;
}
goto again; /* retry with more memory */
case NSS_STATUS_SUCCESS:
for (i = 0; i < num_gids; i++) {
if (ret) {
return ret;
}
}
break;
default:
break;
}
return ret;
}
/* =Proxy_Id-Functions====================================================*/
{
struct be_acct_req *ar;
struct proxy_id_ctx *ctx;
struct sss_domain_info *domain;
int ret;
struct proxy_id_ctx);
}
/* for now we support only core attrs */
}
case BE_REQ_USER: /* user */
switch (ar->filter_type) {
case BE_FILTER_NAME:
} else {
}
break;
case BE_FILTER_IDNUM:
EINVAL, "Invalid attr type");
} else {
char *endptr;
errno = 0;
EINVAL, "Invalid attr type");
}
}
break;
default:
EINVAL, "Invalid filter type");
}
break;
case BE_REQ_GROUP: /* group */
switch (ar->filter_type) {
case BE_FILTER_NAME:
} else {
}
break;
case BE_FILTER_IDNUM:
EINVAL, "Invalid attr type");
} else {
char *endptr;
errno = 0;
EINVAL, "Invalid attr type");
}
}
break;
default:
EINVAL, "Invalid filter type");
}
break;
case BE_REQ_INITGROUPS: /* init groups for user */
EINVAL, "Invalid filter type");
}
EINVAL, "Invalid filter value");
}
ENODEV, "Initgroups call not supported");
}
break;
case BE_REQ_NETGROUP:
EINVAL, "Invalid filter type");
}
ENODEV, "Netgroups are not supported");
}
ENOSYS, "Netgroups not implemented");
default: /*fail*/
EINVAL, "Invalid request type");
}
if (ret) {
}
return;
}
}