{"id":2754,"date":"2011-10-01T03:08:26","date_gmt":"2011-09-30T18:08:26","guid":{"rendered":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=2754"},"modified":"2011-10-02T00:14:52","modified_gmt":"2011-10-01T15:14:52","slug":"unix-%e3%83%89%e3%83%a1%e3%82%a4%e3%83%b3%e3%82%bd%e3%82%b1%e3%83%83%e3%83%88%e3%81%a7%e3%81%ae-unix-credentials-%e3%81%ae%e3%82%84%e3%82%8a%e3%81%a8%e3%82%8a%ef%bc%88sock_stream-%e7%b7%a8%ef%bc%89","status":"publish","type":"post","link":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=2754","title":{"rendered":"UNIX \u30c9\u30e1\u30a4\u30f3\u30bd\u30b1\u30c3\u30c8\u3067\u306e unix credentials \u306e\u3084\u308a\u3068\u308a\uff08SOCK_STREAM \u7de8\uff09"},"content":{"rendered":"<p>UNIX \u30c9\u30e1\u30a4\u30f3\u30bd\u30b1\u30c3\u30c8\u3092\u4f7f\u3063\u3066\u3044\u308b\u5834\u5408\u3001INET \u30c9\u30e1\u30a4\u30f3\u3084 INET6 \u30c9\u30e1\u30a4\u30f3\u306a\u3069\u306e\u5834\u5408\u3068\u9055\u3063\u3066\u3001\u901a\u4fe1\u76f8\u624b\uff08\u6b63\u78ba\u306b\u306f\u901a\u4fe1\u3092\u958b\u59cb\u3057\u305f\u76f8\u624b\uff09\u306e PID, UID, GID \u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002\u901a\u4fe1\u76f8\u624b\u304c\u540d\u4e57\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u30ab\u30fc\u30cd\u30eb\u304b\u3089\u60c5\u5831\u3092\u53d6\u308b\u3053\u3068\u306b\u306a\u308b\u306e\u3067\u3001\u53d6\u5f97\u3057\u305f\u60c5\u5831\u306f\u4fe1\u983c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3061\u3087\u3063\u3068\u5fc5\u8981\u306b\u306a\u3063\u305f\u306e\u3067\u3001SOCK_STREAM \u306a\u30bd\u30b1\u30c3\u30c8\u306e\u5834\u5408\u3092\u8abf\u3079\u3066\u307f\u307e\u3057\u305f\u3002SOCK_DGRAM \u306e\u5834\u5408\u3067\u3082\u53d6\u5f97\u3067\u304d\u307e\u3059\u304c\u3001\u305d\u306e\u5834\u5408\u3060\u3068\u540c\u4e00\u306e\u30bd\u30b1\u30c3\u30c8\u3067\u3042\u3063\u3066\u3082\u30d1\u30b1\u30c3\u30c8\u3054\u3068\u306b\u9055\u3046\u76f8\u624b\u3067\u3042\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u305f\u3081\u3001\u53d6\u5f97\u304c\u3081\u3093\u3069\u304f\u3055\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u30bd\u30b1\u30c3\u30c8\u306b\u95a2\u3059\u308b\u60c5\u5831\u306a\u306e\u3067\u3001\u5f53\u7136 getsockopt() \u3067\u53d6\u5f97\u3059\u308b\u306e\u3067\u3059\u304c\u3001\u3053\u306e\u3042\u305f\u308a\u306f POSIX \u306a\u3069\u3067\u306f\u6a19\u6e96\u5316\u3055\u308c\u3066\u304a\u3089\u305a\u3001OS \u306b\u3088\u3063\u3066\u307e\u3061\u307e\u3061\u3067\u3059\u3002\u305d\u306e\u307e\u3061\u307e\u3061\u306a\u306e\u3092\u8abf\u3079\u305f\u306e\u304c\u4ee5\u4e0b\u306e\u8868\u3067\u3059\u3002<\/p>\n<table border>\n<tr>\n<th rowspan=\"2\">OS<\/th>\n<th colspan=\"3\">getsockopt() \u306e\u5f15\u6570<\/th>\n<th rowspan=\"2\">&lt;sys\/socket.h&gt; \u3068 &lt;sys\/un.h&gt; \u4ee5\u5916\u306b\u5fc5\u8981\u306a\u30d8\u30c3\u30c0\u30d5\u30a1\u30a4\u30eb<\/th>\n<th rowspan=\"2\">\u5148\u306b\u5b9a\u7fa9\u3059\u308b\u5fc5\u8981\u306e\u3042\u308b\u30de\u30af\u30ed<\/th>\n<\/tr>\n<tr>\n<th>\u7b2c2\u5f15\u6570 (level)<\/th>\n<th>\u7b2c3\u5f15\u6570 (optname)<\/th>\n<th>\u7b2c4\u5f15\u6570\u306e\u578b<\/th>\n<\/tr>\n<tr>\n<td>Linux<\/td>\n<td>SOL_SOCKET<\/td>\n<td>SO_PEERCRED<\/td>\n<td>struct ucred<\/td>\n<td>\u4e0d\u8981<\/td>\n<td>_GNU_SOURCE<\/td>\n<\/tr>\n<tr>\n<td>FreeBSD<\/td>\n<td>0<\/td>\n<td>LOCAL_PEERCRED<\/td>\n<td>struct xucred<br \/>PID \u306f\u53d6\u308c\u306a\u3044<br \/>GID \u306f\u30d7\u30e9\u30a4\u30de\u30ea\u4ee5\u5916\u306e\u3082\u306e\u3082\u53d6\u308c\u308b<\/td>\n<td>&lt;sys\/ucred.h&gt;<\/td>\n<td>\u306a\u3057<\/td>\n<\/tr>\n<tr>\n<td>OpenBSD<\/td>\n<td>SOL_SOCKET<\/td>\n<td>SO_PEERCRED<\/td>\n<td>struct sockpeercred<\/td>\n<td>\u4e0d\u8981<\/td>\n<td>_BSD_SOURCE<\/td>\n<\/tr>\n<tr>\n<td>NetBSD 5 \u4ee5\u964d<\/td>\n<td>0<\/td>\n<td>LOCAL_PEEREID<\/td>\n<td>struct unpcbid<\/td>\n<td>\u4e0d\u8981<\/td>\n<td>_NETBSD_SOURCE<\/td>\n<\/tr>\n<tr>\n<td>Mac OS X<\/td>\n<td>0<\/td>\n<td>LOCAL_PEERCRED<\/td>\n<td>struct xucred<br \/>PID \u306f\u53d6\u308c\u306a\u3044<br \/>GID \u306f\u30d7\u30e9\u30a4\u30de\u30ea\u4ee5\u5916\u306e\u3082\u306e\u3082\u53d6\u308c\u308b<\/td>\n<td>&lt;sys\/ucred.h&gt;<\/td>\n<td>\u306a\u3057<\/td>\n<\/tr>\n<\/table>\n<p>\u3061\u306a\u307f\u306b\u3001\u300c\u901a\u4fe1\u76f8\u624b \u306e PID \u7b49\u300d\u304c\u78ba\u5b9a\u3059\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u306f\u3001\u53b3\u5bc6\u306b\u8a00\u3046\u3068\u5b9f\u88c5\u306b\u3088\u3063\u3066\u5fae\u5999\u306b\u7570\u306a\u308a\u307e\u3059\u3002socketpair() \u3067\u4f5c\u3063\u305f\u30bd\u30b1\u30c3\u30c8\u306e\u5834\u5408\u306f socketpair() \u3092\u547c\u3093\u3060\u30bf\u30a4\u30df\u30f3\u30b0\u306e\u3082\u306e\u304c\u53d6\u308c\u3001accept() \u3067\u8fd4\u3063\u3066\u304d\u305f\u30bd\u30b1\u30c3\u30c8\u306e\u5834\u5408\u306f\u901a\u4fe1\u76f8\u624b\uff08\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\uff09\u306e\u30bd\u30b1\u30c3\u30c8\u306b\u95a2\u3057\u3066 connect() \u3092\u547c\u3093\u3060\u30bf\u30a4\u30df\u30f3\u30b0\u306e\u3082\u306e\u304c\u53d6\u308c\u307e\u3059\uff08\u3053\u3053\u307e\u3067\u306f\u3069\u306e\u5b9f\u88c5\u3082\u540c\u3058\uff09\u3002\u4e00\u65b9\u3001connect() \u304c\u5b8c\u4e86\u3057\u305f\u30bd\u30b1\u30c3\u30c8\u306e\u5834\u5408\u306f\u3001\u901a\u4fe1\u76f8\u624b\uff08\u30b5\u30fc\u30d0\uff09\u306e\u30bd\u30b1\u30c3\u30c8\u306e\u5143\u3068\u306a\u3063\u305f\u30bd\u30b1\u30c3\u30c8\u306b\u95a2\u3057\u3066 bind() \u3092\u547c\u3093\u3060\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u3042\u3063\u305f\u308a\u3001listen() \u3092\u547c\u3093\u3060\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u3042\u3063\u305f\u308a\u3057\u307e\u3059\u3002\u3082\u3063\u3068\u3082\u3001bind() \u6642\u3068 listen() \u6642\u3068\u3067 PID \u3084 EUID \u304c\u9055\u3046\u3068\u3044\u3046\u3053\u3068\u306f\u666e\u901a\u306a\u3044\u306e\u3067\u3001\u6c17\u306b\u3059\u308b\u3088\u3046\u306a\u3053\u3068\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u3002privilege separation \u3057\u3066\u3044\u308b\u3068\u5225\u3067\u3059\u304c\u3002\u3066\u3044\u3046\u304b\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u304c\u30b5\u30fc\u30d0\u306e UID \u3092\u53d6\u5f97\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u5834\u9762\u3082\u306a\u304b\u306a\u304b\u7121\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<hr \/>\n<p>\u3068\u3053\u308d\u3067\u3001\u9014\u4e2d\u307e\u3067\u8abf\u3079\u3066\u3001MySQL\u306e\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306b\u306f\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u305f\u30e6\u30fc\u30b6\u3092\u5143\u306b\u30e6\u30fc\u30b6\u540d\u3084\u30d1\u30b9\u30ef\u30fc\u30c9\u7b49\u3092\u805e\u304b\u305a\u306b\u8a8d\u8a3c\u3059\u308b\u4ed5\u7d44\u307f\u304c\u3042\u3063\u305f\u306e\u3092\u601d\u3044\u51fa\u3057\u305f\u306e\u3067\u3001\u306a\u30fc\u3093\u3060 MySQL \u306e\u30bd\u30fc\u30b9\u898b\u305f\u3089\uff08\u81ea\u5206\u3067\u8abf\u3079\u306a\u304f\u3066\u3082\uff09\u89e3\u6c7a\u3058\u3083\u30fc\u3093\u3068\u601d\u3063\u305f\u3093\u3067\u3059\u304c\u3001\u30bd\u30fc\u30b9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u3088\u304f\u898b\u305f\u3089 Linux \u306e\u5b9f\u88c5\u3057\u304b\u5165\u3063\u3066\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u3050\u3063\u3059\u3057\u3002\u3093\u3067\u81ea\u5206\u3067\u8abf\u3079\u305f\u7d50\u679c\u304c\u4e0a\u306e\u8868\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>UNIX \u30c9\u30e1\u30a4\u30f3\u30bd\u30b1\u30c3\u30c8\u3092\u4f7f\u3063\u3066\u3044\u308b\u5834\u5408\u3001INET \u30c9\u30e1\u30a4\u30f3\u3084 INET6 \u30c9\u30e1\u30a4\u30f3\u306a\u3069\u306e\u5834\u5408\u3068\u9055\u3063\u3066\u3001\u901a\u4fe1\u76f8\u624b\uff08\u6b63\u78ba\u306b\u306f\u901a\u4fe1\u3092\u958b\u59cb\u3057\u305f\u76f8\u624b\uff09\u306e PID, UID, GID \u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002\u901a\u4fe1\u76f8\u624b\u304c\u540d\u4e57\u308b\u306e [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-2754","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2754","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2754"}],"version-history":[{"count":23,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2754\/revisions"}],"predecessor-version":[{"id":2779,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2754\/revisions\/2779"}],"wp:attachment":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2754"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}