summaryrefslogtreecommitdiffstats
path: root/src/responder/nss
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2011-08-08 10:57:16 +0200
committerStephen Gallagher <sgallagh@redhat.com>2011-08-08 10:23:43 -0400
commitb03a48297a3dc03ea59360345f352bc449189589 (patch)
treec1a82beaa4e5a9710eba054a0717e9c79dc91ef0 /src/responder/nss
parentd7ef16231ce8db7b54b7dd242a38b29afdcd2337 (diff)
downloadsssd-b03a48297a3dc03ea59360345f352bc449189589.tar.gz
sssd-b03a48297a3dc03ea59360345f352bc449189589.tar.xz
sssd-b03a48297a3dc03ea59360345f352bc449189589.zip
Prevent segfault if vetoed_shells are specified without allowed_shells
https://fedorahosted.org/sssd/ticket/954
Diffstat (limited to 'src/responder/nss')
-rw-r--r--src/responder/nss/nsssrv_cmd.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c
index 5dbd3ca74..56ebe4815 100644
--- a/src/responder/nss/nsssrv_cmd.c
+++ b/src/responder/nss/nsssrv_cmd.c
@@ -316,8 +316,7 @@ static const char *get_shell_override(TALLOC_CTX *mem_ctx,
if (!user_shell) return NULL;
if (!nctx->allowed_shells && !nctx->vetoed_shells) return talloc_strdup(mem_ctx, user_shell);
- if (nctx->vetoed_shells)
- {
+ if (nctx->vetoed_shells) {
for (i=0; nctx->vetoed_shells[i]; i++) {
if (strcmp(nctx->vetoed_shells[i], user_shell) == 0) {
DEBUG(5, ("The shell '%s' is vetoed. "
@@ -327,24 +326,28 @@ static const char *get_shell_override(TALLOC_CTX *mem_ctx,
}
}
- for (i=0; nctx->etc_shells[i]; i++) {
- if (strcmp(user_shell, nctx->etc_shells[i]) == 0) {
- DEBUG(9, ("Shell %s found in /etc/shells\n",
- nctx->etc_shells[i]));
- break;
+ if (nctx->etc_shells) {
+ for (i=0; nctx->etc_shells[i]; i++) {
+ if (strcmp(user_shell, nctx->etc_shells[i]) == 0) {
+ DEBUG(9, ("Shell %s found in /etc/shells\n",
+ nctx->etc_shells[i]));
+ break;
+ }
}
- }
- if (nctx->etc_shells[i]) {
- DEBUG(9, ("Using original shell '%s'\n", user_shell));
- return talloc_strdup(mem_ctx, user_shell);
+ if (nctx->etc_shells[i]) {
+ DEBUG(9, ("Using original shell '%s'\n", user_shell));
+ return talloc_strdup(mem_ctx, user_shell);
+ }
}
- for (i=0; nctx->allowed_shells[i]; i++) {
- if (strcmp(nctx->allowed_shells[i], user_shell) == 0) {
- DEBUG(5, ("The shell '%s' is allowed but does not exist. "
- "Using fallback\n", user_shell));
- return talloc_strdup(mem_ctx, nctx->shell_fallback);
+ if (nctx->allowed_shells) {
+ for (i=0; nctx->allowed_shells[i]; i++) {
+ if (strcmp(nctx->allowed_shells[i], user_shell) == 0) {
+ DEBUG(5, ("The shell '%s' is allowed but does not exist. "
+ "Using fallback\n", user_shell));
+ return talloc_strdup(mem_ctx, nctx->shell_fallback);
+ }
}
}