Skip to content

Commit

Permalink
Add domain variable for use in pam_authz_search
Browse files Browse the repository at this point in the history
This adds a domain variable (if it can be determined on the system) that
can be used in pam_authz_search and pam_authc_search filters to build
search filters that search on the domain name (the FQDN without the
starting host name).

Closes #8
  • Loading branch information
arthurdejong committed Jul 21, 2018
1 parent 9fbcdd1 commit 84676ab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions man/nslcd.conf.5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,7 @@
<literal>$ruser</literal>, <literal>$rhost</literal>,
<literal>$tty</literal>, <literal>$hostname</literal>,
<literal>$fqdn</literal>, <!-- since 0.8.1 -->
<literal>$domain</literal>, <!-- since 0.9.10 -->
<literal>$dn</literal>, and <literal>$uid</literal>.
These references are substituted in the search filter using the
same syntax as described in the section on attribute mapping
Expand Down
1 change: 1 addition & 0 deletions nslcd/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ static void check_search_variables(
(strcmp(list[i], "tty") != 0) &&
(strcmp(list[i], "hostname") != 0) &&
(strcmp(list[i], "fqdn") != 0) &&
(strcmp(list[i], "domain") != 0) &&
(strcmp(list[i], "dn") != 0) &&
(strcmp(list[i], "uid") != 0))
{
Expand Down
8 changes: 6 additions & 2 deletions nslcd/pam.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pam.c - pam processing routines
Copyright (C) 2009 Howard Chu
Copyright (C) 2009-2017 Arthur de Jong
Copyright (C) 2009-2018 Arthur de Jong
Copyright (C) 2015 Nokia Solutions and Networks
This library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -71,7 +71,7 @@ static DICT *search_vars_new(const char *dn, const char *username,
char hostname[BUFLEN_HOSTNAME];
/* allocating this on the stack is OK because search_var_add()
will allocate new memory for the value */
const char *fqdn;
const char *fqdn, *found;
DICT *dict;
dict = dict_new();
if (dict == NULL)
Expand All @@ -89,7 +89,11 @@ static DICT *search_vars_new(const char *dn, const char *username,
if (gethostname(hostname, sizeof(hostname)) == 0)
search_var_add(dict, "hostname", hostname);
if ((fqdn = getfqdn()) != NULL)
{
search_var_add(dict, "fqdn", fqdn);
if (((found = strchr(fqdn, '.'))) != NULL && (found[1] != '\0'))
search_var_add(dict, "domain", found + 1);
}
search_var_add(dict, "dn", dn);
search_var_add(dict, "uid", username);
return dict;
Expand Down

0 comments on commit 84676ab

Please sign in to comment.