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 `/save` replacing symlinks with regular files #909

Merged
merged 2 commits into from Aug 27, 2018

Conversation

Projects
None yet
3 participants
@meribold
Copy link
Contributor

meribold commented Aug 12, 2018

A side-effect of 8deb618 is that /save may replace configuration files that are symlinks with regular files. Fix this by resolving all symlinks before renaming the temporary file.

This fixes #906.

Fix `/save` replacing symlinks with regular files
A side-effect of 8deb618 is that `/save` may replace configuration files
that are symlinks with regular files.  Fix this by resolving all
symlinks before renaming the temporary file.
@ailin-nemui

This comment has been minimized.

Copy link
Contributor

ailin-nemui commented Aug 12, 2018

rename doesn't work if symlink point to another FS, I didn't check your fix yet but did you consider this?

@meribold

This comment has been minimized.

Copy link
Contributor

meribold commented Aug 12, 2018

I didn't. I can change the code to base the path of the temporary file on the expanded path of the configuration file. I assume that would take care of this issue.

Fix potential `rename(3)` across file systems
Make sure the temporary file in the `config_write` function is created
on the same file system as the file we `rename` it to later.
@meribold

This comment has been minimized.

Copy link
Contributor

meribold commented Aug 12, 2018

I added another commit that should prevent renames across file systems.

@ailin-nemui

This comment has been minimized.

Copy link
Contributor

ailin-nemui commented Aug 13, 2018

@ailin-nemui

This comment has been minimized.

Copy link
Contributor

ailin-nemui commented Aug 20, 2018

@ailin-nemui ailin-nemui merged commit 1bbd9f3 into irssi:master Aug 27, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@dequis

This comment has been minimized.

Copy link
Member

dequis commented Sep 1, 2018

Turns out this breaks when the file didn't already exist

Error: Couldn't save configuration file: No such file or directory
18:50 -!- Irssi: Error saving theme to /tmp/foobar/default.theme: No such file or directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment