functions.core.posix.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /* $Id: functions.core.posix.php 2834 2007-04-08 12:51:00Z b4rt $ */
  3. /*******************************************************************************
  4. LICENSE
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License (GPL)
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. To read the license please visit http://www.gnu.org/copyleft/gpl.html
  14. *******************************************************************************/
  15. /**
  16. * posix_kill
  17. *
  18. * @param $pid
  19. * @param $sig
  20. * @return string
  21. */
  22. function posix_kill($pid, $sig) {
  23. return exec("kill -s ".$sig." ".$pid);
  24. }
  25. /**
  26. * posix_geteuid
  27. *
  28. * @author osearth@gmail.c0m
  29. *
  30. * @return string
  31. */
  32. function posix_geteuid() {
  33. return exec("id -u");
  34. }
  35. /**
  36. * posix_getpwuid
  37. *
  38. * @author osearth@gmail.c0m
  39. *
  40. * @param $uid
  41. * @return array
  42. */
  43. function posix_getpwuid($uid) {
  44. if (!$uid) return FALSE;
  45. $file = file("/etc/passwd");
  46. foreach ($file as $f) {
  47. $l = explode(":",$f);
  48. if ($l[2] == $uid) {
  49. $out[name] = $l[0];
  50. $out[passwd] = $l[1];
  51. $out[uid] = $l[2];
  52. $out[gid] = $l[3];
  53. $out[gecos] = $l[4];
  54. $out[dir] = $l[5];
  55. $out[shell] = $l[6];
  56. return $out;
  57. }
  58. }
  59. }
  60. ?>