summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Beaupré2010-07-19 16:20:16 (GMT)
committeranarcat2010-07-20 01:07:19 (GMT)
commit37eb51ec372325b2ef025fe4b689645518621d9f (patch)
tree847dec048b1e150e9908b0656b744a9e1d8b2c8c
parent68c205c01df58c41374c26664aab73d672aef5cf (diff)
don't use get_current_user() to figure out the aegir user, but rely on the running uid instead
-rw-r--r--install.hostmaster.inc2
-rw-r--r--provision.environment.inc2
-rw-r--r--provision.file.inc6
-rw-r--r--provision.inc17
4 files changed, 22 insertions, 5 deletions
diff --git a/install.hostmaster.inc b/install.hostmaster.inc
index 0280703..3cb1dd8 100644
--- a/install.hostmaster.inc
+++ b/install.hostmaster.inc
@@ -42,7 +42,7 @@ function drush_provision_hostmaster_install($site = NULL) {
// files
'remote_host' => php_uname('n'),
'aegir_root' => $aegir_root,
- 'script_user' => drush_get_option('script_user', get_current_user()),
+ 'script_user' => drush_get_option('script_user', provision_current_user()),
// apache
'http_service_type' => 'apache',
'web_group' => drush_get_option('web_group', _provision_default_web_group()),
diff --git a/provision.environment.inc b/provision.environment.inc
index 7ba18da..721fbb4 100644
--- a/provision.environment.inc
+++ b/provision.environment.inc
@@ -317,7 +317,7 @@ class provisionServer extends provisionEnvironment {
$this->setProperty('remote_host', 'localhost');
if ($this->name == '@server_master') {
$this->setProperty('aegir_root', getenv('HOME'));
- $this->setProperty('script_user', get_current_user());
+ $this->setProperty('script_user', provision_current_user());
}
else {
$this->aegir_root = d('@server_master')->aegir_root;
diff --git a/provision.file.inc b/provision.file.inc
index a515382..e13254e 100644
--- a/provision.file.inc
+++ b/provision.file.inc
@@ -229,13 +229,13 @@ class provisionFileSystem extends provisionChainedState {
$func = ($recursive) ? array($this, '_chgrp_recursive') : 'chgrp';
if ($group = provision_posix_groupname($gid)) {
- if (provision_user_in_group(get_current_user(), $gid)) {
+ if (provision_user_in_group(provision_current_user(), $gid)) {
if (!call_user_func($func, $path, $group)) {
$this->tokens['@reason'] = dt("chgrp to @group failed on @path", array('@group' => $group, '@path' => $path));
}
}
else {
- $this->tokens['@reason'] = dt("@user is not in @group group", array("@user" => get_current_user(), "@group" => $group));
+ $this->tokens['@reason'] = dt("@user is not in @group group", array("@user" => provision_current_user(), "@group" => $group));
}
}
elseif (!@call_user_func($func, $path, $gid)) { # try to change the group anyways
@@ -394,7 +394,7 @@ class provisionFileSystem extends provisionChainedState {
}
if ($exists) {
- $this->chown($path, get_current_user())
+ $this->chown($path, provision_current_user())
->succeed($name . ' ownership of @path has been changed to @uid.')
->fail($name . ' ownership of @path could not be changed to @uid.', 'DRUSH_PERM_ERROR');
diff --git a/provision.inc b/provision.inc
index 2a76134..2f40bcb 100644
--- a/provision.inc
+++ b/provision.inc
@@ -171,6 +171,23 @@ function provision_shell_exec() {
}
/**
+ * Find the username of the current running procses
+ *
+ * This will return the username of the current running user (as seen
+ * from posix_geteuid()) and should be used instead of
+ * get_current_user() (which looks at the file owner instead).
+ *
+ * @see get_current_user()
+ * @see posix_geteuid()
+ *
+ * @return
+ * String. The username.
+ */
+function provision_current_user() {
+ return provision_posix_username(posix_geteuid());
+}
+
+/**
* Check whether a user is a member of a group.
*
* @param user