Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 379228 Details for
Bug 376817
make OpenVZ host to automatically filters out container's processes
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Working, in production patch for OpenVZ pid filtering from Funtoo Linux.
fix-openvz-r1.patch (text/plain), 1.87 KB, created by
Daniel Robbins
on 2014-06-18 21:48:59 UTC
(
hide
)
Description:
Working, in production patch for OpenVZ pid filtering from Funtoo Linux.
Filename:
MIME Type:
Creator:
Daniel Robbins
Created:
2014-06-18 21:48:59 UTC
Size:
1.87 KB
patch
obsolete
>diff -urN openrc-0.12.3/src/librc/librc-daemon.c openrc-0.12.3-fixed/src/librc/librc-daemon.c >--- openrc-0.12.3/src/librc/librc-daemon.c 2013-10-22 20:59:16.000000000 -0600 >+++ openrc-0.12.3-fixed/src/librc/librc-daemon.c 2014-05-29 09:23:39.196960207 -0600 >@@ -90,6 +90,11 @@ > { > DIR *procdir; > struct dirent *entry; >+ FILE *fp; >+ bool container_pid = false; >+ bool openvz_host = false; >+ char *line = NULL; >+ size_t len = 0; > pid_t p; > char buffer[PATH_MAX]; > struct stat sb; >@@ -117,6 +122,26 @@ > runscript_pid = 0; > } > >+ /* >+ If /proc/self/status contains EnvID: 0, then we are an OpenVZ host, >+ and we will need to filter out processes that are inside containers >+ from our list of pids. >+ */ >+ >+ if (exists("/proc/self/status")) { >+ fp = fopen("/proc/self/status", "r"); >+ if (fp) { >+ while(! feof(fp)) { >+ rc_getline(&line, &len, fp); >+ if (strncmp(line, "envID:\t0", 8) == 0) { >+ openvz_host = true; >+ break; >+ } >+ } >+ fclose(fp); >+ } >+ } >+ > while ((entry = readdir(procdir)) != NULL) { > if (sscanf(entry->d_name, "%d", &p) != 1) > continue; >@@ -134,6 +159,25 @@ > if (argv && > !pid_is_argv(p, (const char *const *)argv)) > continue; >+ // We are on an OpenVZ host -- filter out container processes: >+ if (openvz_host) { >+ snprintf(buffer, sizeof(buffer), "/proc/%d/status", p); >+ if (exists(buffer)) { >+ fp = fopen(buffer, "r"); >+ if (! fp) >+ continue; >+ while (! feof(fp)) { >+ rc_getline(&line, &len, fp); >+ if (strncmp(line, "envID:", 6) == 0) { >+ container_pid = ! (strncmp(line, "envID:\t0", 8) == 0); >+ break; >+ } >+ } >+ fclose(fp); >+ } >+ } >+ if (container_pid) >+ continue; > if (!pids) { > pids = xmalloc(sizeof(*pids)); > LIST_INIT(pids); >@@ -142,6 +186,8 @@ > pi->pid = p; > LIST_INSERT_HEAD(pids, pi, entries); > } >+ if (line != NULL) >+ free(line); > closedir(procdir); > return pids; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 376817
:
285095
|
373506
|
373606
|
374934
| 379228