You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class CreateCoursesFromStructuredFileCommand extends Command
31
35
{
@@ -40,16 +44,33 @@ public function __construct(
40
44
41
45
protectedfunctionconfigure(): void
42
46
{
43
-
$this->addArgument(
44
-
'folder',
45
-
InputArgument::REQUIRED,
46
-
'Absolute path to the folder that contains course files'
47
-
);
47
+
$this
48
+
->addArgument(
49
+
'folder',
50
+
InputArgument::REQUIRED,
51
+
'Absolute path to the folder that contains course files'
52
+
)
53
+
->addOption(
54
+
'user',
55
+
null,
56
+
InputOption::VALUE_OPTIONAL,
57
+
'Expected user owner of created files (e.g. www-data)',
58
+
'www-data'
59
+
);
48
60
}
49
61
50
62
protectedfunctionexecute(InputInterface$input, OutputInterface$output): int
51
63
{
52
-
$io = newSymfonyStyle($input, $output);
64
+
$io = newSymfonyStyle($input, $output);
65
+
66
+
$expectedUser = $input->getOption('user');
67
+
$realUser = get_current_user();
68
+
69
+
if ($realUser !== $expectedUser) {
70
+
$io->warning("You are running this command as '$realUser', but expected user is '$expectedUser'.If file permissions are too restrictive (e.g. 0660), the web server may not be able to access the files.
71
+
To avoid this issue, consider running the command like this: sudo -u {$expectedUser} php bin/console app:create-courses-from-structured-file /path/to/folder");
72
+
}
73
+
53
74
$adminUser = $this->getFirstAdmin();
54
75
if (!$adminUser) {
55
76
$io->error('No admin user found in the system.');
@@ -63,12 +84,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
63
84
}
64
85
65
86
// Retrieve Unix permissions from platform settings
0 commit comments