usertools.c revision c86904baad32fbf9e66bf1cdc667aa5e683b48ba
/*
SSSD
User tools
Copyright (C) Stephen Gallagher <sgallagh@redhat.com> 2009
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 <pwd.h>
#include <pcre.h>
#include <errno.h>
#include <talloc.h>
#include "util/safe-format-string.h"
#include "responder/common/responder.h"
#ifdef HAVE_LIBPCRE_LESSER_THAN_7
#define NAME_DOMAIN_PATTERN_OPTIONS (PCRE_EXTENDED)
#else
#endif
{
char *username;
return username;
}
/* Function returns given realm name as new uppercase string */
{
char *realm;
char *c;
if (!realm) {
return NULL;
}
c = realm;
while(*c != '\0') {
*c = toupper(*c);
c++;
}
return realm;
}
{
}
return 0;
}
#define IPA_AD_DEFAULT_RE "(((?P<domain>[^\\\\]+)\\\\(?P<name>.+$))|" \
"((?P<name>[^@]+)@(?P<domain>.+$))|" \
"(^(?P<name>[^@\\\\]+)$))"
struct confdb_ctx *cdb,
const char *conf_path,
char **re_pattern)
{
#ifdef HAVE_LIBPCRE_LESSER_THAN_7
("The libpcre version on this system is too old. Only "
"the user@DOMAIN name fully qualified name format will "
"be supported\n"));
*re_pattern = NULL;
return EOK;
#else
int ret;
size_t c;
char *id_provider = NULL;
struct provider_default_re {
const char *name;
const char *re;
{"ad", IPA_AD_DEFAULT_RE},
NULL, &id_provider);
"from conf db.\n"));
goto done;
}
if (id_provider == NULL) {
*re_pattern = NULL;
} else {
if (*re_pattern == NULL) {
goto done;
}
break;
}
}
}
done:
return ret;
#endif
}
{
char *fq;
return ENOMEM;
}
/* Fail if the name specifier is missing, or if the format is
* invalid */
return EINVAL;
return ENOENT;
}
talloc_free (fq);
return EOK;
}
{
struct sss_names_ctx *ctx;
const char *errstr;
int errval;
int errpos;
int ret;
goto done;
}
goto done;
}
goto done;
}
done:
}
return ret;
}
{
char *re_pattern = NULL;;
int ret;
goto done;
}
goto done;
}
}
/* If not found in the domain, look in globals */
if (re_pattern == NULL) {
}
"expression for domain [%s].\n", domain));
goto done;
}
}
if (!re_pattern) {
"(?P<name>[^@]+)@?(?P<domain>[^@]*$)");
if (!re_pattern) {
goto done;
}
#ifdef HAVE_LIBPCRE_LESSER_THAN_7
} else {
"not support non-unique named subpatterns.\n"));
"subpatterns with a unique name and uses "
"the Python syntax (?P<name>).\n", re_pattern));
#endif
}
}
/* If not found in the domain, look in globals */
}
if (!fq_fmt) {
if (!fq_fmt) {
goto done;
}
}
done:
return ret;
}
struct sss_names_ctx *snctx,
{
const char *result;
int ovec[30];
int origlen;
if (ret == PCRE_ERROR_NOMATCH) {
return EINVAL;
} else if (ret < 0) {
return EINVAL;
}
if (ret == 0) {
}
return EINVAL;
}
} else {
/* ignore "" string */
if (*result) {
} else {
}
}
return EOK;
}
static struct sss_domain_info * match_any_domain_or_subdomain_name(
struct sss_domain_info *dom,
const char *dmatch)
{
return dom;
}
}
struct sss_domain_info *domains,
const char *default_domain,
{
char *candidate_name = NULL;
char *candidate_domain = NULL;
bool name_mismatch = false;
int ret;
return ENOMEM;
/*
* If the name matched without the domain part, make note of it.
* All the other domain expressions must agree on the domain-less
* name.
*/
if (candidate_name == NULL) {
name_mismatch = true;
}
/*
* If a domain was returned, then it must match the name of the
* domain that this expression was found on, or one of the
* subdomains.
*/
} else {
"domain '%s', user is %s\n",
goto done;
}
break;
} else if (candidate_name == NULL) {
}
}
/* EINVAL is returned when name doesn't match */
goto done;
}
}
if (candidate_name && !name_mismatch) {
if (default_domain != NULL) {
goto done;
}
break;
}
}
"not know, trying to look it up.\n",
rdomain));
goto done;
}
}
} else if (candidate_domain) {
goto done;
}
}
("name '%s' did not match any domain's expression\n", orig));
goto done;
}
}
}
done:
return ret;
}
char *
const char *orig_name,
bool case_sensitive)
{
}
bool case_sensitive, const char ***_cased)
{
const char **out;
return EOK;
}
if (num == 0) {
return EOK;
}
return ENOMEM;
}
for (i = 0; i < num; i++) {
return ENOMEM;
}
}
return EOK;
}
static inline const char *
{
const char *s;
if (s == NULL) {
"flat name set, falling back to domain name\n"));
}
return s;
}
char *
{
}
static void
safe_talloc_callback (void *data,
const char *piece,
{
}
char *
const char *domain_name, const char *flat_dom_name,
const char *name)
{
char *output;
return output;
}
int
{
}
char *
const char *orig_name,
struct sss_domain_info *dom)
{
char *user_name;
/* we always use the fully qualified name for subdomain users */
} else {
}
return user_name;
}