Skip to content

Commit

Permalink
pam: add pam_gssapi_services option
Browse files Browse the repository at this point in the history
:config: Added `pam_gssapi_services` to list PAM services
  that can authenticate using GSSAPI

Reviewed-by: Robbie Harwood <rharwood@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
  • Loading branch information
pbrezina authored and sumit-bose committed Dec 16, 2020
1 parent dcc4201 commit d63172f
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/confdb/confdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,18 @@ static int confdb_get_domain_internal(struct confdb_ctx *cdb,
}
}

tmp = ldb_msg_find_attr_as_string(res->msgs[0], CONFDB_PAM_GSSAPI_SERVICES,
"-");
if (tmp != NULL) {
ret = split_on_separator(domain, tmp, ',', true, true,
&domain->gssapi_services, NULL);
if (ret != 0) {
DEBUG(SSSDBG_FATAL_FAILURE,
"Cannot parse %s\n", CONFDB_PAM_GSSAPI_SERVICES);
goto done;
}
}

domain->has_views = false;
domain->view_name = NULL;

Expand Down
4 changes: 4 additions & 0 deletions src/confdb/confdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
#define CONFDB_PAM_P11_ALLOWED_SERVICES "pam_p11_allowed_services"
#define CONFDB_PAM_P11_URI "p11_uri"
#define CONFDB_PAM_INITGROUPS_SCHEME "pam_initgroups_scheme"
#define CONFDB_PAM_GSSAPI_SERVICES "pam_gssapi_services"

/* SUDO */
#define CONFDB_SUDO_CONF_ENTRY "config/sudo"
Expand Down Expand Up @@ -431,6 +432,9 @@ struct sss_domain_info {

/* Keytab used by this domain. */
const char *krb5_keytab;

/* List of PAM services that are allowed to authenticate with GSSAPI. */
char **gssapi_services;
};

/**
Expand Down
1 change: 1 addition & 0 deletions src/config/SSSDConfig/sssdoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def __init__(self):
'p11_wait_for_card_timeout': _('Additional timeout to wait for a card if requested'),
'p11_uri': _('PKCS#11 URI to restrict the selection of devices for Smartcard authentication'),
'pam_initgroups_scheme' : _('When shall the PAM responder force an initgroups request'),
'pam_gssapi_services' : _('List of PAM services that are allowed to authenticate with GSSAPI.'),

# [sudo]
'sudo_timed': _('Whether to evaluate the time-based attributes in sudo rules'),
Expand Down
6 changes: 4 additions & 2 deletions src/config/SSSDConfigTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,8 @@ def testListOptions(self):
'full_name_format',
're_expression',
'cached_auth_timeout',
'auto_private_groups']
'auto_private_groups',
'pam_gssapi_services']

self.assertTrue(type(options) == dict,
"Options should be a dictionary")
Expand Down Expand Up @@ -1030,7 +1031,8 @@ def testRemoveProvider(self):
'full_name_format',
're_expression',
'cached_auth_timeout',
'auto_private_groups']
'auto_private_groups',
'pam_gssapi_services']

self.assertTrue(type(options) == dict,
"Options should be a dictionary")
Expand Down
3 changes: 3 additions & 0 deletions src/config/cfg_rules.ini
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ option = pam_p11_allowed_services
option = p11_wait_for_card_timeout
option = p11_uri
option = pam_initgroups_scheme
option = pam_gssapi_services

[rule/allowed_sudo_options]
validator = ini_allowed_options
Expand Down Expand Up @@ -437,6 +438,7 @@ option = wildcard_limit
option = full_name_format
option = re_expression
option = auto_private_groups
option = pam_gssapi_services

#Entry cache timeouts
option = entry_cache_user_timeout
Expand Down Expand Up @@ -831,6 +833,7 @@ option = ad_backup_server
option = ad_site
option = use_fully_qualified_names
option = auto_private_groups
option = pam_gssapi_services

[rule/sssd_checks]
validator = sssd_checks
Expand Down
2 changes: 2 additions & 0 deletions src/config/etc/sssd.api.conf
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ pam_p11_allowed_services = str, None, false
p11_wait_for_card_timeout = int, None, false
p11_uri = str, None, false
pam_initgroups_scheme = str, None, false
pam_gssapi_services = str, None, false

[sudo]
# sudo service
Expand Down Expand Up @@ -199,6 +200,7 @@ cached_auth_timeout = int, None, false
full_name_format = str, None, false
re_expression = str, None, false
auto_private_groups = str, None, false
pam_gssapi_services = str, None, false

#Entry cache timeouts
entry_cache_user_timeout = int, None, false
Expand Down
13 changes: 13 additions & 0 deletions src/db/sysdb_subdomains.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ struct sss_domain_info *new_subdomain(TALLOC_CTX *mem_ctx,
dom->homedir_substr = parent->homedir_substr;
dom->override_gid = parent->override_gid;

dom->gssapi_services = parent->gssapi_services;

if (parent->sysdb == NULL) {
DEBUG(SSSDBG_OP_FAILURE, "Missing sysdb context in parent domain.\n");
goto fail;
Expand Down Expand Up @@ -241,6 +243,17 @@ check_subdom_config_file(struct confdb_ctx *confdb,
sd_conf_path, CONFDB_DOMAIN_FQ,
subdomain->fqnames ? "TRUE" : "FALSE");

/* allow to set pam_gssapi_services */
ret = confdb_get_string_as_list(confdb, subdomain, sd_conf_path,
CONFDB_PAM_GSSAPI_SERVICES,
&subdomain->gssapi_services);
if (ret != EOK && ret != ENOENT) {
DEBUG(SSSDBG_OP_FAILURE,
"Failed to get %s option for the subdomain: %s\n",
CONFDB_PAM_GSSAPI_SERVICES, subdomain->name);
goto done;
}

ret = EOK;
done:
talloc_free(tmp_ctx);
Expand Down
30 changes: 30 additions & 0 deletions src/man/sssd.conf.5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,35 @@ p11_uri = library-description=OpenSC%20smartcard%20framework;slot-id=2
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>pam_gssapi_services</term>
<listitem>
<para>
Comma separated list of PAM services that are
allowed to try GSSAPI authentication using
pam_sss_gss.so module.
</para>
<para>
To disable GSSAPI authentication, set this option
to <quote>-</quote> (dash).
</para>
<para>
Note: This option can also be set per-domain which
overwrites the value in [pam] section. It can also
be set for trusted domain which overwrites the value
in the domain section.
</para>
<para>
Example:
<programlisting>
pam_gssapi_services = sudo, sudo-i
</programlisting>
</para>
<para>
Default: - (GSSAPI authentication is disabled)
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect2>

Expand Down Expand Up @@ -3780,6 +3809,7 @@ ldap_user_extra_attrs = phone:telephoneNumber
<para>ad_backup_server,</para>
<para>ad_site,</para>
<para>use_fully_qualified_names</para>
<para>pam_gssapi_services</para>
<para>
For more details about these options see their individual description
in the manual page.
Expand Down
21 changes: 21 additions & 0 deletions src/responder/pam/pamsrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,27 @@ static int pam_process_init(TALLOC_CTX *mem_ctx,
}
}

ret = confdb_get_string(pctx->rctx->cdb, pctx, CONFDB_PAM_CONF_ENTRY,
CONFDB_PAM_GSSAPI_SERVICES, "-", &tmpstr);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE,
"Failed to determine gssapi services.\n");
goto done;
}
DEBUG(SSSDBG_TRACE_INTERNAL, "Found value [%s] for option [%s].\n", tmpstr,
CONFDB_PAM_GSSAPI_SERVICES);

if (tmpstr != NULL) {
ret = split_on_separator(pctx, tmpstr, ',', true, true,
&pctx->gssapi_services, NULL);
if (ret != EOK) {
DEBUG(SSSDBG_MINOR_FAILURE,
"split_on_separator() failed [%d]: [%s].\n", ret,
sss_strerror(ret));
goto done;
}
}

/* The responder is initialized. Now tell it to the monitor. */
ret = sss_monitor_service_init(rctx, rctx->ev, SSS_BUS_PAM,
SSS_PAM_SBUS_SERVICE_NAME,
Expand Down
3 changes: 3 additions & 0 deletions src/responder/pam/pamsrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ struct pam_ctx {
int num_prompting_config_sections;

enum pam_initgroups_scheme initgroups_scheme;

/* List of PAM services that are allowed to authenticate with GSSAPI. */
char **gssapi_services;
};

struct pam_auth_req {
Expand Down

0 comments on commit d63172f

Please sign in to comment.