~ubuntu-branches/ubuntu/utopic/audit/utopic

« back to all changes in this revision

Viewing changes to tools/aulastlog/aulastlog.c

  • Committer: Bazaar Package Importer
  • Author(s): Philipp Matthias Hahn
  • Date: 2009-04-07 00:03:54 UTC
  • mfrom: (1.2.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20090407000354-ny4m29eckoycogz5
Tags: 1.7.12-1
* New upstream release. (Closes: #522026)
* Fix "typo in long description: (Closes: #513937)
* debian/control:
  - Bump Standards-Version: 3.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * aulastlog.c - A lastlog program based on audit logs 
3
 
 * Copyright (c) 2008 Red Hat Inc., Durham, North Carolina.
 
3
 * Copyright (c) 2008-2009 Red Hat Inc., Durham, North Carolina.
4
4
 * All Rights Reserved.
5
5
 *
6
6
 * This software may be freely redistributed and/or modified under the
31
31
 
32
32
void usage(void)
33
33
{
34
 
        fprintf(stderr, "usage: aulastlog [--user name]\n");
 
34
        fprintf(stderr, "usage: aulastlog [--stdin] [--user name]\n");
35
35
}
36
36
 
37
37
int main(int argc, char *argv[])
38
38
{
39
 
        int i;
 
39
        int i, use_stdin = 0;
40
40
        char *user = NULL;
41
41
        struct passwd *p;
42
42
        auparse_state_t *au;
43
43
        llist l;
44
44
 
 
45
        setlocale (LC_ALL, "");
45
46
        for (i=1; i<argc; i++) {
46
47
                if ((strcmp(argv[i], "--user") == 0) || 
47
48
                                (strcmp(argv[i], "-u") == 0)) {
52
53
                                usage();
53
54
                                return 1;
54
55
                        }
 
56
                } else if (strcmp(argv[i], "--stdin") == 0) {
 
57
                        use_stdin = 1;
55
58
                } else {
56
59
                        usage();
57
60
                        return 1;
58
61
                }
59
62
        }
60
63
 
61
 
        setlocale (LC_ALL, "");
62
64
        list_create(&l);
63
65
 
64
66
        // Stuff linked lists with all users 
83
85
        }
84
86
 
85
87
        // Search for successful user logins
86
 
        au = auparse_init(AUSOURCE_LOGS, NULL);
 
88
        if (use_stdin)
 
89
                au = auparse_init(AUSOURCE_FILE_POINTER, stdin);
 
90
        else
 
91
                au = auparse_init(AUSOURCE_LOGS, NULL);
87
92
        if (au == NULL) {
88
93
                printf("Error - %s\n", strerror(errno));
89
94
                goto error_exit_1;