diff --git a/src/Mage/Runtime/Runtime.php b/src/Mage/Runtime/Runtime.php index cab246d..8ec0036 100644 --- a/src/Mage/Runtime/Runtime.php +++ b/src/Mage/Runtime/Runtime.php @@ -446,4 +446,15 @@ class Runtime { return tempnam(sys_get_temp_dir(), 'mage'); } + + /** + * Get the current user + * + * @return string + */ + public function getCurrentUser() + { + $userData = posix_getpwuid(posix_geteuid()); + return $userData['name']; + } } diff --git a/src/Mage/Task/BuiltIn/Deploy/RsyncTask.php b/src/Mage/Task/BuiltIn/Deploy/RsyncTask.php index da5fd04..5ae69ae 100644 --- a/src/Mage/Task/BuiltIn/Deploy/RsyncTask.php +++ b/src/Mage/Task/BuiltIn/Deploy/RsyncTask.php @@ -35,7 +35,7 @@ class RsyncTask extends AbstractTask { $flags = $this->runtime->getConfigOptions('rsync', '-avz'); $sshConfig = $this->runtime->getSSHConfig(); - $user = $this->runtime->getEnvironmentConfig('user'); + $user = $this->runtime->getEnvironmentConfig('user', $this->runtime->getCurrentUser()); $host = $this->runtime->getWorkingHost(); $hostPath = rtrim($this->runtime->getEnvironmentConfig('host_path'), '/'); $targetDir = rtrim($hostPath, '/'); diff --git a/src/Mage/Task/BuiltIn/Deploy/TarGz/CopyTask.php b/src/Mage/Task/BuiltIn/Deploy/TarGz/CopyTask.php index ba16706..03201d1 100644 --- a/src/Mage/Task/BuiltIn/Deploy/TarGz/CopyTask.php +++ b/src/Mage/Task/BuiltIn/Deploy/TarGz/CopyTask.php @@ -37,7 +37,7 @@ class CopyTask extends AbstractTask throw new DeploymentException('This task is only available with releases enabled', 40); } - $user = $this->runtime->getEnvironmentConfig('user'); + $user = $this->runtime->getEnvironmentConfig('user', $this->runtime->getCurrentUser()); $host = $this->runtime->getWorkingHost(); $sshConfig = $sshConfig = $this->runtime->getSSHConfig(); $hostPath = rtrim($this->runtime->getEnvironmentConfig('host_path'), '/'); diff --git a/src/Mage/Tests/Runtime/RuntimeTest.php b/src/Mage/Tests/Runtime/RuntimeTest.php index 020bcc4..d8c4c84 100644 --- a/src/Mage/Tests/Runtime/RuntimeTest.php +++ b/src/Mage/Tests/Runtime/RuntimeTest.php @@ -154,4 +154,14 @@ class RuntimeTest extends TestCase $process = $runtime->runLocalCommand('false'); $this->assertFalse($process->isSuccessful()); } + + public function testCurrentUser() + { + $runtime = new Runtime(); + $userData = posix_getpwuid(posix_geteuid()); + + $this->assertTrue(is_array($userData)); + $this->assertArrayHasKey('name', $userData); + $this->assertEquals($userData['name'], $runtime->getCurrentUser()); + } }