Lines 80-88
rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
Link Here
|
80 |
DIR *procdir; |
80 |
DIR *procdir; |
81 |
struct dirent *entry; |
81 |
struct dirent *entry; |
82 |
FILE *fp; |
82 |
FILE *fp; |
|
|
83 |
int rc; |
83 |
bool container_pid = false; |
84 |
bool container_pid = false; |
84 |
bool openvz_host = false; |
85 |
bool openvz_host = false; |
85 |
char *line = NULL; |
86 |
char *line = NULL; |
|
|
87 |
char my_ns[30]; |
88 |
char proc_ns[30]; |
86 |
size_t len = 0; |
89 |
size_t len = 0; |
87 |
pid_t p; |
90 |
pid_t p; |
88 |
char buffer[PATH_MAX]; |
91 |
char buffer[PATH_MAX]; |
Lines 131-136
rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
Link Here
|
131 |
} |
134 |
} |
132 |
} |
135 |
} |
133 |
|
136 |
|
|
|
137 |
memset(my_ns, 0, sizeof(my_ns)); |
138 |
memset(proc_ns, 0, sizeof(proc_ns)); |
139 |
if (exists("/proc/self/ns/pid")) { |
140 |
rc = readlink("/proc/self/ns/pid", my_ns, sizeof(my_ns)); |
141 |
if (rc <= 0) |
142 |
my_ns[0] = '\0'; |
143 |
} |
144 |
|
134 |
while ((entry = readdir(procdir)) != NULL) { |
145 |
while ((entry = readdir(procdir)) != NULL) { |
135 |
if (sscanf(entry->d_name, "%d", &p) != 1) |
146 |
if (sscanf(entry->d_name, "%d", &p) != 1) |
136 |
continue; |
147 |
continue; |
Lines 138-143
rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
Link Here
|
138 |
continue; |
149 |
continue; |
139 |
if (pid != 0 && pid != p) |
150 |
if (pid != 0 && pid != p) |
140 |
continue; |
151 |
continue; |
|
|
152 |
snprintf(buffer, sizeof(buffer), "/proc/%d/ns/pid", p); |
153 |
if (exists(buffer)) { |
154 |
rc = readlink(buffer, proc_ns, sizeof(proc_ns)); |
155 |
if (rc <= 0) |
156 |
proc_ns[0] = '\0'; |
157 |
} |
158 |
if (strcmp(my_ns, proc_ns)) |
159 |
continue; |
141 |
if (uid) { |
160 |
if (uid) { |
142 |
snprintf(buffer, sizeof(buffer), "/proc/%d", p); |
161 |
snprintf(buffer, sizeof(buffer), "/proc/%d", p); |
143 |
if (stat(buffer, &sb) != 0 || sb.st_uid != uid) |
162 |
if (stat(buffer, &sb) != 0 || sb.st_uid != uid) |
144 |
- |
|
|