diff --git a/electron-builder.json b/electron-builder.json index 1d2bdfb4..70cad6e6 100644 --- a/electron-builder.json +++ b/electron-builder.json @@ -25,6 +25,7 @@ ] } ], + "afterPack": "scripts/afterpack.js", "afterSign": "scripts/notarize.js", "deb": { "synopsis": "Mattermost" diff --git a/scripts/afterpack.js b/scripts/afterpack.js new file mode 100644 index 00000000..a760129f --- /dev/null +++ b/scripts/afterpack.js @@ -0,0 +1,23 @@ +// 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}` + ); + } + } + }); + } +}; \ No newline at end of file