{"id":293235,"date":"2019-08-12T03:00:20","date_gmt":"2019-08-12T03:00:20","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=293235"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=293235","title":{"rendered":"\u0413\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0432 Linux namespaces, \u0447\u0430\u0441\u0442\u044c 2"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/post\/458462\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 <\/a> \u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043a\u0443\u043d\u0443\u043b\u0438 \u043f\u0430\u043b\u044c\u0446\u044b \u043d\u043e\u0433 \u0432 \u0432\u043e\u0434\u044b namespace \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0443\u0432\u0438\u0434\u0435\u043b\u0438, \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c UTS namespace. \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u043c\u044b \u043e\u0441\u0432\u0435\u0442\u0438\u043c User namespace.<\/p>\n<p>  <\/p>\n<p>\u0421\u0440\u0435\u0434\u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c\u044e, <a href=\"http:\/\/man7.org\/linux\/man-pages\/man7\/user_namespaces.7.html\">User namespaces<\/a> \u0438\u0437\u043e\u043b\u0438\u0440\u0443\u0435\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0433\u0440\u0443\u043f\u043f \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u043c\u044b \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u043c\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u0445 user \u0438 group ID (UID \u0438 GID \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e), \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0438 \u0438\u0433\u0440\u0430\u044e\u0442 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u043e\u043b\u044c \u0432 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0432\u043e \u0432\u0441\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<p>  <\/p>\n<p>\u0412 Linux \u044d\u0442\u0438 ID \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0433\u0440\u0443\u043f\u043f\u044b \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u0418 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0438\u0437 \u043d\u0438\u0445, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0434\u0430\u0442\u044c \u043a \u043a\u0430\u043a\u0438\u043c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438\/\u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f. \u0421\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043d\u0430\u043d\u0435\u0441\u0442\u0438 \u0443\u0449\u0435\u0440\u0431 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u043c\u0438 ID.<a name=\"habracut\"><\/a><\/p>\n<p>  <\/p>\n<h2 id=\"user-namespaces\">User Namespaces<\/h2>\n<p>  <\/p>\n<blockquote><p><em>\u041c\u044b \u043f\u0440\u043e\u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 user namespaces, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 ID. \u0422\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u0438\u0435 \u0436\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u044b \u043a \u0433\u0440\u0443\u043f\u043f\u043e\u0432\u044b\u043c ID, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u0434\u0430\u043b\u0435\u0435 \u0432 \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0441\u0442\u0435.<\/em><\/p><\/blockquote>\n<p>User namespace \u0438\u043c\u0435\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043a\u043e\u043f\u0438\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0438 \u0433\u0440\u0443\u043f\u043f\u043e\u0432\u043e\u0433\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432. \u0417\u0430\u0442\u0435\u043c \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u043c ID \u2014 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 user namespace, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043e\u043d \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 <code>$pid<\/code> \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043e\u0442 <code>root<\/code> (UID 0) \u0432 user namespace <strong>P<\/strong> \u0438 \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043e\u0442 <code>proxy<\/code> (UID 13) \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 user namespace <strong>Q<\/strong>.<\/p>\n<p>  <\/p>\n<p>User spaces \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c\u0438! \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e namespace (\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439) \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u043e\u043b\u044c \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d, \u0438 \u043a\u0430\u0436\u0434\u043e\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d \u043c\u043e\u0436\u0435\u0442, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0438\u043c\u0435\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435\u2026 (\u0434\u043e \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u0435\u043b\u0430 \u0432 32 \u0443\u0440\u043e\u0432\u043d\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438). \u041a\u043e\u0433\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 namespace <strong>C<\/strong>, Linux \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 User namespace \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 <strong>P<\/strong>, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0435\u0433\u043e <strong>C<\/strong>, \u043a\u0430\u043a \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0434\u043b\u044f <strong>C<\/strong> \u0438 \u044d\u0442\u043e \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043e \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0441\u0435 user namespaces \u0438\u043c\u0435\u044e\u0442 \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f, \u043e\u0431\u0440\u0430\u0437\u0443\u044f \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d. \u0418, \u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0434\u0435\u0440\u0435\u0432\u044c\u044f\u043c\u0438, \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430\u0432\u0435\u0440\u0445\u0443, \u0433\u0434\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 (\u0438\u043b\u0438 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439, \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0439) namespace. \u042d\u0442\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0435 \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442\u0435 \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043d\u0443\u044e \u043c\u0430\u0433\u0438\u044e, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e user namespace, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0442 \u0432\u0441\u0435 \u0432\u0430\u0448\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 user namespace \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<\/p>\n<p>  <\/p>\n<blockquote><p><em>\u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 P$ \u0438 C$ \u0434\u043b\u044f \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0448\u0435\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c <strong>P<\/strong> \u0438 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u043c <strong>C<\/strong> user namespace \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/em><\/p><\/blockquote>\n<p>  <\/p>\n<h2 id=\"mappingi-user-id\">\u041c\u0430\u043f\u043f\u0438\u043d\u0433\u0438 User ID<\/h2>\n<p>  <\/p>\n<p>User namespace, \u043f\u043e \u0441\u0443\u0442\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0430\u0431\u043e\u0440 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u044e\u0449\u0443\u044e \u044d\u0442\u0438 ID \u0441 \u043d\u0430\u0431\u043e\u0440\u043e\u043c ID \u0434\u0440\u0443\u0433\u0438\u0445 user namespace \u2014 \u044d\u0442\u043e\u0442 \u0434\u0443\u044d\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e ID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">P$ whoami iffy P$ id uid=1000(iffy) gid=1000(iffy)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0434\u0440\u0443\u0433\u043e\u043c \u043e\u043a\u043d\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0448\u0435\u043b\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>unshare<\/code> (\u0444\u043b\u0430\u0433 <code>-U<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432 \u043d\u043e\u0432\u043e\u043c user namespace):<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">P$ whoami iffy P$ unshare -U bash # \u0412\u0445\u043e\u0434\u0438\u043c \u0432 \u043d\u043e\u0432\u044b\u0439 \u0448\u0435\u043b\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u043c user namespace C$ whoami nobody C$ id uid=65534(nobody) gid=65534(nogroup)  C$ ls -l my_file -rw-r--r-- 1 nobody nogroup 0 May 18 16:00 my_file<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0433\u043e\u0434\u0438\u0442\u0435, \u043a\u0442\u043e? \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u0432\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u043c \u0448\u0435\u043b\u043b\u0435 \u0432 <strong>C<\/strong>, \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f nobody? \u041c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <strong>C<\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u043c user namespace, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0438\u043d\u043e\u0439 \u0432\u0438\u0434 ID. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0438 \u043d\u0435 \u0436\u0434\u0430\u043b\u0438, \u0447\u0442\u043e \u043e\u043d \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f <code>iffy<\/code>, \u043d\u043e <code>nobody<\/code> \u2014 \u044d\u0442\u043e \u043d\u0435 \u0441\u043c\u0435\u0448\u043d\u043e. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u044d\u0442\u043e \u0437\u0434\u043e\u0440\u043e\u0432\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438 \u0445\u043e\u0442\u0435\u043b\u0438. \u041d\u0430\u0448 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0442\u0435\u043f\u0435\u0440\u044c \u0438\u043c\u0435\u0435\u0442 \u0434\u0440\u0443\u0433\u0443\u044e (\u0445\u043e\u0442\u044c \u0438 \u043f\u043e\u043b\u043e\u043c\u0430\u043d\u043d\u0443\u044e) \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 ID \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u2014 \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u043d \u0432\u0438\u0434\u0438\u0442 \u0432\u0441\u0435\u0445, \u043a\u0430\u043a <code>nobody<\/code> \u0438 \u043a\u0430\u0436\u0434\u0443\u044e \u0433\u0440\u0443\u043f\u043f\u0443 \u043a\u0430\u043a <code>nogroup<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u044e\u0449\u0430\u044f UID \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e user namespace \u0441 \u0434\u0440\u0443\u0433\u0438\u043c, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <strong>\u043c\u0430\u043f\u043f\u0438\u043d\u0433\u043e\u043c user ID<\/strong>. \u041e\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f ID \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c user namespace \u0434\u043b\u044f ID \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 namespace \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 user namespace \u0441\u0432\u044f\u0437\u0430\u043d \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u043d\u0438\u043c \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u043e\u043c UID (\u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0435\u0449\u0435 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0443 GID \u0434\u043b\u044f group ID).<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0438 \u0435\u0441\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u0441\u043b\u043e\u043c\u0430\u043d\u043e \u0432 \u043d\u0430\u0448\u0435\u043c <code>unshare<\/code> \u0448\u0435\u043b\u043b\u0435. \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043d\u043e\u0432\u044b\u0435 user namespaces \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u0443\u0441\u0442\u043e\u0433\u043e \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430, \u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 Linux \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0443\u0436\u0430\u0441\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f <code>nobody<\/code>. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u043b\u0438\u0431\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u043d\u0430\u0448\u0435\u043c \u043d\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0451\u043d. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>setuid<\/code>), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 UID, \u043f\u043e\u0442\u0435\u0440\u043f\u044f\u0442 \u043d\u0435\u0443\u0434\u0430\u0447\u0443. \u041d\u043e \u043d\u0435 \u0431\u043e\u0439\u0442\u0435\u0441\u044c! \u0412\u0435\u0440\u043d\u044b\u0439 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u0438 <em>\u0432\u0441\u0451-\u0435\u0441\u0442\u044c-\u0444\u0430\u0439\u043b<\/em>, Linux \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u044d\u0442\u043e\u0442 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b <code>\/proc<\/code> \u0432 <code>\/proc\/$pid\/uid_map<\/code> (\u0432 <code>\/proc\/$pid\/gid_map<\/code> \u0434\u043b\u044f GID), \u0433\u0434\u0435 <code>$pid<\/code> \u2014 ID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 <em>map-\u0444\u0430\u0439\u043b\u0430\u043c\u0438<\/em><\/p>\n<p>  <\/p>\n<h2 id=\"map-fayly\">Map-\u0444\u0430\u0439\u043b\u044b<\/h2>\n<p>  <\/p>\n<p>Map-\u0444\u0430\u0439\u043b\u044b \u2014 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u0427\u0435\u043c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u044b\u0435? \u041d\u0443, \u0442\u0435\u043c, \u0447\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0440\u0430\u0437\u043d\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0432\u0441\u044f\u043a\u0438\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0447\u0438\u0442\u0430\u0435\u0442\u0435 \u0438\u0437 \u043d\u0438\u0445, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u043e\u0439 \u0432\u0430\u0448 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0447\u0438\u0442\u0430\u0435\u0442. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, map-\u0444\u0430\u0439\u043b <code>\/proc\/$pid\/uid_maps<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u043e\u0442 UID&#8217;\u043e\u0432 \u0438\u0437 user namespace, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 <code>$pid<\/code>, UID&#8217;\u0430\u043c \u0432 user namespace \u0447\u0438\u0442\u0430\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u0418, \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 <strong>X<\/strong>, \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u0435\u0440\u043d\u0443\u043b\u043e\u0441\u044c \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 <strong>Y<\/strong>, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0447\u0438\u0442\u0430\u044e\u0442 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 map \u0444\u0430\u0439\u043b \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 <strong>X<\/strong>, \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0439 UID map-\u0444\u0430\u0439\u043b <code>\/proc\/$pid\/uid_map<\/code>, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u0430\u0431\u043e\u0440 \u0441\u0442\u0440\u043e\u043a. \u041a\u0430\u0436\u0434\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d UID&#8217;\u043e\u0432 \u0432 user namespace <strong>C<\/strong> \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 <code>$pid<\/code>, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0443 UID \u0432 \u0434\u0440\u0443\u0433\u043e\u043c namespace.<\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0438\u043c\u0435\u0435\u0442 \u0444\u043e\u0440\u043c\u0430\u0442 <code>$fromID $toID $length<\/code>, \u0433\u0434\u0435:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>$fromID<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u043c UID \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 \u0434\u043b\u044f user namespace \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 <code>$pid<\/code><\/li>\n<li><code>$lenght<\/code> \u2014 \u044d\u0442\u043e \u0434\u043b\u0438\u043d\u0430 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430.<\/li>\n<li>\u0422\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u044f <code>$toID<\/code> \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0447\u0438\u0442\u0430\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 <strong>X<\/strong>. \u0415\u0441\u043b\u0438 <strong>X<\/strong> \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u0434\u0440\u0443\u0433\u043e\u043c\u0443 user namespace <strong>U<\/strong>, \u0442\u043e <code>$toID<\/code> \u2014 \u044d\u0442\u043e \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 UID \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 \u0432 <strong>U<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u0430\u043f\u0438\u0442\u0441\u044f \u0441 <code>$fromID<\/code>. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>$toID<\/code> \u2014 \u044d\u0442\u043e \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 UID \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 \u0432 <strong>P<\/strong> \u2014 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e user namespace \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 <strong>C<\/strong>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0447\u0438\u0442\u0430\u0435\u0442 \u0444\u0430\u0439\u043b <code>\/proc\/1409\/uid_map<\/code> \u0438 \u0441\u0440\u0435\u0434\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a \u0432\u0438\u0434\u043d\u043e <code>15 22 5<\/code>, \u0442\u043e UID&#8217;\u044b \u0441 15 \u043f\u043e 19 \u0432 user namespace \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 <code>1409<\/code> \u043c\u0430\u043f\u043f\u044f\u0442\u0441\u044f \u0432 UID&#8217;\u044b 22-26 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e user namespace \u0447\u0438\u0442\u0430\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430.<\/p>\n<p>  <\/p>\n<p>\u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0447\u0438\u0442\u0430\u0435\u0442 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 <code>\/proc\/$$\/uid_map<\/code> (\u0438\u043b\u0438 map-\u0444\u0430\u0439\u043b\u0430 \u043b\u044e\u0431\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0449\u0435\u0433\u043e \u0442\u043e\u043c\u0443 \u0436\u0435 user namespace, \u0447\u0442\u043e \u0438 \u0447\u0438\u0442\u0430\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441) \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 <code>15 22 5<\/code>, \u0442\u043e UID&#8217;\u044b c 15 \u043f\u043e 19 \u0432 user namespace <strong>C<\/strong> \u043c\u0430\u043f\u043f\u044f\u0442\u0441\u044f \u0432 UID&#8217;\u044b c 22 \u043f\u043e 26 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0434\u043b\u044f <strong>C<\/strong> user namespace.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u044d\u0442\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">P$ echo $$ 1442 # \u0412 \u043d\u043e\u0432\u043e\u043c user namespace... C$ echo $$ 1409 # C \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u043e\u0432 \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u043d\u043e\u0432\u044b\u0439 C$ cat \/proc\/1409\/uid_map # \u041f\u0443\u0441\u0442\u043e # \u041f\u043e\u043a\u0430 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 namespace P \u0438\u043c\u0435\u0435\u0442 \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0438 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 # UIDs \u0432 \u0442\u0435 \u0436\u0435 UID \u0432 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435 P$ cat \/proc\/1442\/uid_map          0          0 4294967295 # UIDs \u0441 0 \u0434\u043e 4294967294 \u0432 P \u043c\u0430\u043f\u043f\u044f\u0442\u0441\u044f # \u0432 4294967295 - \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 ID no user - \u0432 C. C$ cat \/proc\/1409\/uid_map          0 4294967295 4294967295<\/code><\/pre>\n<p>  <\/p>\n<p>\u0425\u043e\u0440\u043e\u0448\u043e, \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u044b\u043b\u0438 \u0434\u0432\u0430 \u043a\u0440\u0430\u0439\u043d\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f, \u043d\u043e \u044d\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u0442\u0430\u043c \u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0432\u0435\u0449\u0430\u0445:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u0412\u043d\u043e\u0432\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 user namespace \u0431\u0443\u0434\u0435\u0442 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u043c\u0435\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u0435 map-\u0444\u0430\u0439\u043b\u044b.<\/li>\n<li>UID 4294967295 \u043d\u0435 \u043c\u0430\u043f\u043f\u0438\u0442\u0441\u044f \u0438 \u043d\u0435\u043f\u0440\u0438\u0433\u043e\u0434\u0435\u043d \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u0436\u0435 \u0432 <code>root<\/code> user namespace. Linux \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044d\u0442\u043e\u0442 UID \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c <strong>\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 user ID<\/strong>.<\/li>\n<\/ol>\n<p>  <\/p>\n<h2 id=\"napisanie-uid-map-faylov\">\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 UID Map \u0444\u0430\u0439\u043b\u043e\u0432<\/h2>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0448 \u0432\u043d\u043e\u0432\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 user namespace <strong>C<\/strong>, \u043d\u0430\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u043d\u0443\u0436\u043d\u044b\u0435 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0438, \u0437\u0430\u043f\u0438\u0441\u0430\u0432 \u0438\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0432 map-\u0444\u0430\u0439\u043b\u044b \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 <strong>C<\/strong> (\u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043d\u0435\u0433\u043e). \u0417\u0430\u043f\u0438\u0441\u044c \u0432 \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0433\u043e\u0432\u043e\u0440\u0438\u0442 Linux \u0434\u0432\u0435 \u0432\u0435\u0449\u0438:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u041a\u0430\u043a\u0438\u0435 UID&#8217;\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u0446\u0435\u043b\u0435\u0432\u043e\u043c\u0443 user namespace <strong>C<\/strong>.<\/li>\n<li>\u041a\u0430\u043a\u0438\u0435 UID&#8217;s \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c user namespace \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 UID&#8217;\u0430\u043c \u0432 <strong>C<\/strong>.<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043c\u044b \u0438\u0437 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e user namespace <strong>P<\/strong> \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0432 map-\u0444\u0430\u0439\u043b \u0434\u043b\u044f \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d <strong>C<\/strong>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">0 1000 1 3    0 1<\/code><\/pre>\n<p>  <\/p>\n<p>\u043c\u044b \u043f\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443 \u0433\u043e\u0432\u043e\u0440\u0438\u043c Linux, \u0447\u0442\u043e:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0432 <strong>C<\/strong>, \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c UID&#8217;\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f UID&#8217;\u044b <code>0<\/code> \u0438 <code>3<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <code>setuid(9)<\/code> \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0442\u044c\u0441\u044f \u0447\u0435\u043c-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 <em>\u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0433\u043e id \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/em>.<\/li>\n<li>UID&#8217;\u044b <code>1000<\/code> \u0438 <code>0<\/code> \u0432 <strong>P<\/strong> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 UID&#8217;\u0430\u043c <code>0<\/code> \u0438 <code>3<\/code> \u0432 <strong>C<\/strong>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0441 UID <code>1000<\/code> \u0432 <strong>P<\/strong>, \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f \u0432 <strong>C<\/strong>, \u043e\u043d \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0435\u0433\u043e UID \u0441\u0442\u0430\u043b <code>root<\/code> <code>0<\/code>.<\/li>\n<\/ol>\n<p>  <\/p>\n<h2 id=\"vladelec-prostranstv-imyon-i-privilegii\">\u0412\u043b\u0430\u0434\u0435\u043b\u0435\u0446 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d \u0438 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0438<\/h2>\n<p>  <\/p>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/post\/458462\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043f\u043e\u0441\u0442\u0435<\/a> \u043c\u044b \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u043b\u0438, \u0447\u0442\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0443\u043f \u0441 \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0441\u0443\u043f\u0435\u0440\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. User namespaces \u043d\u0435 \u043d\u0430\u043b\u0430\u0433\u0430\u044e\u0442 \u044d\u0442\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0435\u0449\u0435 \u043e\u0434\u043d\u043e\u0439 \u0438\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 <em>\u0432\u043b\u0430\u0434\u0435\u0442\u044c<\/em> \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430\u043c\u0438 \u0438\u043c\u0451\u043d.<\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u044f\u043a\u0438\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u0435 user namespace <strong>N<\/strong>, Linux \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 user namespace <strong>P<\/strong> \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0435\u0433\u043e <strong>N<\/strong>, <em>\u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0435\u043c<\/em> namespace <strong>N<\/strong>. \u0415\u0441\u043b\u0438 <strong>P<\/strong> \u0441\u043e\u0437\u0434\u0430\u043d \u043d\u0430\u0440\u044f\u0434\u0443 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430\u043c\u0438 \u0438\u043c\u0451\u043d \u0432 \u043e\u0434\u043d\u043e\u043c \u0438 \u0442\u043e\u043c \u0436\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 <code>clone<\/code>, Linux \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e <strong>P<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u043f\u0435\u0440\u0432\u044b\u043c \u0438 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0435\u043c \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d.<\/p>\n<p>  <\/p>\n<p>\u0412\u043b\u0430\u0434\u0435\u043b\u0435\u0446 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d \u0432\u0430\u0436\u0435\u043d \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0430\u0434 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c, \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043d\u0435 user namespace, \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u0432\u043e\u0438 UID \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0438, \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0435 \u0432 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0438 \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0430 \u044d\u0442\u043e\u0433\u043e user namespace, \u0430 \u043d\u0435 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e user namespace. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043a\u0430\u0436\u0435\u043c, \u0447\u0442\u043e <strong>P<\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c user namespace \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e <strong>C<\/strong>, \u0430 <strong>P<\/strong> \u0438 <strong>C<\/strong> \u0432\u043b\u0430\u0434\u0435\u044e\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 network namespace <strong>M<\/strong> \u0438 <strong>N<\/strong> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0438\u043c\u0435\u0442\u044c \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432, \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u0432 <strong>M<\/strong>, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043b\u044f <strong>N<\/strong>.<\/p>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435\u043c \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0430 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d \u0434\u043b\u044f \u043d\u0430\u0441 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 <code>sudo<\/code> \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>unshare<\/code> \u0438\u043b\u0438 <code>isolate<\/code>, \u0435\u0441\u043b\u0438 \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 user namespace. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>unshare -u bash<\/code> \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 <code>sudo<\/code>, \u043d\u043e <code>unshare -Uu bash<\/code> \u2014 \u0443\u0436\u0435 \u043d\u0435\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\"># UID 1000 -- \u044d\u0442\u043e \u043d\u0435\u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c user namespace P. P$ id uid=1000(iffy) gid=1000(iffy) # \u0418 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043d\u0435 \u0443\u0434\u0430\u0451\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c # network namespace. P$ ip link add type veth RTNETLINK answers: Operation not permitted # \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0435\u0449\u0451 \u0440\u0430\u0437 \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c \u0441\u0447\u0430\u0441\u0442\u044c\u044f, \u043d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0441 # \u0434\u0440\u0443\u0433\u0438\u043c\u0438 user \u0438 network namespace P$ unshare -nU bash # \u0417\u0410\u041c\u0415\u0422\u041a\u0410: \u0431\u0435\u0437 sudo C$ ip link add type veth RTNETLINK answers: Operation not permitted # \u0425\u043c, \u043f\u043e\u043a\u0430 \u0431\u0435\u0437\u0443\u0441\u043f\u0435\u0448\u043d\u043e. \u041b\u043e\u0433\u0438\u0447\u043d\u043e, \u0442\u043e\u043b\u044c\u043a\u043e # UID 0 (root) \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u0430 # \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043c\u044b nobody. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c. C$ echo $$ 13294 # \u0412\u0435\u0440\u043d\u0443\u0432\u0448\u0438\u0441\u044c \u0432 P, \u043c\u044b \u043c\u0430\u043f\u043f\u0438\u043c UID 1000 \u0432 P \u0441 UID 0 \u0432 C P$ echo \"0 1000 1\" &gt; \/proc\/13294\/uid_map # \u041a\u0442\u043e \u043c\u044b \u0442\u0435\u043f\u0435\u0440\u044c? C$ id uid=0(root) gid=65534(nogroup) C$ ip link add type veth # \u0423\u0441\u043f\u0435\u0445!<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p><em>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043c\u044b \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0430\u0432 \u0441\u0443\u043f\u0435\u0440\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u043e\u0441\u0442\u0435, \u0442\u0430\u043a \u043a\u0430\u043a <code>isolate<\/code> \u043d\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u044f\u0445 <code>root<\/code> \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c user namespace, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c Mount \u0438 Network namespace. \u041d\u043e \u043c\u044b \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u043c \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439.<\/em><\/p><\/blockquote>\n<p>  <\/p>\n<h2 id=\"kak-razreshayutsya-id\">\u041a\u0430\u043a \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044e\u0442\u0441\u044f ID<\/h2>\n<p>  <\/p>\n<p>\u041c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0443\u0432\u0438\u0434\u0435\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0439 \u043e\u0442 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f <code>1000<\/code> \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u043b\u0441\u044f \u043d\u0430 <code>root<\/code>. \u041d\u0435 \u0432\u043e\u043b\u043d\u0443\u0439\u0442\u0435\u0441\u044c, \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u044d\u0441\u043a\u0430\u043b\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439 \u043d\u0435 \u0431\u044b\u043b\u043e. \u041f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e <em>\u043c\u0430\u043f\u043f\u0438\u043d\u0433<\/em> ID: \u043f\u043e\u043a\u0430 \u043d\u0430\u0448 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 <em>\u0434\u0443\u043c\u0430\u0435\u0442<\/em>, \u0447\u0442\u043e \u043e\u043d \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c <code>root<\/code> \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, Linux \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e <code>root<\/code> \u2014 \u0432 \u0435\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 UID <code>1000<\/code> (\u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043d\u0430\u0448\u0435\u043c\u0443 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0443). \u0422\u0430\u043a \u0447\u0442\u043e \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d, \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0449\u0438\u0435 \u0435\u0433\u043e \u043d\u043e\u0432\u043e\u043c\u0443 user namespace (\u043f\u043e\u0434\u043e\u0431\u043d\u043e network namespace \u0432 <strong>C<\/strong>), \u043f\u0440\u0438\u0437\u043d\u0430\u044e\u0442 \u0435\u0433\u043e \u043f\u0440\u0430\u0432\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 <code>root<\/code>, \u0434\u0440\u0443\u0433\u0438\u0435 (\u043a\u0430\u043a \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, network namespace \u0432 <strong>P<\/strong>) \u2014 \u043d\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0438\u0447\u0435\u0433\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c <code>1000<\/code> \u043d\u0435 \u0441\u043c\u043e\u0433 \u0431\u044b.<\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u044f\u043a\u0438\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u043c user namespace \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u2014 \u0435\u0433\u043e UID \u0432 \u044d\u0442\u043e\u043c user namespace \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u043c ID \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c user namespace \u043f\u0443\u0442\u0451\u043c \u043e\u0431\u0445\u043e\u0434\u0430 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u043e\u0432 \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432 \u0438\u043c\u0451\u043d \u0434\u043e \u043a\u043e\u0440\u043d\u044f. \u0412 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0447\u0438\u0442\u0430\u0435\u0442 ID \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043a\u0430\u043a \u043c\u044b \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>ls -l my_file<\/code>. UID \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0430 <code>my_file<\/code> \u043c\u0430\u043f\u043f\u0438\u0442\u0441\u044f \u0438\u0437 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e user namespace \u0434\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0438 \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 ID (\u0438\u043b\u0438 nobody, \u0435\u0441\u043b\u0438 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0433\u0434\u0435-\u043b\u0438\u0431\u043e \u0432\u0434\u043e\u043b\u044c \u0432\u0441\u0435\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430) \u043e\u0442\u0434\u0430\u0451\u0442\u0441\u044f \u0447\u0438\u0442\u0430\u044e\u0449\u0435\u043c\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443.<\/p>\n<p>  <\/p>\n<h2 id=\"gruppovye-id\">\u0413\u0440\u0443\u043f\u043f\u043e\u0432\u044b\u0435 ID<\/h2>\n<p>  <\/p>\n<p>\u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043c\u044b \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c root \u0432 <strong>C<\/strong>, \u043c\u044b \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0441 \u0443\u0436\u0430\u0441\u043d\u043e\u0439 <code>nogroup<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0430\u0448\u0435\u0433\u043e ID \u0433\u0440\u0443\u043f\u043f\u044b. \u041d\u0430\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u043b\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e <code>\/proc\/$pid\/gid_map<\/code>. \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <code>setgroups<\/code> (\u0432 \u044d\u0442\u043e\u043c \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0443\u0436\u0435 \u0435\u0441\u0442\u044c <code>CAP_SETGID<\/code> capability \u0432 <strong>P<\/strong>, \u043d\u043e \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c \u044d\u0442\u043e\u0433\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0434\u0451\u0442 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u044f\u043c\u0438 \u0441\u0443\u043f\u0435\u0440\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f), \u043d\u0430\u043f\u0438\u0441\u0430\u0432 &#171;deny&#187; \u0432 \u0444\u0430\u0439\u043b <code>proc\/$pid\/setgroups<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\"># \u0413\u0434\u0435 13294 -- pid \u0434\u043b\u044f unshared \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 C$ id uid=0(root) gid=65534(nogroup) P$ echo deny &gt; \/proc\/13294\/setgroups P$ echo \"0 1000 1\" &gt; \/proc\/13294\/gid_map # \u041d\u0430\u0448 group ID \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f C$ id uid=0(root) gid=0(root)<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"realizaciya\">\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>  <\/p>\n<blockquote><p><em>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0441\u0442\u0443 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/github.com\/iffyio\/isolate\/tree\/part-2\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/em><\/p><\/blockquote>\n<p>\u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c, \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c user namespaces, \u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430. \u0412\u0441\u0451, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0443\u0447\u0443 \u0441\u0442\u0440\u043e\u043a \u0432 \u0444\u0430\u0439\u043b \u2014 \u043c\u0443\u0442\u043e\u0440\u043d\u043e \u0431\u044b\u043b\u043e \u0443\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0438 \u0433\u0434\u0435 \u043f\u0438\u0441\u0430\u0442\u044c. \u0411\u0435\u0437 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0446\u0435\u0440\u0435\u043c\u043e\u043d\u0438\u0439, \u0432\u043e\u0442 \u043d\u0430\u0448\u0438 \u0446\u0435\u043b\u0438:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u041a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0432 \u0435\u0433\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c user namespace.<\/li>\n<li>\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 UID \u0438 GID map-\u0444\u0430\u0439\u043b\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430.<\/li>\n<li>\u0421\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0432\u0441\u0435 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0438 \u0441\u0443\u043f\u0435\u0440\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/li>\n<\/ol>\n<p>  <\/p>\n<p><code>1<\/code> \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0444\u043b\u0430\u0433\u0430 <code>CLONE_NEWUSER<\/code> \u0432 \u043d\u0430\u0448 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <code>clone<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">int clone_flags = SIGCHLD | CLONE_NEWUTS | CLONE_NEWUSER;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f <code>2<\/code> \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>prepare_user_ns<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f <code>1000<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 <code>root<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">static void prepare_userns(int pid) {     char path[100];     char line[100];      int uid = 1000;      sprintf(path, \"\/proc\/%d\/uid_map\", pid);     sprintf(line, \"0 %d 1\\n\", uid);     write_file(path, line);      sprintf(path, \"\/proc\/%d\/setgroups\", pid);     sprintf(line, \"deny\");     write_file(path, line);      sprintf(path, \"\/proc\/%d\/gid_map\", pid);     sprintf(line, \"0 %d 1\\n\", uid);     write_file(path, line); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c user namespace \u043f\u0440\u044f\u043c\u043e \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043c\u044b \u043f\u043e\u0434\u0430\u0434\u0438\u043c \u0441\u0438\u0433\u043d\u0430\u043b \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443.<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">    ...     \/\/ \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u043a \u0437\u0430\u043f\u0438\u0441\u0438 \u043a\u043e\u043d\u0435\u0446 \u043f\u0430\u0439\u043f\u0430.     int pipe = params.fd[1];      \/\/ \u0422\u0443\u0442 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 namespace ...     prepare_userns(cmd_pid);      \/\/ \u0421\u0438\u0433\u043d\u0430\u043b \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443, \u0447\u0442\u043e \u043c\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438 \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u043e\u0439.     ...<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0448\u0430\u0433\u0430 <code>3<\/code> \u043c\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>cmd_exec<\/code>, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0442 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043d\u0435\u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f <code>1000<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0432 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0435 (\u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e root \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c <code>0<\/code> \u0432 user namespace \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u2014 \u044d\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c <code>1000<\/code>):<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">    ...     \/\/ \u041e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 '\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430' \u043e\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430.     await_setup(params-&gt;fd[0]);      if (setgid(0) == -1)       die(\"Failed to setgid: %m\\n\");     if (setuid(0) == -1)       die(\"Failed to setuid: %m\\n\");     ...<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u044d\u0442\u043e \u0432\u0441\u0451! <code>isolate<\/code> \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c user namespace.<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ .\/isolate sh ===========sh============ $ id uid=0(root) gid=0(root)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u0431\u044b\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0435\u0439 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 User namespaces, \u043d\u043e \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0431\u044b\u043b\u0430 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u0435\u0437\u0431\u043e\u043b\u0435\u0437\u043d\u0435\u043d\u043d\u043e\u0439. \u0412 <a href=\"http:\/\/ifeanyi.co\/posts\/linux-namespaces-part-3\/\">\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u043e\u0441\u0442\u0435<\/a> \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 \u0441\u0432\u043e\u0451\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c Mount namespace \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>isolate<\/code> (\u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u044f \u0442\u0430\u0439\u043d\u0443, \u0441\u0442\u043e\u044f\u0449\u0443\u044e \u0437\u0430 <a href=\"https:\/\/docs.docker.com\/engine\/reference\/builder\/#from\">\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439<\/a> <code>FROM<\/code> \u0438\u0437 <code>Dockerfile<\/code>). \u0422\u0430\u043c \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u043c\u043e\u0447\u044c Linux, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438\u043d\u0441\u0442\u0430\u043d\u0441.<\/p>\n<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \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:\/\/habr.com\/ru\/post\/459574\/\"> https:\/\/habr.com\/ru\/post\/459574\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/post\/458462\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 <\/a> \u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043a\u0443\u043d\u0443\u043b\u0438 \u043f\u0430\u043b\u044c\u0446\u044b \u043d\u043e\u0433 \u0432 \u0432\u043e\u0434\u044b namespace \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0443\u0432\u0438\u0434\u0435\u043b\u0438, \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c UTS namespace. \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u043c\u044b \u043e\u0441\u0432\u0435\u0442\u0438\u043c User namespace.<\/p>\n<p>  <\/p>\n<p>\u0421\u0440\u0435\u0434\u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c\u044e, <a href=\"http:\/\/man7.org\/linux\/man-pages\/man7\/user_namespaces.7.html\">User namespaces<\/a> \u0438\u0437\u043e\u043b\u0438\u0440\u0443\u0435\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0433\u0440\u0443\u043f\u043f \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u043c\u044b \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u043c\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u0445 user \u0438 group ID (UID \u0438 GID \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e), \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0438 \u0438\u0433\u0440\u0430\u044e\u0442 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u043e\u043b\u044c \u0432 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0432\u043e \u0432\u0441\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<p>  <\/p>\n<p>\u0412 Linux \u044d\u0442\u0438 ID \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0433\u0440\u0443\u043f\u043f\u044b \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u0418 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0438\u0437 \u043d\u0438\u0445, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0434\u0430\u0442\u044c \u043a \u043a\u0430\u043a\u0438\u043c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438\/\u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f. \u0421\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043d\u0430\u043d\u0435\u0441\u0442\u0438 \u0443\u0449\u0435\u0440\u0431 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u043c\u0438 ID.<\/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-293235","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/293235","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=293235"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/293235\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=293235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=293235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=293235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}