usertools.c revision 62def404cb14e02d2903c68fb730c5281ad902fe
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder Copyright (C) Stephen Gallagher <sgallagh@redhat.com> 2009
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder This program is free software; you can redistribute it and/or modify
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder it under the terms of the GNU General Public License as published by
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder the Free Software Foundation; either version 3 of the License, or
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder (at your option) any later version.
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder This program is distributed in the hope that it will be useful,
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder but WITHOUT ANY WARRANTY; without even the implied warranty of
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder GNU General Public License for more details.
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder You should have received a copy of the GNU General Public License
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder along with this program. If not, see <http://www.gnu.org/licenses/>.
0c92a39a4adf3c1cbe173e3b16c65c159a1ce612Christian Maeder#define NAME_DOMAIN_PATTERN_OPTIONS (PCRE_EXTENDED)
0c92a39a4adf3c1cbe173e3b16c65c159a1ce612Christian Maeder#define NAME_DOMAIN_PATTERN_OPTIONS (PCRE_DUPNAMES | PCRE_EXTENDED)
0c92a39a4adf3c1cbe173e3b16c65c159a1ce612Christian Maederchar *get_username_from_uid(TALLOC_CTX *mem_ctx, uid_t uid)
0c92a39a4adf3c1cbe173e3b16c65c159a1ce612Christian Maeder username = talloc_strdup(mem_ctx, pwd->pw_name);
0c92a39a4adf3c1cbe173e3b16c65c159a1ce612Christian Maederstatic int sss_names_ctx_destructor(struct sss_names_ctx *snctx)
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maederint sss_names_init(TALLOC_CTX *mem_ctx, struct confdb_ctx *cdb, struct sss_names_ctx **out)
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder ctx = talloc_zero(mem_ctx, struct sss_names_ctx);
36a493b7eec0f9d719674296c26afe7fd9bfe327Christian Maeder talloc_set_destructor(ctx, sss_names_ctx_destructor);
36a493b7eec0f9d719674296c26afe7fd9bfe327Christian Maeder ret = confdb_get_string(cdb, ctx, CONFDB_MONITOR_CONF_ENTRY,
bb2c1beb7ab66a49627a2a34df80864a3c65cc83Christian Maeder CONFDB_MONITOR_NAME_REGEX, NULL, &ctx->re_pattern);
36a493b7eec0f9d719674296c26afe7fd9bfe327Christian Maeder "(?P<name>[^@]+)@?(?P<domain>[^@]*$)");
36a493b7eec0f9d719674296c26afe7fd9bfe327Christian Maeder DEBUG(2, ("This binary was build with a version of libpcre that does "
36a493b7eec0f9d719674296c26afe7fd9bfe327Christian Maeder "not support non-unique named subpatterns.\n"));
36a493b7eec0f9d719674296c26afe7fd9bfe327Christian Maeder DEBUG(2, ("Please make sure that your pattern [%s] only contains "
36a493b7eec0f9d719674296c26afe7fd9bfe327Christian Maeder "subpatterns with a unique name and uses "
36a493b7eec0f9d719674296c26afe7fd9bfe327Christian Maeder "the Python syntax (?P<name>).\n", ctx->re_pattern));
36a493b7eec0f9d719674296c26afe7fd9bfe327Christian Maeder ret = confdb_get_string(cdb, ctx, CONFDB_MONITOR_CONF_ENTRY,
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder CONFDB_MONITOR_FULL_NAME_FORMAT, NULL, &ctx->fq_fmt);
d4aed7a2eea6b546c0d9520d85038addb7beb12fChristian Maeder ctx->fq_fmt = talloc_strdup(ctx, "%1$s@%2$s");
36a493b7eec0f9d719674296c26afe7fd9bfe327Christian Maeder DEBUG(1, ("Invalid Regular Expression pattern at position %d."
36a493b7eec0f9d719674296c26afe7fd9bfe327Christian Maeder " (Error: %d [%s])\n", errpos, errval, errstr));
0c92a39a4adf3c1cbe173e3b16c65c159a1ce612Christian Maeder const char *orig, char **domain, char **name)
13140d161d2d2d11d87283d01d57ee3a738a833dChristian Maeder ret = pcre_exec(re, NULL, orig, origlen, 0, PCRE_NOTEMPTY, ovec, 30);
13140d161d2d2d11d87283d01d57ee3a738a833dChristian Maeder DEBUG(2, ("PCRE Matching error, %d\n", ret));
0c92a39a4adf3c1cbe173e3b16c65c159a1ce612Christian Maeder DEBUG(1, ("Too many matches, the pattern is invalid.\n"));
return EINVAL;
if (*result) {
return EOK;
const char *orig_name,
bool case_sensitive)
const char **out;
return EOK;
if (num == 0) {
return EOK;
return ENOMEM;
for (i = 0; i < num; i++) {
return ENOMEM;
return EOK;