Skip to content

Commit 3c8e117

Browse files
Merge branch '4.4' into 5.0
* 4.4: (30 commits) [Security] Check UserInterface::getPassword is not null before calling needsRehash gracefully handle missing event dispatchers Fix TokenStorage::reset not called in stateless firewall [DotEnv] Remove `usePutEnv` property default value [HttpFoundation] get currently session.gc_maxlifetime if ttl doesnt exists Set up typo fix [DependencyInjection] Handle env var placeholders in CheckTypeDeclarationsPass [Cache] fix memory leak when using PhpArrayAdapter [Validator] Allow underscore character "_" in URL username and password [TwigBridge] Update bootstrap_4_layout.html.twig [FrameworkBundle][SodiumVault] Create secrets directory only when needed fix parsing negative octal numbers [SecurityBundle] Passwords are not encoded when algorithm set to \"true\" [DependencyInjection] Resolve expressions in CheckTypeDeclarationsPass [SecurityBundle] Properly escape regex in AddSessionDomainConstraintPass do not validate passwords when the hash is null [DI] fix resolving bindings for named TypedReference [Config] never try loading failed classes twice with ClassExistenceResource [Mailer] Fix SMTP Authentication when using STARTTLS [DI] Fix making the container path-independent when the app is in /app ...
2 parents 1ea35cf + c71ab8d commit 3c8e117

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Command/ContainerDebugCommand.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Component\Console\Input\InputOption;
2222
use Symfony\Component\Console\Output\OutputInterface;
2323
use Symfony\Component\Console\Style\SymfonyStyle;
24+
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
2425
use Symfony\Component\DependencyInjection\ContainerBuilder;
2526
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
2627
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
@@ -228,6 +229,8 @@ protected function getContainerBuilder(): ContainerBuilder
228229
$container->compile();
229230
} else {
230231
(new XmlFileLoader($container = new ContainerBuilder(), new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump'));
232+
$locatorPass = new ServiceLocatorTagPass();
233+
$locatorPass->process($container);
231234
}
232235

233236
return $this->containerBuilder = $container;

Secrets/SodiumVault.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class SodiumVault extends AbstractVault implements EnvVarLoaderInterface
2525
private $encryptionKey;
2626
private $decryptionKey;
2727
private $pathPrefix;
28+
private $secretsDir;
2829

2930
/**
3031
* @param string|object|null $decryptionKey A string or a stringable object that defines the private key to use to decrypt the vault
@@ -36,12 +37,9 @@ public function __construct(string $secretsDir, $decryptionKey = null)
3637
throw new \TypeError(sprintf('Decryption key should be a string or an object that implements the __toString() method, %s given.', \gettype($decryptionKey)));
3738
}
3839

39-
if (!is_dir($secretsDir) && !@mkdir($secretsDir, 0777, true) && !is_dir($secretsDir)) {
40-
throw new \RuntimeException(sprintf('Unable to create the secrets directory (%s)', $secretsDir));
41-
}
42-
4340
$this->pathPrefix = rtrim(strtr($secretsDir, '/', \DIRECTORY_SEPARATOR), \DIRECTORY_SEPARATOR).\DIRECTORY_SEPARATOR.basename($secretsDir).'.';
4441
$this->decryptionKey = $decryptionKey;
42+
$this->secretsDir = $secretsDir;
4543
}
4644

4745
public function generateKeys(bool $override = false): bool
@@ -203,9 +201,20 @@ private function export(string $file, string $data): void
203201
$data = str_replace('%', '\x', rawurlencode($data));
204202
$data = sprintf("<?php // %s on %s\n\nreturn \"%s\";\n", $name, date('r'), $data);
205203

204+
$this->createSecretsDir();
205+
206206
if (false === file_put_contents($this->pathPrefix.$file.'.php', $data, LOCK_EX)) {
207207
$e = error_get_last();
208208
throw new \ErrorException($e['message'] ?? 'Failed to write secrets data.', 0, $e['type'] ?? E_USER_WARNING);
209209
}
210210
}
211+
212+
private function createSecretsDir(): void
213+
{
214+
if ($this->secretsDir && !is_dir($this->secretsDir) && !@mkdir($this->secretsDir, 0777, true) && !is_dir($this->secretsDir)) {
215+
throw new \RuntimeException(sprintf('Unable to create the secrets directory (%s)', $this->secretsDir));
216+
}
217+
218+
$this->secretsDir = null;
219+
}
211220
}

0 commit comments

Comments
 (0)