sysdb_search.c revision 02d1cb8935d5c9b57cd05dfdbfe6ed38e0d61c28
/*
SSSD
System Database
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/>.
*/
#include "db/sysdb_private.h"
#include <time.h>
#include <ctype.h>
/* users */
struct sss_domain_info *domain,
const char *name,
struct ldb_result **_res)
{
static const char *attrs[] = SYSDB_PW_ATTRS;
struct ldb_result *res;
char *sanitized_name;
const char *src_name;
int ret;
if (!tmp_ctx) {
return ENOMEM;
}
if (!base_dn) {
goto done;
}
/* If this is a subomain we need to use fully qualified names for the
* search as well by default */
if (!src_name) {
goto done;
}
goto done;
}
if (ret) {
goto done;
}
done:
return ret;
}
struct sss_domain_info *domain,
struct ldb_result **_res)
{
static const char *attrs[] = SYSDB_PW_ATTRS;
struct ldb_result *res;
int ret;
if (!tmp_ctx) {
return ENOMEM;
}
if (!base_dn) {
goto done;
}
if (ret) {
goto done;
}
done:
return ret;
}
struct sss_domain_info *domain,
struct ldb_result **_res)
{
static const char *attrs[] = SYSDB_PW_ATTRS;
struct ldb_result *res;
int ret;
if (!tmp_ctx) {
return ENOMEM;
}
if (!base_dn) {
goto done;
}
if (ret) {
goto done;
}
done:
return ret;
}
/* groups */
{
struct ldb_message_element *el;
int i;
/* see if this is a user to convert to a group */
for (i = 0; i < el->num_values; i++) {
break;
}
}
/* no, leave as is */
/* yes, convert */
return EOK;
}
{
int ret;
int i;
if (ret) {
return ret;
}
}
return EOK;
}
struct sss_domain_info *domain,
const char *name,
struct ldb_result **_res)
{
static const char *attrs[] = SYSDB_GRSRC_ATTRS;
const char *fmt_filter;
char *sanitized_name;
struct ldb_result *res;
const char *src_name;
int ret;
if (!tmp_ctx) {
return ENOMEM;
}
} else {
}
if (!base_dn) {
goto done;
}
/* If this is a subomain we need to use fully qualified names for the
* search as well by default */
if (!src_name) {
goto done;
}
goto done;
}
if (ret) {
goto done;
}
if (ret) {
goto done;
}
done:
return ret;
}
struct sss_domain_info *domain,
struct ldb_result **_res)
{
static const char *attrs[] = SYSDB_GRSRC_ATTRS;
const char *fmt_filter;
struct ldb_result *res;
int ret;
if (!tmp_ctx) {
return ENOMEM;
}
} else {
}
if (!base_dn) {
goto done;
}
if (ret) {
goto done;
}
if (ret) {
goto done;
}
done:
return ret;
}
struct sss_domain_info *domain,
struct ldb_result **_res)
{
static const char *attrs[] = SYSDB_GRSRC_ATTRS;
const char *fmt_filter;
struct ldb_result *res;
int ret;
if (!tmp_ctx) {
return ENOMEM;
}
} else {
}
if (!base_dn) {
goto done;
}
if (ret) {
goto done;
}
if (ret) {
goto done;
}
done:
return ret;
}
struct sss_domain_info *domain,
const char *name,
struct ldb_result **_res)
{
struct ldb_result *res;
struct ldb_request *req;
struct ldb_control **ctrl;
struct ldb_asq_control *control;
static const char *attrs[] = SYSDB_INITGR_ATTRS;
int ret;
if (!tmp_ctx) {
return ENOMEM;
}
goto done;
}
/* User is not cached yet */
goto done;
goto done;
}
/* no need to steal the dn, we are not freeing the result */
/* note we count on the fact that the default search callback
* will just keep appending values. This is by design and can't
* change so it is ok to already have a result (from the getpwnam)
* even before we call the next search */
if (!ctrl) {
goto done;
}
if (!ctrl[0]) {
goto done;
}
if (!control) {
goto done;
}
if (!control->source_attribute) {
goto done;
}
NULL);
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret == LDB_SUCCESS) {
}
if (ret != LDB_SUCCESS) {
goto done;
}
done:
return ret;
}
struct sss_domain_info *domain,
const char *name,
const char **attributes,
struct ldb_result **_res)
{
struct ldb_result *res;
char *sanitized_name;
int ret;
if (!tmp_ctx) {
return ENOMEM;
}
if (!base_dn) {
goto done;
}
goto done;
}
if (ret) {
goto done;
}
done:
return ret;
}
/* This function splits a three-tuple into three strings
* It assumes that any whitespace between the parentheses
* and commas are intentional and does not attempt to
* strip them out. Leading and trailing whitespace is
* ignored.
*
* This behavior is compatible with nss_ldap's
* implementation.
*/
const char *triple,
char **hostname,
char **username,
char **domainname)
{
const char *p = triple;
const char *p_host;
const char *p_user;
const char *p_domain;
/* Pre-set the values to NULL here so if they are not
* copied, we don't return garbage below.
*/
*domainname = NULL;
if (!tmp_ctx) {
return ENOMEM;
}
/* Remove any leading whitespace */
while (*p && isspace(*p)) p++;
if (*p != '(') {
/* Triple must start and end with parentheses */
goto done;
}
p++;
p_host = p;
/* Find the first comma */
while (*p && *p != ',') p++;
if (!*p) {
/* No comma was found: parse error */
goto done;
}
if (len > 0) {
/* Copy the host string */
if (!host) {
goto done;
}
}
p++;
p_user = p;
/* Find the second comma */
while (*p && *p != ',') p++;
if (!*p) {
/* No comma was found: parse error */
goto done;
}
if (len > 0) {
/* Copy the user string */
if (!user) {
goto done;
}
}
p++;
p_domain = p;
/* Find the closing parenthesis */
while (*p && *p != ')') p++;
if (*p != ')') {
/* No trailing parenthesis: parse error */
goto done;
}
if (len > 0) {
/* Copy the domain string */
if (!domain) {
goto done;
}
}
p++;
/* skip trailing whitespace */
while (*p && isspace(*p)) p++;
if (*p) {
/* Extra data after the closing parenthesis
* is a parse error
*/
goto done;
}
/* Return any non-NULL values */
if (host) {
}
if (user) {
}
if (domain) {
}
done:
return ret;
}
struct ldb_result *res,
struct sysdb_netgroup_ctx ***entries)
{
size_t c = 0;
char *triple_str;
struct ldb_message_element *el;
int i, j;
return ENOENT;
}
if (!tmp_ctx) {
return ENOMEM;
}
}
}
}
goto done;
}
if (size != 0) {
/* Copy in all of the entries */
for(j = 0; j < el->num_values; j++) {
if (!triple_str) {
goto done;
}
struct sysdb_netgroup_ctx);
if (!tmp_entry[c]) {
goto done;
}
goto done;
}
c++;
}
}
for(j = 0; j < el->num_values; j++) {
struct sysdb_netgroup_ctx);
if (!tmp_entry[c]) {
goto done;
}
goto done;
}
c++;
}
}
}
}
/* Add NULL terminator */
done:
return ret;
}
struct sss_domain_info *domain,
const char *netgroup,
struct ldb_result **res)
{
static const char *attrs[] = SYSDB_NETGR_ATTRS;
struct ldb_result *result;
char *sanitized_netgroup;
char *netgroup_dn;
int lret;
if (!tmp_ctx) {
return ENOMEM;
}
if (!base_dn) {
goto done;
}
goto done;
}
if (!netgroup_dn) {
goto done;
}
goto done;
}
done:
return ret;
}
struct sss_domain_info *domain,
const char *netgrname,
const char **attributes,
struct ldb_result **res)
{
struct ldb_result *result;
char *sanitized_netgroup;
int ret;
if (!tmp_ctx) {
return ENOMEM;
}
if (!base_dn) {
goto done;
}
goto done;
}
if (ret) {
goto done;
}
done:
return ret;
}
struct sss_domain_info *dom,
enum sysdb_member_type mtype,
const char *name,
char ***_direct_parents)
{
const char *dn;
char *sanitized_dn;
const char *member_filter;
size_t direct_sysdb_count = 0;
char **direct_parents = NULL;
int i, pi;
const char *tmp_str;
if (mtype == SYSDB_MEMBER_USER) {
} else if (mtype == SYSDB_MEMBER_GROUP) {
} else {
goto done;
}
if (!dn) {
goto done;
}
goto done;
}
if (!member_filter) {
goto done;
}
if (!basedn) {
goto done;
}
direct_sysdb_count = 0;
goto done;
}
/* EOK */
/* Get the list of sysdb groups by name */
if (!direct_parents) {
goto done;
}
pi = 0;
for(i = 0; i < direct_sysdb_count; i++) {
SYSDB_NAME, NULL);
if (!tmp_str) {
/* This should never happen, but if it does, just continue */
continue;
}
if (!direct_parents[pi]) {
goto done;
}
pi++;
}
done:
return ret;
}