[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.
This commit is contained in:
Guillermo Vayá 2020-02-07 18:04:45 +01:00 committed by GitHub
parent ac3ac24c42
commit 07e177e693
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View file

@ -25,6 +25,7 @@
]
}
],
"afterPack": "scripts/afterpack.js",
"afterSign": "scripts/notarize.js",
"deb": {
"synopsis": "Mattermost"

23
scripts/afterpack.js Normal file
View file

@ -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}`
);
}
}
});
}
};