Dr. Werner Fink 2012-03-16 17:02:25 +00:00 committed by Git OBS Bridge
parent 4188ff4ed6
commit c2e9a5b0f8
4 changed files with 210 additions and 7 deletions

View File

@ -0,0 +1,38 @@
Index: src/killall5.c
===================================================================
--- src/killall5.c (revision 114)
+++ src/killall5.c (working copy)
@@ -638,8 +638,32 @@ int readproc(int do_stat)
if ((p->nfs = check4nfs(path, buf)))
goto link;
case DO_STAT:
- if (stat(path, &st) != 0)
+ if (stat(path, &st) != 0) {
+ char * ptr;
+
+ len = readlink(path, buf, PATH_MAX);
+ if (len <= 0)
+ break;
+ buf[len] = '\0';
+
+ ptr = strstr(buf, " (deleted)");
+ if (!ptr)
+ break;
+ *ptr = '\0';
+ len -= strlen(" (deleted)");
+
+ if (stat(buf, &st) != 0)
+ break;
+ p->dev = st.st_dev;
+ p->ino = st.st_ino;
+ p->pathname = (char *)xmalloc(len + 1);
+ memcpy(p->pathname, buf, len);
+ p->pathname[len] = '\0';
+
+ /* All done */
break;
+ }
+
p->dev = st.st_dev;
p->ino = st.st_ino;

148
sysvinit-2.88+dsf-env.patch Normal file
View File

@ -0,0 +1,148 @@
Index: src/init.c
===================================================================
--- src/init.c (revision 113)
+++ src/init.c (working copy)
@@ -248,7 +248,7 @@ void *imalloc(size_t size)
}
static
-char *istrdup(char *s)
+char *istrdup(const char *s)
{
char *m;
int l;
@@ -880,6 +880,27 @@ void initlog(int loglevel, char *s, ...)
}
}
+/*
+ * Add or replace specific environment value
+ */
+int addnewenv(const char *new, char **curr, int n)
+{
+ size_t nlen = strcspn(new, "=");
+ int i;
+ for (i = 0; i < n; i++) {
+ if (nlen != strcspn(curr[i], "="))
+ continue;
+ if (strncmp (new, curr[i], nlen) == 0)
+ break;
+ }
+ if (i >= n)
+ curr[n++] = istrdup(new);
+ else {
+ free(curr[i]);
+ curr[i] = istrdup(new);
+ }
+ return n;
+}
/*
* Build a new environment for execve().
@@ -888,7 +909,7 @@ char **init_buildenv(int child)
{
char i_lvl[] = "RUNLEVEL=x";
char i_prev[] = "PREVLEVEL=x";
- char i_cons[32];
+ char i_cons[128];
char i_shell[] = "SHELL=" SHELL;
char **e;
int n, i;
@@ -898,25 +919,30 @@ char **init_buildenv(int child)
n += NR_EXTRA_ENV;
if (child)
n += 8;
- e = calloc(n, sizeof(char *));
+ while ((e = (char**)calloc(n, sizeof(char *))) == NULL) {
+ initlog(L_VB, "out of memory");
+ do_sleep(5);
+ }
+
for (n = 0; environ[n]; n++)
e[n] = istrdup(environ[n]);
for (i = 0; i < NR_EXTRA_ENV; i++) {
- if (extra_env[i])
- e[n++] = istrdup(extra_env[i]);
+ if (extra_env[i] == NULL || *extra_env[i] == '\0')
+ continue;
+ n = addnewenv(extra_env[i], e, n);
}
if (child) {
snprintf(i_cons, sizeof(i_cons), "CONSOLE=%s", console_dev);
i_lvl[9] = thislevel;
i_prev[10] = prevlevel;
- e[n++] = istrdup(i_shell);
- e[n++] = istrdup(i_lvl);
- e[n++] = istrdup(i_prev);
- e[n++] = istrdup(i_cons);
- e[n++] = istrdup(E_VERSION);
+ n = addnewenv(i_shell, e, n);
+ n = addnewenv(i_lvl, e, n);
+ n = addnewenv(i_prev, e, n);
+ n = addnewenv(i_cons, e, n);
+ n = addnewenv(E_VERSION, e, n);
}
e[n++] = NULL;
@@ -2133,41 +2159,46 @@ void fifo_new_level(int level)
static
void initcmd_setenv(char *data, int size)
{
- char *env, *p, *e, *eq;
- int i, sz;
+ char *env, *p, *e;
+ size_t sz;
+ int i, eq;
e = data + size;
while (*data && data < e) {
- eq = NULL;
for (p = data; *p && p < e; p++)
- if (*p == '=') eq = p;
+ ;
if (*p) break;
env = data;
data = ++p;
- sz = eq ? (eq - env) : (p - env);
-
- /*initlog(L_SY, "init_setenv: %s, %s, %d", env, eq, sz);*/
-
/*
* We only allow INIT_* to be set.
*/
if (strncmp(env, "INIT_", 5) != 0)
continue;
+ sz = strcspn(env, "=");
+ eq = (env[sz] == '=');
+
+ /*initlog(L_SY, "init_setenv: %s, %d, %d", env, eq, sz);*/
+
/* Free existing vars. */
for (i = 0; i < NR_EXTRA_ENV; i++) {
- if (extra_env[i] == NULL) continue;
- if (!strncmp(extra_env[i], env, sz) &&
- extra_env[i][sz] == '=') {
+ if (extra_env[i] == NULL)
+ continue;
+ if (sz != strcspn(extra_env[i], "="))
+ continue;
+ if (strncmp(extra_env[i], env, sz) == 0) {
free(extra_env[i]);
extra_env[i] = NULL;
}
}
+ if (eq == 0)
+ continue;
+
/* Set new vars if needed. */
- if (eq == NULL) continue;
for (i = 0; i < NR_EXTRA_ENV; i++) {
if (extra_env[i] == NULL) {
extra_env[i] = istrdup(env);

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Fri Mar 16 16:51:33 UTC 2012 - werner@suse.de
- Add two patch from upstream
+ Handle deleted binaries in pidof (was upstream bug #34992)
+ Allow init to delte extra environment variables (was upstream
bug #35858)
+ Avoid that init double environment variables for its childs
(was upstream bug #35855)
-------------------------------------------------------------------
Wed Feb 8 12:35:24 UTC 2012 - werner@suse.de

View File

@ -1,7 +1,7 @@
#
# spec file for package sysvinit
#
# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -15,8 +15,6 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# norootforbuild
Name: sysvinit
%define PDVER 2.0.2
@ -24,13 +22,16 @@ Name: sysvinit
%define SCVER 1.16
%define SIVER 2.88+
%define START 0.58
Version: %{SIVER}
Release: 0
Summary: SysV-Style init
License: GPL-2.0+
Group: System/Base
Version: %{SIVER}
Release: 58
Summary: SysV-Style init
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: audit-devel libselinux-devel libsepol-devel pam-devel
BuildRequires: audit-devel
BuildRequires: libselinux-devel
BuildRequires: libsepol-devel
BuildRequires: pam-devel
Url: http://savannah.nongnu.org/projects/sysvinit/
Source: sysvinit-%{SIVER}dsf.tar.bz2
Source2: killproc-%{KPVER}.tar.bz2
@ -52,6 +53,8 @@ Patch6: %{name}-%{version}dsf-run.diff
Patch7: %{name}-%{version}dsf-crypt.patch
Patch8: %{name}-%{version}dsf-blowfish.dif
Patch9: %{name}-2.88dsf-no-kill.patch
Patch10: %{name}-%{version}dsf-env.patch
Patch11: %{name}-%{version}dsf-dostat.patch
Patch20: powerd-%{PDVER}.dif
Patch21: powerd-%{PDVER}-getaddrinfo.patch
Patch30: killproc-%{KPVER}.dif
@ -71,6 +74,7 @@ more information.
%package tools
Summary: Tools for basic booting
Group: System/Base
%if 0%{suse_version} > 1120
Requires(preun): coreutils %insserv_prereq
Requires(postun): coreutils %insserv_prereq
@ -85,6 +89,7 @@ sysvinit package.
%package init
Summary: Provides /sbin/init for sysvinit
Group: System/Base
Provides: sbin_init
Conflicts: otherproviders(sbin_init)
Requires: %{name}
@ -103,6 +108,8 @@ Just some symlinks and manual page for sysvinit
%patch7 -p0 -b .crypt
%patch8 -p0 -b .blowfish
%patch9 -p0 -b .no-kill
%patch10 -p0 -b .env
%patch11 -p0 -b .dostat
%patch
pushd doc
mkdir killproc powerd showconsole