[dovecot-cvs] dovecot/src/auth passdb-pam.c,1.25,1.26
cras at dovecot.org
cras at dovecot.org
Fri Jul 22 20:07:07 EEST 2005
Update of /var/lib/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv11757
Modified Files:
passdb-pam.c
Log Message:
Open/close PAM session if -session option is given. Patch by Pasi Sjöholm.
Index: passdb-pam.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-pam.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- passdb-pam.c 12 Jul 2005 12:58:47 -0000 1.25
+++ passdb-pam.c 22 Jul 2005 17:07:04 -0000 1.26
@@ -71,6 +71,7 @@
const char *pass;
};
+static int pam_session;
static char *service_name;
static struct timeout *to_wait;
@@ -193,6 +194,22 @@
return status;
}
+ if (pam_session) {
+ if ((status = pam_open_session(pamh, 0)) != PAM_SUCCESS) {
+ *error = t_strdup_printf(
+ "pam_open_session() failed: %s",
+ pam_strerror(pamh, status));
+ return status;
+ }
+
+ if ((status = pam_close_session(pamh, 0)) != PAM_SUCCESS) {
+ *error = t_strdup_printf(
+ "pam_close_session() failed: %s",
+ pam_strerror(pamh, status));
+ return status;
+ }
+ }
+
status = pam_get_item(pamh, PAM_USER, (linux_const void **)&item);
if (status != PAM_SUCCESS) {
*error = t_strdup_printf("pam_get_item() failed: %s",
@@ -387,8 +404,29 @@
static void pam_init(const char *args)
{
- service_name = strcmp(args, "*") == 0 ? NULL :
- i_strdup(*args != '\0' ? args : "dovecot");
+ const char *const *t_args;
+ int i;
+
+ pam_session = FALSE;
+ service_name = i_strdup("dovecot");
+
+ t_push();
+ t_args = t_strsplit(args, " ");
+ for(i = 0; t_args[i] != NULL; i++) {
+ if (strcmp(t_args[i], "-session") == 0)
+ pam_session = TRUE;
+ else if (strcmp(t_args[i], "*") == 0) {
+ i_free(service_name);
+ service_name = NULL;
+ } else {
+ if (*t_args[i] != '\0') {
+ i_free(service_name);
+ service_name = i_strdup(t_args[i]);
+ }
+ }
+ }
+ t_pop();
+
to_wait = NULL;
}
More information about the dovecot-cvs
mailing list