mattermost-desktop/scripts/afterpack.js
Guillermo Vayá 07e177e693
[MM-21400] Enable setuid on linux packaging (#1156)
* Fix chrome-sandbox permissions for Appimages and .debs.
* NOTE: Patch not working for tar.gz due to the way 7za is called which isn't preserving permissions. Need to create manual tar.gz target in future patch.
2020-02-07 18:04:45 +01:00

23 lines
763 B
JavaScript

// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
const path = require('path');
const {spawn} = require('electron-notarize/lib/spawn.js');
const SETUID_PERMISSIONS = '4755';
exports.default = async function afterPack(context) {
if (context.electronPlatformName === 'linux') {
context.targets.forEach(async (target) => {
if (!['appimage', 'snap'].includes(target.name.toLowerCase())) {
const result = await spawn('chmod', [SETUID_PERMISSIONS, path.join(context.appOutDir, 'chrome-sandbox')]);
if (result.code !== 0) {
throw new Error(
`Failed to set proper permissions for linux arch on ${target.name}`
);
}
}
});
}
};