Skip to content

Commit 7f919be

Browse files
committed
Prevent creating users with existing files
Signed-off-by: Joas Schilling <[email protected]>
1 parent 279c0cb commit 7f919be

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lib/private/User/Manager.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,11 +460,11 @@ public function countDisabledUsers(): int {
460460
->andWhere($queryBuilder->expr()->eq('configkey', $queryBuilder->createNamedParameter('enabled')))
461461
->andWhere($queryBuilder->expr()->eq('configvalue', $queryBuilder->createNamedParameter('false'), IQueryBuilder::PARAM_STR));
462462

463-
463+
464464
$result = $queryBuilder->execute();
465465
$count = $result->fetchColumn();
466466
$result->closeCursor();
467-
467+
468468
if ($count !== false) {
469469
$count = (int)$count;
470470
} else {
@@ -494,7 +494,7 @@ public function countDisabledUsersOfGroups(array $groups): int {
494494
$result = $queryBuilder->execute();
495495
$count = $result->fetchColumn();
496496
$result->closeCursor();
497-
497+
498498
if ($count !== false) {
499499
$count = (int)$count;
500500
} else {
@@ -611,10 +611,18 @@ public function getByEmail($email) {
611611
private function verifyUid(string $uid): bool {
612612
$appdata = 'appdata_' . $this->config->getSystemValueString('instanceid');
613613

614-
if ($uid === '.htaccess' || $uid === 'files_external' || $uid === '.ocdata' || $uid === 'owncloud.log' || $uid === 'nextcloud.log' || $uid === $appdata) {
614+
if (\in_array($uid, [
615+
'.htaccess',
616+
'files_external',
617+
'.ocdata',
618+
'owncloud.log',
619+
'nextcloud.log',
620+
$appdata], true)) {
615621
return false;
616622
}
617623

618-
return true;
624+
$dataDirectory = $this->config->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data');
625+
626+
return !file_exists(rtrim($dataDirectory, '/') . '/' . $uid);
619627
}
620628
}

0 commit comments

Comments
 (0)