1
0
Fork 0

Merge pull request #7819 from yassine-ah/patch-3

Ask confirmation when is run as admin
pull/7947/head
Jordi Boggiano 2018-12-21 11:56:45 +01:00 committed by GitHub
commit 618e21f1c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -207,6 +207,12 @@ class Application extends BaseApplication
if (function_exists('posix_getuid') && posix_getuid() === 0) { if (function_exists('posix_getuid') && posix_getuid() === 0) {
if ($commandName !== 'self-update' && $commandName !== 'selfupdate') { if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {
$io->writeError('<warning>Do not run Composer as root/super user! See https://getcomposer.org/root for details</warning>'); $io->writeError('<warning>Do not run Composer as root/super user! See https://getcomposer.org/root for details</warning>');
if ($io->isInteractive()) {
if (!$io->askConfirmation('<info>Continue as root/super user</info> [<comment>yes</comment>]? ', true)) {
return 1;
}
}
} }
if ($uid = (int) getenv('SUDO_UID')) { if ($uid = (int) getenv('SUDO_UID')) {
// Silently clobber any sudo credentials on the invoking user to avoid privilege escalations later on // Silently clobber any sudo credentials on the invoking user to avoid privilege escalations later on