Dr. Werner Fink 2012-01-31 16:45:43 +00:00 committed by Git OBS Bridge
parent a0414ccb1d
commit b054fba91d
15 changed files with 44 additions and 816 deletions

View File

@ -1,409 +0,0 @@
--- checkproc.8
+++ checkproc.8 2011-10-18 09:29:16.195166916 +0000
@@ -17,6 +17,7 @@ Pidofproc \- Checks for a process by exe
.HP
.B checkproc
.RB [ \-vLkNz ]
+.RB [ \-x ]
.RB [ \-p\ \fIpid_file\fP ]
.RB [ \-i\ \fIingnore_file\fP ]
.RB [ \-c\ \fIroot\fP ]
@@ -30,10 +31,12 @@ Pidofproc \- Checks for a process by exe
.B checkproc
.B \ \
.RB [ \-vk ]
+.RB [ \-x ]
.I basename_of_executable
.HP
.B pidofproc
.RB [ \-LkNz ]
+.RB [ \-x ]
.RB [ \-p\ \fIpid_file\fP ]
.RB [ \-i\ \fIingnore_file\fP ]
.RB [ \-c\ \fIroot\fP ]
@@ -47,6 +50,7 @@ Pidofproc \- Checks for a process by exe
.B pidofproc
.B \ \
.RB [ \-k ]
+.RB [ \-x ]
.I basename_of_executable
.SH SYNOPSIS LSB 3.1
.HP
@@ -250,6 +254,15 @@ are in the zombie state. Without this o
handled as not existent because such a process isn't
alive but listed in the process table and waits on its
parent process.
+.TP
+.B \-x
+Tells
+.B checkproc
+as well as
+.B pidofproc
+to use the upto 15 byte long filename name found in
+.I /proc/<pid>/stat
+to be able to identify scripts overwriting their command line.
.PP
.\"
.SH EXAMPLE
--- checkproc.c
+++ checkproc.c 2011-10-17 15:41:46.671646382 +0000
@@ -60,7 +60,7 @@ int main(int argc, char **argv)
posixa = getenv("_POSIX_OPTION_ORDER"); unsetenv("_POSIX_OPTION_ORDER");
posixb = getenv("POSIXLY_CORRECT"); unsetenv("POSIXLY_CORRECT");
opterr = 0;
- while ((c = getopt(argc, argv, "c:kp:nNhqvzLi:")) != -1) {
+ while ((c = getopt(argc, argv, "c:kp:nNhqvzLi:x")) != -1) {
switch (c) {
case 'c':
if (optarg && optarg[0] != '-' && !root) {
@@ -86,6 +86,9 @@ int main(int argc, char **argv)
case 'N':
init_nfs();
break;
+ case 'x':
+ flags |= STSCRPT;
+ break;
case 'z':
flags &= ~NZOMBIE;
break;
--- killproc.8
+++ killproc.8 2011-10-18 09:27:22.403146549 +0000
@@ -16,6 +16,7 @@ Killproc \- Send signals to processes by
.B killproc
.RB [ \-vqLN ]
.RB [ \-g | -G ]
+.RB [ \-x ]
.RB [ \-p\ \fIpid_file\fP ]
.RB [ \-i\ \fIingnore_file\fP ]
.RB [ \-c\ \fIroot\fP ]
@@ -269,6 +270,13 @@ Be more verbose.
This option list all available signals and some of their
synonyms by their number and signal names to standard out.
and exits.
+.TP
+.B \-x
+Tells
+.B killproc
+to use the upto 15 byte long filename name found in
+.I /proc/<pid>/stat
+to be able to identify scripts overwriting their command line.
.\"
.SH EXAMPLES
.TP
--- killproc.c
+++ killproc.c 2011-10-17 15:42:52.871147146 +0000
@@ -96,7 +96,7 @@ int main(int argc, char **argv)
posixa = getenv("_POSIX_OPTION_ORDER"); unsetenv("_POSIX_OPTION_ORDER");
posixb = getenv("POSIXLY_CORRECT"); unsetenv("POSIXLY_CORRECT");
opterr = 0;
- while ((c = getopt(argc, argv, "c:p:gGnNhlvqt:Li:")) != -1) {
+ while ((c = getopt(argc, argv, "c:p:gGnNhlvqt:Li:x")) != -1) {
switch (c) {
case 'c':
if (optarg && optarg[0] != '-' && !root) {
@@ -135,6 +135,9 @@ int main(int argc, char **argv)
case 'N':
init_nfs();
break;
+ case 'x':
+ flags |= STSCRPT;
+ break;
case 'p': /* Changed from -f to -p to fit startproc and LSB */
/* Allocate here: address optarg (current *argv) isn't freeable */
if (optarg && !pid_file) {
--- libinit.c
+++ libinit.c 2011-10-24 10:27:48.559146999 +0000
@@ -430,7 +430,19 @@ void logprogress(int prio, const char *f
va_end(args);
}
-/* For mounting the /proc file system */
+/*
+ * For mounting the /proc file system if missed
+ * and run umount() at exit() for this case.
+ */
+static void undo_proc(void)
+{
+#ifdef MNT_DETACH
+ umount2("/proc", MNT_DETACH);
+#else
+ umount("/proc");
+#endif
+}
+
void getproc(void)
{
struct stat st;
@@ -441,6 +453,8 @@ void getproc(void)
errno = 0;
if (stat("/proc/version", &st) < 0)
error(100, "/proc not mounted, failed to mount: %s\n", strerror(errno));
+
+ atexit(undo_proc);
}
/* Open the /proc directory, if necessary mounts it */
@@ -570,13 +584,12 @@ static const char * checkscripts(char* e
*/
scrpt = (char *)memchr(scrpt, 0, cnt);
if (!scrpt || (cnt = len - (++scrpt - ent)) <= 0)
- goto out;
+ break;
if (*scrpt == '/') {
ret = scrpt;
goto out;
}
} while (scrpt && cnt > 0);
-
out:
if (scrpt && root) {
char *ptr = strdupa(scrpt);
@@ -877,8 +890,11 @@ int pidof (const char * inname, const ch
continue;
/* Seek for a script not for a binary */
- if (!(scrpt = checkscripts(entry, root, len, d->d_name)))
+ if (!(scrpt = checkscripts(entry, root, len, d->d_name))) {
+ if (flags & STSCRPT)
+ goto risky;
continue;
+ }
/* Don't blame our boot scripts having the same name */
if ( (flags & (KILL|DAEMON))
@@ -1128,7 +1144,7 @@ risky:
return -1;
}
- if (!(flags & (KTHREAD|KSHORT))&& isscrpt &&
+ if (!(flags & (KTHREAD|KSHORT)) && isscrpt &&
(fp = open(proc(buf, "cmdline"), O_PROCMODE)) != -1) {
char entry[PATH_MAX+1];
@@ -1142,15 +1158,18 @@ risky:
goto out;
/* Seek for a script not for a binary */
- if (!(scrpt = checkscripts(entry, root, len, buf)))
+ if (!(scrpt = checkscripts(entry, root, len, buf))) {
+ if (flags & STSCRPT)
+ goto nameonly;
goto out; /* Nothing found */
+ }
if (scrpt && strcmp(scrpt,fullname) == 0) {
do_list(pid,getsession(pid),ignore);
goto out; /* Done */
}
}
-
+nameonly:
if ((fp = open(proc(buf, "stat"), O_PROCMODE)) != -1) {
char entry[PATH_MAX+1];
@@ -1313,7 +1332,7 @@ int check_pids (const char * inname, con
skip = true; /* No stat entry check needed */
}
-risky:
+ risky:
if (!(flags & (KTHREAD|KSHORT)) && isscrpt &&
(fp = open(proc(pid, "cmdline"), O_PROCMODE)) != -1) {
@@ -1332,7 +1351,8 @@ risky:
if ((scrpt = checkscripts(entry, root, len, pid))) {
if (strcmp(scrpt,fullname) == 0)
continue; /* Found */
- skip = true; /* No stat entry check needed */
+ if (!(flags & STSCRPT))
+ skip = true; /* No stat entry check needed */
}
}
--- libinit.h
+++ libinit.h 2011-10-18 09:13:36.923145552 +0000
@@ -106,6 +106,7 @@
#define FLWLINK 0x0040
#define KSTOP 0x0080
#define KBASE 0x0100
+#define STSCRPT 0x0200
#define MAXENV 20
#define CMDLLEN MAXNAMLEN /* The string length of /proc/12345/cmdline\0\0 + 1 */
@@ -116,6 +117,7 @@
#endif
#define DEFPIDEXT ".pid"
#define DEFPIDLEN 14 /* The string length of /var/run/.pid + 1 */
+#define COMM_LEN 15 /* The lenght of the task command name in /proc/<pid>/stat */
extern char **environ;
extern char * newenvp[];
@@ -216,10 +218,12 @@ static inline char * base_name ( const c
static inline char * swap_name ( const char * base )
{
- size_t len = strlen(base) + 2 + 1;
- char *swap = (char*)xmalloc(len);
-
- return strcat(strcat(strcpy(swap,"("),base),")");
+ size_t len = strlen(base);
+ char *swap;
+ if (len > COMM_LEN)
+ len = COMM_LEN;
+ swap = (char*)xmalloc(len + 2 + 1);
+ return strcat(strncat(strcpy(swap,"("),base, COMM_LEN),")");
}
extern void addnewenv ( const char * name, const char * entry );
--- startproc.8
+++ startproc.8 2011-10-18 09:28:45.875646247 +0000
@@ -18,6 +18,7 @@ Start_daemon \- Start processes identifi
.HP
.B startproc
.RB [ \-fLves ]
+.RB [ \-x ]
.RB [[ \-n\ ] \fI+/\-<prio>\fP ]
.RB [ \- ( t | T )\ \fI<sec>\fP ]
.RB [ \-u\ \fIuser\fP ]
@@ -32,6 +33,7 @@ Start_daemon \- Start processes identifi
.HP
.B start_daemon
.RB [ \-fLve ]
+.RB [ \-x ]
.RB [ \-n\ \fI+/\-<prio>\fP ]
.RB [ \-u\ \fIuser\fP ]
.RB [ \-g\ \fIgroup\fP ]
@@ -249,6 +251,15 @@ Sets the user ID of the process to
.TP
.B \-v
Verbose output.
+.TP
+.B \-x
+Tells
+.B startproc
+as well as
+.B start_daemon
+to use the upto 15 byte long filename name found in
+.I /proc/<pid>/stat
+to be able to identify scripts overwriting their command line.
.\"
.SH EXAMPLE
.TP
--- startproc.c
+++ startproc.c 2011-10-20 12:19:33.523206609 +0000
@@ -109,7 +109,7 @@ int main(int argc, char **argv)
}
opterr = 0;
- while ((c = getopt(argc, argv, "+c:edp:l:hqvsu:g:t:n:fLi:T:wW:")) != -1) { /* `+' is POSIX correct */
+ while ((c = getopt(argc, argv, "+c:edp:l:hqvsu:g:t:n:fLi:T:wW:x")) != -1) { /* `+' is POSIX correct */
switch (c) {
case 'v':
quiet = 0;
@@ -127,6 +127,9 @@ int main(int argc, char **argv)
dialog = true;
seconds = 15;
break;
+ case 'x':
+ flags |= STSCRPT;
+ break;
case 'p': /* Former option -f */
if (force)
warn("option -p does not work in force mode\n");
@@ -412,6 +415,8 @@ static int do_start(const char *inname,
const char * fullname;
char proc_exe[6+9+4+1];
static struct stat itsme;
+ sigset_t newset, oldset;
+ int pipe[2];
if ((n = snprintf(proc_exe, sizeof(proc_exe) - 1, "/proc/%d/exe", getpid())) > 0) {
proc_exe[n] = '\0';
@@ -445,11 +450,17 @@ static int do_start(const char *inname,
if (sdaemon)
pid = 0;
else {
+ sigemptyset(&newset);
+ sigaddset(&newset, SIGQUIT);
+ sigaddset(&newset, SIGCHLD);
+ sigprocmask(SIG_UNBLOCK, &newset, &oldset);
save_sigquit = signal(SIGQUIT, sig_quit);
if (sigchld)
(void)signal(SIGCHLD, sig_chld);
else
(void)signal(SIGCHLD, SIG_DFL);
+ if (pipe2(pipe, O_CLOEXEC) < 0)
+ error(100, "cannot open a pipe: %m\n");
if ((pid = fork()) == 0) {
/* Update again to point to the child pid */
fwd_sd_listen_pid();
@@ -459,10 +470,15 @@ static int do_start(const char *inname,
switch (pid) {
case 0:
if (!sdaemon) {
+ sigprocmask(SIG_SETMASK, &oldset, NULL);
(void)signal(SIGINT, SIG_DFL);
(void)signal(SIGQUIT, SIG_DFL);
(void)signal(SIGSEGV, SIG_DFL);
(void)signal(SIGTERM, SIG_DFL);
+
+ close(pipe[1]);
+ read(pipe[0], proc_exe, 1); /* Wait on parent with the pipe here */
+ close(pipe[0]);
}
if (root) {
@@ -615,8 +631,8 @@ static int do_start(const char *inname,
fclose(tmp);
fflush(stdout);
fflush(stderr); /* flush stdout and especially stderr */
- usleep(1); /* Force the kernel to run the scheduler and update
- the environment of the current processes */
+
+ close(pipe[0]);
if ((n = snprintf(proc_exe, sizeof(proc_exe) - 1, "/proc/%d/exe", pid)) > 0) {
proc_exe[n] = '\0';
@@ -628,17 +644,21 @@ static int do_start(const char *inname,
* pid but before the execve() is done by the kernel, in later
* case be sure not to run on our own binary.
*/
+ n = 0;
do {
struct stat serv;
errno = 0;
if (stat(proc_exe, &serv) < 0) {
if (errno == ENOENT)
- break; /* Seems to be a fast system */
-
+ break; /* Seems to be a very fast system
+ * should not happen due to the pipe */
error(100, "cannot stat %s: %s\n", proc_exe, strerror(errno));
}
+ if (n++ == 0)
+ close(pipe[1]); /* Sync child over the pipe */
+
if (itsme.st_dev != serv.st_dev || itsme.st_ino != serv.st_ino)
break; /* Seems to be a slow system */
@@ -647,6 +667,9 @@ static int do_start(const char *inname,
} while (true);
} else {
+
+ close(pipe[1]); /* Sync child over the pipe */
+
warn("error in snprintf: %s\n", strerror(errno));
usleep(100*1000);
}
@@ -657,7 +680,7 @@ retry:
case -1: /* WNOHANG and hopefully no child but daemon */
if (errno == EINTR)
goto retry;
- if (errno != ECHILD) /* ECHILD shouldn´t happen, should it? (it does) */
+ if (errno != ECHILD) /* ECHILD should not happen, should it? (it does) */
error(LSB_PROOFE," waitpid on %s: %s\n", fullname, strerror(errno));
break;
case 0: /* WNOHANG and no status available */

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6c090a32b4d4c06140b06c9633492cff2a1b0de2f87d48d9c29f0ba72e0f02cc
size 42751

4
killproc-2.21.dif Normal file
View File

@ -0,0 +1,4 @@
--- .#empty
+++ .#empty 2012-01-30 17:44:30.343145442 +0000
@@ -0,0 +1 @@
+Place holder

3
killproc-2.21.tar.bz2 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:359ffe52eaf1f510d6581cba5d799a3926d8e1f202ddf0d76c20a1c6603e2659
size 44469

View File

@ -1,82 +0,0 @@
--- libconsole.c
+++ libconsole.c 2011-12-19 18:11:00.323146490 +0000
@@ -1154,14 +1154,45 @@ static dev_t fallback(const pid_t pid, c
static int checkdev(char ** retname, const dev_t dev, DIR * ddev)
{
- int found = 0;
- struct dirent * d;
- struct stat st;
+ int found = 0, fd;
+ struct dirent *d;
static int deep;
- memset(&st, 0, sizeof(struct stat));
- while ((d = readdir(ddev))) {
- char * name = d->d_name;
+ if (deep == 0) {
+
+ fd = dirfd(ddev);
+ rewinddir(ddev);
+
+ while ((d = readdir(ddev))) { /* First scan all devices direct in /dev/ of devtmpfs */
+ struct stat st;
+ char *name = d->d_name;
+ char path[PATH_MAX+1];
+
+ if (*name == '.')
+ continue;
+ if (fstatat(fd, name, &st, 0) < 0)
+ continue;
+ if (!S_ISCHR(st.st_mode))
+ continue;
+ if (dev != st.st_rdev)
+ continue;
+ if ((size_t)snprintf(path, sizeof(path), "/dev/%s", name) >= sizeof(path))
+ continue;
+ name = realpath(path, NULL);
+ if (!name)
+ break;
+ *retname = name;
+ found++;
+ break;
+ }
+ if (found)
+ goto out;
+ }
+
+ rewinddir(ddev);
+ while ((d = readdir(ddev))) { /* now allow also deeper entries of none devtmpfs */
+ struct stat st;
+ char *name = d->d_name;
if (*name == '.')
continue;
@@ -1306,7 +1337,7 @@ static int checkdev(char ** retname, con
*retname = name;
break;
}
-
+out:
return found;
}
@@ -1448,7 +1479,7 @@ char * fetchtty(const pid_t pid, const p
if (!(name = ttyname(0)) || !strcmp(name, "/dev/console"))
dev = fallback(pid, ppid);
else {
- name = strdup(name);
+ name = realpath(name, NULL);
if (!name)
error("fetchtty(): %m\n");
goto out;
--- showconsole.8
+++ showconsole.8 2011-09-08 15:13:48.000000000 +0000
@@ -8,7 +8,6 @@
.\"
.TH SHOWCONSOLE 8 "Nov 10, 2000" "Version 1.16" "The SuSE boot concept"
.UC 8
-.OS SuSE Linux
.SH NAME
Showconsole \- determines the real tty of stdin
.br

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:24074b56e133f3136b9654a6e5950d8582b9e6cf7c4e8af5bf4cc09728db6028
size 25634

4
showconsole-1.16.dif Normal file
View File

@ -0,0 +1,4 @@
--- .#empty
+++ .#empty 2012-01-30 17:44:30.343145442 +0000
@@ -0,0 +1 @@
+Place holder

3
showconsole-1.16.tar.bz2 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:578c8f49c393790150d9028755f44634a78bac4b0147879e0f2b065afcac5c46
size 25738

View File

@ -1,311 +0,0 @@
--- makeboot.c
+++ makeboot.c 2011-04-19 13:45:33.532428242 +0000
@@ -320,6 +320,7 @@ static void filter_files(const char *dir
t = lookup_target(dirlist[i]->d_name + 3);
if (t) {
t->status = 1;
+ t->filter_prefix = filter_prefix;
if (asprintf(&t->arg0, "%s/%s", path, dirlist[i]->d_name) < 0)
t->arg0 = (char*)0;
}
@@ -407,6 +408,7 @@ void check_run_files(const char *action,
*/
#ifndef USE_BLOGD
# define bootlog(arg...)
+# define closeblog()
#endif
/*
@@ -437,7 +439,7 @@ struct makenode *pickup_task(void)
close(fd);
}
#endif
- bootlog(B_NOTICE, "service %s %s", best->name, (filter_prefix == 'K') ? "stop" : "start");
+ bootlog(B_NOTICE, "service %s %s", best->name, (best->filter_prefix == 'K') ? "stop" : "start");
best->status = T_RUNNING;
}
return best;
--- makeboot.h
+++ makeboot.h 2011-04-19 13:45:22.304426128 +0000
@@ -35,6 +35,7 @@ struct makenode {
struct makenode *next;
int interactive;
int importance;
+ int filter_prefix;
};
/* dependency and selection list nodes */
--- proc.c
+++ proc.c 2011-03-11 16:00:04.000000000 +0000
@@ -94,3 +94,74 @@ int read_proc(unsigned long int * const
return 0;
}
+struct console {
+ char * tty;
+ int tlock;
+ struct termios ltio, otio;
+ struct console *restrict next;
+};
+static struct console *restrict consoles;
+static dev_t comparedev;
+static char* scandev(DIR *dir)
+{
+ char *name = (char*)0;
+ struct dirent *dent;
+ int fd;
+
+ fd = dirfd(dir);
+ rewinddir(dir);
+ while ((dent = readdir(dir))) {
+ char path[PATH_MAX];
+ struct stat st;
+ if (fstatat(fd, dent->d_name, &st, 0) < 0)
+ continue;
+ if (!S_ISCHR(st.st_mode))
+ continue;
+ if (comparedev != st.st_rdev)
+ continue;
+ if ((size_t)snprintf(path, sizeof(path), "/dev/%s", dent->d_name) >= sizeof(path))
+ continue;
+ name = realpath(path, NULL);
+ break;
+ }
+ return name;
+}
+
+void detect_consoles(void)
+{
+ FILE *fc;
+ if ((fc = fopen("/proc/consoles", "r"))) {
+ char fbuf[16];
+ int maj, min;
+ DIR *dir;
+ dir = opendir("/dev");
+ if (!dir)
+ goto out;
+ while ((fscanf(fc, "%*s %*s (%[^)]) %d:%d", &fbuf[0], &maj, &min) == 3)) {
+ struct console *restrict tail;
+ char * name;
+
+ if (!strchr(fbuf, 'E'))
+ continue;
+ comparedev = makedev(maj, min);
+ name = scandev(dir);
+
+ if (!name)
+ continue;
+
+ if (posix_memalign((void*)&tail, sizeof(void*), alignof(typeof(struct console))) != 0)
+ perror("memory allocation");
+
+ tail->next = (struct console*)0;
+ tail->tty = name;
+
+ if (!consoles)
+ consoles = tail;
+ else
+ consoles->next = tail;
+ }
+ closedir(dir);
+ out:
+ fclose(fc);
+ }
+}
--- proc.h
+++ proc.h 2010-09-30 12:41:35.000000000 +0000
@@ -19,5 +19,3 @@
extern int read_proc(unsigned long int *prcs_run, unsigned long int *prcs_blked);
extern void detect_consoles(void);
-extern void unraw_consoles(void);
-extern void raw_consoles(void);
--- startpar.c
+++ startpar.c 2011-04-20 11:13:07.375925983 +0000
@@ -52,6 +52,12 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
+#ifdef USE_BLOGD
+# include <libblogger.h>
+#else
+# define bootlog(arg...)
+# define closeblog()
+#endif
#include "makeboot.h"
#include "proc.h"
@@ -197,6 +203,7 @@ void closeall(void)
for (s = 0; s < par; s++)
if (prgs[s].fd)
close(prgs[s].fd);
+ closeblog();
}
void callsplash(int n, const char *path, char *action)
@@ -241,14 +248,7 @@ void callsplash(int n, const char *path,
return;
}
- (void)sigemptyset(&nmask);
- (void)sigaddset(&nmask, SIGINT);
- (void)sigaddset(&nmask, SIGHUP);
- (void)sigaddset(&nmask, SIGQUIT);
- (void)sigaddset(&nmask, SIGSEGV);
- (void)sigaddset(&nmask, SIGTERM);
- (void)sigaddset(&nmask, SIGCHLD);
- (void)sigaddset(&nmask, SIGTTIN);
+ (void)sigfillset(&nmask);
sigprocmask(SIG_UNBLOCK, &nmask, NULL);
(void)signal(SIGINT, SIG_DFL);
@@ -258,6 +258,7 @@ void callsplash(int n, const char *path,
(void)signal(SIGTERM, SIG_DFL);
(void)signal(SIGCHLD, SIG_DFL);
(void)signal(SIGTTIN, SIG_DFL);
+ (void)signal(SIGTTOU, SIG_DFL);
TEMP_FAILURE_RETRY(dup2(2, 1));
closeall();
@@ -456,14 +457,7 @@ void run(struct prg *p)
return;
}
- (void)sigemptyset(&nmask);
- (void)sigaddset(&nmask, SIGINT);
- (void)sigaddset(&nmask, SIGHUP);
- (void)sigaddset(&nmask, SIGQUIT);
- (void)sigaddset(&nmask, SIGSEGV);
- (void)sigaddset(&nmask, SIGTERM);
- (void)sigaddset(&nmask, SIGCHLD);
- (void)sigaddset(&nmask, SIGTTIN);
+ (void)sigfillset(&nmask);
sigprocmask(SIG_UNBLOCK, &nmask, NULL);
(void)signal(SIGINT, SIG_DFL);
@@ -473,12 +467,14 @@ void run(struct prg *p)
(void)signal(SIGTERM, SIG_DFL);
(void)signal(SIGCHLD, SIG_DFL);
(void)signal(SIGTTIN, SIG_DFL);
+ (void)signal(SIGTTOU, SIG_DFL);
if (setpgid(0, 0))
perror("setpgid");
if (m && p->fd)
{
+ sigset_t smask, omask;
TEMP_FAILURE_RETRY(close(1));
if (open(m, O_RDWR) != 1)
{
@@ -486,8 +482,12 @@ void run(struct prg *p)
_exit(1);
}
TEMP_FAILURE_RETRY(dup2(1, 2));
- if (tcsetattr(1, TCSANOW, &tio))
+ sigemptyset(&smask);
+ sigaddset(&smask, SIGTTOU);
+ sigprocmask(SIG_BLOCK, &smask, &omask);
+ if (tcsetattr(1, TCSANOW, &tio) && errno != ENOTTY)
perror("tcsetattr");
+ sigprocmask(SIG_SETMASK, &omask, NULL);
if (wzok)
ioctl(1, TIOCSWINSZ, &wz);
putenv(sz.env_row);
@@ -582,14 +582,7 @@ int run_single(const char *prg, const ch
{
sigset_t nmask;
- (void)sigemptyset(&nmask);
- (void)sigaddset(&nmask, SIGINT);
- (void)sigaddset(&nmask, SIGHUP);
- (void)sigaddset(&nmask, SIGQUIT);
- (void)sigaddset(&nmask, SIGSEGV);
- (void)sigaddset(&nmask, SIGTERM);
- (void)sigaddset(&nmask, SIGCHLD);
- (void)sigaddset(&nmask, SIGTTIN);
+ (void)sigfillset(&nmask);
sigprocmask(SIG_UNBLOCK, &nmask, NULL);
(void)signal(SIGINT, SIG_DFL);
@@ -599,6 +592,7 @@ int run_single(const char *prg, const ch
(void)signal(SIGTERM, SIG_DFL);
(void)signal(SIGCHLD, SIG_DFL);
(void)signal(SIGTTIN, SIG_DFL);
+ (void)signal(SIGTTOU, SIG_DFL);
TEMP_FAILURE_RETRY(dup2(2, 1));
closeall();
@@ -632,19 +626,20 @@ void do_forward(void)
{
if (errno == EINTR)
continue;
+#if defined(DEBUG) && (DEBUG > 0)
perror("\n\rstartpar: forward read");
+#endif
break;
}
b = buf;
while (r > 0)
{
rr = write(1, b, r);
- if (rr == -1)
+ if (rr < 0)
{
if (errno == EINTR)
continue;
perror("\n\rstartpar: forward write");
- break;
rr = r;
}
r -= rr;
@@ -730,9 +725,23 @@ void detach(struct prg *p, const int sto
{
if ((pid = fork()) == 0)
{
+ sigset_t nmask;
+ (void)sigfillset(&nmask);
+ sigprocmask(SIG_UNBLOCK, &nmask, NULL);
+
+ (void)signal(SIGINT, SIG_DFL);
+ (void)signal(SIGHUP, SIG_DFL);
+ (void)signal(SIGQUIT, SIG_DFL);
+ (void)signal(SIGSEGV, SIG_DFL);
+ (void)signal(SIGTERM, SIG_DFL);
+ (void)signal(SIGCHLD, SIG_DFL);
+ (void)signal(SIGTTIN, SIG_DFL);
+ (void)signal(SIGTTOU, SIG_DFL);
+
TEMP_FAILURE_RETRY(dup2(p->fd, 0));
TEMP_FAILURE_RETRY(dup2(2, 1));
closeall();
+
execlp(myname, myname, "-f", "--", p->name, NULL);
do_forward();
}
@@ -833,6 +842,8 @@ int main(int argc, char **argv)
char *splashopt = 0;
sigset_t nmask, omask, smask;
+ detect_consoles();
+
(void)sigemptyset(&nmask);
(void)sigaddset(&nmask, SIGHUP);
sigprocmask(SIG_UNBLOCK, &nmask, NULL);
@@ -1015,10 +1026,15 @@ int main(int argc, char **argv)
if (tcgetattr(0, &tio))
{
- perror("tcgetattr");
+ if (errno != ENOTTY)
+ perror("tcgetattr");
tcgetattr(2, &tio);
}
cfmakeraw(&tio);
+ tio.c_lflag &= ~ECHO;
+ tio.c_lflag |= ISIG;
+ tio.c_cc[VTIME] = 0;
+ tio.c_cc[VMIN] = CMIN;
if (ioctl(0, TIOCGWINSZ, &wz) == 0)
wzok = 1;

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9a2e9f57f34110b89bf3905c779b482120ef065080856b40fa045b436f75a889
size 20456

4
startpar-0.58.dif Normal file
View File

@ -0,0 +1,4 @@
--- .#empty
+++ .#empty 2012-01-30 17:44:30.343145442 +0000
@@ -0,0 +1 @@
+Place holder

3
startpar-0.58.tar.bz2 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ff1db9a30fea2882c49a8c6aa2fa706e568f58b930cd35d643f304ff0f734a72
size 21247

View File

@ -2,3 +2,6 @@ addFilter(".*statically-linked-binary.*/sbin/init.*")
addFilter(".*files-duplicate.*/usr/share/man/man.*") addFilter(".*files-duplicate.*/usr/share/man/man.*")
addFilter(".*non-remote_fs-dependency.*/etc/init.d/powerd.*") addFilter(".*non-remote_fs-dependency.*/etc/init.d/powerd.*")
addFilter(".*incoherent-init-script-name.*powerd.*") addFilter(".*incoherent-init-script-name.*powerd.*")
addFilter(".*no-manual-page-for-binary.*sysvinit.*")
addFilter(".*dangling-symlink.*/sbin/init.*/sbin/sysvinit.*")
addFilter(".*no-manual-page-for-binary.*rcpowerd.*")

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Tue Jan 31 16:40:18 UTC 2012 - werner@suse.de
- New killproc-2.21 which includes the last bug fixes as well as
new features like support for ionice with startproc
- New showconsole-1.16 which includes the last bug fixes
- New startpar-0.58 which includes the last bug fixes as well as
the patches from Debian
- Make rpmlint happy
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Dec 19 18:13:19 UTC 2011 - werner@suse.de Mon Dec 19 18:13:19 UTC 2011 - werner@suse.de

View File

@ -19,12 +19,11 @@
Name: sysvinit Name: sysvinit
%define MGVER 0.9.6s
%define PDVER 2.0.2 %define PDVER 2.0.2
%define KPVER 2.20 %define KPVER 2.21
%define SCVER 1.15 %define SCVER 1.16
%define SIVER 2.88+ %define SIVER 2.88+
%define START 0.57 %define START 0.58
License: GPL-2.0+ License: GPL-2.0+
Group: System/Base Group: System/Base
Version: %{SIVER} Version: %{SIVER}
@ -91,7 +90,7 @@ Conflicts: otherproviders(sbin_init)
Requires: %{name} Requires: %{name}
%description init %description init
Just some symlinks Just some symlinks and manual page for sysvinit
%prep %prep
%setup -n %{name}-%{SIVER}dsf -q -b 2 -b 3 -b 4 -b 5 %setup -n %{name}-%{SIVER}dsf -q -b 2 -b 3 -b 4 -b 5
@ -165,7 +164,9 @@ popd
mkdir -m 755 -p ${RPM_BUILD_ROOT}%{_mandir}/man8 mkdir -m 755 -p ${RPM_BUILD_ROOT}%{_mandir}/man8
make install -C src MANPATH=%{_mandir} ROOT=${RPM_BUILD_ROOT} WITH_SELINUX=yes DISTRO=SuSE make install -C src MANPATH=%{_mandir} ROOT=${RPM_BUILD_ROOT} WITH_SELINUX=yes DISTRO=SuSE
mv ${RPM_BUILD_ROOT}/sbin/init ${RPM_BUILD_ROOT}/sbin/sysvinit mv ${RPM_BUILD_ROOT}/sbin/init ${RPM_BUILD_ROOT}/sbin/sysvinit
mv ${RPM_BUILD_ROOT}%{_mandir}/man8/init.8 ${RPM_BUILD_ROOT}/%{_mandir}/man8/sysvinit.8
ln -s /sbin/sysvinit ${RPM_BUILD_ROOT}/sbin/init ln -s /sbin/sysvinit ${RPM_BUILD_ROOT}/sbin/init
ln -s sysvinit.8 ${RPM_BUILD_ROOT}%{_mandir}/man8/init.8
mkdir -p ${RPM_BUILD_ROOT}/lib/sysvinit mkdir -p ${RPM_BUILD_ROOT}/lib/sysvinit
ln -sf /sbin/sysvinit ${RPM_BUILD_ROOT}/lib/sysvinit/telinit ln -sf /sbin/sysvinit ${RPM_BUILD_ROOT}/lib/sysvinit/telinit
ln -sf /sbin/sysvinit ${RPM_BUILD_ROOT}/sbin/telinit ln -sf /sbin/sysvinit ${RPM_BUILD_ROOT}/sbin/telinit
@ -190,6 +191,7 @@ pushd ../powerd-%{PDVER}
echo '# ' >> ${RPM_BUILD_ROOT}/etc/powerd.conf echo '# ' >> ${RPM_BUILD_ROOT}/etc/powerd.conf
mkdir -p ${RPM_BUILD_ROOT}/etc/init.d mkdir -p ${RPM_BUILD_ROOT}/etc/init.d
install -m 0744 %{SOURCE6} ${RPM_BUILD_ROOT}/etc/init.d/powerd install -m 0744 %{SOURCE6} ${RPM_BUILD_ROOT}/etc/init.d/powerd
ln -sf /etc/init.d/powerd ${RPM_BUILD_ROOT}/sbin/rcpowerd
%endif %endif
popd popd
pushd ../startpar-%{START} pushd ../startpar-%{START}
@ -234,6 +236,7 @@ if test -x /sbin/mkinitrd_setup; then
fi fi
%postun tools %postun tools
%restart_on_update powered
%insserv_cleanup %insserv_cleanup
if test -x /sbin/mkinitrd_setup; then if test -x /sbin/mkinitrd_setup; then
mkinitrd_setup mkinitrd_setup
@ -258,6 +261,7 @@ fi
%doc %{_mandir}/man5/initscript.5.gz %doc %{_mandir}/man5/initscript.5.gz
%doc %{_mandir}/man5/inittab.5.gz %doc %{_mandir}/man5/inittab.5.gz
%doc %{_mandir}/man8/init.8.gz %doc %{_mandir}/man8/init.8.gz
%doc %{_mandir}/man8/sysvinit.8.gz
%doc %{_mandir}/man8/poweroff.8.gz %doc %{_mandir}/man8/poweroff.8.gz
%doc %{_mandir}/man8/reboot.8.gz %doc %{_mandir}/man8/reboot.8.gz
%doc %{_mandir}/man8/runlevel.8.gz %doc %{_mandir}/man8/runlevel.8.gz
@ -300,6 +304,7 @@ fi
%ifnarch s390 s390x %ifnarch s390 s390x
/sbin/powerd /sbin/powerd
/sbin/detectups /sbin/detectups
/sbin/rcpowerd
%endif %endif
/sbin/startpar /sbin/startpar
/sbin/rvmtab /sbin/rvmtab