{"id":176631,"date":"2013-04-21T17:43:03","date_gmt":"2013-04-21T13:43:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=176631"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=176631","title":{"rendered":"<span class=\"post_title\">\u041e\u0441\u043d\u043e\u0432\u044b \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b Android. Native user space, \u0447.2<\/span>"},"content":{"rendered":"<div class=\"content html_format\">\n<h3>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0443 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435 \u044f\u0434\u0440\u0430. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043e\u0442\u043a\u0443\u0434\u0430 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f system.img, userdata.img \u0438 cache.img, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0432 Native user space.<br \/>  \u0412\u0441\u0435\u043c \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c!<br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  <\/p>\n<h4>\u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0442\u0430\u0442\u0435\u0439<\/h4>\n<p> \u0417\u0434\u0435\u0441\u044c \u0441\u043e\u0431\u0440\u0430\u043d\u044b \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043c\u043e\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u0438\u0437 \u044d\u0442\u043e\u0439 \u0442\u0435\u043c\u044b:  <\/p>\n<ol>\n<li><a href=\"http:\/\/habrahabr.ru\/post\/175517\/\">\u041e\u0441\u043d\u043e\u0432\u044b \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b Android. \u0423\u0440\u043e\u0432\u0435\u043d\u044c \u044f\u0434\u0440\u0430<\/a><\/li>\n<li><a href=\"http:\/\/habrahabr.ru\/post\/176131\/\">\u041e\u0441\u043d\u043e\u0432\u044b \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b Android. Native user space, \u0447.1<\/a><\/li>\n<li><a href=\"http:\/\/habrahabr.ru\/post\/176631\/\">\u041e\u0441\u043d\u043e\u0432\u044b \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b Android. Native user space, \u0447.2<\/a><\/li>\n<\/ol>\n<p>  <\/p>\n<h4>\u0427\u0442\u043e \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434 Native user space<\/h4>\n<p> \u041f\u043e\u0434 Native user space \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432\u043d\u0435 Dalvik Virtual Machine, \u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e Linux kernel. Native user space \u2014 \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0434 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443. \u041a \u043d\u0438\u043c \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u0438\u0437 init \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u043b\u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f, toolbox \u0443\u0442\u0438\u043b\u0438\u0442\u044b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0438\u0437-\u043f\u043e\u0434 shell.<\/p>\n<h3>\u041d\u0430\u0447\u0430\u043b\u043e<\/h3>\n<p>  \u041a\u0430\u043a \u044f \u0443\u0436\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 Android \u043b\u0435\u0436\u0438\u0442 Linux kernel. \u041a\u0430\u043a \u0438 \u0432\u043e \u0432\u0441\u0435\u0445 Linux \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445, \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 Android \u043b\u0435\u0436\u0438\u0442 access control. \u0422.\u0435. \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0435\u0441\u0443\u0440\u0441 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0444\u0430\u0439\u043b) \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0435\u0442\u0430-\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u043a\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043b \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u2014 owner (\u0432\u043b\u0430\u0434\u0435\u043b\u0435\u0446) \u2014 \u0438 \u043a \u043a\u0430\u043a\u043e\u0439 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u0435 (owner group) \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 owner (\u0432\u043b\u0430\u0434\u0435\u043b\u0435\u0446). \u041a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e user (\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f). \u0423 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0435\u0441\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0447\u043b\u0435\u043d\u043e\u043c \u0434\u0440\u0443\u0433\u0438\u0445 \u0433\u0440\u0443\u043f\u043f. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0435\u0441\u043b\u0438 \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0440\u0435\u0441\u0443\u0440\u0441\u0443 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e (\u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 rwxrwxrwx) \u043e \u0442\u043e\u043c, \u043a\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0447\u0438\u0442\u0430\u0442\u044c\/\u043f\u0438\u0441\u0430\u0442\u044c\/\u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0444\u0430\u0439\u043b), \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u044d\u0442\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u0443. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0444\u0430\u0439\u043b\u0443 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f: \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u044d\u0442\u0438\u043c \u0444\u0430\u0439\u043b\u043e\u043c owner (\u0432\u043b\u0430\u0434\u0435\u043b\u0435\u0446) \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430; \u0447\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432 owner group; \u0447\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0442\u0432\u043e\u0440\u0438\u0442\u044c \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435. <a href=\"http:\/\/library.linode.com\/using-linux\/users-and-groups\">\u0417\u0434\u0435\u0441\u044c<\/a> \u043e\u0431 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435.<\/p>\n<p>  \u041d\u043e \u0443 Android \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u044f. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e Android \u2014 \u044d\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043b\u044f \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u043a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u043e\u0447\u0435\u043d\u044c \u043b\u0438\u0447\u043d\u044b\u043c \u0432\u0435\u0449\u0430\u043c \u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043d\u0435 \u043b\u044e\u0431\u0438\u043c \u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u0447\u0443\u0436\u0438\u0435 \u0440\u0443\u043a\u0438. \u0422\u043e \u0435\u0441\u0442\u044c \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u0430 \u043a\u0430\u043a \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 Linux users \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 (\u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u2014 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u043a\u0430\u043a \u044f \u0443\u0436\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435). \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0432 Android \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 user (\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438) \u0438 \u0438\u0445 UID (\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b) \u0431\u044b\u043b\u0438 \u0436\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u0447\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u043d\u0430\u0440\u0435\u043a\u0430\u043d\u0438\u0439 \u043b\u044e\u0434\u0435\u0439 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c\u044e (\u0445\u043e\u0442\u044f \u044f, \u0435\u0441\u043b\u0438 \u0447\u0435\u0441\u0442\u043d\u043e, \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u043f\u043e\u0447\u0435\u043c\u0443 \u043a\u0440\u0438\u0442\u0438\u043a\u0443\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434). \u041c\u044b \u0443\u0436\u0435 \u0432\u0438\u0434\u0435\u043b\u0438 \u044d\u0442\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u0444\u0430\u0439\u043b\u0435 <i><a href=\"https:\/\/android.googlesource.com\/platform\/system\/core\/\/+\/master\/include\/private\/android_filesystem_config.h\">system\/core\/include\/private\/android_filesystem_config.h<\/a><\/i> \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <b>root<\/b> \u0438\u043c\u0435\u0435\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 <b>0<\/b>, \u0430 <b>system<\/b> \u2014 <b>1000<\/b>.<\/p>\n<p>  \u041a\u0430\u043a \u044f \u0443\u0436\u0435 \u043e\u0442\u043c\u0435\u0447\u0430\u043b, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (UID), \u0447\u0442\u043e \u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0442.\u0435. UID(calling_process) == UID (called_process). \u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 Android \u2014 <b>init<\/b> \u2014 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 root (UID == 0). \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e-\u0438\u0434\u0435\u0435, \u0432\u0441\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u044b \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438. \u0422\u0430\u043a \u043e\u043d\u043e, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0431\u044b \u0438 \u0431\u044b\u043b\u043e. \u041d\u043e, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0435 \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \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 (\u0430 \u0442\u0430\u043a \u0436\u0435 \u0442\u0435, \u043a\u0442\u043e \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c\u0438 capabilities), \u043c\u043e\u0433\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0439 UID \u043d\u0430 \u043c\u0435\u043d\u0435\u0435 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439. \u0410 \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0432 Android \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0434\u0435\u043c\u043e\u043d\u043e\u0432 \u0432 <a href=\"https:\/\/android.googlesource.com\/platform\/system\/core\/+\/master\/rootdir\/init.rc\"><i>init.rc<\/i><\/a> \u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0441 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u044f\u043c\u0438 \u043a\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043a\u0430\u043a\u0438\u0445 \u0433\u0440\u0443\u043f\u043f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441.<\/p>\n<pre><code class=\"bash\">... service console \/system\/bin\/sh     class core     console     disabled     user shell     group log ... service servicemanager \/system\/bin\/servicemanager     class core     user system     group system     critical     onrestart restart zygote     onrestart restart media     onrestart restart surfaceflinger     onrestart restart drm ... service media \/system\/bin\/mediaserver     class main     user media     group audio camera inet net_bt net_bt_admin net_bw_acct drmrpc     ioprio rt 4 ...   <\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u044b \u0447\u0435\u0440\u0435\u0437 \u044d\u0442\u0438\u0445 \u0434\u0435\u043c\u043e\u043d\u043e\u0432, \u0443\u0436\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c root \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0438.<\/p>\n<h3>System, data \u0438 cache<\/h3>\n<p>  \u042f \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0430\u043d\u043e\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043b \u044d\u0442\u0443 \u0442\u0435\u043c\u0443, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u043d\u0430 \u043e\u0447\u0435\u043d\u044c \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0438 \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u0430\u044f. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a. <b>System.img<\/b>, <b>userdata.img<\/b> \u0438 <b>cache.img<\/b> \u2014 \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b Android. \u0422\u043e \u0435\u0441\u0442\u044c \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u044d\u0442\u0438 \u0442\u0440\u0438 \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043d\u0430 \u043d\u0430\u0448\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e.<\/p>\n<p>  \u041d\u043e \u0441\u0430\u043c\u043e\u0435 \u0432\u0430\u0436\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u044d\u0442\u043e. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0432 Android \u0441\u0438\u0441\u0442\u0435\u043c\u0435 user name \u0438 UID \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0436\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u0443\u0436\u0435 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043a \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f\u043c \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u0440\u0430\u0437\u0430\u0445. \u042d\u0442\u0438 \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0432 \u0444\u0430\u0439\u043b\u0435 <i><a href=\"https:\/\/android.googlesource.com\/platform\/system\/core\/\/+\/master\/include\/private\/android_filesystem_config.h\">system\/core\/include\/private\/android_filesystem_config.h<\/a><\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0443\u0436\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0438 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u041f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 (android_dirs[]) \u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0444\u0430\u0439\u043b\u043e\u0432 (android_files[]) \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>... struct fs_path_config {     unsigned mode;     unsigned uid;     unsigned gid;     uint64_t capabilities;     const char *prefix; };  \/* Rules for directories. ** These rules are applied based on &quot;first match&quot;, so they ** should start with the most specific path and work their ** way up to the root. *\/  static const struct fs_path_config android_dirs[] = {     { 00770, AID_SYSTEM, AID_CACHE,  0, &quot;cache&quot; },     { 00771, AID_SYSTEM, AID_SYSTEM, 0, &quot;data\/app&quot; },     { 00771, AID_SYSTEM, AID_SYSTEM, 0, &quot;data\/app-private&quot; },     { 00771, AID_SYSTEM, AID_SYSTEM, 0, &quot;data\/dalvik-cache&quot; },     { 00771, AID_SYSTEM, AID_SYSTEM, 0, &quot;data\/data&quot; },     { 00771, AID_SHELL,  AID_SHELL,  0, &quot;data\/local\/tmp&quot; },     { 00771, AID_SHELL,  AID_SHELL,  0, &quot;data\/local&quot; },     { 01771, AID_SYSTEM, AID_MISC,   0, &quot;data\/misc&quot; },     { 00770, AID_DHCP,   AID_DHCP,   0, &quot;data\/misc\/dhcp&quot; },     { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, &quot;data\/media&quot; },     { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, &quot;data\/media\/Music&quot; },     { 00771, AID_SYSTEM, AID_SYSTEM, 0, &quot;data&quot; },     { 00750, AID_ROOT,   AID_SHELL,  0, &quot;sbin&quot; },     { 00755, AID_ROOT,   AID_SHELL,  0, &quot;system\/bin&quot; },     { 00755, AID_ROOT,   AID_SHELL,  0, &quot;system\/vendor&quot; },     { 00755, AID_ROOT,   AID_SHELL,  0, &quot;system\/xbin&quot; },     { 00755, AID_ROOT,   AID_ROOT,   0, &quot;system\/etc\/ppp&quot; },     { 00777, AID_ROOT,   AID_ROOT,   0, &quot;sdcard&quot; },     { 00755, AID_ROOT,   AID_ROOT,   0, 0 }, };  \/* Rules for files. ** These rules are applied based on &quot;first match&quot;, so they ** should start with the most specific path and work their ** way up to the root. Prefixes ending in * denotes wildcard ** and will allow partial matches. *\/ static const struct fs_path_config android_files[] = {     { 00440, AID_ROOT,      AID_SHELL,     0, &quot;system\/etc\/init.goldfish.rc&quot; },     { 00550, AID_ROOT,      AID_SHELL,     0, &quot;system\/etc\/init.goldfish.sh&quot; },     { 00440, AID_ROOT,      AID_SHELL,     0, &quot;system\/etc\/init.trout.rc&quot; },     { 00550, AID_ROOT,      AID_SHELL,     0, &quot;system\/etc\/init.ril&quot; },     { 00550, AID_ROOT,      AID_SHELL,     0, &quot;system\/etc\/init.testmenu&quot; },     { 00550, AID_DHCP,      AID_SHELL,     0, &quot;system\/etc\/dhcpcd\/dhcpcd-run-hooks&quot; },     { 00440, AID_BLUETOOTH, AID_BLUETOOTH, 0, &quot;system\/etc\/dbus.conf&quot; },     { 00444, AID_RADIO,     AID_AUDIO,     0, &quot;system\/etc\/AudioPara4.csv&quot; },     { 00555, AID_ROOT,      AID_ROOT,      0, &quot;system\/etc\/ppp\/*&quot; },     { 00555, AID_ROOT,      AID_ROOT,      0, &quot;system\/etc\/rc.*&quot; },     { 00644, AID_SYSTEM,    AID_SYSTEM,    0, &quot;data\/app\/*&quot; },     { 00644, AID_MEDIA_RW,  AID_MEDIA_RW,  0, &quot;data\/media\/*&quot; },     { 00644, AID_SYSTEM,    AID_SYSTEM,    0, &quot;data\/app-private\/*&quot; },     { 00644, AID_APP,       AID_APP,       0, &quot;data\/data\/*&quot; },     { 00755, AID_ROOT,      AID_ROOT,      0, &quot;system\/bin\/ping&quot; },      \/* the following file is INTENTIONALLY set-gid and not set-uid.      * Do not change. *\/     { 02750, AID_ROOT,      AID_INET,      0, &quot;system\/bin\/netcfg&quot; },      \/* the following five files are INTENTIONALLY set-uid, but they      * are NOT included on user builds. *\/     { 06755, AID_ROOT,      AID_ROOT,      0, &quot;system\/xbin\/su&quot; },     { 06755, AID_ROOT,      AID_ROOT,      0, &quot;system\/xbin\/librank&quot; },     { 06755, AID_ROOT,      AID_ROOT,      0, &quot;system\/xbin\/procrank&quot; },     { 06755, AID_ROOT,      AID_ROOT,      0, &quot;system\/xbin\/procmem&quot; },     { 06755, AID_ROOT,      AID_ROOT,      0, &quot;system\/xbin\/tcpdump&quot; },     { 04770, AID_ROOT,      AID_RADIO,     0, &quot;system\/bin\/pppd-ril&quot; },      \/* the following file has enhanced capabilities and IS included in user builds. *\/     { 00750, AID_ROOT,      AID_SHELL,     (1 &lt;&lt; CAP_SETUID) | (1 &lt;&lt; CAP_SETGID), &quot;system\/bin\/run-as&quot; },      { 00755, AID_ROOT,      AID_SHELL,     0, &quot;system\/bin\/*&quot; },     { 00755, AID_ROOT,      AID_ROOT,      0, &quot;system\/lib\/valgrind\/*&quot; },     { 00755, AID_ROOT,      AID_SHELL,     0, &quot;system\/xbin\/*&quot; },     { 00755, AID_ROOT,      AID_SHELL,     0, &quot;system\/vendor\/bin\/*&quot; },     { 00750, AID_ROOT,      AID_SHELL,     0, &quot;sbin\/*&quot; },     { 00755, AID_ROOT,      AID_ROOT,      0, &quot;bin\/*&quot; },     { 00750, AID_ROOT,      AID_SHELL,     0, &quot;init*&quot; },     { 00750, AID_ROOT,      AID_SHELL,     0, &quot;charger*&quot; },     { 00750, AID_ROOT,      AID_SHELL,     0, &quot;sbin\/fs_mgr&quot; },     { 00640, AID_ROOT,      AID_SHELL,     0, &quot;fstab.*&quot; },     { 00644, AID_ROOT,      AID_ROOT,      0, 0 }, }; ... <\/code><\/pre>\n<p>  \u0410 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <i>static inline void fs_config(const char *path, int dir, unsigned *uid, unsigned *gid, unsigned *mode, uint64_t *capabilities)<\/i>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u0432 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 owner, owner group, capabilities \u0438 \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043e <a href=\"http:\/\/hi.baidu.com\/donghaozheng\/item\/5fb55bbc6687d7f163388ee4\">\u0432\u0440\u0435\u043c\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043e\u0431\u0440\u0430\u0437\u0430<\/a>.<\/p>\n<p>  \u0412 \u043e\u0431\u0449\u0435\u043c \u0437\u0434\u0435\u0441\u044c \u0432\u0441\u0451 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u0435\u0435-\u043c\u0435\u043d\u0435\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 <a href=\"http:\/\/ru.wikipedia.org\/wiki\/Suid\">\u0444\u043b\u0430\u0433\u043e\u0432 \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430<\/a> (setuid \u0438 setgid) \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u00absystem\/xbin\/su\u00bb \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043a\u0430\u043a 06755, \u0433\u0434\u0435 \u043f\u0435\u0440\u0432\u0430\u044f 6 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0444\u043b\u0430\u0433 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 ID \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (4) \u0438 \u0444\u043b\u0430\u0433 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 ID \u0433\u0440\u0443\u043f\u043f\u044b (2)). \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u044d\u0442\u0438\u0445 \u0444\u043b\u0430\u0433\u043e\u0432 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0434\u043e \u0443\u0440\u043e\u0432\u043d\u044f owner (\u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0430) \u0444\u0430\u0439\u043b\u0430 \u0438\u043b\u0438 owner group (\u0433\u0440\u0443\u043f\u043f\u044b \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0430). \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 Android, \u043a\u0430\u0436\u0434\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u043e \u0441\u0432\u043e\u0438\u043c\u0438 UID \u0438 GID. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u0437 \u0441\u0432\u043e\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0435 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c native executable, \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u0442\u0435\u043c\u0438 \u0436\u0435 UID \u0438 GID, \u043a\u0430\u043a \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u0432\u044b\u0437\u0432\u0430\u0432\u0448\u0435\u0435. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0444\u043b\u0430\u0433\u043e\u0432 \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c native executable \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0430. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0432\u043b\u0430\u0434\u0435\u043b\u0435\u0446 \u2014 AID_ROOT (root). \u041f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u044d\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0437\u0430\u0437\u043e\u043c <a href=\"https:\/\/android.googlesource.com\/platform\/system\/extras\/+\/master\/su\/su.c\"><i>system\/extras\/su\/su.c<\/i><\/a>:<\/p>\n<pre><code>int main(int argc, char **argv) {     ...     int uid, gid, myuid;     ...     if(setgid(gid) || setuid(uid)) {         ...     } ... } <\/code><\/pre>\n<p>  \u0422.\u0435. \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <i>setuid<\/i> \u0438 <i>setgid<\/i>. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0438\u0441\u044c \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 owner \u0438 owner group \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u0440\u0430\u0432\u0430 \u0441\u0443\u043f\u0435\u0440\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0442.\u0435. \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451, \u0447\u0442\u043e \u0435\u043c\u0443 \u043f\u043e\u0436\u0435\u043b\u0430\u0435\u0442\u0441\u044f \ud83d\ude42 \u041f\u043e\u0434\u043e\u0431\u043d\u0430\u044f \u0430\u043d\u0430\u0440\u0445\u0438\u044f \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 Linux \u0432\u0432\u0435\u043b\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u0435 <a href=\"http:\/\/linux.die.net\/man\/7\/capabilities\">capabilities<\/a>. \u0422\u0430\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u00abrun-as\u00bb \u043d\u0435 \u043d\u0443\u0436\u043d\u044b \u0432\u0441\u0451 \u043f\u0440\u0430\u0432\u0430 \u0441\u0443\u043f\u0435\u0440\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0435\u043c\u0443 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u041a\u0441\u0442\u0430\u0442\u0438, capabilities \u043f\u043e\u0445\u043e\u0436\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u2014 \u0432 Android 2.3.x \u044f \u0438\u0445 \u043d\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b.<\/p>\n<h3>\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c<\/h3>\n<p>  \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c (\u0442\u0438\u043f\u0430, su) \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u043a\u0440\u0443\u0433 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043b\u044e\u0431\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u0441\u0443\u043f\u0435\u0440\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u0432 \u0442\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044e\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043f\u043e UID:<\/p>\n<pre><code class=\"cpp\">... #include &lt;private\/android_filesystem_config.h&gt; ... int main(int argc, char **argv) {     struct passwd *pw;     int uid, gid, myuid;      \/* Until we have something better, only root and the shell can use su. *\/     myuid = getuid();     if (myuid != AID_ROOT && myuid != AID_SHELL) {         fprintf(stderr,&quot;su: uid %d not allowed to su\\n&quot;, myuid);         return 1;     }     ... } <\/code><\/pre>\n<p>  \u0422.\u0435. \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u043e\u0442 \u0447\u044c\u0435\u0433\u043e \u0438\u043c\u0435\u043d\u0438 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044e <b>getuid()<\/b>. \u0410 \u043f\u043e\u0442\u043e\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u044d\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0436\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0435 \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 <i>\u00absystem\u00bb<\/i> \u0438 <i>\u00abroot\u00bb<\/i> \u0438\u043c\u0435\u044e\u0442 \u043f\u0440\u0430\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <b>su<\/b>.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c, \u043a\u0430\u043a \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 Native user space. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u044f \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 permission (\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f), \u043d\u043e \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u043d\u0435 \u0437\u043d\u0430\u044e, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u043b\u044e \u043a \u0438\u0445 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e. \u041a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430, \u0431\u0443\u0434\u0443 \u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0434 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f\u043c \u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c.<\/p>\n<p>  P.S. \u041f\u0440\u0438\u0433\u043b\u0430\u0441\u0438\u043b\u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0434\u043e\u043a\u043b\u0430\u0434 \u043d\u0430 <a href=\"http:\/\/habrahabr.ru\/company\/devconf\/blog\/177307\/\">DevConf@mobi <\/a> \u041a\u0430\u043a \u0432\u044b \u0434\u0443\u043c\u0430\u0435\u0442\u0435, \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044f\u043c \u0434\u043e\u043a\u043b\u0430\u0434 \u043f\u0440\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b Android \u043d\u0430 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439? <\/p>\n<p>  <\/p>\n<h4>\u0421\u0441\u044b\u043b\u043a\u0438<\/h4>\n<p>  <\/p>\n<ol>\n<li><a href=\"http:\/\/shop.oreilly.com\/product\/0636920021094.do\">\u00abEmbedded Android\u00bb<\/a> by Karim Yaghmour<\/li>\n<li><a href=\"https:\/\/marakana.com\/s\/post\/1393\/slides.htm\">\u00abAndroid Security Underpinnings\u00bb<\/a> by Marko Gargenta<\/li>\n<li><a href=\"http:\/\/library.linode.com\/using-linux\/users-and-groups\">Linux Users and Groups<\/a><\/li>\n<li><a href=\"http:\/\/hi.baidu.com\/donghaozheng\/item\/5fb55bbc6687d7f163388ee4\">\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043e\u0431\u0440\u0430\u0437\u0430<\/a><\/li>\n<li><a href=\"http:\/\/ru.wikipedia.org\/wiki\/Suid\">Suid<\/a><\/li>\n<li><a href=\"http:\/\/linux.die.net\/man\/7\/capabilities\">Overview of capabilities<\/a><\/li>\n<\/ol>\n<div class=\"clear\"><\/div>\n<\/p><\/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=\"http:\/\/habrahabr.ru\/post\/176631\/\"> http:\/\/habrahabr.ru\/post\/176631\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">\n<h3>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0443 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435 \u044f\u0434\u0440\u0430. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043e\u0442\u043a\u0443\u0434\u0430 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f system.img, userdata.img \u0438 cache.img, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0432 Native user space.<br \/>  \u0412\u0441\u0435\u043c \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c!  <\/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-176631","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/176631","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=176631"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/176631\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=176631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=176631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=176631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}