{"id":276131,"date":"2016-03-15T10:58:03","date_gmt":"2016-03-15T07:58:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=276131"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=276131","title":{"rendered":"\u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438: namespaces"},"content":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/375\/098\/1be\/3750981be6a67aa0e2ec4687455b81c6.png\" alt=\"namespaces\" width=\"100%\" height=\"100%\"\/><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u044b \u0440\u043e\u0441\u0442\u043e\u043c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438 \u00ab\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043d\u044b\u0445\u00bb \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u041e\u0421&nbsp;Linux. \u041e&nbsp;\u0442\u043e\u043c, \u043a\u0430\u043a \u0438&nbsp;\u0434\u043b\u044f \u043a\u0430\u043a\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b, \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u043d\u043e\u0433\u043e \u0433\u043e\u0432\u043e\u0440\u044f\u0442 \u0438&nbsp;\u043f\u0438\u0448\u0443\u0442. \u0410&nbsp;\u0432\u043e\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430\u043c, \u043b\u0435\u0436\u0430\u0449\u0438\u043c \u0432&nbsp;\u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0443\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f. <\/p>\n<p>  \u0412\u0441\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438&nbsp;&mdash; \u0431\u0443\u0434\u044c&nbsp;\u0442\u043e Docker, LXC \u0438\u043b\u0438 <a href=\"https:\/\/blog.selectel.ru\/systemd-i-kontejnery-znakomstvo-s-systemd-nspawn\/\">systemd-nspawn<\/a>,&mdash; \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430&nbsp;\u0434\u0432\u0443\u0445 \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u044f\u0434\u0440\u0430 Linux: namespaces \u0438&nbsp;cgroups. \u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c namespaces (\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d) \u043c\u044b&nbsp;\u0445\u043e\u0442\u0435\u043b\u0438&nbsp;\u0431\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432&nbsp;\u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. <\/p>\n<p>  \u041d\u0430\u0447\u043d\u0451\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u0434\u0430\u043b\u0435\u043a\u0430. \u0418\u0434\u0435\u0438, \u043b\u0435\u0436\u0430\u0449\u0438\u0435 \u0432&nbsp;\u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d, \u043d\u0435&nbsp;\u043d\u043e\u0432\u044b. \u0415\u0449\u0451 \u0432&nbsp;1979 \u0433\u043e\u0434\u0443 \u0432&nbsp;UNIX \u0431\u044b\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 chroot() &mdash; \u043a\u0430\u043a \u0440\u0430\u0437 \u0441&nbsp;\u0446\u0435\u043b\u044c\u044e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044e \u0438&nbsp;\u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043e\u0442&nbsp;\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u043b\u043e\u0449\u0430\u0434\u043a\u0443 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u0435\u043b\u0438\u0448\u043d\u0438\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u043a\u0430\u043a \u043e\u043d&nbsp;\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0417\u0430\u0442\u0435\u043c \u043c\u044b&nbsp;\u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d \u0432&nbsp;\u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 Linux-\u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<h2>Chroot(): \u043f\u0435\u0440\u0432\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438<\/h2>\n<p>  \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 chroot \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043e\u0442&nbsp;change root, \u0447\u0442\u043e \u0434\u043e\u0441\u043b\u043e\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u0430\u043a \u00ab\u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u043e\u0440\u0435\u043d\u044c\u00bb. \u0421&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 <a href=\"http:\/\/linux.die.net\/man\/2\/chroot\" rel=\"nofollow\">chroot()<\/a> \u0438&nbsp;\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433. \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435, \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u0439 \u0441&nbsp;\u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u044b\u043c \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u043c, \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u044b, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0435\u0441\u044f \u0432&nbsp;\u044d\u0442\u043e\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435. <\/p>\n<p>  \u0424\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 UNIX \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u0443\u044e \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c7f\/dc5\/a3a\/c7fdc5a3a414aa2932051fedb5451391.png\" alt=\"chroot\" width=\"100%\" height=\"100%\"\/><\/p>\n<p>  \u0412\u0435\u0440\u0448\u0438\u043d\u043e\u0439 \u044d\u0442\u043e\u0439 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \/, \u043e\u043d&nbsp;\u0436\u0435 root. \u0412\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438&nbsp;&mdash; usr, local, bin \u0438&nbsp;\u0434\u0440\u0443\u0433\u0438\u0435,&nbsp;&mdash; \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0441&nbsp;\u043d\u0438\u043c.<br \/>  \u0421&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e chroot \u0432&nbsp;\u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0439 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441&nbsp;\u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0438\u0447\u0435\u043c \u043d\u0435&nbsp;\u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442&nbsp;\u043f\u0435\u0440\u0432\u043e\u0433\u043e. \u0424\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u0432&nbsp;\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u044b\u0439 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433, \u043c\u043e\u0436\u043d\u043e \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f2e\/e2a\/330\/f2ee2a33067c5f589fc9c0a13d8c0f5d.png\" alt=\"chroot\" width=\"100%\" height=\"100%\"\/><\/p>\n<p>  \u0424\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438, \u0438 \u043e\u043d\u0438 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0432\u043b\u0438\u044f\u044e\u0442 \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430. \u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 chroot? \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e chroot \u0432 OC 4.4 BSD-Lite. <\/p>\n<p>  \u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 chroot \u043e\u043f\u0438\u0441\u0430\u043d \u0432 \u0444\u0430\u0439\u043b\u0435 <a href=\"https:\/\/github.com\/denghuancong\/4.4BSD-Lite\/blob\/master\/usr\/src\/sys\/kern\/vfs_syscalls.c#L520\" rel=\"nofollow\">vfs_syscall.c<\/a>:<\/p>\n<pre><code>\u0441hroot(p, uap, retval) \tstruct proc *p; \tstruct chroot_args *uap; \tint *retval; { \tregister struct filedesc *fdp = p-&gt;p_fd; \tint error; \tstruct nameidata nd;  \tif (error = suser(p-&gt;p_ucred, &p-&gt;p_acflag)) \t\treturn (error); \tNDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap-&gt;path, p); \tif (error = change_dir(&nd, p)) \t\treturn (error); \tif (fdp-&gt;fd_rdir != NULL) \t\tvrele(fdp-&gt;fd_rdir); \tfdp-&gt;fd_rdir = nd.ni_vp; \treturn (0); }  <\/code><\/pre>\n<p>  \u0421\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043f\u0440\u0435\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u043c\u0438 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430: \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439.<br \/>  \u0412 \u044f\u0434\u0440\u0435 Linux \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 chroot \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435 (\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0432\u0437\u044f\u0442 <a href=\"https:\/\/github.com\/torvalds\/linux\/blob\/master\/fs\/open.c#L431\" rel=\"nofollow\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a>):<\/p>\n<pre><code>SYSCALL_DEFINE1(chroot, const char __user *, filename) { \tstruct path path; \tint error; \tunsigned int lookup_flags = LOOKUP_FOLLOW | LOOKUP_DIRECTORY; retry: \terror = user_path_at(AT_FDCWD, filename, lookup_flags, &path); \tif (error) \t\tgoto out;  \terror = inode_permission(path.dentry-&gt;d_inode, MAY_EXEC | MAY_CHDIR); \tif (error) \t\tgoto dput_and_out;  \terror = -EPERM; \tif (!ns_capable(current_user_ns(), CAP_SYS_CHROOT)) \t\tgoto dput_and_out; \terror = security_path_chroot(&path); \tif (error) \t\tgoto dput_and_out;  \tset_fs_root(current-&gt;fs, &path); \terror = 0; dput_and_out: \tpath_put(&path); \tif (retry_estale(error, lookup_flags)) { \t\tlookup_flags |= LOOKUP_REVAL; \t\tgoto retry; \t} out: \treturn error; } <\/code><\/pre>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b chroot \u0432 Linux \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445.<br \/>  \u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"bash\">$ mkdir test $ chroot test \/bin\/bash <\/code><\/pre>\n<p>  \u0412&nbsp;\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u0442\u043e\u0440\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043c\u044b&nbsp;\u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431&nbsp;\u043e\u0448\u0438\u0431\u043a\u0435:<\/p>\n<pre><code class=\"bash\">chroot: failed to run command \u2018\/bin\/bash\u2019: No such file or directory <\/code><\/pre>\n<p>  \u041e\u0448\u0438\u0431\u043a\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432&nbsp;\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c: \u043d\u0435 \u0431\u044b\u043b\u0430 \u043d\u0430\u0439\u0434\u0435\u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0430\u044f \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0430. \u041e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430&nbsp;\u044d\u0442\u043e\u0442 \u0432\u0430\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442: \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e chroot \u043c\u044b&nbsp;\u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043d\u043e\u0432\u0443\u044e, \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435&nbsp;\u0438\u043c\u0435\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a&nbsp;\u0442\u0435\u043a\u0443\u0449\u0435\u0439. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043d\u043e\u0432\u0430:<\/p>\n<pre><code class=\"bash\">$ mkdir test\/bin $ cp \/bin\/bash test\/bin $ chroot test chroot: failed to run command \u2018\/bin\/bash\u2019: No such file or directory <\/code><\/pre>\n<p>  \u041e\u043f\u044f\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0430&nbsp;&mdash; \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430&nbsp;\u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435&nbsp;\u0442\u0430\u043a\u0430\u044f, \u043a\u0430\u043a \u0432&nbsp;\u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437. \u041f\u0440\u043e\u0448\u043b\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u0432\u044b\u0434\u0430\u043b \u0448\u0435\u043b\u043b, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435&nbsp;\u043d\u0430\u0448\u0451\u043b \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430. \u0412&nbsp;\u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435 \u043e\u0431&nbsp;\u043e\u0448\u0438\u0431\u043a\u0435 \u0441\u043e\u043e\u0431\u0449\u0438\u043b \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043b\u0438\u043d\u043a\u043e\u0432\u0449\u0438\u043a: \u043e\u043d&nbsp;\u043d\u0435&nbsp;\u043d\u0430\u0448\u0451\u043b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a&nbsp;\u043d\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f, \u0438\u0445&nbsp;\u0442\u043e\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432&nbsp;chroot. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">$  ldd \/bin\/bash \tlinux-vdso.so.1 =&gt;  (0x00007fffd08fa000) \tlibtinfo.so.5 =&gt; \/lib\/x86_64-linux-gnu\/libtinfo.so.5 (0x00007f30289b2000) \tlibdl.so.2 =&gt; \/lib\/x86_64-linux-gnu\/libdl.so.2 (0x00007f30287ae000) \tlibc.so.6 =&gt; \/lib\/x86_64-linux-gnu\/libc.so.6 (0x00007f30283e8000) \t\/lib64\/ld-linux-x86-64.so.2 (0x00007f3028be6000) <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"bash\">$ mkdir test\/lib test\/lib64 $ cp \/lib\/x86_64-linux-gnu\/libtinfo.so.5 test\/lib\/ $ cp \/lib\/x86_64-linux-gnu\/libdl.so.2 test\/lib\/ $ cp \/lib64\/ld-linux-x86-64.so.2 test\/lib64\/ $ cp \/lib\/x86_64-linux-gnu\/libc.so.6 test\/lib $ chroot test bash-4.3#  <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c! \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432&nbsp;\u043d\u043e\u0432\u043e\u0439 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u043c\u0430\u043d\u0434\u0443&nbsp;ls:<\/p>\n<pre><code class=\"bash\">bash-4.3# ls <\/code><\/pre>\n<p>  \u0412&nbsp;\u043e\u0442\u0432\u0435\u0442 \u043c\u044b&nbsp;\u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431&nbsp;\u043e\u0448\u0438\u0431\u043a\u0435:<\/p>\n<pre><code class=\"bash\">bash: ls: command not found <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u043f\u043e\u043d\u044f\u0442\u043d\u0430: \u0432&nbsp;\u043d\u043e\u0432\u043e\u0439 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 ls&nbsp;\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442. \u041d\u0443\u0436\u043d\u043e \u043e\u043f\u044f\u0442\u044c \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b \u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043a\u0430\u043a \u044d\u0442\u043e \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435. \u0412&nbsp;\u044d\u0442\u043e\u043c \u0438&nbsp;\u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u044b\u0439 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a chroot: \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u043d\u0443\u0436\u043d\u043e \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0415\u0441\u0442\u044c \u0443&nbsp;chroot \u0438&nbsp;\u0440\u044f\u0434 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432 \u0441&nbsp;\u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. <\/p>\n<p>  \u041f\u043e\u043f\u044b\u0442\u043a\u0438 \u0443\u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c chroot \u0438&nbsp;\u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0434\u0451\u0436\u043d\u0443\u044e \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044e \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u044c \u043d\u0435\u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e: \u0442\u0430\u043a, \u0432&nbsp;\u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0442\u0430\u043a\u0438\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438, \u043a\u0430\u043a <a href=\"https:\/\/www.freebsd.org\/doc\/handbook\/jails.html\" rel=\"nofollow\">FreeBSD Jail<\/a> \u0438&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Solaris_Containers\">Solaris Zones<\/a>. <br \/>  \u0412&nbsp;\u044f\u0434\u0440\u0435 Linux \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0431\u044b\u043b\u0430 \u0443\u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0430 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u043d\u043e\u0432\u044b\u0445 \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c \u0438&nbsp;\u043d\u043e\u0432\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437&nbsp;\u043d\u0438\u0445 \u043c\u044b&nbsp;\u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u043d\u0438\u0436\u0435.<\/p>\n<h2>\u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d<\/h2>\n<p>  \u041f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d (\u0430\u043d\u0433\u043b. namespace)&nbsp;&mdash; \u044d\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u044f\u0434\u0440\u0430 Linux, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0434\u0440\u0443\u0433 \u043e\u0442&nbsp;\u0434\u0440\u0443\u0433\u0430. \u0420\u0430\u0431\u043e\u0442\u0430 \u043f\u043e&nbsp;\u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u044b\u043b\u0430 \u043d\u0430\u0447\u0430\u0442\u0430 \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 \u044f\u0434\u0440\u0430 2.4.19.<br \/>  \u041d\u0430&nbsp;\u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432&nbsp;Linux \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0448\u0435\u0441\u0442\u044c \u0442\u0438\u043f\u043e\u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d:<\/p>\n<table>\n<tr>\n<th>\u041f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d<\/th>\n<th>\u0427\u0442\u043e \u0438\u0437\u043e\u043b\u0438\u0440\u0443\u0435\u0442<\/th>\n<\/tr>\n<tr>\n<td>PID<\/td>\n<td>PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432<\/td>\n<\/tr>\n<tr>\n<td>NETWORK<\/td>\n<td>\u0421\u0435\u0442\u0435\u0432\u044b\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u0441\u0442\u0435\u043a\u0438, \u043f\u043e\u0440\u0442\u044b \u0438 \u0442.\u043f.<\/td>\n<\/tr>\n<tr>\n<td>USER<\/td>\n<td>ID \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0433\u0440\u0443\u043f\u043f<\/td>\n<\/tr>\n<tr>\n<td>MOUNT<\/td>\n<td>\u0422\u043e\u0447\u043a\u0438 \u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/td>\n<\/tr>\n<tr>\n<td>IPC<\/td>\n<td>SystemV IPC, \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 POSIX<\/td>\n<\/tr>\n<tr>\n<td>UTS<\/td>\n<td>\u0418\u043c\u044f \u0445\u043e\u0441\u0442\u0430 \u0438 \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u0435 \u0438\u043c\u044f NIS<\/td>\n<\/tr>\n<\/table>\n<p>  \u0412\u0441\u0435 \u044d\u0442\u0438 \u0442\u0438\u043f\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u043c\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438 (Docker, LXC \u0438&nbsp;\u0434\u0440\u0443\u0433\u0438\u043c\u0438) \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c.<\/p>\n<h2>PID: \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044f PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432<\/h2>\n<p>  \u0418\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438 \u0432&nbsp;\u044f\u0434\u0440\u0435 Linux \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u0434\u0435\u0440\u0435\u0432\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. \u0414\u0435\u0440\u0435\u0432\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u0434\u0435\u0440\u0435\u0432\u0443 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u0432 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<br \/>  \u0421&nbsp;\u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 namespaces \u0441\u0442\u0430\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0440\u0443\u0433 \u043e\u0442&nbsp;\u0434\u0440\u0443\u0433\u0430. <\/p>\n<p>  \u041f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0432&nbsp;Linux \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441&nbsp;\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u043d\u043e\u043c\u0435\u0440\u043e\u043c (PID) 1. \u0412&nbsp;\u0434\u0435\u0440\u0435\u0432\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043e\u043d&nbsp;\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u043c. \u041e\u043d&nbsp;\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0438&nbsp;\u0441\u043b\u0443\u0436\u0431\u044b. \u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c namespaces \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u043e\u0442\u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0435\u0440\u0435\u0432\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0441&nbsp;\u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c PID 1. \u041f\u0440\u043e\u0446\u0435\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0442\u0430\u043a\u043e\u0435 \u043e\u0442\u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0435, \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430, \u043d\u043e&nbsp;\u0435\u0433\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u043c \u0432&nbsp;\u043d\u043e\u0432\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435. <\/p>\n<p>  \u041f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0432&nbsp;\u043d\u043e\u0432\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435 \u043d\u0438\u043a\u0430\u043a \u043d\u0435&nbsp;\u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0441&nbsp;\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u0438&nbsp;\u0434\u0430\u0436\u0435 \u043d\u0435&nbsp;\u00ab\u0432\u0438\u0434\u044f\u0442\u00bb \u0435\u0433\u043e. \u0412&nbsp;\u0442\u043e&nbsp;\u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c \u0432&nbsp;\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432\u0441\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430. \u041d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u044d\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0430&nbsp;\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0445\u0435\u043c\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/852\/7b2\/45f\/8527b245fa0293e7d6786bf1f4664342.png\" alt=\"PID Namespace\" width=\"100%\" height=\"100%\"\/><\/p>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d PID: \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432&nbsp;\u043d\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0451\u043d PID, a&nbsp;\u0442\u043e\u0442 \u0432&nbsp;\u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432&nbsp;\u043d\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438&nbsp;\u0442.\u043f.<\/p>\n<p>  \u041e\u0434\u0438\u043d \u0438&nbsp;\u0442\u043e\u0442&nbsp;\u0436\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 PID (\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d).<\/p>\n<p>  \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d PID \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <a href=\"http:\/\/linux.die.net\/man\/2\/clone\" rel=\"nofollow\">clone()<\/a> c&nbsp;\u0444\u043b\u0430\u0433\u043e\u043c CLONE_NEWPID. \u0421&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u0444\u043b\u0430\u0433\u0430 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432&nbsp;\u043d\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0451\u043d \u0438&nbsp;\u0432&nbsp;\u043d\u043e\u0432\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432&nbsp;\u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430&nbsp;\u044f\u0437\u044b\u043a\u0435&nbsp;C:<\/p>\n<pre><code> #define _GNU_SOURCE #include &lt;sched.h&gt; #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;sys\/wait.h&gt; #include &lt;unistd.h&gt;  static char child_stack[1048576];  static int child_fn() {   printf(&quot;PID: %ld\\n&quot;, (long)getpid());   return 0; }  int main() {   pid_t child_pid = clone(child_fn, child_stack+1048576, CLONE_NEWPID | SIGCHLD, NULL);   printf(&quot;clone() = %ld\\n&quot;, (long)child_pid);    waitpid(child_pid, NULL, 0);   return 0; } <\/code><\/pre>\n<p>  \u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0438&nbsp;\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u044d\u0442\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443. \u041f\u043e&nbsp;\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0435\u0451&nbsp;\u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u044b&nbsp;\u0443\u0432\u0438\u0434\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u044b\u0432\u043e\u0434:<\/p>\n<pre><code class=\"bash\">clone() = 9910 PID: 1 <\/code><\/pre>\n<p>  \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432&nbsp;\u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e. \u0424\u0443\u043d\u043a\u0446\u0438\u044f clone() \u0441\u043e\u0437\u0434\u0430\u043b\u0430 \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0432 \u0442\u0435\u043a\u0443\u0449\u0438\u0439, \u0438&nbsp;\u043d\u0430\u0447\u0430\u043b\u0430 \u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u0438\u043b\u0430 \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0442&nbsp;\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u0438&nbsp;\u0441\u043e\u0437\u0434\u0430\u043b\u0430 \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. <\/p>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443e\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438&nbsp;\u0443\u0437\u043d\u0430\u0442\u044c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 PID&nbsp;\u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430:<\/p>\n<pre><code>static int child_fn() {   printf(&quot;\u0420\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 PID: %ld\\n&quot;, (long)getppid());   return 0; } <\/code><\/pre>\n<p>  \u0412\u044b\u0432\u043e\u0434 \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">clone() = 9985 \u0420\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 PID: 0 <\/code><\/pre>\n<p>  \u0421\u0442\u0440\u043e\u043a\u0430 \u00ab\u0420\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 PID: 0\u00bb&nbsp;\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0443&nbsp;\u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043d\u0430\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043d\u0435\u0442. \u0412\u043d\u0435\u0441\u0451\u043c \u0432&nbsp;\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0438&nbsp;\u0443\u0431\u0435\u0440\u0451\u043c \u0444\u043b\u0430\u0433 CLONE_NEWPID \u0438\u0437&nbsp;\u0432\u044b\u0437\u043e\u0432\u0430 clone():<\/p>\n<pre><code>pid_t child_pid = clone(child_fn, child_stack+1048576, SIGCHLD, NULL); <\/code><\/pre>\n<p>  \u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 clone \u0432&nbsp;\u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0430\u043a&nbsp;\u0436\u0435, \u043a\u0430\u043a <a href=\"http:\/\/linux.die.net\/man\/2\/fork\" rel=\"nofollow\">fork()<\/a> \u0438&nbsp;\u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043b \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u041c\u0435\u0436\u0434\u0443 fork() \u0438&nbsp;clone(), \u043e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e.<\/p>\n<p>  Fork() \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043e\u043f\u0438\u044e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e. \u0420\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e&nbsp;\u0432\u0441\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e, \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c\u0438 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0438&nbsp;\u0442.\u043f.<\/p>\n<p>  \u0412&nbsp;\u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442&nbsp;fork() \u0432\u044b\u0437\u043e\u0432 clone() \u043d\u0435&nbsp;\u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043a\u043e\u043f\u0438\u044e, \u043d\u043e&nbsp;\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u043c \u0438&nbsp;\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438. \u0412&nbsp;\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043a\u043e\u0434\u0430 \u0441&nbsp;\u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 clone \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 child_stack, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0434\u0430\u0451\u0442 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u0438&nbsp;\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c, \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0435&nbsp;\u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432&nbsp;\u0442\u043e\u043c&nbsp;\u0436\u0435 \u0441\u0442\u0435\u043a\u0435, \u0447\u0442\u043e \u0438&nbsp;\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e \u0438&nbsp;\u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430&nbsp;\u043d\u0435\u0433\u043e \u0432&nbsp;\u0432\u044b\u0437\u043e\u0432\u0435 clone(). \u0415\u0449\u0451 \u043e\u0434\u0438\u043d \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0441&nbsp;\u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 clone() &mdash; \u044d\u0442\u043e \u0444\u043b\u0430\u0433\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u0438&nbsp;\u0434\u043e\u0447\u0435\u0440\u043d\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438. \u0412&nbsp;\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u043c \u043d\u0430\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0444\u043b\u0430\u0433 CLONE_NEWPID, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d \u0432&nbsp;\u043d\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0451\u043d PID. \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u043b\u0430\u0433\u043e\u0432 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043d\u0438\u0436\u0435.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044e \u043d\u0430&nbsp;\u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043c\u044b&nbsp;\u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438. \u041d\u043e&nbsp;\u044d\u0442\u043e&nbsp;&mdash; \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0448\u0430\u0433. \u0417\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0439 \u0432&nbsp;\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0451\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u043e&nbsp;\u0432\u0441\u0435\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c. \u0415\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0443\u0448\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 80-\u0439 \u043f\u043e\u0440\u0442, \u044d\u0442\u043e \u044d\u0442\u043e\u0442 \u043f\u043e\u0440\u0442 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. \u0418\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d.<\/p>\n<h2>NET: \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044f \u0441\u0435\u0442\u0435\u0439<\/h2>\n<p>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0443 \u0438\u043c\u0451\u043d NET \u043c\u044b&nbsp;\u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u0434\u043b\u044f \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0441e\u0442\u0435\u0432\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b. \u0414\u0430\u0436\u0435 loopback-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c.<\/p>\n<p>  \u0421\u0435\u0442\u0435\u0432\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 clone() \u0441&nbsp;\u0444\u043b\u0430\u0433\u043e\u043c CLONE_NEWNET. \u0422\u0430\u043a\u0436\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e iproute2:<\/p>\n<pre><code class=\"bash\">$ ip netns add netns1 <\/code><\/pre>\n<p>  \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f strace \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"bash\">..... socket(PF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, 0) = 3 setsockopt(3, SOL_SOCKET, SO_SNDBUF, [32768], 4) = 0 setsockopt(3, SOL_SOCKET, SO_RCVBUF, [1048576], 4) = 0 bind(3, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 0 getsockname(3, {sa_family=AF_NETLINK, pid=1270, groups=00000000}, [12]) = 0 mkdir(&quot;\/var\/run\/netns&quot;, 0755)           = 0 mount(&quot;&quot;, &quot;\/var\/run\/netns&quot;, &quot;none&quot;, MS_REC|MS_SHARED, NULL) = -1 EINVAL (Invalid argument) mount(&quot;\/var\/run\/netns&quot;, &quot;\/var\/run\/netns&quot;, 0x4394fd, MS_BIND, NULL) = 0 mount(&quot;&quot;, &quot;\/var\/run\/netns&quot;, &quot;none&quot;, MS_REC|MS_SHARED, NULL) = 0 open(&quot;\/var\/run\/netns\/netns1&quot;, O_RDONLY|O_CREAT|O_EXCL, 0) = 4 close(4)                                = 0 unshare(CLONE_NEWNET)                   = 0 mount(&quot;\/proc\/self\/ns\/net&quot;, &quot;\/var\/run\/netns\/netns1&quot;, 0x4394fd, MS_BIND, NULL) = 0 exit_group(0)                           = ? +++ exited with 0 +++ <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435: \u0437\u0434\u0435\u0441\u044c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0451\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <a href=\"http:\/\/linux.die.net\/man\/2\/unshare\" rel=\"nofollow\">unshare()<\/a>, \u0430&nbsp;\u043d\u0435&nbsp;\u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0439 \u043d\u0430\u043c clone. Unshare() \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u0438\u043b\u0438 \u0442\u0440\u0435\u0434\u0443 \u043e\u0442\u0434\u0435\u043b\u044f\u0442\u044c \u0447\u0430\u0441\u0442\u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043e\u0431\u0449\u0438\u0435 \u0441&nbsp;\u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 (\u0438\u043b\u0438 \u0442\u0440\u0435\u0434\u0430\u043c\u0438).<\/p>\n<p>  \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0432&nbsp;\u043d\u043e\u0432\u043e\u0435 \u0441\u0435\u0442\u0435\u0432\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d?<br \/>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0441\u043e\u0437\u0434\u0430\u0432\u0448\u0438\u0439 \u043d\u043e\u0432\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d, \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u0438&nbsp;\u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437&nbsp;\u044d\u0442\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f. <\/p>\n<p>  \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0432&nbsp;\u044f\u0434\u0440\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432&nbsp;&mdash; <a href=\"http:\/\/linux.die.net\/man\/2\/setns\" rel=\"nofollow\">setns()<\/a>. \u0421&nbsp;\u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u043b\u0438 \u0442\u0440\u0435\u0434 \u0432&nbsp;\u043d\u0443\u0436\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430&nbsp;\u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f. \u041e\u043d&nbsp;\u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432&nbsp;\u0444\u0430\u0439\u043b\u0435 \/proc\/&lt;PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430&gt;\/ns\/net. \u041e\u0442\u043a\u0440\u044b\u0432 \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b, \u043c\u044b&nbsp;\u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 setns(). <\/p>\n<p>  \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0439\u0442\u0438 \u0438&nbsp;\u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0443\u0442\u0451\u043c. \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b ip&nbsp;\u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0444\u0430\u0439\u043b \u0432&nbsp;\u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \/var\/run\/netns\/ (\u0441\u043c. \u0432&nbsp;\u0432\u044b\u0432\u043e\u0434\u0435 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u0432\u044b\u0448\u0435). \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b.<\/p>\n<p>  \u0421\u0435\u0442\u0435\u0432\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d \u043d\u0435\u043b\u044c\u0437\u044f \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430. \u041e\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u043f\u043e\u043a\u0430 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0445\u043e\u0442\u044f&nbsp;\u0431\u044b \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441.<\/p>\n<h2>MOUNT: \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/h2>\n<p>  \u041e\u0431&nbsp;\u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u043d\u0430&nbsp;\u0443\u0440\u043e\u0432\u043d\u0435 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043c\u044b&nbsp;\u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u0438 \u0432\u044b\u0448\u0435, \u043a\u043e\u0433\u0434\u0430 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u043b\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 chroot (). \u041c\u044b&nbsp;\u043e\u0442\u043c\u0435\u0442\u0438\u043b\u0438, \u0447\u0442\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 chroot() \u043d\u0435&nbsp;\u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043d\u0430\u0434\u0451\u0436\u043d\u043e\u0439 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438. \u0421&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e&nbsp;\u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d MOUNT \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0441&nbsp;\u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/229\/84d\/87d\/22984d87d3230585163aa511726d2654.png\" alt=\"MOUNT namespace\" width=\"100%\" height=\"100%\"\/><\/p>\n<p>  \u0414\u043b\u044f \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 clone() c&nbsp;\u0444\u043b\u0430\u0433\u043e\u043c CLONE_NEWNS:<\/p>\n<pre><code>clone(child_fn, child_stack+1048576, CLONE_NEWPID | CLONE_NEWNET | CLONE_NEWNS | SIGCHLD, NULL) <\/code><\/pre>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u00ab\u0432\u0438\u0434\u0438\u0442\u00bb \u0442\u0435&nbsp;\u0436\u0435 \u0442\u043e\u0447\u043a\u0438 \u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0447\u0442\u043e \u0438&nbsp;\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0451\u043d \u0432&nbsp;\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d, \u043a&nbsp;\u043d\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0438&nbsp;\u044d\u0442\u043e \u043d\u0438\u043a\u0430\u043a \u043d\u0435&nbsp;\u0437\u0430\u0442\u0440\u043e\u043d\u0435\u0442 \u043d\u0438&nbsp;\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043d\u0438&nbsp;\u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d.<\/p>\n<h2>\u0414\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d<\/h2>\n<p>  \u0418\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043c\u0435\u0449\u0451\u043d \u0432&nbsp;\u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d: UID, IPC \u0438&nbsp;PTS. UID \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0438 root \u0432&nbsp;\u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d. \u0421&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d IPC \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0434\u043b\u044f \u043a\u043e\u043c\u043c\u0443\u043d\u0438\u043a\u0430\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438.<br \/>  UTS \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432: \u0438\u043c\u0435\u043d\u0438 \u0443\u0437\u043b\u0430 (nodename) \u0438&nbsp;\u0438\u043c\u0435\u043d\u0438 \u0434\u043e\u043c\u0435\u043d\u0430 (domainame), \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c \u0432\u044b\u0437\u043e\u0432\u043e\u043c <a href=\"http:\/\/man7.org\/linux\/man-pages\/man2\/uname.2.html\" rel=\"nofollow\">uname()<\/a>. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0449\u0451 \u043e\u0434\u043d\u0443 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443:<\/p>\n<pre><code>#define _GNU_SOURCE #include &lt;sched.h&gt; #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;sys\/utsname.h&gt; #include &lt;sys\/wait.h&gt; #include &lt;unistd.h&gt;   static char child_stack[1048576];  static void print_nodename() {   struct utsname utsname;   uname(&utsname);   printf(&quot;%s\\n&quot;, utsname.nodename); }  static int child_fn() {   printf(&quot;\u041d\u043e\u0432\u043e\u0435 \u0438\u043c\u044f: &quot;);   print_nodename();    printf(&quot;\u0418\u043c\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043e \u0432 \u043d\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0451\u043d!\\n&quot;);   sethostname(&quot;NewOS&quot;, 6);    printf(&quot;\u041d\u043e\u0432\u043e\u0435 \u0438\u043c\u044f \u0443\u0437\u043b\u0430: &quot;);   print_nodename();   return 0; }  int main() {   printf(&quot;\u041f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u043c\u044f \u0443\u0437\u043b\u0430: &quot;);   print_nodename();    pid_t child_pid = clone(child_fn, child_stack+1048576, CLONE_NEWUTS | SIGCHLD, NULL);    sleep(1);    printf(&quot;\u041f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u043c\u044f \u0443\u0437\u043b\u0430: &quot;);   print_nodename();    waitpid(child_pid, NULL, 0);    return 0; } <\/code><\/pre>\n<p>  \u0412\u044b\u0432\u043e\u0434 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">\u041f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u043c\u044f \u0443\u0437\u043b\u0430: lilah \u041d\u043e\u0432\u043e\u0435 \u0438\u043c\u044f \u0443\u0437\u043b\u0430: lilah \u0418\u043c\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043e \u0432 \u043d\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0451\u043d! New UTS namespace nodename: NewOS <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0444\u0443\u043d\u043a\u0446\u0438\u044f child_fn() \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0438\u043c\u044f \u0443\u0437\u043b\u0430, \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u0435\u0433\u043e, \u0430&nbsp;\u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0443\u0436\u0435 \u043d\u043e\u0432\u043e\u0435 \u0438\u043c\u044f. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u0412&nbsp;\u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b&nbsp;\u0432&nbsp;\u043e\u0431\u0449\u0438\u0445 \u0447\u0435\u0440\u0442\u0430\u0445 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c namespaces. \u041d\u0430\u0434\u0435\u0435\u043c\u0441\u044f, \u043e\u043d\u0430 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432. <br \/>  \u041f\u043e&nbsp;\u0442\u0440\u0430\u0434\u0438\u0446\u0438\u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430&nbsp;\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b:<\/p>\n<ul>\n<li><a href=\"http:\/\/lwn.net\/Articles\/531114\/\" rel=\"nofollow\">\u0446\u0438\u043a\u043b \u0441\u0442\u0430\u0442\u0435\u0439 \u043e&nbsp;\u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d \u043d\u0430&nbsp;\u043f\u043e\u0440\u0442\u0430\u043b\u0435 LWN.net;<\/a><\/li>\n<li><a href=\"http:\/\/man7.org\/linux\/man-pages\/man7\/namespaces.7.html\" rel=\"nofollow\">\u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 namespaces;<\/a><\/li>\n<li><a href=\"http:\/\/www.haifux.org\/lectures\/299\/netLec7.pdf\">\u043a\u043e\u043d\u0441\u043f\u0435\u043a\u0442 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u043b\u0435\u043a\u0446\u0438\u0438 \u043e&nbsp;namespaces \u0438&nbsp;cgroups<\/a>.<\/li>\n<\/ul>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u044b&nbsp;\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c. \u0412&nbsp;\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043c\u044b&nbsp;\u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c \u043e&nbsp;\u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0435 cgroups.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e \u0442\u0435\u043c \u0438\u043b\u0438 \u0438\u043d\u044b\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0437\u0434\u0435\u0441\u044c &mdash; \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c <a href=\"https:\/\/blog.selectel.ru\/mexanizmy-kontejnerizacii-namespaces\/\">\u0432 \u043d\u0430\u0448 \u0431\u043b\u043e\u0433<\/a>.               <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/279281\/\"> https:\/\/habrahabr.ru\/post\/279281\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/375\/098\/1be\/3750981be6a67aa0e2ec4687455b81c6.png\" alt=\"namespaces\" width=\"100%\" height=\"100%\"\/><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u044b \u0440\u043e\u0441\u0442\u043e\u043c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438 \u00ab\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043d\u044b\u0445\u00bb \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u041e\u0421&nbsp;Linux. \u041e&nbsp;\u0442\u043e\u043c, \u043a\u0430\u043a \u0438&nbsp;\u0434\u043b\u044f \u043a\u0430\u043a\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b, \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u043d\u043e\u0433\u043e \u0433\u043e\u0432\u043e\u0440\u044f\u0442 \u0438&nbsp;\u043f\u0438\u0448\u0443\u0442. \u0410&nbsp;\u0432\u043e\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430\u043c, \u043b\u0435\u0436\u0430\u0449\u0438\u043c \u0432&nbsp;\u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0443\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f. <\/p>\n<p>  \u0412\u0441\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438&nbsp;&mdash; \u0431\u0443\u0434\u044c&nbsp;\u0442\u043e Docker, LXC \u0438\u043b\u0438 <a href=\"https:\/\/blog.selectel.ru\/systemd-i-kontejnery-znakomstvo-s-systemd-nspawn\/\">systemd-nspawn<\/a>,&mdash; \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430&nbsp;\u0434\u0432\u0443\u0445 \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u044f\u0434\u0440\u0430 Linux: namespaces \u0438&nbsp;cgroups. \u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c namespaces (\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d) \u043c\u044b&nbsp;\u0445\u043e\u0442\u0435\u043b\u0438&nbsp;\u0431\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432&nbsp;\u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. <\/p>\n<p>  \u041d\u0430\u0447\u043d\u0451\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u0434\u0430\u043b\u0435\u043a\u0430. \u0418\u0434\u0435\u0438, \u043b\u0435\u0436\u0430\u0449\u0438\u0435 \u0432&nbsp;\u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d, \u043d\u0435&nbsp;\u043d\u043e\u0432\u044b. \u0415\u0449\u0451 \u0432&nbsp;1979 \u0433\u043e\u0434\u0443 \u0432&nbsp;UNIX \u0431\u044b\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 chroot() &mdash; \u043a\u0430\u043a \u0440\u0430\u0437 \u0441&nbsp;\u0446\u0435\u043b\u044c\u044e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u044e \u0438&nbsp;\u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043e\u0442&nbsp;\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u043b\u043e\u0449\u0430\u0434\u043a\u0443 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u0435\u043b\u0438\u0448\u043d\u0438\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u043a\u0430\u043a \u043e\u043d&nbsp;\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0417\u0430\u0442\u0435\u043c \u043c\u044b&nbsp;\u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d \u0432&nbsp;\u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 Linux-\u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-276131","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/276131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=276131"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/276131\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=276131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=276131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=276131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}