From 485b4a0e7a95a2ca0ff21637d073ee510468b9de Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Tue, 26 Mar 2019 12:02:50 +0000 Subject: sysvinit: consolidate patches (From OE-Core rev: b89a48da4bc25c769f8dbc15d5e8596258cda472) Signed-off-by: Ross Burton Signed-off-by: Richard Purdie --- ...-sysmacros.h-for-major-minor-defines-in-g.patch | 71 -------- .../sysvinit/sysvinit-2.88dsf/crypt-lib.patch | 25 --- .../sysvinit/sysvinit-2.88dsf/install.patch | 83 --------- .../sysvinit-2.88dsf/pidof-add-m-option.patch | 189 --------------------- ...-sysmacros.h-for-major-minor-defines-in-g.patch | 71 ++++++++ .../recipes-core/sysvinit/sysvinit/crypt-lib.patch | 25 +++ meta/recipes-core/sysvinit/sysvinit/install.patch | 83 +++++++++ .../sysvinit/sysvinit/pidof-add-m-option.patch | 189 +++++++++++++++++++++ 8 files changed, 368 insertions(+), 368 deletions(-) delete mode 100644 meta/recipes-core/sysvinit/sysvinit-2.88dsf/0001-include-sys-sysmacros.h-for-major-minor-defines-in-g.patch delete mode 100644 meta/recipes-core/sysvinit/sysvinit-2.88dsf/crypt-lib.patch delete mode 100644 meta/recipes-core/sysvinit/sysvinit-2.88dsf/install.patch delete mode 100644 meta/recipes-core/sysvinit/sysvinit-2.88dsf/pidof-add-m-option.patch create mode 100644 meta/recipes-core/sysvinit/sysvinit/0001-include-sys-sysmacros.h-for-major-minor-defines-in-g.patch create mode 100644 meta/recipes-core/sysvinit/sysvinit/crypt-lib.patch create mode 100644 meta/recipes-core/sysvinit/sysvinit/install.patch create mode 100644 meta/recipes-core/sysvinit/sysvinit/pidof-add-m-option.patch (limited to 'meta/recipes-core/sysvinit') diff --git a/meta/recipes-core/sysvinit/sysvinit-2.88dsf/0001-include-sys-sysmacros.h-for-major-minor-defines-in-g.patch b/meta/recipes-core/sysvinit/sysvinit-2.88dsf/0001-include-sys-sysmacros.h-for-major-minor-defines-in-g.patch deleted file mode 100644 index 2575b59b5e..0000000000 --- a/meta/recipes-core/sysvinit/sysvinit-2.88dsf/0001-include-sys-sysmacros.h-for-major-minor-defines-in-g.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 29c7a529d3bb0c1e20239f885e74c5036f1a908c Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Mon, 6 Aug 2018 15:38:58 -0700 -Subject: [PATCH] include sys/sysmacros.h for major/minor defines in glibc - -Signed-off-by: Khem Raj -Upstream-Status: Pending ---- - src/bootlogd.c | 3 +++ - src/bootlogd.o | Bin 58448 -> 60376 bytes - src/dowall.c | 3 +++ - src/shutdown.c | 4 +++- - 4 files changed, 9 insertions(+), 1 deletion(-) - -Index: sysvinit-2.88dsf/src/bootlogd.c -=================================================================== ---- sysvinit-2.88dsf.orig/src/bootlogd.c -+++ sysvinit-2.88dsf/src/bootlogd.c -@@ -53,6 +53,9 @@ - #ifdef __linux__ - #include - #endif -+#ifdef __GLIBC__ -+#include -+#endif - - char *Version = "@(#) bootlogd 2.86 03-Jun-2004 miquels@cistron.nl"; - -Index: sysvinit-2.88dsf/src/dowall.c -=================================================================== ---- sysvinit-2.88dsf.orig/src/dowall.c -+++ sysvinit-2.88dsf/src/dowall.c -@@ -37,6 +37,9 @@ - #include - #include - #include -+#ifdef __GLIBC__ -+#include -+#endif - - #ifndef _PATH_DEV - # define _PATH_DEV "/dev/" -Index: sysvinit-2.88dsf/src/shutdown.c -=================================================================== ---- sysvinit-2.88dsf.orig/src/shutdown.c -+++ sysvinit-2.88dsf/src/shutdown.c -@@ -57,7 +57,9 @@ - #include "reboot.h" - #include "initreq.h" - #include "init.h" -- -+#ifdef __GLIBC__ -+#include -+#endif - - char *Version = "@(#) shutdown 2.86-1 31-Jul-2004 miquels@cistron.nl"; - -Index: sysvinit-2.88dsf/src/mountpoint.c -=================================================================== ---- sysvinit-2.88dsf.orig/src/mountpoint.c -+++ sysvinit-2.88dsf/src/mountpoint.c -@@ -32,6 +32,9 @@ - #include - #include - #include -+#ifdef __GLIBC__ -+#include -+#endif - - int dostat(char *path, struct stat *st, int do_lstat, int quiet) - { diff --git a/meta/recipes-core/sysvinit/sysvinit-2.88dsf/crypt-lib.patch b/meta/recipes-core/sysvinit/sysvinit-2.88dsf/crypt-lib.patch deleted file mode 100644 index 7b342901e1..0000000000 --- a/meta/recipes-core/sysvinit/sysvinit-2.88dsf/crypt-lib.patch +++ /dev/null @@ -1,25 +0,0 @@ -Upstream-Status: Inappropriate [configuration] - -# The src Makefile was checking for libcrypt.a on the host, not in the -# build environment. This patch checks for $LCRYPT in the environment -# and uses it if it's there. -# - jdike@linux.intel.com - -Index: sysvinit-2.88dsf/src/Makefile -=================================================================== ---- sysvinit-2.88dsf.orig/src/Makefile -+++ sysvinit-2.88dsf/src/Makefile -@@ -85,9 +85,13 @@ else - endif - - # Additional libs for GNU libc. -+ifneq ($(LCRYPT),) -+ SULOGINLIBS += $(LCRYPT) -+else - ifneq ($(wildcard /usr/lib*/libcrypt.a),) - SULOGINLIBS += -lcrypt - endif -+endif - - all: $(BIN) $(SBIN) $(USRBIN) - diff --git a/meta/recipes-core/sysvinit/sysvinit-2.88dsf/install.patch b/meta/recipes-core/sysvinit/sysvinit-2.88dsf/install.patch deleted file mode 100644 index 6c4225a678..0000000000 --- a/meta/recipes-core/sysvinit/sysvinit-2.88dsf/install.patch +++ /dev/null @@ -1,83 +0,0 @@ -Upstream-Status: Pending - -diff --git a/src/Makefile b/src/Makefile -index e2b8028..3e11e92 100644 ---- a/src/Makefile -+++ b/src/Makefile -@@ -65,7 +65,14 @@ else - INSTALL_DATA = install -m 644 - endif - INSTALL_DIR = install -m 755 -d --MANDIR = /usr/share/man -+ -+ROOT ?= -+base_bindir ?= /bin -+base_sbindir ?= /sbin -+bindir ?= /usr/bin -+sysconfdir ?= /etc -+includedir ?= /usr/include -+mandir ?= /usr/share/man - - ifeq ($(WITH_SELINUX),yes) - SELINUX_DEF = -DWITH_SELINUX -@@ -138,39 +145,39 @@ clobber: cleanobjs - distclean: clobber - - install: -- $(INSTALL_DIR) $(ROOT)/bin/ $(ROOT)/sbin/ -- $(INSTALL_DIR) $(ROOT)/usr/bin/ -+ $(INSTALL_DIR) $(ROOT)$(base_bindir)/ $(ROOT)$(base_sbindir)/ -+ $(INSTALL_DIR) $(ROOT)$(bindir)/ - for i in $(BIN); do \ -- $(INSTALL_EXEC) $$i $(ROOT)/bin/ ; \ -+ $(INSTALL_EXEC) $$i $(ROOT)$(base_bindir)/ ; \ - done - for i in $(SBIN); do \ -- $(INSTALL_EXEC) $$i $(ROOT)/sbin/ ; \ -+ $(INSTALL_EXEC) $$i $(ROOT)$(base_sbindir)/ ; \ - done - for i in $(USRBIN); do \ -- $(INSTALL_EXEC) $$i $(ROOT)/usr/bin/ ; \ -+ $(INSTALL_EXEC) $$i $(ROOT)$(bindir)/ ; \ - done -- # $(INSTALL_DIR) $(ROOT)/etc/ -- # $(INSTALL_EXEC) initscript.sample $(ROOT)/etc/ -- ln -sf halt $(ROOT)/sbin/reboot -- ln -sf halt $(ROOT)/sbin/poweroff -- ln -sf init $(ROOT)/sbin/telinit -- ln -sf /sbin/killall5 $(ROOT)/bin/pidof -- if [ ! -f $(ROOT)/usr/bin/lastb ]; then \ -- ln -sf last $(ROOT)/usr/bin/lastb; \ -+ # $(INSTALL_DIR) $(ROOT)$(sysconfdir)/ -+ # $(INSTALL_EXEC) initscript.sample $(ROOT)$(sysconfdir)/ -+ ln -sf halt $(ROOT)$(base_sbindir)/reboot -+ ln -sf halt $(ROOT)$(base_sbindir)/poweroff -+ ln -sf init $(ROOT)$(base_sbindir)/telinit -+ ln -sf $(base_sbindir)/killall5 $(ROOT)$(base_bindir)/pidof -+ if [ ! -f $(ROOT)$(bindir)/lastb ]; then \ -+ ln -sf last $(ROOT)$(bindir)/lastb; \ - fi -- $(INSTALL_DIR) $(ROOT)/usr/include/ -- $(INSTALL_DATA) initreq.h $(ROOT)/usr/include/ -- $(INSTALL_DIR) $(ROOT)$(MANDIR)/man1/ -- $(INSTALL_DIR) $(ROOT)$(MANDIR)/man5/ -- $(INSTALL_DIR) $(ROOT)$(MANDIR)/man8/ -+ $(INSTALL_DIR) $(ROOT)$(includedir)/ -+ $(INSTALL_DATA) initreq.h $(ROOT)$(includedir)/ -+ $(INSTALL_DIR) $(ROOT)$(mandir)/man1/ -+ $(INSTALL_DIR) $(ROOT)$(mandir)/man5/ -+ $(INSTALL_DIR) $(ROOT)$(mandir)/man8/ - for i in $(MAN1); do \ -- $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man1/; \ -+ $(INSTALL_DATA) ../man/$$i $(ROOT)$(mandir)/man1/; \ - done - for i in $(MAN5); do \ -- $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man5/; \ -+ $(INSTALL_DATA) ../man/$$i $(ROOT)$(mandir)/man5/; \ - done - for i in $(MAN8); do \ -- $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man8/; \ -+ $(INSTALL_DATA) ../man/$$i $(ROOT)$(mandir)/man8/; \ - done - ifeq ($(ROOT),) - # diff --git a/meta/recipes-core/sysvinit/sysvinit-2.88dsf/pidof-add-m-option.patch b/meta/recipes-core/sysvinit/sysvinit-2.88dsf/pidof-add-m-option.patch deleted file mode 100644 index 5b5dfdc001..0000000000 --- a/meta/recipes-core/sysvinit/sysvinit-2.88dsf/pidof-add-m-option.patch +++ /dev/null @@ -1,189 +0,0 @@ -pidof: add -m option - -When used with -o, will also omit any processes that have the same -argv[0] and argv[1] as any explicitly omitted process ids. This can be -used to avoid multiple shell scripts concurrently calling pidof returning -each other's pids. - -https://bugzilla.redhat.com/show_bug.cgi?id=883856 - -Upstream-Status: backport -Imported patch from: https://bugzilla.redhat.com/attachment.cgi?id=658166 - -Signed-off-by: Hongxu Jia ---- - man/pidof.8 | 6 ++++++ - src/killall5.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- - 2 files changed, 65 insertions(+), 3 deletions(-) - -diff --git a/man/pidof.8 b/man/pidof.8 ---- a/man/pidof.8 -+++ b/man/pidof.8 -@@ -24,6 +24,7 @@ pidof -- find the process ID of a running program. - .RB [ \-c ] - .RB [ \-n ] - .RB [ \-x ] -+.RB [ \-m ] - .RB [ \-o - .IR omitpid[,omitpid..] ] - .RB [ \-o -@@ -63,6 +64,11 @@ shells running the named scripts. - Tells \fIpidof\fP to omit processes with that process id. The special - pid \fB%PPID\fP can be used to name the parent process of the \fIpidof\fP - program, in other words the calling shell or shell script. -+.IP -m -+When used with -o, will also omit any processes that have the same -+argv[0] and argv[1] as any explicitly omitted process ids. This can be -+used to avoid multiple shell scripts concurrently calling pidof returning -+each other's pids. - .SH "EXIT STATUS" - .TP - .B 0 -diff --git a/src/killall5.c b/src/killall5.c -index 5937d98..e73885e 100644 ---- a/src/killall5.c -+++ b/src/killall5.c -@@ -118,6 +118,7 @@ typedef struct _s_nfs - - /* List of processes. */ - PROC *plist; -+PROC *olist; - - /* List of processes to omit. */ - OMIT *omit; -@@ -345,6 +346,20 @@ static void clear_mnt(void) - } - } - -+static void clear_omit(void) -+{ -+ OMIT *o; -+ PROC *p; -+ for (o = omit; o; o = omit) { -+ omit = omit->next; -+ free(o); -+ } -+ for (p = olist; p; p = olist) { -+ olist = olist->next; -+ free(p); -+ } -+} -+ - /* - * Check if path is ia shadow off a NFS partition. - */ -@@ -452,6 +467,7 @@ int readproc(int do_stat) - DIR *dir; - FILE *fp; - PROC *p, *n; -+ OMIT *o, *m; - struct dirent *d; - struct stat st; - char path[PATH_MAX+1]; -@@ -624,6 +640,17 @@ int readproc(int do_stat) - p->next = plist; - plist = p; - p->pid = pid; -+ /* Could be smarter, but it's a small list. */ -+ m = omit; -+ for (o = omit; m; o = m) { -+ m = o->next; -+ if (o->pid == p->pid) { -+ n = (PROC*)xmalloc(sizeof(PROC)); -+ *n = *p; -+ n->next = olist; -+ olist = n; -+ } -+ } - } - closedir(dir); - -@@ -813,6 +840,26 @@ PIDQ_HEAD *pidof(char *prog) - return q; - } - -+int matches(PROC *o, PROC *p) -+{ -+ int ret = 0; -+ char *oargv1, *pargv1; -+ if ((o->argv0 && p->argv0 && !strcmp(o->argv0,p->argv0))) { -+ if (o->argv1 && p->argv1) { -+ if ((oargv1 = canonicalize_file_name(o->argv1)) == NULL) -+ oargv1 = strdup(o->argv1); -+ if ((pargv1 = canonicalize_file_name(p->argv1)) == NULL) -+ pargv1 = strdup(p->argv1); -+ if (! strcmp(oargv1, pargv1)) { -+ ret = 1; -+ } -+ free(oargv1); -+ free(pargv1); -+ } -+ } -+ return ret; -+} -+ - /* Give usage message and exit. */ - void usage(void) - { -@@ -845,6 +892,7 @@ void nsyslog(int pri, char *fmt, ...) - #define PIDOF_SINGLE 0x01 - #define PIDOF_OMIT 0x02 - #define PIDOF_NETFS 0x04 -+#define PIDOF_OMIT_OMIT_MATCHES 0x08 - - /* - * Pidof functionality. -@@ -861,6 +909,7 @@ int main_pidof(int argc, char **argv) - struct stat st; - char tmp[512]; - -+ olist = (PROC*)0; - omit = (OMIT*)0; - nlist = (NFS*)0; - opterr = 0; -@@ -868,7 +917,7 @@ int main_pidof(int argc, char **argv) - if ((token = getenv("PIDOF_NETFS")) && (strcmp(token,"no") != 0)) - flags |= PIDOF_NETFS; - -- while ((opt = getopt(argc,argv,"hco:sxn")) != EOF) switch (opt) { -+ while ((opt = getopt(argc,argv,"hcmo:sxn")) != EOF) switch (opt) { - case '?': - nsyslog(LOG_ERR,"invalid options on command line!\n"); - closelog(); -@@ -907,6 +956,9 @@ int main_pidof(int argc, char **argv) - case 'x': - scripts_too++; - break; -+ case 'm': -+ flags |= PIDOF_OMIT_OMIT_MATCHES; -+ break; - case 'n': - flags |= PIDOF_NETFS; - break; -@@ -938,10 +990,13 @@ int main_pidof(int argc, char **argv) - pid_t spid = 0; - while ((p = get_next_from_pid_q(q))) { - if ((flags & PIDOF_OMIT) && omit) { -- OMIT * optr; -- for (optr = omit; optr; optr = optr->next) { -+ PROC * optr; -+ for (optr = olist; optr; optr = optr->next) { - if (optr->pid == p->pid) - break; -+ if (flags & PIDOF_OMIT_OMIT_MATCHES) -+ if (matches(optr, p)) -+ break; - } - - /* -@@ -977,6 +1032,7 @@ int main_pidof(int argc, char **argv) - if (!first) - printf("\n"); - -+ clear_omit(); - clear_mnt(); - - closelog(); --- -1.8.1.2 - diff --git a/meta/recipes-core/sysvinit/sysvinit/0001-include-sys-sysmacros.h-for-major-minor-defines-in-g.patch b/meta/recipes-core/sysvinit/sysvinit/0001-include-sys-sysmacros.h-for-major-minor-defines-in-g.patch new file mode 100644 index 0000000000..2575b59b5e --- /dev/null +++ b/meta/recipes-core/sysvinit/sysvinit/0001-include-sys-sysmacros.h-for-major-minor-defines-in-g.patch @@ -0,0 +1,71 @@ +From 29c7a529d3bb0c1e20239f885e74c5036f1a908c Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Mon, 6 Aug 2018 15:38:58 -0700 +Subject: [PATCH] include sys/sysmacros.h for major/minor defines in glibc + +Signed-off-by: Khem Raj +Upstream-Status: Pending +--- + src/bootlogd.c | 3 +++ + src/bootlogd.o | Bin 58448 -> 60376 bytes + src/dowall.c | 3 +++ + src/shutdown.c | 4 +++- + 4 files changed, 9 insertions(+), 1 deletion(-) + +Index: sysvinit-2.88dsf/src/bootlogd.c +=================================================================== +--- sysvinit-2.88dsf.orig/src/bootlogd.c ++++ sysvinit-2.88dsf/src/bootlogd.c +@@ -53,6 +53,9 @@ + #ifdef __linux__ + #include + #endif ++#ifdef __GLIBC__ ++#include ++#endif + + char *Version = "@(#) bootlogd 2.86 03-Jun-2004 miquels@cistron.nl"; + +Index: sysvinit-2.88dsf/src/dowall.c +=================================================================== +--- sysvinit-2.88dsf.orig/src/dowall.c ++++ sysvinit-2.88dsf/src/dowall.c +@@ -37,6 +37,9 @@ + #include + #include + #include ++#ifdef __GLIBC__ ++#include ++#endif + + #ifndef _PATH_DEV + # define _PATH_DEV "/dev/" +Index: sysvinit-2.88dsf/src/shutdown.c +=================================================================== +--- sysvinit-2.88dsf.orig/src/shutdown.c ++++ sysvinit-2.88dsf/src/shutdown.c +@@ -57,7 +57,9 @@ + #include "reboot.h" + #include "initreq.h" + #include "init.h" +- ++#ifdef __GLIBC__ ++#include ++#endif + + char *Version = "@(#) shutdown 2.86-1 31-Jul-2004 miquels@cistron.nl"; + +Index: sysvinit-2.88dsf/src/mountpoint.c +=================================================================== +--- sysvinit-2.88dsf.orig/src/mountpoint.c ++++ sysvinit-2.88dsf/src/mountpoint.c +@@ -32,6 +32,9 @@ + #include + #include + #include ++#ifdef __GLIBC__ ++#include ++#endif + + int dostat(char *path, struct stat *st, int do_lstat, int quiet) + { diff --git a/meta/recipes-core/sysvinit/sysvinit/crypt-lib.patch b/meta/recipes-core/sysvinit/sysvinit/crypt-lib.patch new file mode 100644 index 0000000000..7b342901e1 --- /dev/null +++ b/meta/recipes-core/sysvinit/sysvinit/crypt-lib.patch @@ -0,0 +1,25 @@ +Upstream-Status: Inappropriate [configuration] + +# The src Makefile was checking for libcrypt.a on the host, not in the +# build environment. This patch checks for $LCRYPT in the environment +# and uses it if it's there. +# - jdike@linux.intel.com + +Index: sysvinit-2.88dsf/src/Makefile +=================================================================== +--- sysvinit-2.88dsf.orig/src/Makefile ++++ sysvinit-2.88dsf/src/Makefile +@@ -85,9 +85,13 @@ else + endif + + # Additional libs for GNU libc. ++ifneq ($(LCRYPT),) ++ SULOGINLIBS += $(LCRYPT) ++else + ifneq ($(wildcard /usr/lib*/libcrypt.a),) + SULOGINLIBS += -lcrypt + endif ++endif + + all: $(BIN) $(SBIN) $(USRBIN) + diff --git a/meta/recipes-core/sysvinit/sysvinit/install.patch b/meta/recipes-core/sysvinit/sysvinit/install.patch new file mode 100644 index 0000000000..6c4225a678 --- /dev/null +++ b/meta/recipes-core/sysvinit/sysvinit/install.patch @@ -0,0 +1,83 @@ +Upstream-Status: Pending + +diff --git a/src/Makefile b/src/Makefile +index e2b8028..3e11e92 100644 +--- a/src/Makefile ++++ b/src/Makefile +@@ -65,7 +65,14 @@ else + INSTALL_DATA = install -m 644 + endif + INSTALL_DIR = install -m 755 -d +-MANDIR = /usr/share/man ++ ++ROOT ?= ++base_bindir ?= /bin ++base_sbindir ?= /sbin ++bindir ?= /usr/bin ++sysconfdir ?= /etc ++includedir ?= /usr/include ++mandir ?= /usr/share/man + + ifeq ($(WITH_SELINUX),yes) + SELINUX_DEF = -DWITH_SELINUX +@@ -138,39 +145,39 @@ clobber: cleanobjs + distclean: clobber + + install: +- $(INSTALL_DIR) $(ROOT)/bin/ $(ROOT)/sbin/ +- $(INSTALL_DIR) $(ROOT)/usr/bin/ ++ $(INSTALL_DIR) $(ROOT)$(base_bindir)/ $(ROOT)$(base_sbindir)/ ++ $(INSTALL_DIR) $(ROOT)$(bindir)/ + for i in $(BIN); do \ +- $(INSTALL_EXEC) $$i $(ROOT)/bin/ ; \ ++ $(INSTALL_EXEC) $$i $(ROOT)$(base_bindir)/ ; \ + done + for i in $(SBIN); do \ +- $(INSTALL_EXEC) $$i $(ROOT)/sbin/ ; \ ++ $(INSTALL_EXEC) $$i $(ROOT)$(base_sbindir)/ ; \ + done + for i in $(USRBIN); do \ +- $(INSTALL_EXEC) $$i $(ROOT)/usr/bin/ ; \ ++ $(INSTALL_EXEC) $$i $(ROOT)$(bindir)/ ; \ + done +- # $(INSTALL_DIR) $(ROOT)/etc/ +- # $(INSTALL_EXEC) initscript.sample $(ROOT)/etc/ +- ln -sf halt $(ROOT)/sbin/reboot +- ln -sf halt $(ROOT)/sbin/poweroff +- ln -sf init $(ROOT)/sbin/telinit +- ln -sf /sbin/killall5 $(ROOT)/bin/pidof +- if [ ! -f $(ROOT)/usr/bin/lastb ]; then \ +- ln -sf last $(ROOT)/usr/bin/lastb; \ ++ # $(INSTALL_DIR) $(ROOT)$(sysconfdir)/ ++ # $(INSTALL_EXEC) initscript.sample $(ROOT)$(sysconfdir)/ ++ ln -sf halt $(ROOT)$(base_sbindir)/reboot ++ ln -sf halt $(ROOT)$(base_sbindir)/poweroff ++ ln -sf init $(ROOT)$(base_sbindir)/telinit ++ ln -sf $(base_sbindir)/killall5 $(ROOT)$(base_bindir)/pidof ++ if [ ! -f $(ROOT)$(bindir)/lastb ]; then \ ++ ln -sf last $(ROOT)$(bindir)/lastb; \ + fi +- $(INSTALL_DIR) $(ROOT)/usr/include/ +- $(INSTALL_DATA) initreq.h $(ROOT)/usr/include/ +- $(INSTALL_DIR) $(ROOT)$(MANDIR)/man1/ +- $(INSTALL_DIR) $(ROOT)$(MANDIR)/man5/ +- $(INSTALL_DIR) $(ROOT)$(MANDIR)/man8/ ++ $(INSTALL_DIR) $(ROOT)$(includedir)/ ++ $(INSTALL_DATA) initreq.h $(ROOT)$(includedir)/ ++ $(INSTALL_DIR) $(ROOT)$(mandir)/man1/ ++ $(INSTALL_DIR) $(ROOT)$(mandir)/man5/ ++ $(INSTALL_DIR) $(ROOT)$(mandir)/man8/ + for i in $(MAN1); do \ +- $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man1/; \ ++ $(INSTALL_DATA) ../man/$$i $(ROOT)$(mandir)/man1/; \ + done + for i in $(MAN5); do \ +- $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man5/; \ ++ $(INSTALL_DATA) ../man/$$i $(ROOT)$(mandir)/man5/; \ + done + for i in $(MAN8); do \ +- $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man8/; \ ++ $(INSTALL_DATA) ../man/$$i $(ROOT)$(mandir)/man8/; \ + done + ifeq ($(ROOT),) + # diff --git a/meta/recipes-core/sysvinit/sysvinit/pidof-add-m-option.patch b/meta/recipes-core/sysvinit/sysvinit/pidof-add-m-option.patch new file mode 100644 index 0000000000..5b5dfdc001 --- /dev/null +++ b/meta/recipes-core/sysvinit/sysvinit/pidof-add-m-option.patch @@ -0,0 +1,189 @@ +pidof: add -m option + +When used with -o, will also omit any processes that have the same +argv[0] and argv[1] as any explicitly omitted process ids. This can be +used to avoid multiple shell scripts concurrently calling pidof returning +each other's pids. + +https://bugzilla.redhat.com/show_bug.cgi?id=883856 + +Upstream-Status: backport +Imported patch from: https://bugzilla.redhat.com/attachment.cgi?id=658166 + +Signed-off-by: Hongxu Jia +--- + man/pidof.8 | 6 ++++++ + src/killall5.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- + 2 files changed, 65 insertions(+), 3 deletions(-) + +diff --git a/man/pidof.8 b/man/pidof.8 +--- a/man/pidof.8 ++++ b/man/pidof.8 +@@ -24,6 +24,7 @@ pidof -- find the process ID of a running program. + .RB [ \-c ] + .RB [ \-n ] + .RB [ \-x ] ++.RB [ \-m ] + .RB [ \-o + .IR omitpid[,omitpid..] ] + .RB [ \-o +@@ -63,6 +64,11 @@ shells running the named scripts. + Tells \fIpidof\fP to omit processes with that process id. The special + pid \fB%PPID\fP can be used to name the parent process of the \fIpidof\fP + program, in other words the calling shell or shell script. ++.IP -m ++When used with -o, will also omit any processes that have the same ++argv[0] and argv[1] as any explicitly omitted process ids. This can be ++used to avoid multiple shell scripts concurrently calling pidof returning ++each other's pids. + .SH "EXIT STATUS" + .TP + .B 0 +diff --git a/src/killall5.c b/src/killall5.c +index 5937d98..e73885e 100644 +--- a/src/killall5.c ++++ b/src/killall5.c +@@ -118,6 +118,7 @@ typedef struct _s_nfs + + /* List of processes. */ + PROC *plist; ++PROC *olist; + + /* List of processes to omit. */ + OMIT *omit; +@@ -345,6 +346,20 @@ static void clear_mnt(void) + } + } + ++static void clear_omit(void) ++{ ++ OMIT *o; ++ PROC *p; ++ for (o = omit; o; o = omit) { ++ omit = omit->next; ++ free(o); ++ } ++ for (p = olist; p; p = olist) { ++ olist = olist->next; ++ free(p); ++ } ++} ++ + /* + * Check if path is ia shadow off a NFS partition. + */ +@@ -452,6 +467,7 @@ int readproc(int do_stat) + DIR *dir; + FILE *fp; + PROC *p, *n; ++ OMIT *o, *m; + struct dirent *d; + struct stat st; + char path[PATH_MAX+1]; +@@ -624,6 +640,17 @@ int readproc(int do_stat) + p->next = plist; + plist = p; + p->pid = pid; ++ /* Could be smarter, but it's a small list. */ ++ m = omit; ++ for (o = omit; m; o = m) { ++ m = o->next; ++ if (o->pid == p->pid) { ++ n = (PROC*)xmalloc(sizeof(PROC)); ++ *n = *p; ++ n->next = olist; ++ olist = n; ++ } ++ } + } + closedir(dir); + +@@ -813,6 +840,26 @@ PIDQ_HEAD *pidof(char *prog) + return q; + } + ++int matches(PROC *o, PROC *p) ++{ ++ int ret = 0; ++ char *oargv1, *pargv1; ++ if ((o->argv0 && p->argv0 && !strcmp(o->argv0,p->argv0))) { ++ if (o->argv1 && p->argv1) { ++ if ((oargv1 = canonicalize_file_name(o->argv1)) == NULL) ++ oargv1 = strdup(o->argv1); ++ if ((pargv1 = canonicalize_file_name(p->argv1)) == NULL) ++ pargv1 = strdup(p->argv1); ++ if (! strcmp(oargv1, pargv1)) { ++ ret = 1; ++ } ++ free(oargv1); ++ free(pargv1); ++ } ++ } ++ return ret; ++} ++ + /* Give usage message and exit. */ + void usage(void) + { +@@ -845,6 +892,7 @@ void nsyslog(int pri, char *fmt, ...) + #define PIDOF_SINGLE 0x01 + #define PIDOF_OMIT 0x02 + #define PIDOF_NETFS 0x04 ++#define PIDOF_OMIT_OMIT_MATCHES 0x08 + + /* + * Pidof functionality. +@@ -861,6 +909,7 @@ int main_pidof(int argc, char **argv) + struct stat st; + char tmp[512]; + ++ olist = (PROC*)0; + omit = (OMIT*)0; + nlist = (NFS*)0; + opterr = 0; +@@ -868,7 +917,7 @@ int main_pidof(int argc, char **argv) + if ((token = getenv("PIDOF_NETFS")) && (strcmp(token,"no") != 0)) + flags |= PIDOF_NETFS; + +- while ((opt = getopt(argc,argv,"hco:sxn")) != EOF) switch (opt) { ++ while ((opt = getopt(argc,argv,"hcmo:sxn")) != EOF) switch (opt) { + case '?': + nsyslog(LOG_ERR,"invalid options on command line!\n"); + closelog(); +@@ -907,6 +956,9 @@ int main_pidof(int argc, char **argv) + case 'x': + scripts_too++; + break; ++ case 'm': ++ flags |= PIDOF_OMIT_OMIT_MATCHES; ++ break; + case 'n': + flags |= PIDOF_NETFS; + break; +@@ -938,10 +990,13 @@ int main_pidof(int argc, char **argv) + pid_t spid = 0; + while ((p = get_next_from_pid_q(q))) { + if ((flags & PIDOF_OMIT) && omit) { +- OMIT * optr; +- for (optr = omit; optr; optr = optr->next) { ++ PROC * optr; ++ for (optr = olist; optr; optr = optr->next) { + if (optr->pid == p->pid) + break; ++ if (flags & PIDOF_OMIT_OMIT_MATCHES) ++ if (matches(optr, p)) ++ break; + } + + /* +@@ -977,6 +1032,7 @@ int main_pidof(int argc, char **argv) + if (!first) + printf("\n"); + ++ clear_omit(); + clear_mnt(); + + closelog(); +-- +1.8.1.2 + -- cgit v1.2.3-54-g00ecf