ruby-changes:10566
From: akr <ko1@a...>
Date: Sun, 8 Feb 2009 18:47:25 +0900 (JST)
Subject: [ruby-changes:10566] Ruby:r22122 (trunk): * ext/socket/ancdata.c (anc_inspect_passcred_credentials): new
akr 2009-02-08 18:47:00 +0900 (Sun, 08 Feb 2009) New Revision: 22122 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=22122 Log: * ext/socket/ancdata.c (anc_inspect_passcred_credentials): new function to show SCM_CREDENTIALS on GNU/Linux. Modified files: trunk/ChangeLog trunk/ext/socket/ancdata.c Index: ChangeLog =================================================================== --- ChangeLog (revision 22121) +++ ChangeLog (revision 22122) @@ -1,3 +1,8 @@ +Sun Feb 8 18:46:15 2009 Tanaka Akira <akr@f...> + + * ext/socket/ancdata.c (anc_inspect_passcred_credentials): new + function to show SCM_CREDENTIALS on GNU/Linux. + Sun Feb 8 18:34:43 2009 Nobuyoshi Nakada <nobu@r...> * io.c (rb_io_s_binread): ensures file path. [ruby-dev:37940] Index: ext/socket/ancdata.c =================================================================== --- ext/socket/ancdata.c (revision 22121) +++ ext/socket/ancdata.c (revision 22122) @@ -376,6 +376,23 @@ } #endif +#if defined(SCM_CREDENTIALS) /* GNU/Linux */ +static int +anc_inspect_passcred_credentials(int level, int type, VALUE data, VALUE ret) +{ + if (level == SOL_SOCKET && type == SCM_CREDENTIALS && + RSTRING_LEN(data) == sizeof(struct ucred)) { + struct ucred cred; + memcpy(&cred, RSTRING_PTR(data), sizeof(struct ucred)); + rb_str_catf(ret, " pid=%u uid=%u gid=%u", cred.pid, cred.uid, cred.gid); + return 0; + } + else { + return -1; + } +} +#endif + #if defined(IPPROTO_IP) && defined(IP_RECVDSTADDR) /* 4.4BSD */ static int anc_inspect_ip_recvdstaddr(int level, int type, VALUE data, VALUE ret) @@ -497,6 +514,9 @@ # if defined(SCM_RIGHTS) /* 4.4BSD */ case SCM_RIGHTS: if (anc_inspect_socket_rights(level, type, data, ret) == -1) goto dump; break; # endif +# if defined(SCM_CREDENTIALS) /* GNU/Linux */ + case SCM_CREDENTIALS: if (anc_inspect_passcred_credentials(level, type, data, ret) == -1) goto dump; break; +# endif default: goto dump; } break; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/