mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-09-12 10:05:37 +00:00
only warn for inherited file descriptors
As discussed in thread: http://sourceforge.net/mailarchive/forum.php?thread_name=4E5618C3.5060507%40free.fr&forum_name=lxc-devel We think it's better for now to only warn the user about a fd leaking into the container. Also remove the call to readlink() as it isn't really useful now: since the container will start anyway, the user can look into /proc/../fd or use lsof or whatever. Signed-off-by: Greg Kurz <gkurz@fr.ibm.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
parent
1c41ddcb4a
commit
92c7f62955
@ -141,7 +141,6 @@ int lxc_check_inherited(int fd_to_ignore)
|
|||||||
struct dirent dirent, *direntp;
|
struct dirent dirent, *direntp;
|
||||||
int fd, fddir;
|
int fd, fddir;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
dir = opendir("/proc/self/fd");
|
dir = opendir("/proc/self/fd");
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
@ -152,9 +151,6 @@ int lxc_check_inherited(int fd_to_ignore)
|
|||||||
fddir = dirfd(dir);
|
fddir = dirfd(dir);
|
||||||
|
|
||||||
while (!readdir_r(dir, &dirent, &direntp)) {
|
while (!readdir_r(dir, &dirent, &direntp)) {
|
||||||
char procpath[64];
|
|
||||||
char path[PATH_MAX];
|
|
||||||
|
|
||||||
if (!direntp)
|
if (!direntp)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -171,22 +167,12 @@ int lxc_check_inherited(int fd_to_ignore)
|
|||||||
|
|
||||||
if (match_fd(fd))
|
if (match_fd(fd))
|
||||||
continue;
|
continue;
|
||||||
/*
|
|
||||||
* found inherited fd
|
|
||||||
*/
|
|
||||||
ret = -1;
|
|
||||||
|
|
||||||
snprintf(procpath, sizeof(procpath), "/proc/self/fd/%d", fd);
|
WARN("inherited fd %d", fd);
|
||||||
|
|
||||||
if (readlink(procpath, path, sizeof(path)) == -1)
|
|
||||||
ERROR("readlink(%s) failed : %m", procpath);
|
|
||||||
else
|
|
||||||
ERROR("inherited fd %d on %s", fd, path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (closedir(dir))
|
closedir(dir); /* cannot fail */
|
||||||
ERROR("failed to close directory");
|
return 0;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int setup_signal_fd(sigset_t *oldmask)
|
static int setup_signal_fd(sigset_t *oldmask)
|
||||||
|
Loading…
Reference in New Issue
Block a user