Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2183 Fixed .my.cnf messing up mysql connection + minor credential-leak fix #2387

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion includes/filesystem.inc
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,12 @@ function drush_program_exists($program) {
* @param string $suffix
* Append string to filename. use of this parameter if is discouraged. @see
* drush_tempnam().
* @param int $mode
* Optional filemode to set upon creation.
* @return string
* A path to the file.
*/
function drush_save_data_to_temp_file($data, $suffix = NULL) {
function drush_save_data_to_temp_file($data, $suffix = NULL, $mode = NULL) {
static $fp;

$file = drush_tempnam('drush_', NULL, $suffix);
Expand All @@ -425,6 +427,11 @@ function drush_save_data_to_temp_file($data, $suffix = NULL) {
$file = $meta_data['uri'];
fclose($fp);

// Set filemode.
if ($mode) {
@chmod($file, $mode);
}

return $file;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Drush/Sql/Sqlmysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public function creds($hide_password = TRUE) {
password="{$this->db_spec['password']}"
EOT;

$file = drush_save_data_to_temp_file($contents);
$parameters['defaults-extra-file'] = $file;
$file = drush_save_data_to_temp_file($contents, NULL, 0600);
$parameters['defaults-file'] = $file;
}
else {
// User is required. Drupal calls it 'username'. MySQL calls it 'user'.
Expand Down
3 changes: 1 addition & 2 deletions lib/Drush/Sql/Sqlpgsql.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ private function password_file() {
$part = str_replace(array('\\', ':'), array('\\\\', '\:'), $part);
});
$pgpass_contents = implode(':', $pgpass_parts);
$password_file = drush_save_data_to_temp_file($pgpass_contents);
chmod($password_file, 0600);
$password_file = drush_save_data_to_temp_file($pgpass_contents, NULL, 0600);
}
return $password_file;
}
Expand Down