~xnox/ubuntu/quantal/shadow/clear-locks

« back to all changes in this revision

Viewing changes to libmisc/audit_help.c

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2009-05-05 09:45:21 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090505094521-wpk2wn3q7957tlah
Tags: 1:4.1.3.1-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Ubuntu specific:
    + debian/login.defs: use SHA512 by default for password crypt routine.
  - debian/patches/stdout-encrypted-password.patch: chpasswd can report
    password hashes on stdout (debian bug 505640).
  - debian/login.pam: Enable SELinux support (debian bug 527106).
  - debian/securetty.linux: support Freescale MX-series (debian bug 527095).
* Add debian/patches/300_lastlog_failure: fixed upstream (debian bug 524873).
* Drop debian/patches/593_omit_lastchange_field_if_clock_is_misset: fixed
  upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Audit helper functions used throughout shadow
3
 
 *
4
 
 *  Copyright (C) 2005, Red Hat, Inc.
 
2
 * Copyright (c) 2005       , Red Hat, Inc.
 
3
 * Copyright (c) 2005       , Tomasz Kłoczko
 
4
 * Copyright (c) 2008       , Nicolas François
 
5
 * All rights reserved.
5
6
 *
6
7
 * Redistribution and use in source and binary forms, with or without
7
8
 * modification, are permitted provided that the following conditions
11
12
 * 2. Redistributions in binary form must reproduce the above copyright
12
13
 *    notice, this list of conditions and the following disclaimer in the
13
14
 *    documentation and/or other materials provided with the distribution.
14
 
 * 3. Neither the name of Julianne F. Haugh nor the names of its contributors
15
 
 *    may be used to endorse or promote products derived from this software
16
 
 *    without specific prior written permission.
 
15
 * 3. The name of the copyright holders or contributors may not be used to
 
16
 *    endorse or promote products derived from this software without
 
17
 *    specific prior written permission.
17
18
 *
18
 
 * THIS SOFTWARE IS PROVIDED BY JULIE HAUGH AND CONTRIBUTORS ``AS IS'' AND
19
 
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
 
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
 
 * ARE DISCLAIMED.  IN NO EVENT SHALL JULIE HAUGH OR CONTRIBUTORS BE LIABLE
22
 
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
 
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
 
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
 
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26
 
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27
 
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28
 
 * SUCH DAMAGE.
 
19
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
20
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
21
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 
22
 * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
 
23
 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
24
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
25
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
26
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
27
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
28
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
29
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30
 */
30
31
 
 
32
/*
 
33
 *  Audit helper functions used throughout shadow
 
34
 *
 
35
 */
31
36
 
32
37
#include <config.h>
33
38
 
39
44
#include <libaudit.h>
40
45
#include <errno.h>
41
46
#include <stdio.h>
 
47
#include "prototypes.h"
42
48
int audit_fd;
43
49
 
44
50
void audit_help_open (void)
50
56
                if (errno == EINVAL || errno == EPROTONOSUPPORT ||
51
57
                    errno == EAFNOSUPPORT)
52
58
                        return;
53
 
                fprintf (stderr, "Cannot open audit interface - aborting.\n");
 
59
                fprintf (stderr,
 
60
                         _("Cannot open audit interface - aborting.\n"));
54
61
                exit (1);
55
62
        }
56
63
}
69
76
 * result - 1 is "success" and 0 is "failed"
70
77
 */
71
78
void audit_logger (int type, const char *pgname, const char *op,
72
 
                   const char *name, unsigned int id, int result)
 
79
                   const char *name, unsigned int id,
 
80
                   shadow_audit_result result)
73
81
{
74
 
        if (audit_fd < 0)
 
82
        if (audit_fd < 0) {
75
83
                return;
76
 
        else
 
84
        } else {
77
85
                audit_log_acct_message (audit_fd, type, NULL, op, name, id,
78
 
                                        NULL, NULL, NULL, result);
 
86
                                        NULL, NULL, NULL, (int) result);
 
87
        }
 
88
}
 
89
 
 
90
void audit_logger_message (const char *message, shadow_audit_result result)
 
91
{
 
92
        if (audit_fd < 0) {
 
93
                return;
 
94
        } else {
 
95
                audit_log_user_message (audit_fd,
 
96
                                        AUDIT_USYS_CONFIG,
 
97
                                        message,
 
98
                                        NULL, /* hostname */
 
99
                                        NULL, /* addr */
 
100
                                        NULL, /* tty */
 
101
                                        (int) result);
 
102
        }
79
103
}
80
104
 
81
105
#else                           /* WITH_AUDIT */
82
106
extern int errno;       /* warning: ANSI C forbids an empty source file */
83
107
#endif                          /* WITH_AUDIT */
 
108