Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Go言語で実装するLinuxNameServer
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Kazuhiko Yamashita
May 21, 2016
Technology
4.4k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Go言語で実装するLinuxNameServer
PHPカンファレンス福岡で発表したGo言語とSTNSに関する話です。
言語カンファレンスなのですこしだけ技術的な側面に触れています。
Kazuhiko Yamashita
May 21, 2016
More Decks by Kazuhiko Yamashita
See All by Kazuhiko Yamashita
タクシーアプリ『GO』の バックエンド開発のおける AI利活用と若者のすべて
pyama86
3
2.7k
継続的な負荷検証を目指して
pyama86
3
1.9k
成長期における、 ユーザー領域の複雑さと 整備の進め方
pyama86
1
840
Stay Hacker 〜九州で生まれ、Perlに出会い、コミュニティで育つ〜
pyama86
2
6.7k
Managing Database Migrations in Go Backend Systems
pyama86
0
610
新しい職場の CI が 20 分かかっていたらあなたならどうする?
pyama86
2
1.6k
事業を差別化する技術を生み出す技術
pyama86
4
2.4k
Re:Define 可用性を支える モニタリング、パフォーマンス最適化、そしてセキュリティ
pyama86
9
11k
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
2.2k
Other Decks in Technology
See All in Technology
NDIでApple Vision Proにリアルタイム映像送信
jyouryuusui
0
130
Active Record Connection Adaptersにおける長年の課題に再び取り組む
yahonda
0
200
Post AI時代のリファクタリング実践記 / Refactoring in the post AI era
kaminashi
1
270
PHPカンファレンス関西の招待状 / Invitation to PHP Conference Kansai
ykanoh
0
200
AIカンパニーへの転換を支えた、エンジニアの仕事の再定義
kworkdev
PRO
2
1.3k
コンテナ運用におけるネットワーク・コンテナコストの削減方法/How to Reduce Network and Container Costs in Container Operations
masakiokuda
1
280
会社説明資料
persolserverworks
0
9.8k
V8のArray.prototype.flatを最大約20倍速くするまでと、巨大OSSへの大規模コミットの道のり
riyaamemiya
0
300
SAENM ~Jupyterで残すPoCの試行錯誤、未来の自分と仲間を助ける記録!~
terapyon
0
120
S3 Filesで挑む! 八戸せんべい汁の食べ頃問題
usanchuu
0
110
Tofu-Controller lightning talk @ Containerday 2026
gionn
0
120
オントロジーって 結局なにもの? AI エージェントに「意味」を渡す知識設計の話
greenmidori
0
230
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
330
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
370
Color Theory Basics | Prateek | Gurzu
gurzu
1
490
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
380
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
340
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
220
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
310
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
1k
Transcript
ʙීஈPHPॻ͍ͯ·͢ฤʙ GoݴޠͰ࣮͢ΔLinuxNameServer
hi! GMO Pepabo, Inc. ϗεςΟϯάࣄۀ෦ ϜʔϜʔυϝΠϯάϧʔϓ γχΞΤϯδχΞ @pyama86
blog https://ten-snapon.com
Go 1.5
-buildmode=c-shared Go 1.5͔ΒCGOΛར༻͠ڞ༗ϥΠϒϥϦΛ࡞Մೳʹ http://qiita.com/masakielastic/items/09018646d7d34996190a
Go?
ϫϯόΠφϦͰΠέͯΔίϚϯυ peco pt ghq ghr
ઌਐతWeb։ൃʁ
Linux Middleware
Before Go 1.5 LinuxͷOSϨΠϠͷ༷Λม͑Δʹɺਂ͘ͳΕ ͳΔ΄ͲCݴޠͷ΄΅ಠஃͰ͋ͬͨͱࢥ͏
After Go 1.5 GoݴޠΛ༻͍ͯɺLightweight LanguageͷΑ͏ͳॻ͖ ຯͰɺLinuxOSͷϛυϧΣΞ։ൃ͕Մೳʹͳͬͨ package main /* #include
<pwd.h> #include <sys/types.h> */ import "C" //export _nss_stns_getpwnam_r func _nss_stns_getpwnam_r(name *C.char, pwd *C.struct_passwd) int { return set(&Passwd{pwd, result}, "user", "name", C.GoString(name)) }
None
STNS LinuxͷϢʔβʔɺάϧʔϓͷ໊લղܾɺೝূػೳΛ ఏڙ͢ΔLinuxNameService % ls -ltr -rw-r--r-- 1 pyama wheel
0 May 8 00:09 php_fukuoka.txt % ls -ltr -rw-r--r-- 1 1000 1000 0 May 8 00:09 php_fukuoka.txt id:1000 to pyamaͷ໊લղܾ
STNSͷഎܠ 1.DevOpsɺσϓϩΠڥͷભҠʹΑͬͯSSHϩάΠ ϯ͕ඞཁͳϢʔβʔͷ૿Ճ 2.Ϣʔβʔ૿Ճ࿈ܞઌ૿Ճʹ͍ഁ͔͚ͨ͠ LDAP͔ΒͷҠߦઌ 3.ͱʹ͔͘ͱ͍͏࠽ೳΛӡ༻ཧͱ͔ʹ͍ͨ͘ ͳ͔ͬͨ
ίϯηϓτ ໊લղܾɺެ։伴औಘɺsudoೝূͷΈΛఏڙ͢Δɻ ଟ͘ΛΒͣɺγϯϓϧʹอͭ͜ͱͰཧɺ Έ߹ΘͤΛ༰қʹɻ https://github.com/STNS/STNS
ΞʔΩςΫνϟ STNS http(1104) Client ls libnss-stns libpam-stns query-wrapper key-wrapper /user/name/pyama
{ name:pyama, id: 1000, dir:/home/pyama … }
ΞʔΩςΫνϟ STNS http(1104) Client ls libnss-stns libpam-stns query-wrapper key-wrapper /user/name/pyama
{ name:pyama, id: 1000, dir:/home/pyama … }
nss Network Security Service libnss_<name>.so.2(version)ͷϥΠϒϥϦΛಡΈࠐ Έɺ໋໊نʹ߹கͨ͠γϯϘϧ͕ଘࡏ͢Δ߹ίʔ ϧͯ͘͠ΕΔ http://www.gnu.org/software/libc/manual/html_node/NSS- Modules-Interface.html
nss passwd _nss_stns_getpwnam_r _nss_stns_getpwuid_r _nss_stns_setpwent _nss_stns_endpwent _nss_stns_getpwent_r group _nss_stns_getgrnam_r _nss_stns_getgrgid_r
_nss_stns_setgrent _nss_stns_endgrent _nss_stns_getgrent_r shadow _nss_stns_getspnam_r _nss_stns_setspent _nss_stns_endspent _nss_stns_getspent_r libnss_stns.so ͜ͷ໊લͷfunctionΛఆٛ͢Δ͚ͩͰ STNS࡞ΕΔ
stns.conf(αʔό) port = 1104 include = "/etc/stns/conf.d/*" # ϕʔγοΫೝূΛαϙʔτ user
= "basic_user" password = "basic_password" [users.example] id = 1001 group_id = 1001 keys = ["ssh-rsa XXXXX…"] [groups.example] id = 1001 users = ["example"] [sudoers.example] password = "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" hash_type = "sha256"
ࠓ෩ͳػೳ
ΞϓϦέʔγϣϯσϓϩΠ
[email protected]
[email protected]
[email protected]
/home/deploy/.ssh/authrized_keys ʹ֤Ϣʔβʔͷެ։伴Λొ
σϓϩΠϢʔβʔͷཧ ࡢࠓͷWebαʔϏεͰσϓϩΠઐ༻ϢʔβʔΛઃ ͚ͯσϓϩΠ͢Δ͜ͱ͕ଟ͍ɻ ͔͠͠ɺطଘͷΈͰ࣮ݱ͢ΔʹσϓϩΠϢʔ βʔͷ~/.ssh/authorized_keysʹσϓϩΠ͢ΔϢʔ βʔͷެ։伴ΛฒͨΓ͢Δඞཁ͕͋ͬͨ
σϓϩΠϢʔβʔͷཧ [users.deploy] id = 1000 group_id = 1000 link_users =
[“example1","example2"] [users.foo] keys = ["ssh-rsa aaa”] [users.bar] keys = ["ssh-rsa bbb"] deployϢʔβʔͰSSHϩάΠϯ͢Δࡍʹɺlink_usersͰ ࢦఆͨ͠Ϣʔβʔͷެ։伴Λར༻͢Δ͜ͱ͕ग़དྷΔ →authorized_keysʹॻ͔ͳͯ͘ྑ্͍ʹɺ ɹ୭͕σϓϩΠग़དྷΔͷ͔Ұྎવ
ͬͯΈΔʁ
ಋೖͷखܰ͞ 1ίϚϯυͰϦϙδτϦΛՃ͠ɺ yumɺaptͰ࠷৽൛Λར༻Մೳ
ಋೖͷखܰ͞ puppetϚχϑΣετɺchefΫοΫϒοΫΛఏڙ Ճ͑ͯຊޠΠϯετʔϧυΩϡϝϯτ https://github.com/STNS/STNS/blob/master/docs/install_ja.md
ৄࡉઌि౦ژʹஔ͍͖ͯͨ https://www.youtube.com/watch?v=ZBuEsQ3rnm4
ͯ͞ΓɺGo
CGOʹز੍͔͕ͭ͋Δ 1.ڞ༗ϥΠϒϥϦʹग़དྷΔͷmainύοέʔδͷΈ 2.CGOtestʹؚΊΒΕͳ͍ 3.Go 1.5Ͱ32bitͷڞ༗ϥΠϒϥϦ͕αϙʔτ͞Ε ͍ͯͳ͍(1.6OK)
LinuxϛυϧΣΞ࡞Δʹ֮ޛ͕͍Δ ʮ$ ls ~ʯͷΑ͏ʹೖྗޙλϒิͨ͠ࡍʹɺ bash͕clone͞Εͯɺΰϧʔνϯ͕ແݶϧʔϓͨ͠Γ
$ strace getent passwd
$ LD_DEBUG=symbols,bindings id
$ vim ldap-pwd.c
࠶ܝ ͨͩ͠ɺCݴޠͷ࠷ݶͷࣝɺ ૬Ԡͷσόοάೳྗඞཁ
ʹͱͬͯGo͕ ࠷ޙͷҰຕͩͬͨ
Go ɾόΠφϦ ɾڞ௨ϥΠϒϥϦ ɾαʔό ɾΫϩείϯύΠϧ ɾѹతੜ࢈ੑ
৽͍͠ݴޠͰ ৽͍͠ՁΛੜΊͨ