Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Go言語で実装するLinuxNameServer

 Go言語で実装するLinuxNameServer

PHPカンファレンス福岡で発表したGo言語とSTNSに関する話です。
言語カンファレンスなのですこしだけ技術的な側面に触れています。

Avatar for Kazuhiko Yamashita

Kazuhiko Yamashita

May 21, 2016
Tweet

More Decks by Kazuhiko Yamashita

Other Decks in Technology

Transcript

  1. Go?

  2. 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)) }
  3. 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ͷ໊લղܾ
  4. 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͸࡞ΕΔ
  5. 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"
  6. σϓϩΠϢʔβʔͷ؅ཧ [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ʹॻ͔ͳͯ͘ྑ্͍ʹɺ ɹ୭͕σϓϩΠग़དྷΔͷ͔Ұ໨ྎવ