Commit 2db8273bee3b6900a7a0583da01ef6980e0fa0dd
1 parent
757be03f
Add KTUtil::running_user (a copy of KTLegacyLog::running_user).
It returns the name of the system user that is running the KnowledgeTree server (ie, "www-data", "www-run", "nobody", or similar). git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5238 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
17 additions
and
0 deletions
lib/util/ktutil.inc
| ... | ... | @@ -570,6 +570,23 @@ class KTUtil { |
| 570 | 570 | |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | + function running_user() { | |
| 574 | + if (substr(PHP_OS, 0, 3) == "WIN") { | |
| 575 | + return null; | |
| 576 | + } | |
| 577 | + if (extension_loaded("posix")) { | |
| 578 | + $uid = posix_getuid(); | |
| 579 | + $userdetails = posix_getpwuid($uid); | |
| 580 | + return $userdetails['name']; | |
| 581 | + } | |
| 582 | + if (file_exists('/usr/bin/whoami')) { | |
| 583 | + return exec('/usr/bin/whoami'); | |
| 584 | + } | |
| 585 | + if (file_exists('/usr/bin/id')) { | |
| 586 | + return exec('/usr/bin/id -nu'); | |
| 587 | + } | |
| 588 | + return null; | |
| 589 | + } | |
| 573 | 590 | } |
| 574 | 591 | |
| 575 | 592 | /** | ... | ... |