~ubuntu-branches/ubuntu/gutsy/syslog-ng/gutsy-security

« back to all changes in this revision

Viewing changes to src/afuser.c

  • Committer: Bazaar Package Importer
  • Author(s): Magosányi Árpád (mag)
  • Date: 2004-03-13 18:35:37 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040313183537-g0fsc2j2y1wbxage
Tags: 1.6.2-3
* changed manpage to better reflect -v. Closes: #228377
* fixed build-depends, hopefully correctly now:( Closes: #237668

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 *
20
20
 * Inspired by nsyslog, originally written by Darren Reed.
21
21
 *
22
 
 * $Id: afuser.c,v 1.8 2001/05/04 12:37:43 bazsi Exp $
 
22
 * $Id: afuser.c,v 1.9 2003/01/31 14:26:48 bazsi Exp $
23
23
 *
24
24
 ***************************************************************************/
25
25
 
36
36
#include <utmp.h>
37
37
 
38
38
#include "afuser.c.x"
 
39
#include "macros.h"
39
40
 
40
41
/* CLASS:
41
42
   (class
42
43
     (name afuser_dest)
43
44
     (super log_dest_driver)
44
45
     (vars
45
 
       (username string)))
 
46
       (username string)
 
47
       (template_output string)
 
48
       (template_escape . int)
 
49
       (cfg object syslog_config)))
46
50
*/
47
51
 
 
52
void
 
53
afuser_dest_set_template(struct log_dest_driver *c, char *t)
 
54
{
 
55
        CAST(afuser_dest, self, c);
 
56
 
 
57
        self->template_output = c_format("%z", t);
 
58
}
 
59
 
 
60
void
 
61
afuser_dest_set_template_escape(struct log_dest_driver *c, int enable)
 
62
{
 
63
        CAST(afuser_dest, self, c);
 
64
 
 
65
        self->template_escape = enable;
 
66
}
 
67
 
48
68
static int 
49
69
do_init_afuser_dest(struct log_handler *c, 
50
70
                    struct syslog_config *cfg, 
51
71
                    struct persistent_config *persistent)
52
72
{
 
73
        CAST(afuser_dest, self, c);
 
74
 
 
75
        self->cfg = cfg;
 
76
 
53
77
        return ST_OK | ST_GOON;
54
78
}
55
79
 
56
 
static void do_handle_afuser_log(struct log_handler *c, struct log_info *msg)
 
80
static void
 
81
do_handle_afuser_log(struct log_handler *c, struct log_info *msg)
57
82
{
58
83
        CAST(afuser_dest, self, c);
59
84
        struct utmp *ut;
60
85
        struct ol_string *msg_line;
61
86
 
62
 
        msg_line = c_format("%S %S %S\n", msg->date, msg->host, msg->msg);
 
87
        if (self->template_output) {
 
88
                msg_line = c_format("%fS",
 
89
                                    expand_macros(
 
90
                                            self->cfg,
 
91
                                            self->template_output,
 
92
                                            self->template_escape, msg));
 
93
        } else {
 
94
                msg_line = c_format("%S %S %S\n",
 
95
                                    msg->date, msg->host, msg->msg);
 
96
        }
 
97
 
63
98
        while ((ut = getutent())) {
64
99
#if HAVE_MODERN_UTMP
65
100
                if (ut->ut_type == USER_PROCESS &&