Also check folder permissions for the EEPROM scripts.

This commit is contained in:
flash 2025-04-03 20:09:18 +00:00
parent 9d70505ad8
commit 55dc011df6
Signed by: flash
GPG key ID: 2C9C2C574D47FE3E
8 changed files with 144 additions and 117 deletions

View file

@ -1 +1 @@
20250327.1
20250403

View file

@ -7,8 +7,8 @@ use Misuzu\Storage\HashHelpers;
class FilesStorage {
public function __construct(
private string $localPath,
private string $remotePath,
public private(set) string $localPath,
public private(set) string $remotePath,
) {}
public static function stringifyHash(FileInfo|string $infoOrHash): string {

View file

@ -250,6 +250,9 @@ try {
}
});
if(!empty($msz->storageCtx->filesCtx->storage->localPath)
&& is_dir($msz->storageCtx->filesCtx->storage->localPath)
&& fileowner($msz->storageCtx->filesCtx->storage->localPath) === posix_getuid()) {
msz_sched_task_func('Removing stale entries from storage pools...', false, function() use ($msz) {
$pools = [];
$getPool = fn($ruleRaw) => array_key_exists($ruleRaw->poolId, $pools) ? $pools[$ruleRaw->poolId] : (
@ -367,6 +370,7 @@ try {
}
}
});
}
echo 'Running ' . count($schedTasks) . ' tasks...' . PHP_EOL;

View file

@ -4,6 +4,13 @@ use Index\XNumber;
require_once __DIR__ . '/../misuzu.php';
if(empty($msz->storageCtx->filesCtx->storage->localPath))
die(sprintf('No storage path is specified.%s', PHP_EOL));
if(!is_dir($msz->storageCtx->filesCtx->storage->localPath))
die(sprintf('Storage directory does not exist.%s', PHP_EOL));
if(fileowner($msz->storageCtx->filesCtx->storage->localPath) !== posix_getuid())
die(sprintf('Script must be run as the owner of the storage directory.%s', PHP_EOL));
$options = getopt('s', [
'base62',
], $restIndex);

View file

@ -6,6 +6,13 @@ use Misuzu\Storage\Files\FileInfoGetFileField;
require_once __DIR__ . '/../misuzu.php';
if(empty($msz->storageCtx->filesCtx->storage->localPath))
die(sprintf('No storage path is specified.%s', PHP_EOL));
if(!is_dir($msz->storageCtx->filesCtx->storage->localPath))
die(sprintf('Storage directory does not exist.%s', PHP_EOL));
if(fileowner($msz->storageCtx->filesCtx->storage->localPath) !== posix_getuid())
die(sprintf('Script must be run as the owner of the storage directory.%s', PHP_EOL));
$options = getopt('hsur:', [
'hash',
'base62',

View file

@ -5,6 +5,13 @@ use Misuzu\Storage\Files\FileInfoGetFileField;
require_once __DIR__ . '/../misuzu.php';
if(empty($msz->storageCtx->filesCtx->storage->localPath))
die(sprintf('No storage path is specified.%s', PHP_EOL));
if(!is_dir($msz->storageCtx->filesCtx->storage->localPath))
die(sprintf('Storage directory does not exist.%s', PHP_EOL));
if(fileowner($msz->storageCtx->filesCtx->storage->localPath) !== posix_getuid())
die(sprintf('Script must be run as the owner of the storage directory.%s', PHP_EOL));
$options = getopt('hsuv:', [
'hash',
'base62',

View file

@ -1,17 +1,12 @@
#!/usr/bin/env php
<?php
namespace Misuzu;
require_once __DIR__ . '/../misuzu.php';
$path = $msz->tplCtx->cachePath;
if(empty($path))
if(empty($msz->tplCtx->cachePath))
die(sprintf('No cache path is specified.%s', PHP_EOL));
if(!is_dir($path))
if(!is_dir($msz->tplCtx->cachePath))
die(sprintf('Cache directory does not exist.%s', PHP_EOL));
if(fileowner($path) !== posix_getuid())
if(fileowner($msz->tplCtx->cachePath) !== posix_getuid())
die(sprintf('Script must be run as the owner of the cache directory.%s', PHP_EOL));
echo `rm -rv {$path}`;
echo `rm -rv {$msz->tplCtx->cachePath}`;

View file

@ -2,6 +2,13 @@
<?php
require_once __DIR__ . '/../misuzu.php';
if(empty($msz->storageCtx->filesCtx->storage->localPath))
die(sprintf('No storage path is specified.%s', PHP_EOL));
if(!is_dir($msz->storageCtx->filesCtx->storage->localPath))
die(sprintf('Storage directory does not exist.%s', PHP_EOL));
if(fileowner($msz->storageCtx->filesCtx->storage->localPath) !== posix_getuid())
die(sprintf('Script must be run as the owner of the storage directory.%s', PHP_EOL));
if($argc <= 1)
die(sprintf('No uploader ID specified.%s', PHP_EOL));