Hello community, here is the log from the commit of package sysvinit checked in at Fri Nov 30 16:13:55 CET 2007. -------- --- sysvinit/sysvinit.changes 2007-10-31 18:38:23.000000000 +0100 +++ /mounts/work_src_done/STABLE/sysvinit/sysvinit.changes 2007-11-30 14:06:12.922666000 +0100 @@ -1,0 +2,9 @@ +Fri Nov 30 14:00:20 CET 2007 - werner@suse.de + +- New version 2.13 of killproc + * Add support for more than one ignore pid file (bug #343227) + * Close existing file descriptors on execve even if not a tty + * Do not fork if startpar is used as start_daemon + * Clean up the manual pages + +------------------------------------------------------------------- Old: ---- killproc-2.12.dif killproc-2.12.tar.bz2 New: ---- killproc-2.13.tar.bz2 sysvinit-rpmlintrc ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ sysvinit.spec ++++++ --- /var/tmp/diff_new_pack.lq3620/_old 2007-11-30 16:13:31.000000000 +0100 +++ /var/tmp/diff_new_pack.lq3620/_new 2007-11-30 16:13:31.000000000 +0100 @@ -13,7 +13,7 @@ Name: sysvinit %define MGVER 0.9.6s %define PDVER 2.0.2 -%define KPVER 2.12 +%define KPVER 2.13 %define SCVER 1.08 %define SIVER 2.86 %define START 0.50 @@ -22,19 +22,20 @@ PreReq: coreutils AutoReqProv: on Version: 2.86 -Release: 106 +Release: 112 Summary: SysV-Style init BuildRoot: %{_tmppath}/%{name}-%{version}-build Source: sysvinit-2.86.tar.bz2 -Source2: killproc-2.12.tar.bz2 +Source2: killproc-2.13.tar.bz2 Source3: powerd-2.0.2.tar.bz2 Source4: showconsole-1.08.tar.bz2 Source5: startpar-0.50.tar.bz2 Source6: rc.powerd +Source7: sysvinit-rpmlintrc Patch: sysvinit-2.86.dif Patch1: sysvinit-2.86-nfs4pidof.patch Patch2: powerd-2.0.2.dif -Patch3: killproc-2.12.dif +#Patch3: killproc-2.13.dif Patch5: sysvinit-2.86-sulogin.patch Patch6: sysvinit-2.82-startstop.patch Patch7: sysvinit-2.85-suse.patch @@ -86,7 +87,7 @@ %patch -P 2 popd pushd ../killproc-%{KPVER} -%patch -P 3 +#%patch -P 3 popd pushd ../showconsole-%{SCVER} %patch -P 10 @@ -127,6 +128,7 @@ %install rm -rf ${RPM_BUILD_ROOT} + mkdir ${RPM_BUILD_ROOT} mkdir -m 755 -p ${RPM_BUILD_ROOT}/bin mkdir -m 755 -p ${RPM_BUILD_ROOT}/dev mkdir -m 755 -p ${RPM_BUILD_ROOT}/etc @@ -280,7 +282,14 @@ %doc %{_mandir}/man8/sulogin.8.gz %doc %{_mandir}/man8/telinit.8.gz %doc %{_mandir}/man8/startpar.8.gz + %changelog +* Fri Nov 30 2007 - werner@suse.de +- New version 2.13 of killproc + * Add support for more than one ignore pid file (bug #343227) + * Close existing file descriptors on execve even if not a tty + * Do not fork if startpar is used as start_daemon + * Clean up the manual pages * Wed Oct 31 2007 - werner@suse.de - startpar: make iorate a double * Wed Oct 31 2007 - werner@suse.de ++++++ killproc-2.12.tar.bz2 -> killproc-2.13.tar.bz2 ++++++ diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.12/checkproc.8 new/killproc-2.13/checkproc.8 --- old/killproc-2.12/checkproc.8 2006-12-14 17:18:31.000000000 +0100 +++ new/killproc-2.13/checkproc.8 2007-11-30 14:01:09.000000000 +0100 @@ -14,23 +14,45 @@ Pidofproc \- Checks for a process by exec base name .SH SYNOPSIS .\" +.HP .B checkproc -.RB [ "-v" "] [" "-L" "] [" "-k" "] [" "-N" "] [" -p -.IR pid_file ] -.RB [ -i -.IR ingnore_file ] -.RB [ -c -.IR root ] -.RB [ "-z" ] +.RB [ \-vLkNz ] +.RB [ \-p\ \fIpid_file\fP ] +.RB [ \-i\ \fIingnore_file\fP ] +.RB [ \-c\ \fIroot\fP ] .I /full/path/to/executable -.PP +.HP .B checkproc -.RB [ "-v" "] [" "-k" "] [" "-n" "]" +.B \-n +.RB [ \-vk ] .I name_of_kernel_thread -.PP +.HP +.B checkproc +.B \ \ +.RB [ \-vk ] +.I basename_of_executable +.HP +.B pidofproc +.RB [ \-LkNz ] +.RB [ \-p\ \fIpid_file\fP ] +.RB [ \-i\ \fIingnore_file\fP ] +.RB [ \-c\ \fIroot\fP ] +.I /full/path/to/executable +.HP .B pidofproc +.B \-n +.RB [ \-k ] +.I name_of_kernel_thread +.HP +.B pidofproc +.B \ \ .RB [ \-k ] .I basename_of_executable +.SH SYNOPSIS LSB 3.1 +.HP +.B pidofproc +.RB [ \-p\ \fIpid_file\fP ] +.I /full/path/to/executable .\" .SH DESCRIPTION .B checkproc @@ -144,9 +166,7 @@ .BR killproc (8) which changes the operation mode, e.g. the exit status of the program will be that of -.BR killproc (8) -and -.BR startproc (8). +.BR killproc (8). Without this option, .B checkproc works like diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.12/checkproc.c new/killproc-2.13/checkproc.c --- old/killproc-2.12/checkproc.c 2006-12-14 17:18:31.000000000 +0100 +++ new/killproc-2.13/checkproc.c 2007-11-30 14:01:09.000000000 +0100 @@ -14,6 +14,7 @@ * Author: Werner Fink <werner@suse.de> * 1998/05/06 Werner Fink: rework, added "-p" for pid files * 2000/11/10 Werner Fink: LSB specs, logging + * 2007/11/29 Werner Fink: ignore more than one pid */ #include "libinit.h" @@ -33,25 +34,27 @@ PROC * list; char *fullname = NULL, * basename = NULL; char *pid_file = NULL, *ignore_file = NULL; - char *root = NULL; + char *root = NULL, *iargv[argc]; char *posixa, *posixb; /* Don't fool me with posix correct */ - int quiet = 1; + int quiet = 1, iargc = 0; unsigned short flags = (DAEMON|PIDOF|NZOMBIE); boolean pid_forced = false; we_are = base_name(argv[0]); + for (c = 0; c < argc; c++) + iargv[c] = (char*)0; if (!strcmp(we_are, "pidofproc")) quiet = 0; openlog (we_are, LOG_OPTIONS, LOG_FACILITY); -/* - * We should stat() fullname, because only the path identifies the executable. - * If there is one hardlink we have only to stat() the orignal executable. - * If there is more than one hardlink and we have to distinguish the - * executables by their swapname. Note if the cmdline of some executables - * will changed by the running process its self the name is not clearly - * defined ... see libinit.c for more information. - */ + /* + * We should stat() fullname, because only the path identifies the executable. + * If there is one hardlink we have only to stat() the orignal executable. + * If there is more than one hardlink and we have to distinguish the + * executables by their swapname. Note if the cmdline of some executables + * will changed by the running process its self the name is not clearly + * defined ... see libinit.c for more information. + */ posixa = getenv("_POSIX_OPTION_ORDER"); unsetenv("_POSIX_OPTION_ORDER"); posixb = getenv("POSIXLY_CORRECT"); unsetenv("POSIXLY_CORRECT"); @@ -94,9 +97,9 @@ error(WRGSYNTAX, "Option -p requires pid file to read pid from\n"); break; case 'i': - /* Allocate here: address optarg (current *argv) isn't freeable */ + /* Remember: address optarg (current *argv) */ if (optarg && optarg[0] != '-') { - ignore_file = xstrdup(optarg); + iargv[iargc++] = optarg; } else error(LSB_WRGSYN,"Option -i requires pid file to read pid from\n"); break; @@ -162,8 +165,8 @@ if (remember_pids(pid_file,fullname,root,flags) < 0) exit(LSB_PROOFX); - if (!remember && (flags & KILL)) - exit(LSB_NOPROC); /* New LSB: no pid file is no job */ + if (!remember) + exit(LSB_STATUS_NOPROC); /* New LSB: no pid file is no job */ } /* No pid file means that we have to search in /proc/ */ free(pid_file); @@ -179,24 +182,18 @@ } /* Check and verify the ignore file */ - errno = 0; - if (ignore_file && stat(ignore_file, &st) < 0) { - if (errno != ENOENT) - warn("Can not stat %s: %s\n", ignore_file, strerror(errno)); - - free(ignore_file); - ignore_file = NULL; - } - - if (ignore_file && !st.st_size) { - warn("Empty ignore file %s for %s\n", ignore_file, fullname); - - /* No pid file means that we have to search in /proc/ */ - free(ignore_file); - ignore_file = NULL; - } - - if (ignore_file) { /* The case of having a ignore file */ + for (c = 0; (c < iargc) && (ignore_file = iargv[c]); c++) { + errno = 0; + if (stat(ignore_file, &st) < 0) { + if (errno != ENOENT) + warn("Can not stat %s: %s\n", ignore_file, strerror(errno)); + continue; + } + if (!st.st_size) { + warn("Empty ignore file %s for %s\n", ignore_file, fullname); + continue; + } + /* The case of having a ignore file */ if (verify_pidfile(ignore_file,fullname,root,flags,true) < 0) exit(LSB_PROOFX); } diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.12/fsync.1 new/killproc-2.13/fsync.1 --- old/killproc-2.12/fsync.1 1970-01-01 01:00:00.000000000 +0100 +++ new/killproc-2.13/fsync.1 2007-11-30 14:01:09.000000000 +0100 @@ -0,0 +1,39 @@ +.\" +.\" Copyright 2007 Werner Fink, 2007 SuSE GmbH Nuernberg, Germany. +.\" +.\" This program is free software; you can redistribute it and/or modify +.\" it under the terms of the GNU General Public License as published by +.\" the Free Software Foundation; either version 2 of the License, or +.\" (at your option) any later version. +.\" +.TH FSYNC 1 "Jun 18, 2007" "Version 1.16" "The SuSE boot concept" +.UC 1 +.SH NAME +fsync \- synchronize the specified file with storage device +.\" +.SH SYNOPSIS +.\" +.B fsync +.I file +.\" +.SH DESCRIPTION +.B fsync +synchronize the in-core state of the specified file with the storage device +.\" +.SH BUGS +The +.B fsync +program uses the +.BR fsync (2) +function and therefore shows the same weaknesses +by any system activity. +\." +.SH SEE ALSO +.BR fsync (2), +.BR fdatasync (2). +\." +.SH COPYRIGHT +2007 Werner Fink, +2007 SuSE GmbH Nuernberg, Germany. +.SH AUTHOR +Werner Fink <werner@suse.de> diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.12/fsync.c new/killproc-2.13/fsync.c --- old/killproc-2.12/fsync.c 1970-01-01 01:00:00.000000000 +0100 +++ new/killproc-2.13/fsync.c 2007-11-30 14:01:09.000000000 +0100 @@ -0,0 +1,89 @@ +/* + * fsync.c File data sync for the specified file + * + * Usage: fsync file + * + * Copyright 2007 Werner Fink, 2007 SUSE LINUX Products GmbH, Germany. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Author: Werner Fink <werner@suse.de> + */ + +#ifndef __USE_STRING_INLINES +# define __USE_STRING_INLINES +#endif +#ifdef __NO_STRING_INLINES +# undef __NO_STRING_INLINES +#endif +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include <string.h> +#include <libgen.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <errno.h> + +#define USAGE "Usage:\t%s file\n", we_are + +static char *we_are; +int main(int argc, char **argv) +{ + int ret, fd, flags; + char *path, *dir = NULL; + + if (argc != 2) + goto err; + + if ((path = strdup(argv[1])) == (char*)0) + goto err; + + dir = dirname(path); + flags = O_RDONLY|O_NOCTTY|O_NONBLOCK; + + if (getuid() == 0) + flags |= O_NOATIME; + + if ((fd = open(argv[1], flags)) < 0) { + if (errno != ENOENT) + goto err; + if ((fd = open(dir, flags|O_DIRECTORY)) < 0) + goto err; + ret = fsync(fd); + close(fd); + if (ret < 0) + goto err; + if ((fd = open(argv[1], flags)) < 0) + goto err; + } + ret = fsync(fd); + close(fd); + if (ret < 0) + goto err; + + return 0; + /* Do this at the end for speed */ +err: + we_are = basename(argv[0]); + fprintf(stderr, USAGE); + + if (argc > 1 && *(argv[1]) == '-') { + argv[1]++; + if (!strcmp(argv[1], "-help") || *(argv[1]) == 'h' || *(argv[1]) == '?') { + fprintf(stderr, "Do a fsync(2) on the specified file.\n\n"); + fprintf(stderr, "Help options:\n"); + fprintf(stderr, " -h, -?, --help display this help and exit.\n"); + exit (0); + } + } else if (errno != 0) + fprintf(stderr, "%s: %s\n", argv[1], strerror(errno)); + exit (1); +} diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.12/killproc-2.12.lsm new/killproc-2.13/killproc-2.12.lsm --- old/killproc-2.12/killproc-2.12.lsm 2006-12-14 17:18:31.000000000 +0100 +++ new/killproc-2.13/killproc-2.12.lsm 1970-01-01 01:00:00.000000000 +0100 @@ -1,18 +0,0 @@ -Begin3 -Title: killproc and assorted tools for boot scripts -Version: 2.12 -Entered-date: 14DEC06 -Description: Some useful programs for a replacment of the shell functions - daemom and killproc found in the Linux System V init suite. - killproc(8) for signaling or terminating, checkproc(8) for - checking and startproc(8) for starting processes. - Each program has its own manual page. -Keywords: killproc, startproc, checkproc, process control -Author: Werner Fink <werner@suse.de> -Maintained-by: Werner Fink <werner@suse.de> -Primary-site: sunsite.unc.edu /pub/Linux/system/daemons/init - @UNKNOWN killproc-2.12.tar.gz -Alternate-site: ftp.suse.com /pub/projects/init -Platforms: Linux with System VR2 or higher boot scheme -Copying-policy: GPL -End diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.12/killproc-2.13.lsm new/killproc-2.13/killproc-2.13.lsm --- old/killproc-2.12/killproc-2.13.lsm 1970-01-01 01:00:00.000000000 +0100 +++ new/killproc-2.13/killproc-2.13.lsm 2007-11-30 14:01:09.000000000 +0100 @@ -0,0 +1,35 @@ +Begin3 +\ +Title: killproc and assorted tools for boot scripts +\ +Version: 2.13 +\ +Entered-date: 30NOV07 +\ +Description: Some useful programs for a replacment of the shell functions +\ + daemom and killproc found in the Linux System V init suite. +\ + killproc(8) for signaling or terminating, checkproc(8) for +\ + checking and startproc(8) for starting processes. +\ + Each program has its own manual page. +\ +Keywords: killproc, startproc, checkproc, process control +\ +Author: Werner Fink <werner@suse.de> +\ +Maintained-by: Werner Fink <werner@suse.de> +\ +Primary-site: sunsite.unc.edu /pub/Linux/system/daemons/init +\ + @UNKNOWN killproc-2.13.tar.gz +\ +Alternate-site: ftp.suse.com /pub/projects/init +\ +Platforms: Linux with System VR2 or higher boot scheme +\ +Copying-policy: GPL +\ +End diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.12/killproc.8 new/killproc-2.13/killproc.8 --- old/killproc-2.12/killproc.8 2006-12-14 17:18:31.000000000 +0100 +++ new/killproc-2.13/killproc.8 2007-11-30 14:01:09.000000000 +0100 @@ -12,28 +12,41 @@ Killproc \- Send signals to processes by full path name .SH SYNOPSIS .\" +.HP .B killproc -.RB [ "-v" "] [" "-q" "] [" "-L" "] [" "-g" | "-G" "] [" "-N" "] [" "-p -.IR pid_file ] -.RB [ -i -.IR ingnore_file ] -.RB [ -c -.IR root ] -.RB [ "-t<sec>" "] [" "-SIG" ] +.RB [ \-vqLN ] +.RB [ \-g | -G ] +.RB [ \-p\ \fIpid_file\fP ] +.RB [ \-i\ \fIingnore_file\fP ] +.RB [ \-c\ \fIroot\fP ] +.RB [ \-t\ \fI<sec>\fP ] +.RB [ \-\fI<SIG>\fP ] .I /full/path/to/executable -.PP +.HP .B killproc -.RB [ "-v" "] [" "-q" "] [" "-g" | "-G" "] [" "-n" ] -.RB [ "-t<sec>" "] [" "-SIG" ] +.B \-n +.RB [ \-vq ] +.RB [ \-g | -G ] +.RB [ \-t\ \fI<sec>\fP ] +.RB [ \-\fI<SIG>\fP ] .I name_of_kernel_thread -.PP +.HP .B killproc -.RB [ "-v" "] [" "-q" "] [" "-g" | "-G" "] [" "-n" ] -.RB [ "-t<sec>" "] [" "-SIG" ] +.B \ \ +.RB [ \-vq ] +.RB [ \-g | -G ] +.RB [ \-t\ \fI<sec>\fP ] +.RB [ \-\fI<SIG>\fP ] .I basename_of_executable -.PP +.HP .B killproc .B \-l +.SH SYNOPSIS LSB 3\.1 +.HP +.B killproc +.RB [ \-p\ \fIpid_file\fP ] +.I /full/path/to/executable +.RB [ \-\fI<SIG>\fP ] .\" .SH DESCRIPTION .B killproc @@ -218,15 +231,15 @@ symbolic link will be skipped. .\" .TP -.B \-SIG +.B \-\fI<SIG>\fP Signals can be specified either by name .RB (e.g. " -HUP" , " -SIGHUP" ) or by number .RB (e.g. " -1" ). .TP -.B \-t<sec> +.B \-t\fI<sec>\fP The number -.B <sec> +.I <sec> specifies the seconds to wait between the sent signal .B SIGTERM and the subsequentially signal diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.12/killproc.c new/killproc-2.13/killproc.c --- old/killproc-2.12/killproc.c 2006-12-14 17:18:31.000000000 +0100 +++ new/killproc-2.13/killproc.c 2007-11-30 14:01:09.000000000 +0100 @@ -18,6 +18,7 @@ * 1998/15/09 Werner Fink: exit status for killing not running processes is 0 * 1998/29/09 Werner Fink: Add kernel thread handling. * 2000/11/10 Werner Fink: LSB specs, logging + * 2007/11/29 Werner Fink: ignore more than one pid */ #include "libinit.h" @@ -26,8 +27,9 @@ #define OTHERSIG "HUP" #define USAGE "Usage:\n"\ - "\t%s [-v] [-t<sec>] [-g|-G] [-SIG] /full/path/to/program\n" \ - "\t%s -l\n", we_are, we_are + " %s [-v] [-q] [-L] [-g|-G] [-N] [-p pid_file] [-i ingnore_file] \\\n"\ + " [-c root] [-t<sec>] [-SIG] /full/path/to/executable\n"\ + " %s -l\n", we_are, we_are static int do_kill(const char *name, const pid_t proc, const int sig, const int group_leader, const int process_group); @@ -42,14 +44,16 @@ PROC * list; char *fullname = NULL, *basename = NULL; char *pid_file = NULL, *ignore_file = NULL; - char *root = NULL; + char *root = NULL, *iargv[argc]; char *posixa, *posixb; /* Don't fool me with posix correct */ - int process_group = 0, group_leader = 0, wait = 5; + int process_group = 0, group_leader = 0, wait = 5, iargc = 0; unsigned short flags = (KILL|PIDOF|KSTOP); boolean pid_forced = false; we_are = base_name(argv[0]); openlog (we_are, LOG_OPTIONS, LOG_FACILITY); + for (c = 0; c < argc; c++) + iargv[c] = (char*)0; /* If we are not called as killproc use HUP (e.g. for sigproc) */ if (strcmp(we_are,"killproc") != 0) @@ -140,9 +144,9 @@ list_signames(); exit(0); case 'i': - /* Allocate here: address optarg (current *argv) isn't freeable */ + /* Remember: address optarg (current *argv) */ if (optarg && optarg[0] != '-') { - ignore_file = xstrdup(optarg); + iargv[iargc++] = optarg; } else error(LSB_WRGSYN,"Option -i requires pid file to read pid from\n"); break; @@ -235,29 +239,25 @@ } /* Check and verify the ignore file */ - errno = 0; - if (ignore_file && stat(ignore_file, &st) < 0) { - if (errno != ENOENT) - warn("Can not stat %s: %s\n", ignore_file, strerror(errno)); - - free(ignore_file); - ignore_file = NULL; - } - - if (ignore_file && !st.st_size) { - warn("Empty ignore file %s for %s\n", ignore_file, fullname); - - /* No pid file means that we have to search in /proc/ */ - free(ignore_file); - ignore_file = NULL; - } - - if (ignore_file) { /* The case of having a ignore file */ + for (c = 0; (c < iargc) && (ignore_file = iargv[c]); c++) { + errno = 0; + if (stat(ignore_file, &st) < 0) { + if (errno != ENOENT) + warn("Can not stat %s: %s\n", ignore_file, strerror(errno)); + continue; + } + if (!st.st_size) { + warn("Empty ignore file %s for %s\n", ignore_file, fullname); + continue; + } + /* The case of having a ignore file */ if (verify_pidfile(ignore_file,fullname,root,flags,true) < 0) exit(LSB_PROOFX); - clear_pids(); /* Remove all pids which should be ignored */ } + if (iargc) + clear_pids(); /* Remove all pids which should be ignored */ + /* Do main work */ if (!remember) { /* killing a none existing process is already success. diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.12/libinit.c new/killproc-2.13/libinit.c --- old/killproc-2.12/libinit.c 2006-12-14 17:18:31.000000000 +0100 +++ new/killproc-2.13/libinit.c 2007-11-30 14:01:09.000000000 +0100 @@ -895,15 +895,7 @@ char *fullname = (char *)inname; struct stat pid_st, full_st; - if (ignore) { - PROC *p, *n; - n = doignore; - for (p = doignore; n; p = n) { - n = p->next; - free(p); - } - doignore = (PROC*)0; - } else { + if (!ignore) { PROC *p, *n; n = remember; for (p = remember; n; p = n) { diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.12/Makefile new/killproc-2.13/Makefile --- old/killproc-2.12/Makefile 2006-12-14 17:18:31.000000000 +0100 +++ new/killproc-2.13/Makefile 2007-11-30 14:01:09.000000000 +0100 @@ -12,7 +12,7 @@ PREFIX = /usr DEBUG = DESTDIR = -VERSION = 2.12 +VERSION = 2.13 DATE = $(shell date +'%d%b%y' | tr '[:lower:]' '[:upper:]') ifneq ($(INC),) @@ -53,6 +53,7 @@ ifeq ($(DISTRO),SuSE) UBINPRG += usleep + UBINPRG += fsync endif all: $(SBINPRG) $(UBINPRG) @@ -72,8 +73,11 @@ usleep: usleep.c $(CC) $(CFLAGS) -o $@ $^ +fsync: fsync.c + $(CC) $(CFLAGS) -o $@ $^ + clean: - $(RM) *.o *~ killproc startproc checkproc pidofproc start_daemon usleep + $(RM) *.o *~ killproc startproc checkproc pidofproc start_daemon usleep fsync install: $(TODO) if test -n "$(SBINPRG)" ; then \ @@ -116,6 +120,8 @@ libinit.h \ usleep.c \ usleep.1 \ + fsync.c \ + fsync.1 \ killproc-$(VERSION).lsm dest: diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.12/startproc.8 new/killproc-2.13/startproc.8 --- old/killproc-2.12/startproc.8 2006-12-14 17:18:31.000000000 +0100 +++ new/killproc-2.13/startproc.8 2007-11-30 14:01:09.000000000 +0100 @@ -1,12 +1,13 @@ .\" -.\" Copyright 1994-2000 Werner Fink, 1996-2000 SuSE GmbH Nuernberg, Germany. +.\" Copyright (c) 1994-2007 Werner Fink, 1996-2000 SuSE GmbH, Nuernberg, Germany. +.\" Copyright (c) 2007 SuSE LINUX Products GmbH, Nuernberg, Germany. .\" .\" This program is free software; you can redistribute it and/or modify .\" it under the terms of the GNU General Public License as published by .\" the Free Software Foundation; either version 2 of the License, or .\" (at your option) any later version. .\" -.TH STARTPROC 8 "Nov 10, 2000" "Version 1.16" "The SuSE boot concept" +.TH STARTPROC 8 "Nov 30, 2007" "Version 1.16" "The SuSE boot concept" .UC 8 .SH NAME Startproc \- Start processes identified by path name @@ -14,31 +15,35 @@ Start_daemon \- Start processes identified by path name .SH SYNOPSIS .\" +.HP .B startproc -.RB [ -f ] -.RB [ -L ] -.RB [[ "-n "] +/-<prio> ] -.RB [ -s ] -.RB [ "-t -.IR sec ] -.RB [ "-u" -.IR user ] -.RB [ "-g" -.IR group ] -.RB [ "-v" "] [" "-e" "] [" -l -.I log_file -.RB | -q | -d ] -.RB [ -p -.IR pid_file ] -.RB [ -i -.IR ignore_file ] -.RB [ -c -.IR root ] +.RB [ \-fLves ] +.RB [[ \-n\ ] \fI+/\-<prio>\fP ] +.RB [ \- ( t | T )\ \fI<sec>\fP ] +.RB [ \-u\ \fIuser\fP ] +.RB [ \-g\ \fIgroup\fP ] +.RB [ \-l\ \fIlog_file\fP | \-q | \-d ] +.RB [ \-p\ \fIpid_file\fP ] +.RB [ \-i\ \fIignore_file\fP ] +.RB [ \-c\ \fIroot\fP ] .IR /path/to/executable " [" "arguments for executable" ] -.PP +.\" +.HP .B start_daemon -.RB [ -f ] -.RB [ "-n " +/-<prio> ] +.RB [ \-fLve ] +.RB [ \-n\ \fI+/\-<prio>\fP ] +.RB [ \-u\ \fIuser\fP ] +.RB [ \-g\ \fIgroup\fP ] +.RB [ \-l\ \fIlog_file\fP | \-q | \-d ] +.RB [ \-p\ \fIpid_file\fP ] +.RB [ \-i\ \fIignore_file\fP ] +.RB [ \-c\ \fIroot\fP ] +.IR /path/to/executable " [" "arguments for executable" ] +.SH SYNOPSIS LSB 3\.1 +.HP +.B start_daemon +.RB [ \-f ] +.RB [ \-n\ \fI+/\-<prio>\fP ] .IR /path/to/executable " [" "arguments for executable" ] .\" .SH DESCRIPTION @@ -96,6 +101,15 @@ .B startproc print out verbose diagnostics. .PP +The +.B start_daemon +does not support the options +.BR \- ( t | T )\ \fI<sec>\fP +for waiting for success and +the option +.B \-s +for a new session as this variant does not fork to start the +executable. .\" .SH REQUIRED .TP @@ -106,10 +120,10 @@ obtained from the respective manpage(s). .SH OPTIONS .TP -.RB [ "-n " ] +/-<prio> +.RB [ "-n " ] \fI+/-<prio>\fP Set the nice level for the process. If used, this option should always be the first in the command line. The nice level -.B <prio> +.I <prio> may be specified in the range between -20 and +20. Only root is allowed to set negative nice values. .TP @@ -181,7 +195,7 @@ Starts the process in a new session. The new task is a process group leader and has no controlling tty. .TP -.BI \-t " sec" +.BI \-t " <sec>" The number of seconds to wait after the successful start of a service. This options accepts the number of seconds to wait. You can specify some units after a given number: @@ -192,6 +206,12 @@ .B h for hours to wait. .TP +.BI \-T " <sec>" +The same as for option +.B \-t +but wait only on the started process not on childs forked by +the process. +.TP .BI \-u " user" Sets the user ID of the process to .IR user . @@ -271,6 +291,14 @@ state. Zombies are processes which arn't alive but listed in the process table to have the exit status ready for the corresponding parent processes. Therefore the parent processes should be check out. +.PP +.B Start_daemon +is not able to check for exit status of an executable daemon because after +the final +.BR execve (3) +the +.B start_daemon +as an own process does not exit anymore. .\" .SH FILES .TP @@ -295,7 +323,8 @@ .BR signal (7), .BR proc (5). .SH COPYRIGHT -1994-2000 Werner Fink, +1994-2007 Werner Fink, 1996-2000 SuSE GmbH Nuernberg, Germany. +2007 SuSE LINUX Products GmbH, Nuernberg, Germany. .SH AUTHOR Werner Fink <werner@suse.de> diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/killproc-2.12/startproc.c new/killproc-2.13/startproc.c --- old/killproc-2.12/startproc.c 2006-12-14 17:18:31.000000000 +0100 +++ new/killproc-2.13/startproc.c 2007-11-30 14:01:09.000000000 +0100 @@ -17,26 +17,33 @@ * 1998/05/06 Werner Fink: rework, added "-p" for pid files * 1999/08/05 Werner Fink: added "-t" for time to sleep, reenable "-e" * 2000/11/10 Werner Fink: LSB specs, logging + * 2007/11/29 Werner Fink: ignore more than one pid, close existing files on execve, + * do not fork in case of start_daemon */ #include "libinit.h" #include <sys/time.h> #include <sys/resource.h> #include <sys/ioctl.h> +#include <argz.h> #include <grp.h> #define USAGE "Usage:\n"\ - "\t%s [-f] [+/-<prio>] [-s] [-u uid] [-g gid] [-v] [-l log_file|-q] /full/path/to/program\n" + " %s [-f] [-L] [[-n ]+/-<prio>] [-s] [-t sec|-T sec] [-u uid] [-g gid] [-v] [-e] \\\n"\ + " [-l log|-q|-d] [-p pid_file] [-i ignore_file] [-c root] /path/to/executable [args]\n" #define USAGE_SD "Usage:\n"\ - "\t%s [-f] [-n +/-<prio>] /full/path/to/program\n" + " %s [-f] [-L] [-n +/-<prio>] [-u uid] [-g gid] [-v] [-e] \\\n"\ + " [-l log|-q|-d] [-p pid_file] [-i ignore_file] [-c root] /path/to/executable [args]\n" -static int do_fork(const char *name, char *argv[], const char* log_file, +static int do_start(const char *name, char *argv[], const char* log_file, const int nicelvl, const int env, const char* root, unsigned short flags); +static void closefds(FILE *not); -static int quiet = 1, supprmsg = 0, sess = 0, seconds = 0, force = 0, dialog = 0; +static int quiet = 1, supprmsg = 0, sess = 0, seconds = 0, sigchld = 0, force = 0, dialog = 0; static struct passwd *user = NULL; struct group *grp = NULL; static int syslogd = 0; +static int sdaemon = 0; static volatile sig_atomic_t signaled = 0; static void (*save_sigquit) = SIG_DFL; @@ -46,30 +53,40 @@ signaled = 1; } +static void sig_chld(int nsig) +{ + if (nsig != SIGCHLD) + return; + (void)signal(nsig, SIG_DFL); + seconds = 0; +} + int main(int argc, char **argv) { extern char * we_are; - int c; struct stat st; char *fullname = NULL, *basename = NULL; char *log_file = NULL, *pid_file = NULL, *ignore_file = NULL; - char *root = NULL; - int nicelvl = 0, env = 0; + char *root = NULL, *iargv[argc]; + int c, nicelvl = 0, env = 0, iargc = 0; unsigned short flags = (DAEMON|PIDOF); we_are = base_name(argv[0]); + sdaemon = (strcmp("start_daemon", we_are) == 0) ? 1 : 0; openlog (we_are, LOG_OPTIONS, LOG_FACILITY); + for (c = 0; c < argc; c++) + iargv[c] = (char*)0; -/* - * We should stat() fullname, because only the path identifies the executable. - * If there is one hardlink we have only to stat() the orignal executable. - * If there is more than one hardlink and we have to distinguish the - * executables by their swapname. Note if the cmdline of some executables - * will changed by the running process its self the name is not clearly - * defined ... see libinit.c for more information. - */ + /* + * We should stat() fullname, because only the path identifies the executable. + * If there is one hardlink we have only to stat() the orignal executable. + * If there is more than one hardlink and we have to distinguish the + * executables by their swapname. Note if the cmdline of some executables + * will changed by the running process its self the name is not clearly + * defined ... see libinit.c for more information. + */ - if (*argv) { + if (*argv && !sdaemon) { char **opt = argv; if (*(++opt) && (**opt == '-' || **opt == '+') && (nicelvl = atoi(*opt))) { if (nicelvl > PRIO_MAX) @@ -81,7 +98,7 @@ } opterr = 0; - while ((c = getopt(argc, argv, "+c:edp:l:hqvsu:g:t:n:fLi:")) != -1) { /* `+' is POSIX correct */ + while ((c = getopt(argc, argv, "+c:edp:l:hqvsu:g:t:n:fLi:T:")) != -1) { /* `+' is POSIX correct */ switch (c) { case 'v': quiet = 0; @@ -139,6 +156,7 @@ supprmsg = 1; break; case 's': + if (sdaemon) goto fail; sess = 1; break; case 'u': @@ -169,7 +187,10 @@ } else error(LSB_WRGSYN,"Option -g requires group id or group name\n"); break; + case 'T': + sigchld++; case 't': + if (sdaemon) goto fail; if (optarg && optarg[0] != '/' && optarg[0] != '-') { char *endptr; seconds = (int)strtol(optarg, &endptr, 10); @@ -199,17 +220,18 @@ error(LSB_WRGSYN,"Option -t requires number of seconds\n"); break; case 'i': - /* Allocate here: address optarg (current *argv) isn't freeable */ + /* Remember: address optarg (current *argv) */ if (optarg && optarg[0] != '-') { - ignore_file = xstrdup(optarg); + iargv[iargc++] = optarg; } else error(LSB_WRGSYN,"Option -i requires pid file to read pid from\n"); break; case '?': - error(LSB_WRGSYN, (strcmp("startproc", we_are) ? USAGE_SD : USAGE), we_are); + fail: + error(LSB_WRGSYN, (sdaemon ? USAGE_SD : USAGE), we_are); break; case 'h': - error(0, (strcmp("startproc", we_are) ? USAGE_SD : USAGE), we_are); + error(0, (sdaemon ? USAGE_SD : USAGE), we_are); break; default: break; @@ -220,7 +242,7 @@ argc -= optind; if (!*argv) - error(LSB_WRGSYN, (strcmp("startproc", we_are) ? USAGE_SD : USAGE), we_are); + error(LSB_WRGSYN, (sdaemon ? USAGE_SD : USAGE), we_are); if (root) { fullname = (char*) xmalloc(strlen(*argv)+strlen(root)+1); @@ -275,29 +297,24 @@ } /* Check and verify the ignore file */ - errno = 0; - if (ignore_file && stat(ignore_file, &st) < 0) { - if (errno != ENOENT) - warn("Can not stat %s: %s\n", ignore_file, strerror(errno)); - - free(ignore_file); - ignore_file = NULL; - } - - if (ignore_file && !st.st_size) { - warn("Empty ignore file %s for %s\n", ignore_file, fullname); - - /* No pid file means that we have to search in /proc/ */ - free(ignore_file); - ignore_file = NULL; - } - - if (ignore_file) { /* The case of having a ignore file */ + for (c = 0; (c < iargc) && (ignore_file = iargv[c]); c++) { + errno = 0; + if (stat(ignore_file, &st) < 0) { + if (errno != ENOENT) + warn("Can not stat %s: %s\n", ignore_file, strerror(errno)); + continue; + } + if (!st.st_size) { + warn("Empty ignore file %s for %s\n", ignore_file, fullname); + continue; + } + /* The case of having a ignore file */ if (verify_pidfile(ignore_file,fullname,root,flags,true) < 0) exit(LSB_PROOFX); - clear_pids(); /* Remove all pids which should be ignored */ } + if (iargc) + clear_pids(); /* Remove all pids which should be ignored */ /* Do main work */ if (!remember) { /* No process found with pid file */ @@ -310,7 +327,7 @@ exit(LSB_OK); /* Accordingly to LSB we have succeed. */ force: - (void)do_fork(fullname, argv, log_file, nicelvl, env, root, flags); + (void)do_start(fullname, argv, log_file, nicelvl, env, root, flags); /* Do we have started it? */ @@ -339,7 +356,7 @@ } /* end of main */ /* The core function */ -static int do_fork(const char *inname, char *argv[], const char* log_file, +static int do_start(const char *inname, char *argv[], const char* log_file, const int nicelvl, const int env, const char* root, unsigned short flags) { extern char * we_are; @@ -370,18 +387,29 @@ error(LSB_PROOF," cannot open %s: %s\n", log_file, strerror(errno)); } - (void)signal(SIGQUIT, sig_quit); - (void)signal(SIGCHLD, SIG_DFL); - fflush(stdout); fflush(stderr); /* flush stdout and especially stderr */ errno = 0; - switch ((pid = fork())) { + + if (sdaemon) + pid = 0; + else { + save_sigquit = signal(SIGQUIT, sig_quit); + if (sigchld) + (void)signal(SIGCHLD, sig_chld); + else + (void)signal(SIGCHLD, SIG_DFL); + pid = fork(); + } + + switch (pid) { case 0: - (void)signal(SIGINT, SIG_DFL); - (void)signal(SIGQUIT, SIG_DFL); - (void)signal(SIGSEGV, SIG_DFL); - (void)signal(SIGTERM, SIG_DFL); + if (!sdaemon) { + (void)signal(SIGINT, SIG_DFL); + (void)signal(SIGQUIT, SIG_DFL); + (void)signal(SIGSEGV, SIG_DFL); + (void)signal(SIGTERM, SIG_DFL); + } if (root) { if (chroot(root) < 0) { @@ -402,7 +430,7 @@ if (setpriority(PRIO_PROCESS, getpid(), nicelvl) < 0) error(LSB_PROOF," cannot set nicelevel: %s\n", strerror(errno)); } - if (sess) { + if (sess && !sdaemon) { errno = 0; if (setsid() < 0) error(LSB_PROOF," cannot create session: %s\n", strerror(errno)); @@ -430,14 +458,9 @@ (unsigned int)user->pw_uid, strerror(errno)); } /* - * Close all above stdin, stdout, stderr ... + * Close all above stdin, stdout, stderr ... but not fileno(tmp) */ - while (--tty > fileno(stderr)) { - if (tmp && tty == fileno(tmp)) - continue; - if (isatty(tty)) - close(tty); - } + closefds(tmp); if (dialog) { char * redirect; @@ -521,7 +544,8 @@ close(tty); } openlog (we_are, LOG_OPTIONS, LOG_FACILITY); - kill(getppid(), SIGQUIT); + if (!sdaemon) + kill(getppid(), SIGQUIT); error(LSB_PROOFE," cannot execute %s: %s\n", fullname, strerror(olderr)); break; case -1: @@ -610,3 +634,37 @@ } return 0; } + +/* + * Close all above stdin, stdout, stderr ... but not fileno(tmp) + */ +static void closefds(FILE *not) +{ + char dir[128]; + struct dirent *fdd; + int fd, ret; + DIR *fds; + + if (((ret = snprintf(dir, sizeof(dir), "/proc/%d/fd", (int)getpid())) < 0) || + (ret == sizeof(dir))) + error(100, "error in snprintf: %s\n", strerror(errno)); + if ((fds = opendir(dir)) == (DIR*)0) + error(100, "cannot open dir: %s\n", strerror(errno)); + + while ((fdd = readdir(fds))) { + if ((fd = atoi(fdd->d_name)) <= fileno(stderr)) + continue; + if (not && (fd == fileno(not))) + continue; + if (isatty(fd)) { + close(fd); + continue; + } + if ((ret = fcntl(fd, F_GETFD)) < 0) + continue; + fcntl(fd, F_SETFD, ret|FD_CLOEXEC); + } + + closedir(fds); +} + ++++++ rc.powerd ++++++ --- sysvinit/rc.powerd 2006-02-07 17:31:09.000000000 +0100 +++ /mounts/work_src_done/STABLE/sysvinit/rc.powerd 2007-11-30 13:52:17.372334000 +0100 @@ -10,6 +10,7 @@ # Should-Stop: # Default-Start: 2 3 5 # Default-Stop: 0 1 6 +# Short-Description: Start the UPS monitoring daemon # Description: Start the UPS monitoring daemon ### END INIT INFO ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org
participants (1)
-
root@Hilbert.suse.de