This is an automated email from the git hooks/post-receive script. tmancill pushed a commit to branch master in repository commons-daemon.
commit 9048dc630c53945080200ddb2cb3e23307cda692 Author: Marcus Better <[email protected]> Date: Wed Dec 13 15:09:58 2006 +0100 Imported Debian patch 1.0.2~svn20061127-5 --- debian/changelog | 11 +++ debian/control | 2 +- debian/rules | 12 ++- src/native/unix/config.guess | 32 ++++++-- src/native/unix/config.sub | 16 ++-- src/native/unix/configure.in | 1 - src/native/unix/man/jsvc.1.xml | 12 ++- src/native/unix/native/debug.c | 25 +----- src/native/unix/native/jsvc-unix.c | 161 ++++++++++++++++++++++++++++++++----- 9 files changed, 206 insertions(+), 66 deletions(-) diff --git a/debian/changelog b/debian/changelog index 8a3e5fb..4dd22af 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,14 @@ +commons-daemon (1.0.2~svn20061127-5) unstable; urgency=low + + * jsvc can now redirect daemon output to syslog. (Closes: #402878) + * Added support for the ppc64 architecture. Thanks to Andreas + Jochens. (Closes: #404704) + * Print a useful error message if the capabilities module is + missing. Thanks to Adrian Bridgett. (Closes: #412478) + * Don't use included config.sub and config.guess. + + -- Marcus Better <[email protected]> Wed, 13 Dec 2006 15:09:58 +0100 + commons-daemon (1.0.2~svn20061127-4) unstable; urgency=low * Apparently buildds don't grok Build-Depends-Indep. Moved to diff --git a/debian/control b/debian/control index e31ccf7..e28d391 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: commons-daemon Section: libs Priority: optional Maintainer: Debian Java Maintainers <[email protected]> -Uploaders: Arnaud Vandyck <[email protected]>, Wolfgang Baer <[email protected]>, Michael Koch <[email protected]>, Marcus Better <[email protected]> +Uploaders: Arnaud Vandyck <[email protected]>, Michael Koch <[email protected]>, Marcus Better <[email protected]> Build-Depends: debhelper (>= 5), autoconf, autotools-dev, java-gcj-compat-dev, xsltproc, docbook-xsl, ant Build-Conflicts: autoconf2.13 Standards-Version: 3.7.2 diff --git a/debian/rules b/debian/rules index 5426c48..6d15775 100755 --- a/debian/rules +++ b/debian/rules @@ -1,5 +1,12 @@ #!/usr/bin/make -f +CFLAGS = -g +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif + JAVA_HOME := /usr/lib/jvm/java-gcj DEB_JARS_BASE := /usr/share/java JAVACMD := $(JAVA_HOME)/bin/java @@ -41,7 +48,8 @@ $(NATIVE_SRC)/configure: $(NATIVE_SRC)/configure.in config-stamp: $(NATIVE_SRC)/configure dh_testdir - cd $(NATIVE_SRC); ./configure $(confflags) --with-java=$(JAVA_HOME) + cd $(NATIVE_SRC); touch install-sh; \ + ./configure $(confflags) CFLAGS="$(CFLAGS)" --with-java=$(JAVA_HOME) touch config-stamp build: build-arch build-indep @@ -66,7 +74,7 @@ clean: rm -rf target dist -(cd src/native/unix ; make clean) -rm -f src/native/unix/config.{log,status} - -rm -f src/native/unix/{Makefile,Makedefs,native/Makefile} + -rm -f src/native/unix/{Makefile,Makedefs,native/Makefile,install-sh} cp -f /usr/share/misc/config.sub $(NATIVE_SRC)/config.sub cp -f /usr/share/misc/config.guess $(NATIVE_SRC)/config.guess dh_clean diff --git a/src/native/unix/config.guess b/src/native/unix/config.guess index 396482d..0f0fe71 100644 --- a/src/native/unix/config.guess +++ b/src/native/unix/config.guess @@ -4,7 +4,7 @@ # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, # Inc. -timestamp='2006-07-02' +timestamp='2007-03-06' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -161,6 +161,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched @@ -780,7 +781,7 @@ EOF i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; - i*:MINGW*:*) + *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:windows32*:*) @@ -790,12 +791,15 @@ EOF i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; - x86:Interix*:[3456]*) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; - EM64T:Interix*:[3456]*) - echo x86_64-unknown-interix${UNAME_RELEASE} - exit ;; + *:Interix*:[3456]*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + EM64T | authenticamd) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; @@ -950,6 +954,9 @@ EOF x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; + xtensa:Linux:*:*) + echo xtensa-unknown-linux-gnu + exit ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent @@ -1208,6 +1215,15 @@ EOF SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; diff --git a/src/native/unix/config.sub b/src/native/unix/config.sub index fab0aa3..5defff6 100644 --- a/src/native/unix/config.sub +++ b/src/native/unix/config.sub @@ -4,7 +4,7 @@ # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, # Inc. -timestamp='2006-09-20' +timestamp='2007-01-18' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -245,12 +245,12 @@ case $basic_machine in | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ - | fr30 | frv \ + | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore \ + | maxq | mb | microblaze | mcore | mep \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ @@ -324,7 +324,7 @@ case $basic_machine in | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ @@ -925,6 +925,9 @@ case $basic_machine in basic_machine=sh-hitachi os=-hms ;; + sh5el) + basic_machine=sh5le-unknown + ;; sh64) basic_machine=sh64-unknown ;; @@ -1219,7 +1222,7 @@ case $os in | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers*) + | -skyos* | -haiku* | -rdos* | -toppers* | -drops*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1414,6 +1417,9 @@ case $basic_machine in m68*-cisco) os=-aout ;; + mep-*) + os=-elf + ;; mips*-cisco) os=-elf ;; diff --git a/src/native/unix/configure.in b/src/native/unix/configure.in index 71180a7..1afb5fa 100644 --- a/src/native/unix/configure.in +++ b/src/native/unix/configure.in @@ -29,7 +29,6 @@ sinclude(./support/apfunctions.m4)dnl sinclude(./support/apjava.m4)dnl sinclude(./support/apsupport.m4)dnl AC_INIT(configure.in) -AC_CONFIG_AUX_DIR(./support) dnl ------------------------------------------------------------------------- dnl Check current host (forget about cross compilation) and validate it diff --git a/src/native/unix/man/jsvc.1.xml b/src/native/unix/man/jsvc.1.xml index 677e430..5067a6f 100644 --- a/src/native/unix/man/jsvc.1.xml +++ b/src/native/unix/man/jsvc.1.xml @@ -130,15 +130,19 @@ <varlistentry> <term><option>-outfile</option> /full/path/to/file</term> <listitem> - <para>Location for output from stdout (defaults to /dev/null). Use - the value '&2' to simulate '1>&2'</para> + <para>Location for output from stdout (defaults to + /dev/null). Use the value '&2' to simulate + '1>&2', or 'SYSLOG' to send output to the system + log.</para> </listitem> </varlistentry> <varlistentry> <term><option>-errfile</option> /full/path/to/file</term> <listitem> - <para>Location for output from stderr (defaults to /dev/null). Use - the value '&1' to simulate '2>&1'</para> + <para>Location for output from stderr (defaults to + /dev/null). Use the value '&1' to simulate + '2>&1', or 'SYSLOG' to send output to the system + log.</para> </listitem> </varlistentry> <varlistentry> diff --git a/src/native/unix/native/debug.c b/src/native/unix/native/debug.c index 32dc8cb..277a8f3 100644 --- a/src/native/unix/native/debug.c +++ b/src/native/unix/native/debug.c @@ -14,10 +14,9 @@ limitations under the License. */ /* @version $Id: debug.c 165119 2005-04-28 09:00:08Z jfclere $ */ +#include <stdio.h> + #include "jsvc.h" -#include <sys/types.h> -#include <unistd.h> -#include <time.h> /* Wether debug is enabled or not */ bool log_debug_flag = false; @@ -28,19 +27,9 @@ char *log_prog = "jsvc"; /* Dump a debug message to stderr */ void log_debug(const char *fmt, ...) { va_list ap; - time_t now; - struct tm *nowtm; - char buff[80]; if (log_debug_flag==false) return; - if (fmt==NULL) return; - - now = time(NULL); - nowtm = localtime(&now); - strftime(buff, sizeof(buff), "%d/%m/%Y %T", nowtm); - va_start(ap,fmt); - fprintf(stderr,"%s %d %s debug: ", buff, getpid(), log_prog); vfprintf(stderr,fmt,ap); fprintf(stderr,"\n"); fflush(stderr); @@ -50,21 +39,11 @@ void log_debug(const char *fmt, ...) { /* Dump an error message to stderr */ void log_error(const char *fmt, ...) { va_list ap; - time_t now; - struct tm *nowtm; - char buff[80]; if (fmt==NULL) return; - - now = time(NULL); - nowtm = localtime(&now); - strftime(buff, sizeof(buff), "%d/%m/%Y %T", nowtm); - va_start(ap,fmt); - fprintf(stderr,"%s %d %s error: ", buff, getpid(), log_prog); vfprintf(stderr,fmt,ap); fprintf(stderr,"\n"); fflush(stderr); va_end(ap); } - diff --git a/src/native/unix/native/jsvc-unix.c b/src/native/unix/native/jsvc-unix.c index 8fb222e..aa5373b 100644 --- a/src/native/unix/native/jsvc-unix.c +++ b/src/native/unix/native/jsvc-unix.c @@ -23,8 +23,11 @@ #include <sys/wait.h> #include <fcntl.h> #include <stdio.h> +#include <string.h> #include <pwd.h> #include <grp.h> +#include <syslog.h> +#include <errno.h> #ifdef OS_LINUX #include <sys/prctl.h> #include <sys/syscall.h> @@ -44,12 +47,16 @@ extern char **environ; static mode_t envmask; /* mask to create the files */ pid_t controlled=0; /* the son process pid */ +pid_t logger_pid=0; /* the logger process pid */ static bool stopping=false; static bool doreload=false; static void (*handler_int)(int)=NULL; static void (*handler_hup)(int)=NULL; static void (*handler_trm)(int)=NULL; +static int run_controller(arg_data *args, home_data *data, uid_t uid, + gid_t gid); + #ifdef OS_CYGWIN /* * File locking routine @@ -174,7 +181,8 @@ static int set_caps(int caps) cap.permitted = caps; cap.inheritable = caps; if (syscall(__NR_capset, &caphead, &cap) < 0) { - log_error("syscall failed in set_caps"); + log_error("set_caps: failed to set capabilities"); + log_error("check that your kernel supports capabilities"); return(-1); } return(0); @@ -615,45 +623,140 @@ static FILE *loc_freopen(char *outfile, char *mode, FILE *stream) return(freopen(outfile,mode,stream)); } +#define LOGBUF_SIZE 1024 + +/* Read from file descriptors. Log to syslog. */ +static int logger_child(int out_fd, int err_fd, char *procname) +{ + fd_set rfds; + struct timeval tv; + int retval, n; + char buf[LOGBUF_SIZE]; + + if (out_fd > err_fd) { + n = out_fd + 1; + } else { + n = err_fd + 1; + } + + openlog(procname, LOG_PID, LOG_DAEMON); + + while (1) { + FD_ZERO(&rfds); + FD_SET(out_fd, &rfds); + FD_SET(err_fd, &rfds); + tv.tv_sec = 60; + tv.tv_usec = 0; + retval = select(n, &rfds, NULL, NULL, &tv); + if (retval == -1) + syslog(LOG_ERR, "select: %s", strerror(errno)); + else if (retval) { + if (FD_ISSET(out_fd, &rfds)) { + ssize_t n = read(out_fd, buf, LOGBUF_SIZE-1); + if (n < 0) { + syslog(LOG_ERR, "read: %s", strerror(errno)); + } else if (n > 0 && buf[0] != '\n') { + buf[n] = 0; + syslog(LOG_INFO, "%s", buf); + } + } + if (FD_ISSET(err_fd, &rfds)) { + ssize_t n = read(err_fd, buf, LOGBUF_SIZE-1); + if (n < 0) { + syslog(LOG_ERR, "read: %s", strerror(errno)); + } else if (n > 0 && buf[0] != '\n') { + buf[n] = 0; + syslog(LOG_ERR, "%s", buf); + } + } + } + } +} + /** * Redirect stdin, stdout, stderr. */ -static void set_output(char *outfile, char *errfile) { +static void set_output(char *outfile, char *errfile, char *procname) { + int out_pipe[2] = {0, 0}, err_pipe[2] = {0, 0}, fork_needed = 0; + freopen("/dev/null", "r", stdin); log_debug("redirecting stdout to %s and stderr to %s",outfile,errfile); /* make sure the debug goes out */ if (log_debug_flag==true && strcmp(errfile,"/dev/null") == 0) - return; + return; /* Handle malicious case here */ if(strcmp(outfile, "&2") == 0 && strcmp(errfile,"&1") == 0) { - outfile="/dev/null"; + outfile="/dev/null"; } - if(strcmp(outfile, "&2") != 0) { - loc_freopen(outfile, "a", stdout); + + if (strcmp(outfile, "SYSLOG") == 0) { + /* Send stdout to syslog through a logger process */ + if (pipe(out_pipe) == -1) { + log_error("cannot create stdout pipe: %s", + strerror(errno)); + } else { + fork_needed = 1; + } + } else if (strcmp(outfile, "&2") != 0) { + loc_freopen(outfile, "a", stdout); } - if(strcmp(errfile,"&1") != 0) { - loc_freopen(errfile, "a", stderr); + if (strcmp(errfile, "SYSLOG") == 0) { + /* Send stderr to syslog through a logger process */ + if (pipe(err_pipe) == -1) { + log_error("cannot create stderr pipe: %s", + strerror(errno)); + } else { + fork_needed = 1; + } + } else if (strcmp(errfile, "&1") != 0) { + loc_freopen(errfile, "a", stderr); } else { - close(2); - dup(1); + close(2); + dup(1); } if(strcmp(outfile, "&2") == 0) { - close(1); - dup(2); + close(1); + dup(2); + } + + if (fork_needed) { + pid_t pid = fork(); + if (pid == -1) { + log_error("cannot create logger process: %s", strerror(errno)); + } else { + if (pid) { + logger_pid = pid; + if (out_pipe[0] != 0) { + close(out_pipe[0]); + if (dup2(out_pipe[1], 1) == -1) { + log_error("cannot redirect stdout to pipe for syslog: %s", + strerror(errno)); + } + } + if (err_pipe[0] != 0) { + close(err_pipe[0]); + if (dup2(err_pipe[1], 2) == -1) { + log_error("cannot redirect stderr to pipe for syslog: %s", + strerror(errno)); + } + } + } else { + exit(logger_child(out_pipe[0], err_pipe[0], procname)); + } + } } } int main(int argc, char *argv[]) { arg_data *args=NULL; home_data *data=NULL; - int status=0; pid_t pid=0; uid_t uid=0; gid_t gid=0; - time_t laststart; + int res; /* Parse command line arguments */ args=arguments(argc,argv); @@ -676,7 +779,7 @@ int main(int argc, char *argv[]) { return(0); } -#ifdef OS_LINUX +#if 0 /* On some UNIX operating systems, we need to REPLACE this current process image with another one (thru execve) to allow the correct loading of VMs (notably this is for Linux). Set, replace, and go. */ @@ -750,24 +853,40 @@ int main(int argc, char *argv[]) { } envmask = umask(0077); - set_output(args->outfile, args->errfile); + set_output(args->outfile, args->errfile, args->procname); + + res = run_controller(args, data, uid, gid); + if (logger_pid != 0) { + kill(logger_pid, SIGTERM); + } + + return res; +} + +static int run_controller(arg_data *args, home_data *data, uid_t uid, + gid_t gid) +{ + pid_t pid=0; /* We have to fork: this process will become the controller and the other will be the child */ while ((pid=fork())!=-1) { + time_t laststart; + int status=0; + /* We forked (again), if this is the child, we go on normally */ if (pid==0) exit(child(args,data,uid,gid)); laststart = time(NULL); /* We are in the controller, we have to forward all interesting signals to the child, and wait for it to die */ - controlled=pid; + controlled = pid; #ifdef OS_CYGWIN SetTerm(cygwincontroller); #endif - signal(SIGHUP,controller); - signal(SIGTERM,controller); - signal(SIGINT,controller); + signal(SIGHUP, controller); + signal(SIGTERM, controller); + signal(SIGINT, controller); while (waitpid(pid,&status,0)!=pid); @@ -817,7 +936,6 @@ int main(int argc, char *argv[]) { /* Got out of the loop? A fork() failed then. */ log_error("Cannot decouple controller/child processes"); return(1); - } void main_reload(void) { @@ -829,4 +947,3 @@ void main_shutdown(void) { log_debug("Killing self with TERM signal"); kill(controlled,SIGTERM); } - -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/commons-daemon.git _______________________________________________ pkg-java-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

