Skip to content

Commit a9800d0

Browse files
committed
Fix for bugs 18402580 and 18402999, as suggested for 18402580
Instead of relying on $HOME, use Perl's getpwuid() to get home dir.
1 parent 31b15a5 commit a9800d0

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

scripts/mysql_install_db.pl.in

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -323,17 +323,8 @@ my $password;
323323
my $escaped_password; # the password, with special characters escaped
324324

325325
sub ensure_secret_file {
326-
if ( exists $ENV{HOME} ) {
327-
$secret_file = $ENV{HOME} . "/.mysql_secret";
328-
} elsif ( -d "/root" ) {
329-
# If we don't have any environment this might be because we're
330-
# running as a service script. Assume the user is root and that he has
331-
# a standard root account.
332-
$secret_file= "/root/.mysql_secret";
333-
} else
334-
{
335-
die "ERROR: Found no /root home directory. Please create one.";
336-
}
326+
my $home = (getpwuid($>))[7];
327+
$secret_file = $home . "/.mysql_secret";
337328

338329
# Create safe files to avoid leaking info to other users
339330
# Loop may be extended if we need more ...

0 commit comments

Comments
 (0)