.
OBS-URL: https://build.opensuse.org/package/show/Base:System/sysvinit?expand=0&rev=72
This commit is contained in:
parent
89d4214803
commit
83574d9aed
@ -1,4 +1,58 @@
|
||||
--- .dummy
|
||||
+++ .dummy 2010-08-23 17:38:50.000000000 +0000
|
||||
@@ -0,0 +1 @@
|
||||
+this is a dummy, remove if real changes are required
|
||||
--- blogd.c
|
||||
+++ blogd.c 2010-09-30 13:12:50.172426395 +0000
|
||||
@@ -193,35 +193,16 @@ static void reconnect(int fd)
|
||||
if (c->fd != fd) continue;
|
||||
|
||||
switch (c->fd) {
|
||||
- case 1: /* Standard out */
|
||||
- case 2: /* Standard error */
|
||||
-
|
||||
- if ((newfd = open(c->tty, O_WRONLY|O_NONBLOCK|O_NOCTTY)) < 0)
|
||||
- error("can not open %s: %s\n", c->tty, strerror(errno));
|
||||
-
|
||||
- if (newfd != 1)
|
||||
- dup2(newfd, 1);
|
||||
- if (newfd != 2)
|
||||
- dup2(newfd, 2);
|
||||
- if (newfd > 2)
|
||||
- close(newfd);
|
||||
-
|
||||
+ case 0:
|
||||
+ case -1: /* Weired */
|
||||
break;
|
||||
-
|
||||
- default: /* IO of further consoles */
|
||||
-
|
||||
+ default: /* IO of system consoles */
|
||||
if ((newfd = open(c->tty, O_WRONLY|O_NONBLOCK|O_NOCTTY)) < 0)
|
||||
error("can not open %s: %s\n", c->tty, strerror(errno));
|
||||
-
|
||||
- if (newfd != c->fd) {
|
||||
- dup2(newfd, c->fd);
|
||||
+ dup2(newfd, c->fd);
|
||||
+ if (newfd != c->fd)
|
||||
close(newfd);
|
||||
- }
|
||||
-
|
||||
- case 0:
|
||||
- case -1: /* Weired */
|
||||
-
|
||||
- break;
|
||||
+ break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -418,10 +399,11 @@ int main(int argc, char *argv[])
|
||||
err:
|
||||
for (c = cons; c; c = c->next) {
|
||||
if (c->fd > 0) {
|
||||
- if (c->tlock > 1) /* write back lock if any */
|
||||
- (void)ioctl(c->fd, TIOCSLCKTRMIOS, &c->ltio);
|
||||
if (c->tlock) /* write back old setup */
|
||||
tcsetattr(c->fd, TCSANOW, &c->otio);
|
||||
+ if (c->tlock > 1) /* write back lock if any */
|
||||
+ (void)ioctl(c->fd, TIOCSLCKTRMIOS, &c->ltio);
|
||||
+ c->tlock = 0;
|
||||
close(c->fd);
|
||||
c->fd = -1;
|
||||
}
|
||||
|
@ -1,4 +1,215 @@
|
||||
--- .dummy
|
||||
+++ .dummy 2010-08-23 17:38:50.000000000 +0000
|
||||
@@ -0,0 +1 @@
|
||||
+this is a dummy, remove if real changes are required
|
||||
--- proc.c
|
||||
+++ proc.c 2010-09-30 14:19:15.595926333 +0200
|
||||
@@ -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/tty/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 14:41:35.271926120 +0200
|
||||
@@ -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 2010-09-30 15:01:50.787926081 +0200
|
||||
@@ -241,14 +241,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 +251,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 +450,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,6 +460,7 @@ 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");
|
||||
@@ -582,14 +570,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 +580,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 +614,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 +713,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 +830,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);
|
||||
|
@ -1,3 +1,13 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Oct 1 15:43:16 CEST 2010 - werner@suse.de
|
||||
|
||||
- blogd: correct order of setting back termios and termios locks
|
||||
- startpar: avoid EIO in do_forward if do_forward becomes a
|
||||
background process
|
||||
- Make sure that after installation of /sbin/init the init
|
||||
process does re-execute that is split %post into one for
|
||||
the tools sub package and one of the main package
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 22 14:38:37 CEST 2010 - werner@suse.de
|
||||
|
||||
|
@ -202,12 +202,14 @@ popd
|
||||
%preun tools
|
||||
%stop_on_removal powered
|
||||
|
||||
%post tools
|
||||
%post
|
||||
if test -x /sbin/telinit -a -p /dev/initctl -a -f /proc/1/exe -a -d /proc/1/root -a ! -d /.build ; then
|
||||
if test $(stat -Lc '%%D-%%i' /) = $(stat -Lc '%%D-%%i' /proc/1/root) ; then
|
||||
/sbin/telinit u
|
||||
fi
|
||||
fi
|
||||
|
||||
%post tools
|
||||
if test -x /sbin/mkinitrd_setup; then
|
||||
mkinitrd_setup
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user