Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure control directory has right permissions #261

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

belloyang
Copy link

This PR aims to fix the error:

dpkg-deb: error: control directory has bad permissions 777 (must be >=0755 and <=0775)
Error: Command failed with a non-zero return code (2):
...

Related issues:

  1. Temporary build directory created with insufficient permissions
  2. Set permissions on scripts after copying

Copy link
Member

@malept malept left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable. Can you add a test to avoid regressions in the future?

src/installer.js Outdated
Comment on lines 98 to 99
const contrlDir = path.join(this.stagingDir, 'DEBIAN');
return fs.chmod(contrlDir, 0o755);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit(spelling):

Suggested change
const contrlDir = path.join(this.stagingDir, 'DEBIAN');
return fs.chmod(contrlDir, 0o755);
const controlDir = path.join(this.stagingDir, 'DEBIAN');
return fs.chmod(controlDir, 0o755);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi I'm having difficulty creating a test for this. It would require to interfere in the .deb building process and update the control directory's permissions to 777. not sure if the test code is capable of doing it.

@belloyang belloyang force-pushed the ensure-controll-dir-with-right-permissions branch from 73183c5 to 0d02201 Compare August 27, 2021 15:29
@malept
Copy link
Member

malept commented Aug 27, 2021

Hi I'm having difficulty creating a test for this. It would require to interfere in the .deb building process and update the control directory's permissions to 777. not sure if the test code is capable of doing it.

What are the conditions under which the control directory has permissions of 777 then?

@belloyang
Copy link
Author

Hi I'm having difficulty creating a test for this. It would require to interfere in the .deb building process and update the control directory's permissions to 777. not sure if the test code is capable of doing it.

What are the conditions under which the control directory has permissions of 777 then?

I encountered this error while using electron-installer-debian on the bitbucket pipeline for building. I suspect it's due to the NTFS file system that bitbucket pipeline is using for generating the package. All the files on NTFS automatically have 777 as the permissions. The issue #207 reported a while ago was experiencing the same symptom, however the fix was only to change the permissions of scripts to 755 but not control directory, which should have the same fix to make sure it has the right permissions as well.

@malept
Copy link
Member

malept commented Aug 27, 2021

I suspect in order to make the test (this is only speculation, I haven't tried this), you'll need to:

  • figure out how to change the value of os.tmpdir() so that the staging directory goes to a custom location (I think you should just be able to change the TMPDIR, TMP, or TEMP environment variable(s)). You should do this just in the scope of the test.
  • make sure that the custom location forces all files/folders created in it to have 777 permissions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants