mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 07:05:28 +00:00
Populate /dev/std{in,out,err} symlinks in LXC containers
Some applications expect /dev/std{in,out,err} to exist. Populate them during container startup as symlinks to /proc/self/fd
This commit is contained in:
parent
bc6bb3a3e8
commit
d474dbadde
@ -584,6 +584,15 @@ static int lxcContainerPopulateDevices(char **ttyPaths, size_t nttyPaths)
|
|||||||
{ LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_RANDOM, 0666, "/dev/random" },
|
{ LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_RANDOM, 0666, "/dev/random" },
|
||||||
{ LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_URANDOM, 0666, "/dev/urandom" },
|
{ LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_URANDOM, 0666, "/dev/urandom" },
|
||||||
};
|
};
|
||||||
|
const struct {
|
||||||
|
const char *src;
|
||||||
|
const char *dst;
|
||||||
|
} links[] = {
|
||||||
|
{ "/proc/self/fd/0", "/dev/stdin" },
|
||||||
|
{ "/proc/self/fd/1", "/dev/stdout" },
|
||||||
|
{ "/proc/self/fd/2", "/dev/stderr" },
|
||||||
|
{ "/proc/self/fd", "/dev/fd" },
|
||||||
|
};
|
||||||
|
|
||||||
/* Populate /dev/ with a few important bits */
|
/* Populate /dev/ with a few important bits */
|
||||||
for (i = 0 ; i < ARRAY_CARDINALITY(devs) ; i++) {
|
for (i = 0 ; i < ARRAY_CARDINALITY(devs) ; i++) {
|
||||||
@ -597,6 +606,15 @@ static int lxcContainerPopulateDevices(char **ttyPaths, size_t nttyPaths)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0 ; i < ARRAY_CARDINALITY(links) ; i++) {
|
||||||
|
if (symlink(links[i].src, links[i].dst) < 0) {
|
||||||
|
virReportSystemError(errno,
|
||||||
|
_("Failed to symlink device %s to %s"),
|
||||||
|
links[i].dst, links[i].src);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (access("/dev/pts/ptmx", W_OK) == 0) {
|
if (access("/dev/pts/ptmx", W_OK) == 0) {
|
||||||
/* We have private devpts capability, so bind that */
|
/* We have private devpts capability, so bind that */
|
||||||
if (virFileTouch("/dev/ptmx", 0666) < 0)
|
if (virFileTouch("/dev/ptmx", 0666) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user