summaryrefslogtreecommitdiffabout
path: root/pam_regex/pam_regex.c
Side-by-side diff
Diffstat (limited to 'pam_regex/pam_regex.c') (more/less context) (ignore whitespace changes)
-rw-r--r--pam_regex/pam_regex.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/pam_regex/pam_regex.c b/pam_regex/pam_regex.c
index 95324c0..0c3737b 100644
--- a/pam_regex/pam_regex.c
+++ b/pam_regex/pam_regex.c
@@ -112,7 +112,6 @@ pam_sm_authenticate(pam_handle_t *pamh,
DEBUG(90,("enter pam_sm_authenticate"));
- gray_pam_init(PAM_AUTHINFO_UNAVAIL);
/*
* get username
@@ -129,14 +128,23 @@ pam_sm_authenticate(pam_handle_t *pamh,
char *newname;
gray_slist_t slist;
- gray_set_transform_expr(transform);
+ retval = gray_set_transform_expr(transform);
+ if (retval != PAM_SUCCESS)
+ return retval;
slist = gray_slist_create();
- gray_transform_name_to_slist(slist, name, &newname);
- DEBUG(90,("new name: %s", newname));
- MAKE_STR(pamh, newname, name);
- retval = pam_set_item(pamh, PAM_USER, name);
- gray_slist_free(&slist);
- gray_free_transform_expr();
+ if (!slist)
+ retval = errno_to_pam(errno);
+ else {
+ retval = gray_transform_name_to_slist(slist, name,
+ &newname);
+ if (retval == PAM_SUCCESS) {
+ DEBUG(90,("new name: %s", newname));
+ MAKE_STR(pamh, newname, name);
+ retval = pam_set_item(pamh, PAM_USER, name);
+ gray_slist_free(&slist);
+ }
+ gray_free_transform_expr();
+ }
if (retval != PAM_SUCCESS) {
_pam_log(LOG_ERR, "retval %d", retval);
return PAM_AUTHINFO_UNAVAIL;
@@ -145,7 +153,7 @@ pam_sm_authenticate(pam_handle_t *pamh,
if (regex) {
for (;;) {
- if (rc = regcomp(&rx, regex, regex_flags)) {
+ if ((rc = regcomp(&rx, regex, regex_flags)) != 0) {
char errbuf[512];
regerror (rc, &rx, errbuf, sizeof (errbuf));
_pam_log(LOG_ERR, "can't compile regex: %s",

Return to:

Send suggestions and report system problems to the System administrator.