Fixed bug - files/uploaded had wrong owner
Upgrade to React 16
This commit is contained in:
parent
dce5ba7464
commit
cfdcaf65d8
84 changed files with 2381 additions and 1546 deletions
|
@ -23,6 +23,8 @@ const shares = require('./models/shares');
|
|||
const { AppType } = require('../shared/app');
|
||||
const builtinZoneMta = require('./lib/builtin-zone-mta');
|
||||
|
||||
const { uploadedFilesDir } = require('./lib/file-helpers');
|
||||
|
||||
const trustedPort = config.www.trustedPort;
|
||||
const sandboxPort = config.www.sandboxPort;
|
||||
const publicPort = config.www.publicPort;
|
||||
|
@ -68,7 +70,6 @@ function startHTTPServer(appType, appName, port, callback) {
|
|||
server.listen({port, host}, callback);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// Start the whole circus here
|
||||
// ---------------------------------------------------------------------------------------
|
||||
|
@ -99,7 +100,10 @@ dbcheck(err => { // Check if database needs upgrading before starting the server
|
|||
builtinZoneMta.spawn(() =>
|
||||
startHTTPServer(AppType.TRUSTED, 'trusted', trustedPort, () =>
|
||||
startHTTPServer(AppType.SANDBOXED, 'sandbox', sandboxPort, () =>
|
||||
startHTTPServer(AppType.PUBLIC, 'public', publicPort, () => {
|
||||
startHTTPServer(AppType.PUBLIC, 'public', publicPort, async () => {
|
||||
|
||||
await privilegeHelpers.ensureMailtrainDir(uploadedFilesDir);
|
||||
|
||||
privilegeHelpers.dropRootPrivileges();
|
||||
|
||||
tzupdate.start();
|
||||
|
|
|
@ -18,5 +18,6 @@ function installUploadHandler(router, url, replacementBehavior, type, subType, t
|
|||
}
|
||||
|
||||
module.exports = {
|
||||
installUploadHandler
|
||||
installUploadHandler,
|
||||
uploadedFilesDir
|
||||
};
|
|
@ -3,7 +3,7 @@
|
|||
const log = require('./log');
|
||||
const config = require('config');
|
||||
|
||||
const fs = require('fs');
|
||||
const fs = require('fs-extra-promise');
|
||||
|
||||
const tryRequire = require('try-require');
|
||||
const posix = tryRequire('posix');
|
||||
|
@ -49,6 +49,12 @@ function ensureMailtrainOwner(file, callback) {
|
|||
fs.chown(file, ids.uid, ids.gid, callback);
|
||||
}
|
||||
|
||||
async function ensureMailtrainDir(dir) {
|
||||
const ids = getConfigUidGid();
|
||||
await fs.ensureDir(dir);
|
||||
await fs.chownAsync(dir, ids.uid, ids.gid);
|
||||
}
|
||||
|
||||
function dropRootPrivileges() {
|
||||
if (config.group) {
|
||||
try {
|
||||
|
@ -72,6 +78,7 @@ function dropRootPrivileges() {
|
|||
module.exports = {
|
||||
dropRootPrivileges,
|
||||
ensureMailtrainOwner,
|
||||
ensureMailtrainDir,
|
||||
getConfigUidGid,
|
||||
getConfigROUidGid
|
||||
};
|
||||
|
|
|
@ -25,7 +25,7 @@ function enforceTypePermitted(type, subType) {
|
|||
}
|
||||
|
||||
function getFilePath(type, subType, entityId, filename) {
|
||||
return path.join(path.join(filesDir, type, subType, entityId.toString()), filename);
|
||||
return path.join(filesDir, type, subType, entityId.toString(), filename);
|
||||
}
|
||||
|
||||
function getFileUrl(context, type, subType, entityId, filename) {
|
||||
|
|
|
@ -11,7 +11,8 @@ const fs = require('fs-extra-promise');
|
|||
const path = require('path');
|
||||
const importer = require('../lib/importer');
|
||||
|
||||
const filesDir = path.join(__dirname, '..', 'files', 'imports');
|
||||
const files = require('./files');
|
||||
const filesDir = path.join(files.filesDir, 'imports');
|
||||
|
||||
const allowedKeysCreate = new Set(['name', 'description', 'source', 'settings']);
|
||||
const allowedKeysUpdate = new Set(['name', 'description', 'mapping_type', 'mapping']);
|
||||
|
|
|
@ -9,7 +9,8 @@ const {castToInteger} = require('../../lib/helpers');
|
|||
|
||||
const path = require('path');
|
||||
const files = require('../../models/files');
|
||||
const uploadedFilesDir = path.join(files.filesDir, 'uploaded');
|
||||
|
||||
const {uploadedFilesDir} = require('../../lib/file-helpers')
|
||||
|
||||
const multer = require('multer')({
|
||||
dest: uploadedFilesDir
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue