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

Hack permission fix until core is updated #658

Merged
merged 7 commits into from
Dec 22, 2023
Merged

Hack permission fix until core is updated #658

merged 7 commits into from
Dec 22, 2023

Conversation

oscarlevin
Copy link
Member

No description provided.

Copy link
Member

@StevenClontz StevenClontz left a comment

Choose a reason for hiding this comment

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

can you merge this with #657 to see if tests pass? (or re-implement my test here)

@oscarlevin
Copy link
Member Author

Okay, I see what's happening. You put the test on the non-cli calls. Do you (@StevenClontz) think we need to patch this now, or can that wait for fixes to core?

@oscarlevin
Copy link
Member Author

Turns out it was easy to move into the project's build command, so I just did that.

@oscarlevin
Copy link
Member Author

Alright @StevenClontz. Can you mark your review as approved so we can merge?

@StevenClontz
Copy link
Member

Turns out it was easy to move into the project's build command, so I just did that.

Thanks. IMO the lighter-weight CLI is, the better. It's somewhat interesting that pretext new is implemented purely in the CLI, but it's unclear to me how it would work otherwise: Project() knows only the contents of project.ptx; the actual project itself is all on the disk.

@StevenClontz StevenClontz merged commit 93e3335 into main Dec 22, 2023
6 checks passed
@oscarlevin oscarlevin deleted the permissions branch December 22, 2023 16:47
@bnmnetp
Copy link

bnmnetp commented Jan 10, 2024

I think this PR (or maybe the underlying core problem??) is the cause of recent unpleasantness on Runestone Academy. Suddenly and mysteriously the permissions on the output folder for runestone build books namely published/document-id have lost the execute bit setting for "group" and "other". Because the servers do not run as root, the lack of the x bit doesn't let them see some of the files they need in order to serve pages properly.

I don't think it is good practice to override a users umask settings, or even to mess around with permissions at all.

@oscarlevin
Copy link
Member Author

Can you say more @bnmnetp? I agree that I don't want to be in the business of permission management. The problem is that:

  • python's command to create a temporary directory always sets the permissions of the temp directory to 700.
  • Now that we are using shutil.copy() to move the built files from the temp directory to the output folder, those permissions are preserved.

The hack that this PR uses assumes that the output folder's parent folder has the permissions that should be on the output folder, and just coerces those after moving the built files.

The proposed fix to core would set the permissions to the temp directories created to 755, and then we can revert the hack. But I'm not sure that would help your situation. What do you think?

@StevenClontz
Copy link
Member

To make sure I understand: you want published/document-id to have permissions 777.

For clarity, somewhere (can't find the thread) we found that a core Python routine sets the temporary directory permission at 700, so you'll need to take that up with Python maintainers. Oscar implemented

# Temporary hack to ensure the correct permissions are set on the output directory.
which I believe forces permissions of a build directory to match the project directory. Does your project directory have permissions 777?

As I recall, we have a better fix that needs to be merged into PreTeXtBook/pretext - I'll ping that now...

@bnmnetp
Copy link

bnmnetp commented Jan 10, 2024

I'm not asking for 777 I'm asking for at least 755 or 775.

Perhaps using shutil.copy to copy from a tmp directory is not the best solution. I don't think I would get very far with the Python maintainers.

I think I may not have had the version with Oscar's hack in it. because either remembering what the permissions on the output directory were and then restoring them after the copy, or using the permissions of the parent is also pretty reasonable.

In any case I have not seen any of the output folders set to 700.

@StevenClontz
Copy link
Member

I think I may not have had the version with Oscar's hack in it.

Sounds likely - we've since added tests to our suite to ensure that the lowest permissions our new projects and builds should be are 755:

assert (tmp_path / "new-pretext-project").stat().st_mode % 0o1000 >= 0o755

assert (prj_path / "output" / "web").stat().st_mode % 0o1000 >= 0o755

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.

fix permissions issues for pretext new and pretext build [html format].
3 participants