nss_protocol_pwent.c revision a012a71f21bf1a4687e58085f19c18cc5b2bbadd
/*
Authors:
Pavel Březina <pbrezina@redhat.com>
Copyright (C) 2016 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/>.
*/
#include "responder/nss/nss_protocol.h"
static uint32_t
struct ldb_message *msg)
{
/* First, try to return overriden gid. */
if (DOM_HAS_VIEWS(domain)) {
0);
if (gid != 0) {
return gid;
}
}
/* Try to return domain gid override. */
if (domain->override_gid != 0) {
return domain->override_gid;
}
/* Return original gid. */
}
static const char *
struct ldb_message *msg,
struct sss_domain_info *dom,
struct sss_nss_homedir_ctx *homedir_ctx)
{
const char *homedir;
NULL);
/* Check to see which homedir_prefix to use. */
}
/* Check whether we are unconditionally overriding the server
* for home directory locations.
*/
if (dom->override_homedir) {
} else if (nctx->override_homedir) {
}
/* In the case of a NULL or empty homedir, check to see if
* we have a fallback homedir to use.
*/
if (dom->fallback_homedir) {
} else if (nctx->fallback_homedir) {
}
}
/* Provider can also return template, try to expand it.*/
}
static const char *
struct sss_domain_info *domain,
struct ldb_message *msg,
const char *orig_name,
const char *upn,
{
struct sss_nss_homedir_ctx hd_ctx = { 0 };
const char *homedir;
return "/";
}
return homedir;
}
static const char *
struct sss_domain_info *domain)
{
const char *shell;
int i;
/* Check whether we are unconditionally overriding
* the server for the login shell. */
if (domain->override_shell) {
return domain->override_shell;
} else if (nss_ctx->override_shell) {
return nss_ctx->override_shell;
}
NULL);
/* Check whether there is a default shell specified */
if (domain->default_shell) {
return domain->default_shell;
} else if (nss_ctx->default_shell) {
return nss_ctx->default_shell;
}
return "";
}
return shell;
}
if (nss_ctx->vetoed_shells) {
for (i = 0; nss_ctx->vetoed_shells[i]; i++) {
"The shell '%s' is vetoed. Using fallback.\n",
shell);
return nss_ctx->shell_fallback;
}
}
}
if (nss_ctx->etc_shells) {
for (i = 0; nss_ctx->etc_shells[i]; i++) {
break;
}
}
if (nss_ctx->etc_shells[i]) {
return shell;
}
}
if (nss_ctx->allowed_shells) {
"The shell '%s' is allowed but does not exist. "
"Using fallback\n", shell);
return nss_ctx->shell_fallback;
} else {
for (i = 0; nss_ctx->allowed_shells[i]; i++) {
"The shell '%s' is allowed but does not exist. "
"Using fallback\n", shell);
return nss_ctx->shell_fallback;
}
}
}
}
"The shell '%s' is not allowed and does not exist.\n", shell);
return NOLOGIN_SHELL;
}
static errno_t
struct sss_domain_info *domain,
struct ldb_message *msg,
struct sized_string **_name,
struct sized_string *_gecos,
struct sized_string *_homedir,
struct sized_string *_shell)
{
const char *upn;
const char *name;
const char *gecos;
const char *homedir;
const char *shell;
/* Get fields. */
"Incomplete user object for %s[%u]! Skipping\n",
return EINVAL;
}
NULL);
/* Convert to sized strings. */
"sized_output_name failed, skipping [%d]: %s\n",
return ret;
}
return EOK;
}
struct nss_cmd_ctx *cmd_ctx,
struct sss_packet *packet,
struct cache_req_result *result)
{
struct ldb_message *msg;
struct sized_string pwfield;
struct sized_string *name;
struct sized_string gecos;
struct sized_string homedir;
struct sized_string shell;
int i;
return ENOMEM;
}
/* First two fields (length and reserved), filled up later. */
return ret;
}
num_results = 0;
/* Password field content. */
continue;
}
/* Check negative cache during enumeration. */
if (cmd_ctx->enumeration) {
continue;
}
}
/* Adjust packet size: uid, gid + string fields. */
goto done;
}
/* Fill packet. */
num_results++;
/* Do not store entry in memory cache during enumeration. */
if (!cmd_ctx->enumeration) {
"Failed to store user %s (%s) in mmap cache [%d]: %s!\n",
}
}
}
done:
return ret;
}
return EOK;
}