/code/classes/Daemon/SSHd_Auto/Client.class.php

https://github.com/blekkzor/pinetd2 · PHP · 35 lines · 29 code · 6 blank · 0 comment · 3 complexity · 8c451fe3c3c920709755f31376db56c4 MD5 · raw file

  1. <?php
  2. namespace Daemon\SSHd_Auto;
  3. class Client extends \Daemon\SSHd\Client {
  4. protected function login($login, $pass, $service) {
  5. $data = $this->serverCall('getLogin', array('login' => $login, 'ip' => $this->peer[0]));
  6. if (is_null($data)) return false;
  7. if (crypt($pass, $data['Password']) != $data['Password']) return false;
  8. $info = array(
  9. 'root' => $data['Path'],
  10. 'suid_user' => 'nobody', // force suid on login
  11. 'suid_group' => 'nobody', // force suid on login
  12. 'write_level' => $data['Access'],
  13. );
  14. return $this->doLogin($info);
  15. }
  16. protected function serverCall($method, array $params) {
  17. $params['server'] = $this->IPC->getName();
  18. $headers = array(
  19. 'X-IPC: STATIC',
  20. 'X-Path: Service/Hosting::'.$method,
  21. );
  22. $ch = curl_init('http://www.uid.st/');
  23. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  24. curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
  25. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params, '', '&'));
  26. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  27. return unserialize(curl_exec($ch));
  28. }
  29. }