~ubuntu-branches/ubuntu/jaunty/transmission/jaunty-security

« back to all changes in this revision

Viewing changes to third-party/shttpd/log.c

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2008-11-28 15:33:48 UTC
  • mfrom: (1.1.19 upstream)
  • Revision ID: james.westby@ubuntu.com-20081128153348-it70trfnxiroblmc
Tags: 1.40-0ubuntu1
* New upstream release (LP: #302672)
  - Tracker communication uses fewer resources
  - More accurate bandwidth limits
  - Reduce disk fragmentation by preallocating files (LP: #287726)
  - Stability, security and performance improvements to the RPC /
    Web UI server (closes LP: #290423)
  - Support compression when serving Web UI and RPC responses
  - Simplify the RPC whitelist
  - Fix bug that prevented handshakes with encrypted BitComet peers
  - Fix 1.3x bug that could re-download some data unnecessarily
    (LP: #295040)
  - Option to automatically update the blocklist weekly
  - Added off-hour bandwidth scheduling
  - Simplify file/priority selection in the details dialog
  - Fix a couple of crashes
  - New / updated translations
  - Don't inhibit hibernation by default (LP: #292929)
  - Use "close" animation when sending to notification area (LP: #130811)
  - Fix resize problems (LP: #269872)
  - Support "--version" option when launching from command line
    (LP: #292011)
  - Correctly parse announce URLs that have leading or trailing
    spaces (LP: #262411)
  - Display an error when "Open Torrent" fails (LP: #281463)
* Dropped 10_fix_crasher_from_upstream.dpatch: Fix is in this
  upstream release.
* debian/control: Don't just build-depend on libcurl-dev, which is
  a virtual package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (c) 2004-2005 Sergey Lyubka <valenok@gmail.com>
3
 
 * All rights reserved
4
 
 *
5
 
 * "THE BEER-WARE LICENSE" (Revision 42):
6
 
 * Sergey Lyubka wrote this file.  As long as you retain this notice you
7
 
 * can do whatever you want with this stuff. If we meet some day, and you think
8
 
 * this stuff is worth it, you can buy me a beer in return.
9
 
 */
10
 
 
11
 
#include "defs.h"
12
 
 
13
 
/*
14
 
 * Log function
15
 
 */
16
 
void
17
 
elog(int flags, struct conn *c, const char *fmt, ...)
18
 
{
19
 
        char    date[64], buf[URI_MAX];
20
 
        int     len;
21
 
        FILE    *fp = c == NULL ? NULL : c->ctx->error_log;
22
 
        va_list ap;
23
 
 
24
 
        /* Print to stderr */
25
 
        if (c == NULL || !IS_TRUE(c->ctx, OPT_INETD)) {
26
 
                va_start(ap, fmt);
27
 
                (void) vfprintf(stderr, fmt, ap);
28
 
                (void) fputc('\n', stderr);
29
 
                va_end(ap);
30
 
        }
31
 
 
32
 
        strftime(date, sizeof(date), "%a %b %d %H:%M:%S %Y",
33
 
            localtime(&current_time));
34
 
 
35
 
        len = my_snprintf(buf, sizeof(buf),
36
 
            "[%s] [error] [client %s] \"%s\" ",
37
 
            date, c ? inet_ntoa(c->sa.u.sin.sin_addr) : "-",
38
 
            c && c->request ? c->request : "-");
39
 
 
40
 
        va_start(ap, fmt);
41
 
        (void) vsnprintf(buf + len, sizeof(buf) - len, fmt, ap);
42
 
        va_end(ap);
43
 
 
44
 
        buf[sizeof(buf) - 1] = '\0';
45
 
 
46
 
        if (fp != NULL && (flags & (E_FATAL | E_LOG))) {
47
 
                (void) fprintf(fp, "%s\n", buf);
48
 
                (void) fflush(fp);
49
 
        }
50
 
 
51
 
        if (flags & E_FATAL)
52
 
                exit(EXIT_FAILURE);
53
 
}
54
 
 
55
 
void
56
 
log_access(FILE *fp, const struct conn *c)
57
 
{
58
 
        static const struct vec dash = {"-", 1};
59
 
 
60
 
        const struct vec        *user = &c->ch.user.v_vec;
61
 
        const struct vec        *referer = &c->ch.referer.v_vec;
62
 
        const struct vec        *user_agent = &c->ch.useragent.v_vec;
63
 
        char                    date[64], buf[URI_MAX], *q1 = "\"", *q2 = "\"";
64
 
 
65
 
        if (user->len == 0)
66
 
                user = &dash;
67
 
 
68
 
        if (referer->len == 0) {
69
 
                referer = &dash;
70
 
                q1 = "";
71
 
        }
72
 
 
73
 
        if (user_agent->len == 0) {
74
 
                user_agent = &dash;
75
 
                q2 = "";
76
 
        }
77
 
 
78
 
        (void) strftime(date, sizeof(date), "%d/%b/%Y:%H:%M:%S",
79
 
                        localtime(&c->birth_time));
80
 
 
81
 
        (void) my_snprintf(buf, sizeof(buf),
82
 
            "%s - %.*s [%s %+05d] \"%s\" %d %lu %s%.*s%s %s%.*s%s",
83
 
            inet_ntoa(c->sa.u.sin.sin_addr), user->len, user->ptr,
84
 
            date, tz_offset, c->request ? c->request : "-",
85
 
            c->status, (unsigned long) c->loc.io.total,
86
 
            q1, referer->len, referer->ptr, q1,
87
 
            q2, user_agent->len, user_agent->ptr, q2);
88
 
 
89
 
        if (fp != NULL) {
90
 
                (void) fprintf(fp, "%s\n", buf);
91
 
                (void) fflush(fp);
92
 
        }
93
 
}