Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / contrib / libpam / libpam / pam_end.c
CommitLineData
984263bc
MD
1/* pam_end.c */
2
3/*
4 * $Id: pam_end.c,v 1.5 1996/12/01 03:14:13 morgan Exp $
5 * $FreeBSD: src/contrib/libpam/libpam/pam_end.c,v 1.1.1.1.6.2 2001/06/11 15:28:12 markm Exp $
1de703da 6 * $DragonFly: src/contrib/libpam/libpam/Attic/pam_end.c,v 1.2 2003/06/17 04:24:03 dillon Exp $
984263bc
MD
7 *
8 * $Log: pam_end.c,v $
9 */
10
11#include <stdlib.h>
12
13#include "pam_private.h"
14
15int pam_end(pam_handle_t *pamh, int pam_status)
16{
17 int ret;
18
19 IF_NO_PAMH("pam_end", pamh, PAM_SYSTEM_ERR);
20
21 D(("entering pam_end()"));
22
23 /* first liberate the modules (it is not inconcevible that the
24 modules may need to use the service_name etc. to clean up) */
25
26 _pam_free_data(pamh, pam_status);
27
28 /* now drop all modules */
29
30 if ((ret = _pam_free_handlers(pamh)) != PAM_SUCCESS) {
31 return ret; /* error occurred */
32 }
33
34 /* from this point we cannot call the modules any more. Free the remaining
35 memory used by the Linux-PAM interface */
36
37 _pam_drop_env(pamh); /* purge the environment */
38
39 _pam_overwrite(pamh->authtok); /* blank out old token */
40 _pam_drop(pamh->authtok);
41
42 _pam_overwrite(pamh->oldauthtok); /* blank out old token */
43 _pam_drop(pamh->oldauthtok);
44
45 _pam_overwrite(pamh->former.prompt);
46 _pam_drop(pamh->former.prompt); /* drop saved prompt */
47
48 _pam_overwrite(pamh->service_name);
49 _pam_drop(pamh->service_name);
50
51 _pam_overwrite(pamh->user);
52 _pam_drop(pamh->user);
53
54 _pam_overwrite(pamh->prompt);
55 _pam_drop(pamh->prompt); /* prompt for pam_get_user() */
56
57 _pam_overwrite(pamh->tty);
58 _pam_drop(pamh->tty);
59
60 _pam_overwrite(pamh->rhost);
61 _pam_drop(pamh->rhost);
62
63 _pam_overwrite(pamh->ruser);
64 _pam_drop(pamh->ruser);
65
66 _pam_drop(pamh->pam_conversation);
67 pamh->fail_delay.delay_fn_ptr = NULL;
68
69 _pam_overwrite(pamh->pam_default_log.ident);
70 _pam_drop(pamh->pam_default_log.ident);
71
72 /* and finally liberate the memory for the pam_handle structure */
73
74 _pam_drop(pamh);
75
76 D(("exiting pam_end() successfully"));
77
78 return PAM_SUCCESS;
79}