diff -Naur pam_radius-1.3.16/pam_radius_auth.c pam_radius-1.3.16-patched/pam_radius_auth.c --- pam_radius-1.3.16/pam_radius_auth.c 2003-02-27 18:01:07.000000000 +0000 +++ pam_radius-1.3.16-patched/pam_radius_auth.c 2006-09-28 19:16:42.000000000 +0000 @@ -67,7 +67,7 @@ /* internal data */ static CONST char *pam_module_name = "pam_radius_auth"; static char conf_file[BUFFER_SIZE]; /* configuration file */ - +static char template_user[BUFFER_SIZE]; /* we need to save these from open_session to close_session, since * when close_session will be called we won't be root anymore and * won't be able to access again the radius server configuration file @@ -137,7 +137,11 @@ } else if (!strcmp(*argv, "debug")) { ctrl |= PAM_DEBUG_ARG; conf->debug = 1; - + + } else if (!strncmp(*argv, "template_user=", 14)) { + ctrl |= PAM_TEMPLATE_USER; + strcpy(template_user, (*argv)+14); + } else { _pam_log(LOG_WARNING, "unrecognized option '%s'", *argv); } @@ -1223,6 +1227,8 @@ *pret = retval; pam_set_data( pamh, "rad_setcred_return", (void *) pret, _int_free ); } + if(retval == PAM_SUCCESS && (ctrl & PAM_TEMPLATE_USER)) + pam_set_item(pamh, PAM_USER, template_user); return retval; } diff -Naur pam_radius-1.3.16/pam_radius_auth.h pam_radius-1.3.16-patched/pam_radius_auth.h --- pam_radius-1.3.16/pam_radius_auth.h 2003-09-19 14:41:32.000000000 +0000 +++ pam_radius-1.3.16-patched/pam_radius_auth.h 2006-09-28 19:14:02.000000000 +0000 @@ -82,6 +82,7 @@ #define PAM_SKIP_PASSWD 2 #define PAM_USE_FIRST_PASS 4 #define PAM_TRY_FIRST_PASS 8 +#define PAM_TEMPLATE_USER 16 #define PAM_RETRY 0x30