confdb.c revision 1c48b5a62f73234ed26bb20f0ab345ab61cda0ab
/*
SSSD
NSS Configuratoin DB
Copyright (C) Simo Sorce <ssorce@redhat.com> 2008
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/>.
*/
#define _GNU_SOURCE
#include <ctype.h>
#include "config.h"
#include "confdb/confdb_private.h"
#include "util/strtonum.h"
if (!var) { \
goto label; \
} \
} while(0)
{
char *ret;
if (!ret)
return NULL;
/* move current string to the end */
return ret;
}
{
char *p;
const char *s;
int l, ret;
/* section must be a non null string and must not start with '/' */
s = section;
l = 0;
while ((p = strchrnul(s, '/'))) {
if (l == 0) {
l = 3 + (p-s);
dn[l] = '\0';
} else {
}
if (!dn) {
goto done;
}
if (*p == '\0') {
break; /* reached end */
}
s = p+1;
if (*s == '\0') { /* a section cannot end in '.' */
goto done;
}
}
done:
return ret;
}
bool replace,
const char *section,
const char *attribute,
const char **values)
{
struct ldb_message *msg;
struct ldb_result *res;
char *secdn;
const char *rdn_name;
int ret, i;
if (!tmp_ctx) {
goto done;
}
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
errno = 0;
/* cn first */
if (ret != LDB_SUCCESS) {
goto done;
}
/* now the requested attribute */
for (i = 0; values[i]; i++) {
if (ret != LDB_SUCCESS) {
goto done;
}
}
if (ret != LDB_SUCCESS) {
goto done;
}
} else {
int optype;
errno = 0;
/* mark this as a replacement */
else optype = LDB_FLAG_MOD_ADD;
if (ret != LDB_SUCCESS) {
goto done;
}
/* now the requested attribute */
for (i = 0; values[i]; i++) {
if (ret != LDB_SUCCESS) {
goto done;
}
}
if (ret != LDB_SUCCESS) {
goto done;
}
}
done:
}
return ret;
}
const char *section,
const char *attribute,
char ***values)
{
struct ldb_result *res;
char *secdn;
char **vals;
struct ldb_message_element *el;
int ret, i;
if (!tmp_ctx)
return ENOMEM;
goto done;
}
if (!dn) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
goto done;
}
if (!vals) {
goto done;
}
/* should always be strings so this should be safe */
for (i = 0; i < el->num_values; i++) {
if (!vals[i]) {
goto done;
}
}
}
}
done:
}
return ret;
}
{
char *restr;
int ret;
goto failed;
}
if (values[0]) {
/* too many values */
goto failed;
}
} else {
/* Did not return a value, so use the default */
return EOK;
}
/* Copy the default string */
}
if (!restr) {
goto failed;
}
return EOK;
return ret;
}
{
long val;
int ret;
goto failed;
}
if (values[0]) {
/* too many values */
goto failed;
}
errno = 0;
if (errno) {
goto failed;
}
goto failed;
}
} else {
}
return EOK;
return ret;
}
{
long val;
int ret;
goto failed;
}
if (values[0]) {
/* too many values */
goto failed;
}
errno = 0;
if (errno) {
goto failed;
}
} else {
}
return EOK;
return ret;
}
{
bool val;
int ret;
goto failed;
}
if (values[0]) {
/* too many values */
goto failed;
}
val = false;
val = true;
} else {
goto failed;
}
} else {
}
return EOK;
return ret;
}
/* WARNING: Unlike other similar functions, this one does NOT take a default,
* and returns ENOENT if the attribute was not found ! */
char ***result)
{
int ret;
goto done;
}
/* too many values */
goto done;
}
} else {
/* Did not return a value */
goto done;
}
done:
}
return ret;
}
struct confdb_ctx **cdb_ctx,
char *confdb_location)
{
struct confdb_ctx *cdb;
if (!cdb)
return ENOMEM;
/* Because confdb calls use sync ldb calls, we create a separate event
* context here. This will prevent the ldb sync calls to start nested
* events.
* NOTE: this means that we *cannot* do async calls and return in confdb
* unless we convert all calls and hook back to the main event context.
*/
return EIO;
}
return EIO;
}
if (ret != LDB_SUCCESS) {
DEBUG(0,("Could not set up debug fn.\n"));
return EIO;
}
if (ret != LDB_SUCCESS) {
DEBUG(0, ("Unable to open config database [%s]\n",
return EIO;
}
return EOK;
}
const char *entry,
{
char *endptr;
*return_value = 0;
return EFAULT;
}
return EOK;
}
return EINVAL;
}
if (errno) {
return errno;
}
if (*endptr != '\0') {
/* Not all of the string was a valid number */
return EINVAL;
}
*return_value = u32ret;
return EOK;
}
bool *return_value,
const char *entry,
bool default_value)
{
*return_value = 0;
return EFAULT;
}
return EOK;
}
*return_value = 0;
}
*return_value = 1;
}
else {
return EINVAL;
}
return EOK;
}
const char *name,
struct sss_domain_info **_domain)
{
struct sss_domain_info *domain;
struct ldb_result *res;
const char *tmp;
if (!dn) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
goto done;
}
if (!domain) {
goto done;
}
if (!tmp) {
DEBUG(0, ("Invalid configuration entry, fatal error!\n"));
goto done;
}
goto done;
}
NULL);
if (tmp) {
goto done;
}
}
else {
DEBUG(0, ("Domain [%s] does not specify an ID provider, disabling!\n",
goto done;
}
/* The files provider is not valid anymore */
DEBUG(0, ("The \"files\" provider is invalid\n"));
goto done;
}
/* If this is the local provider, we need to ensure that
* no other provider was specified for other types, since
* the local provider cannot load them.
*/
NULL);
goto done;
}
NULL);
goto done;
}
NULL);
goto done;
}
}
/* Determine if this domain can be enumerated */
/* TEMP: test if the old bitfield conf value is used and warn it has been
* superceeded. */
if (val > 0) { /* ok there was a number in here */
DEBUG(0, ("Warning: enumeration parameter in %s still uses integers! "
} else { /* assume the new format */
goto done;
}
}
}
* in NSS interfaces */
goto done;
}
DEBUG(0, ("Invalid value for minId\n"));
goto done;
}
CONFDB_DOMAIN_MAXID, 0);
DEBUG(0, ("Invalid value for maxId\n"));
goto done;
}
DEBUG(0, ("Invalid domain range\n"));
goto done;
}
/* Do we allow to cache credentials */
goto done;
}
goto done;
}
done:
return ret;
}
struct sss_domain_info **domains)
{
char **domlist;
int ret, i;
return EOK;
}
&domlist);
DEBUG(0, ("No domains configured, fatal error!\n"));
goto done;
}
DEBUG(0, ("Fatal error retrieving domains list!\n"));
goto done;
}
for (i = 0; domlist[i]; i++) {
if (ret) {
DEBUG(0, ("Error (%d [%s]) retrieving domain [%s], skipping!\n",
continue;
}
} else {
}
}
DEBUG(0, ("No properly configured domains, fatal error!\n"));
goto done;
}
done:
return ret;
}
const char *name,
struct sss_domain_info **_domain)
{
int ret;
return ret;
}
return EOK;
}
}
return ENOENT;
}