diff --git a/Makefile b/Makefile index 1ddd355..cd450e9 100644 --- a/Makefile +++ b/Makefile @@ -41,14 +41,14 @@ endif RM = rm -f MKDIR = mkdir -p RMDIR = rm -rf - INSTBINFLAGS = -m 0700 + INSTBINFLAGS = -m 0755 INSTBIN = install $(INSTBINFLAGS) - INSTSRPFLAGS = -m 0700 + INSTSRPFLAGS = -m 0755 INSTSRP = install $(INSTSRPFLAGS) - INSTDOCFLAGS = -c -m 0444 + INSTDOCFLAGS = -c -m 0644 INSTDOC = install $(INSTDOCFLAGS) INSTCONFLAGS = -c -m 0644 - INSTCON = install $(INSTDOCFLAGS) + INSTCON = install $(INSTCONFLAGS) LINK = ln -sf # SDOCDIR = $(DESTDIR)/usr/share/man/man8 diff --git a/insserv.8.in b/insserv.8.in index a4957ea..dba4510 100644 --- a/insserv.8.in +++ b/insserv.8.in @@ -1,8 +1,8 @@ .\" -.\" Copyright 2000-2008 Werner Fink +.\" Copyright 2000-2009 Werner Fink .\" Copyright 2000-2003 SuSE GmbH Nuernberg, Germany -.\" Copyright 2007 SuSE Linux Products GmbH Nuernberg, Germany -.\" Copyright 2008 SuSE Linux Products GmbH Nuernberg, Germany +.\" Copyright 2007-2009 SuSE Linux Products GmbH Nuernberg, Germany +.\" Copyright 2009 Petter Reinholdtsen .\" .\" 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 @@ -21,11 +21,9 @@ @@BEGIN_SUSE@@ .TH INSSERV 8 "Jul 29, 2008" "Version 1.11" "The SuSE boot concept" .UC 8 -.OS SuSE Linux @@ELSE_SUSE@@ .TH INSSERV 8 "Jul 29, 2008" "Version 1.11" .UC 8 -.OS Debian @@END_SUSE@@ .SH NAME insserv \- Enable an installed system init script @@ -43,11 +41,7 @@ insserv \- Enable an installed system init script .RB [ \-v ] .RB [ \-c\ ] .RB [ \-p\ ] -@@BEGIN_SUSE@@ -.RI [[ / ] path/to/init.d/ ] script [ ,start= [ ,\ ... ] -@@ELSE_SUSE@@ -.RI [[ / ] path/to/init.d/ ] script [ ,start= [ ,\ ... ] ,stop= [ ,\ ... ]] -@@END_SUSE@@ +.RI [[ / ] path/to/init.d/ ] script [ ,start=,stop= ] .PP .B insserv .RB [ \-v ] @@ -138,7 +132,7 @@ keyword implies that the script using this keyword should be started .B before the specified service names. -Wereas the optional +Whereas the optional .B X\-Stop\-After keyword implies that the script using this keyword should be stopped @@ -154,6 +148,7 @@ directories (see \fI init.d\fR (7)). @@ELSE_SUSE@@ directories. @@END_SUSE@@ +@@BEGIN_SUSE@@ Known runlevels are: .sp 1 .in +1l @@ -165,15 +160,12 @@ Known runlevels are: \fB4\fR\ reserved for local use \fB5\fR\ used for full multiuser with network and xdm \fB6\fR\ used for System reboot -@@BEGIN_SUSE@@ \fBS\fR\ used during boot into single user mode \fBB\fR\ used during boot before any other runlevel -@@ELSE_SUSE@@ - \fBS\fR\ used during boot before any other runlevel -@@END_SUSE@@ .fi .in -1l .sp 1 +@@END_SUSE@@ .PP .B insserv scans for @@ -244,7 +236,7 @@ case. .BR Required-Stop . @@END_SUSE@@ .P -Beside the defined +In addition to the defined .B System Facilities in the configuration file .IR /etc/insserv.conf , @@ -268,8 +260,8 @@ Specify path to the insserv.conf file and the insserv.conf.d directory. Useful for testing. .TP .BR \-o\ ,\ \-\-override\ -Path to replace existing LSB comment headers with the comment -headers found in this path (default path is +LSB comment headers found in this path will override existing +LSB comment headers of scripts in the init.d directory (default path is .IR /etc/insserv/overrides/ ). .TP .BR \-p\ ,\ \-\-path\ @@ -282,7 +274,7 @@ Do not update symlinks. Remove the listed scripts from all runlevels. .TP .BR \-d ,\ \-\-default -Use default runlevels a defined in the scripts. +Use default runlevels as defined in the scripts. This may restore an edited runlevel link scheme. .TP .BR \-f ,\ \-\-force @@ -327,22 +319,17 @@ checks for the existence of these scripts. For the runlevels the information found in the script is used. .TP -.RI [[ / ] path/to/init.d/ ] script [ ,start= [ , ]]\ ... +.RI [[ / ] path/to/init.d/ ] script [ ,start= ] List of scripts which have to be added to the specified runlevels to be started with. You may use this extension to override the default values for start and stop runlevels of the script. Note that -.BR ,\ ,\ ... +.BR lvl1 ,\ lvl2 ,\ ... are the known runlevels explained above. The extension -.IR ,stop= [ , ]] -is possible -@@BEGIN_SUSE@@ -is possible but ignored on SuSE Linux. -@@ELSE_SUSE@@ +.IR ,stop= is also possible. -@@END_SUSE@@ .TP .RI \fB\-r\fR\ [[ / ] path/to/init.d/ ] script\ ... List of scripts which should be removed from @@ -354,9 +341,9 @@ checks for the existence of these scripts. .\" .SH OVERRIDES Beside using the extensions -.IR ,start= [ , ]] +.IR ,start= and -.IR ,stop= [ , ]] +.IR ,stop= it is possible to use override files replace a LSB comment header or simple provide a missing LSB comment header. This can be done by placing a file with the new LSB comment header using the same @@ -413,7 +400,9 @@ of the following characters .sp 1 will be ignored. .SH BUGS -Boot script sometimes misses comments. +Boot scripts sometimes lack a LSB comment header. Contact a package +maintainer or developer of the software which provides the script to +have a LSB comment header added to it. .SH FILES .TP .I /etc/insserv.conf @@ -452,7 +441,6 @@ for with the help of .BR startpar (8). .in -7 - .\" .SH SEE ALSO @@BEGIN_SUSE@@ @@ -466,12 +454,16 @@ with the help of @@END_SUSE@@ .BR startpar (8). .SH COPYRIGHT -2000\-2008 Werner Fink, +2000\-2009 Werner Fink, +.br +2009 SuSE Linux Products GmbH Nuernberg, Germany. .br 2000\-2003 SuSE GmbH Nuernberg, Germany, .br -2007 SuSE Linux Products GmbH Nuernberg, Germany. -.br -2008 SuSE Linux Products GmbH Nuernberg, Germany. +2007\-2009 SuSE Linux Products GmbH Nuernberg, Germany. .SH AUTHOR Werner Fink +.SH CONTRIBUTORS +Petter Reinholdtsen +.br +Kel Modderman diff --git a/insserv.c b/insserv.c index d872d74..7444f51 100644 --- a/insserv.c +++ b/insserv.c @@ -1,11 +1,11 @@ /* * insserv(.c) * - * Copyright 2000-2008 Werner Fink, 2000 SuSE GmbH Nuernberg, Germany, + * Copyright 2000-2009 Werner Fink, 2000 SuSE GmbH Nuernberg, Germany, * 2003 SuSE Linux AG, Germany. * 2004 SuSE LINUX AG, Germany. - * 2005-2008 SUSE LINUX Products GmbH, Germany. - * Copyright 2005,2008 Petter Reinholdtsen + * 2005-2009 SUSE LINUX Products GmbH, Germany. + * Copyright 2005,2008,2009 Petter Reinholdtsen * * 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 @@ -53,6 +53,20 @@ #endif /* SUSE */ #include "listing.h" +#if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 600 +# ifndef POSIX_FADV_SEQUENTIAL +# define posix_fadvise(fd, off, len, adv) (-1) +# endif +#endif + +#ifndef PATH_MAX +# ifdef MAXPATHLEN +# define PATH_MAX MAXPATHLEN +# else +# define PATH_MAX 2048 +# endif +#endif + #ifdef SUSE # define DEFAULT_START_LVL "3 5" # define DEFAULT_STOP_LVL "3 5" @@ -125,8 +139,8 @@ static char *root; /* The main line buffer if unique */ static char buf[LINE_MAX]; -/* When to be verbose */ -static boolean verbose = false; +/* When to be verbose, and what level of verbosity */ +static int verbose = 0; /* When to be verbose */ static boolean dryrun = false; @@ -726,9 +740,9 @@ static inline void makedep(void) if (dryrun) { #ifdef USE_KILL_IN_BOOT - info("dryrun, not creating .depend.boot, .depend.start, .depend.halt, and .depend.stop\n"); + info(1, "dryrun, not creating .depend.boot, .depend.start, .depend.halt, and .depend.stop\n"); #else /* not USE_KILL_IN_BOOT */ - info("dryrun, not creating .depend.boot, .depend.start, and .depend.stop\n"); + info(1, "dryrun, not creating .depend.boot, .depend.start, and .depend.stop\n"); #endif /* not USE_KILL_IN_BOOT */ return; } @@ -743,8 +757,8 @@ static inline void makedep(void) return; } - info("creating .depend.boot\n"); - info("creating .depend.start\n"); + info(1, "creating .depend.boot\n"); + info(1, "creating .depend.start\n"); lsort('S'); /* Sort into start order, set new sorder */ @@ -875,9 +889,9 @@ static inline void makedep(void) return; } - info("creating .depend.halt\n"); + info(1, "creating .depend.halt\n"); #endif /* USE_KILL_IN_BOOT */ - info("creating .depend.stop\n"); + info(1, "creating .depend.stop\n"); lsort('K'); /* Sort into stop order, set new korder */ @@ -1015,9 +1029,9 @@ void warn (const char *restrict const fmt, ...) /* * Print message when verbose is enabled */ -void info(const char *fmt, ...) { +void info(int level, const char *fmt, ...) { va_list ap; - if (!verbose) + if (level > verbose) goto out; va_start(ap, fmt); _logger(fmt, ap); @@ -1063,7 +1077,7 @@ static DIR * openrcdir(const char *restrict const rcpath) if (stat(rcpath, &st) < 0) { if (errno == ENOENT) { - info("creating directory '%s'\n", rcpath); + info(1, "creating directory '%s'\n", rcpath); if (!dryrun) mkdir(rcpath, (S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)); } else @@ -1188,7 +1202,7 @@ static uchar scan_lsb_headers(const int dfd, const char *restrict const path, #define description script_inf.description #define interactive script_inf.interactive - info("Loading %s\n", path); + info(2, "Loading %s\n", path); if ((fd = xopen(dfd, path, o_flags)) < 0 || (script = fdopen(fd, "r")) == (FILE*)0) error("fopen(%s): %s\n", path, strerror(errno)); @@ -1829,7 +1843,7 @@ static void scan_conf_file(const char *restrict file) regmatch_t subloc[SUBCONFNUM], *val = (regmatch_t*)0; FILE *conf; - info("Loading %s\n", file); + info(2, "Loading %s\n", file); do { const char * fptr = file; @@ -2314,10 +2328,10 @@ int main (int argc, char *argv[]) ignore = true; break; case 'v': - verbose = true; + verbose ++; break; case 'n': - verbose = true; + verbose ++; dryrun = true; break; case 'p': @@ -3200,7 +3214,7 @@ int main (int argc, char *argv[]) */ follow_all(); if (is_loop_detected() && !ignore) - error("exiting without changing boot order!\n"); + error("exiting now without changing boot order!\n"); /* * Be sure that interactive scripts are the only member of diff --git a/listing.c b/listing.c index 53595c9..e7357e6 100644 --- a/listing.c +++ b/listing.c @@ -1,9 +1,9 @@ /* * listing.c * - * Copyright 2000-2008 Werner Fink, 2000 SuSE GmbH Nuernberg, Germany, + * Copyright 2000-2009 Werner Fink, 2000 SuSE GmbH Nuernberg, Germany, * 2003 SuSE Linux AG, Germany. - * 2007-2008 SuSE Linux Products GmbH Nuernberg, Germany + * 2007-2009 SuSE Linux Products GmbH Nuernberg, Germany * * This source is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/listing.h b/listing.h index 2faf835..e48d6fa 100644 --- a/listing.h +++ b/listing.h @@ -1,8 +1,8 @@ /* * listing.h * - * Copyright 2000,2008 Werner Fink, 2000 SuSE GmbH Nuernberg, Germany. - * 2008 SuSE Linux Products GmbH Nuernberg, Germany + * Copyright 2000,2009 Werner Fink, 2000 SuSE GmbH Nuernberg, Germany. + * 2008,2009 SuSE Linux Products GmbH Nuernberg, Germany * * This source is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -293,7 +293,7 @@ extern void lsort(const char type); extern const char *const delimeter; extern void error(const char *restrict fmt, ...) attribute((noreturn,format(printf,1,2))); extern void warn (const char *restrict fmt, ...) attribute((format(printf,1,2))); -extern void info (const char *restrict fmt, ...) attribute((format(printf,1,2))); +extern void info (int level, const char *restrict fmt, ...) attribute((format(printf,2,3))); extern inline int map_has_runlevels(void) attribute((always_inline)); extern inline char map_runlevel_to_key(const int runlevel); extern inline ushort map_key_to_lvl(const char key); @@ -317,42 +317,42 @@ static inline char * xstrdup(const char *restrict s) #define xreset(ptr) \ {char *restrict tmp = (char *restrict)ptr; if (ptr && *tmp) free(ptr);} ptr = NULL -#if defined(HAS_unlinkat) && defined(_ATFILE_SOURCE) +#if defined(HAS_unlinkat) && defined(_ATFILE_SOURCE) && !defined(__stub_unlinkat) # define xremove(d,x) (__extension__ ({ if ((dryrun ? 0 : \ (unlinkat(d,x,0) != 0 && (errno != EISDIR || unlinkat(d,x,AT_REMOVEDIR) != 0)))) \ warn ("can not remove(%s%s): %s\n", rcd, x, strerror(errno)); \ else \ - info("remove service %s/%s%s\n", path, rcd, x); })) + info(1, "remove service %s/%s%s\n", path, rcd, x); })) #else # define xremove(d,x) (__extension__ ({ if ((dryrun ? 0 : (remove(x) != 0))) \ warn ("can not remove(%s%s): %s\n", rcd, x, strerror(errno)); \ else \ - info("remove service %s/%s%s\n", path, rcd, x); })) + info(1, "remove service %s/%s%s\n", path, rcd, x); })) #endif -#if defined(HAS_symlinkat) && defined(_ATFILE_SOURCE) +#if defined(HAS_symlinkat) && defined(_ATFILE_SOURCE) && !defined(__stub_symlinkat) # define xsymlink(d,x,y) (__extension__ ({ if ((dryrun ? 0 : (symlinkat(x, d, y) != 0))) \ warn ("can not symlink(%s, %s%s): %s\n", x, rcd, y, strerror(errno)); \ else \ - info("enable service %s -> %s/%s%s\n", x, path, rcd, y); })) + info(1, "enable service %s -> %s/%s%s\n", x, path, rcd, y); })) #else # define xsymlink(d,x,y) (__extension__ ({ if ((dryrun ? 0 : (symlink(x, y) != 0))) \ warn ("can not symlink(%s, %s%s): %s\n", x, rcd, y, strerror(errno)); \ else \ - info("enable service %s -> %s/%s%s\n", x, path, rcd, y); })) + info(1, "enable service %s -> %s/%s%s\n", x, path, rcd, y); })) #endif -#if defined(HAS_fstatat) && defined(_ATFILE_SOURCE) +#if defined(HAS_fstatat) && defined(_ATFILE_SOURCE) && !defined(__stub_fstatat) # define xstat(d,x,s) (__extension__ ({ fstatat(d,x,s, 0); })) # define xlstat(d,x,s) (__extension__ ({ fstatat(d,x,s, AT_SYMLINK_NOFOLLOW); })) #else # define xstat(d,x,s) (__extension__ ({ stat(x,s); })) # define xlstat(d,x,s) (__extension__ ({ lstat(x,s); })) #endif -#if defined(HAS_readlinkat) && defined(_ATFILE_SOURCE) +#if defined(HAS_readlinkat) && defined(_ATFILE_SOURCE) && !defined(__stub_readlinkat) # define xreadlink(d,x,b,l) (__extension__ ({ readlinkat(d,x,b,l); })) #else # define xreadlink(d,x,b,l) (__extension__ ({ readlink(x,b,l); })) #endif -#if defined(HAS_openat) && defined(_ATFILE_SOURCE) +#if defined(HAS_openat) && defined(_ATFILE_SOURCE) && !defined(__stub_openat) # define xopen(d,x,f) (__extension__ ({ openat(d,x,f); })) #else # define xopen(d,x,f) (__extension__ ({ open(x,f); }))