source: trunk/server/common/patches/httpd-suexec-journald.patch @ 2717

Last change on this file since 2717 was 2603, checked in by achernya, 10 years ago
oops, include the suexec patch
File size: 2.9 KB
  • support/Makefile.in

    From 7eefa90ac1422825db6f1bbbe4e66f1336fca531 Mon Sep 17 00:00:00 2001
    From: Alexander Chernyakhovsky <achernya@mit.edu>
    Date: Thu, 28 Aug 2014 22:51:21 -0400
    Subject: [PATCH] Redirect stderr to systemd-journald
    
    Scripts provides the "logview" facility for users to be able to see
    the error logs from their applications. However, this facility
    requires running the moral equivalent of grep $USER error_log. Not all
    error messages contain the username, and therefore, the logview
    facility is unreliable at best.
    
    Additionally, the error_log contains an interleaving of all errors,
    which makes it difficult for system administrators to help withs
    upport requests in which an Internal Server Error has been
    experienced.
    
    Since systemd-journald supports per-user journals, replace stderr,
    which is provided by Apache, with a file descriptor pointing to the
    journal. Assuming that journald is configured to split the log on
    UIDs, this will allow journalctl --user to show each individual user
    their error logs.
    ---
     support/Makefile.in |  7 ++++++-
     support/suexec.c    | 21 +++++++++++++++++++++
     2 files changed, 27 insertions(+), 1 deletion(-)
    
    diff --git a/support/Makefile.in b/support/Makefile.in
    index 745d86c..4014c1f 100644
    a b checkgid: $(checkgid_OBJECTS) 
    7373        $(LINK) $(checkgid_LTFLAGS) $(checkgid_OBJECTS) $(PROGRAM_LDADD)
    7474
    7575suexec_OBJECTS = suexec.lo
     76suexec_LDADD = "-lsystemd-journal -lsystemd-id128"
     77suexec.lo: suexec.c
     78        $(LIBTOOL) --mode=compile $(CC) $(ab_CFLAGS) $(ALL_CFLAGS) $(ALL_CPPFLAGS) \
     79            $(ALL_INCLUDES) $(PICFLAGS) $(LTCFLAGS) -DSCRIPTS_HAVE_SYSTEMD_JOURNAL \
     80            -c $< && touch $@
    7681suexec: $(suexec_OBJECTS)
    77         $(LINK) $(suexec_OBJECTS)
     82        $(LINK) $(suexec_OBJECTS) $(suexec_LDADD)
    7883
    7984htcacheclean_OBJECTS = htcacheclean.lo
    8085htcacheclean: $(htcacheclean_OBJECTS)
  • support/suexec.c

    diff --git a/support/suexec.c b/support/suexec.c
    index 3a4d802..4fe4c44 100644
    a b  
    6161#include <grp.h>
    6262#endif
    6363
     64#ifdef SCRIPTS_HAVE_SYSTEMD_JOURNAL
     65#include <systemd/sd-journal.h>
     66#include <systemd/sd-daemon.h>
     67#endif
     68
    6469#ifdef AP_LOG_SYSLOG
    6570#include <syslog.h>
    6671#endif
    TRUSTED_DIRECTORY: 
    769774    umask(AP_SUEXEC_UMASK);
    770775#endif /* AP_SUEXEC_UMASK */
    771776
     777#ifdef SCRIPTS_HAVE_SYSTEMD_JOURNAL
     778    int fd = sd_journal_stream_fd("CGI Script", LOG_NOTICE, 0);
     779    if (fd < 0) {
     780        log_err("unable to open systemd-journald file descriptor\n");
     781        exit(254);
     782    }
     783    if (dup2(fd, STDERR_FILENO) < 0) {
     784        log_err("unable to make journald file descriptor available as stderr\n");
     785        exit(253);
     786    }
     787    if (close(fd) < 0) {
     788        log_err("unable to close journald file descriptor copy\n");
     789        exit(252);
     790    }
     791#endif /* SCRIPTS_HAVE_SYSTEMD_JOURNAL */
     792
    772793    /* Be sure to close the log file so the CGI can't mess with it. */
    773794#ifdef AP_LOG_SYSLOG
    774795    if (log_open) {
Note: See TracBrowser for help on using the repository browser.