Skip to content

Instantly share code, notes, and snippets.

@ftnk
Last active November 9, 2015 17:25
Show Gist options
  • Save ftnk/adea7ee7bcd4a66ef5c7 to your computer and use it in GitHub Desktop.
Save ftnk/adea7ee7bcd4a66ef5c7 to your computer and use it in GitHub Desktop.
Rubyを使って Unix Socket 経由で RAD からユーザ情報を取得する
#!/usr/bin/ruby
require 'json'
require 'excon'
require 'pp'
SOCKET_PATH = '/system/volatile/rad/radsocket-http'
connection = Excon.new('unix:///', socket: SOCKET_PATH)
post_response = connection.post(path: '/api/com.oracle.solaris.rad.authentication/1.0/Session',
body: JSON.generate({
'username' => 'root',
'password' => 'solaris',
'scheme' => 'pam',
'preserve' => true,
'timeout' => -1
}),
headers: { 'Content-Type' => 'application/json' }
)
pp post_response
puts post_response.body
cookie = post_response.headers['Set-Cookie']
put_response = connection.put(path: '/api/com.oracle.solaris.rad.usermgr/1.0/UserMgr/_rad_method/getUser',
body: JSON.generate({ 'username' => 'admin' }),
headers: { 'Content-Type' => 'application/json',
'Cookie' => cookie }
)
pp put_response
puts put_response.body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment