View | Details | Raw Unified | Return to bug 59765
Collapse All | Expand All

(-)modules/generators/mod_status.c (-8 / +52 lines)
Lines 89-94 Link Here
89
static int server_limit, thread_limit, threads_per_child, max_servers,
89
static int server_limit, thread_limit, threads_per_child, max_servers,
90
           is_async;
90
           is_async;
91
typedef struct {
92
    int  privacy_mode;
93
} status_config;
94
91
/* Implement 'ap_run_status_hook'. */
95
/* Implement 'ap_run_status_hook'. */
92
APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap, STATUS, int, status_hook,
96
APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap, STATUS, int, status_hook,
93
                                    (request_rec *r, int flags),
97
                                    (request_rec *r, int flags),
Lines 674-679 Link Here
674
    }
678
    }
675
    if (ap_extended_status && !short_report) {
679
    if (ap_extended_status && !short_report) {
680
        status_config *config = (status_config *) ap_get_module_config(r->per_dir_config,
681
                                                                       &status_module);
682
        if (config->privacy_mode)
683
            ap_rputs("\nClient IP removed due to privacy mode set.\n\n", r);
676
        if (no_table_report)
684
        if (no_table_report)
677
            ap_rputs("<hr /><h2>Server Details</h2>\n\n", r);
685
            ap_rputs("<hr /><h2>Server Details</h2>\n\n", r);
678
        else
686
        else
Lines 687-693 Link Here
687
                     "<th>Conn</th><th>Child</th><th>Slot</th>"
695
                     "<th>Conn</th><th>Child</th><th>Slot</th>"
688
                     "<th>Client</th><th>Protocol</th><th>VHost</th>"
696
                     "<th>Client</th><th>Protocol</th><th>VHost</th>"
689
                     "<th>Request</th></tr>\n\n", r);
697
                     "<th>Request</th></tr>\n\n", r);
690
691
        for (i = 0; i < server_limit; ++i) {
698
        for (i = 0; i < server_limit; ++i) {
692
            for (j = 0; j < thread_limit; ++j) {
699
            for (j = 0; j < thread_limit; ++j) {
693
                ap_copy_scoreboard_worker(ws_record, i, j);
700
                ap_copy_scoreboard_worker(ws_record, i, j);
Lines 800-808 Link Here
800
                    ap_rputs(")\n", r);
807
                    ap_rputs(")\n", r);
801
                    ap_rprintf(r,
808
                    ap_rprintf(r,
802
                               " <i>%s {%s}</i> <i>(%s)</i> <b>[%s]</b><br />\n\n",
809
                               " <i>%s {%s}</i> <i>(%s)</i> <b>[%s]</b><br />\n\n",
810
                               config->privacy_mode ? ""
811
                                                   : ap_escape_html(r->pool,
812
                                                                    ws_record->client),
803
                               ap_escape_html(r->pool,
813
                               ap_escape_html(r->pool,
804
                                              ws_record->client),
805
                               ap_escape_html(r->pool,
806
                                              ap_escape_logitem(r->pool,
814
                                              ap_escape_logitem(r->pool,
807
                                                                ws_record->request)),
815
                                                                ws_record->request)),
808
                               ap_escape_html(r->pool,
816
                               ap_escape_html(r->pool,
Lines 887-895 Link Here
887
                    ap_rprintf(r, "</td><td>%s</td><td>%s</td><td nowrap>%s</td>"
895
                    ap_rprintf(r, "</td><td>%s</td><td>%s</td><td nowrap>%s</td>"
888
                                  "<td nowrap>%s</td></tr>\n\n",
896
                                  "<td nowrap>%s</td></tr>\n\n",
897
                               config->privacy_mode ? ""
898
                                                   : ap_escape_html(r->pool,
899
                                                                    ws_record->client),
889
                               ap_escape_html(r->pool,
900
                               ap_escape_html(r->pool,
890
                                              ws_record->client),
891
                               ap_escape_html(r->pool,
892
                                              ws_record->protocol),
901
                                              ws_record->protocol),
893
                               ap_escape_html(r->pool,
902
                               ap_escape_html(r->pool,
894
                                              ws_record->vhost),
903
                                              ws_record->vhost),
Lines 992-997 Link Here
992
}
1001
}
993
#endif
1002
#endif
1003
const char *privacy_mode_set_enabled(cmd_parms *cmd, void *cfg, const char *arg)
1004
{
1005
    status_config *config = (status_config *) cfg;
1006
    if(!strcasecmp(arg, "on"))
1007
        config->privacy_mode = 1;
1008
    else
1009
        config->privacy_mode = 0;
1010
    return NULL;
1011
}
1012
1013
void *create_dir_conf(apr_pool_t *pool, char *dummy)
1014
{
1015
    status_config *cfg = apr_pcalloc(pool, sizeof(status_config));
1016
    if (cfg) {
1017
        cfg->privacy_mode = 0;
1018
    }
1019
    return cfg;
1020
}
1021
1022
void *merge_dir_conf(apr_pool_t *pool, void *BASE, void *ADD)
1023
{
1024
    status_config *add = (status_config *) ADD;
1025
    status_config *base = (status_config *) BASE;
1026
    status_config *conf = (status_config *) create_dir_conf(pool, NULL);
1027
    conf->privacy_mode = add->privacy_mode;
1028
    return add;
1029
}
1030
994
static void register_hooks(apr_pool_t *p)
1031
static void register_hooks(apr_pool_t *p)
995
{
1032
{
996
    ap_hook_handler(status_handler, NULL, NULL, APR_HOOK_MIDDLE);
1033
    ap_hook_handler(status_handler, NULL, NULL, APR_HOOK_MIDDLE);
Lines 1002-1014 Link Here
1002
#endif
1039
#endif
1003
}
1040
}
1041
static const command_rec status_directives[] =
1042
{
1043
    AP_INIT_TAKE1("PrivacyStatus", privacy_mode_set_enabled, NULL, RSRC_CONF|ACCESS_CONF,
1044
                  "Enable or disable Privacy Mode for mod-status"),
1045
    { NULL }
1046
};
1047
1004
AP_DECLARE_MODULE(status) =
1048
AP_DECLARE_MODULE(status) =
1005
{
1049
{
1006
    STANDARD20_MODULE_STUFF,
1050
    STANDARD20_MODULE_STUFF,
1007
    NULL,                       /* dir config creater */
1051
    create_dir_conf,            /* dir config creater */
1008
    NULL,                       /* dir merger --- default is to override */
1052
    merge_dir_conf,             /* dir merger --- default is to override */
1009
    NULL,                       /* server config */
1053
    NULL,                       /* server config */
1010
    NULL,                       /* merge server config */
1054
    NULL,                       /* merge server config */
1011
    NULL,                       /* command table */
1055
    status_directives,          /* command table */
1012
    register_hooks              /* register_hooks */
1056
    register_hooks              /* register_hooks */
1013
};
1057
};

Return to bug 59765