Skip to content

Conversation

@Jappie3
Copy link

@Jappie3 Jappie3 commented Jul 13, 2025

When a sieve script is saved as read-only, calling sieve_storage_setup_bin_path with mkdir_get_executable_mode(save_mode) where - if I understand everything correctly - save_mode is derived from the original sieve script's permissions, will result in a read-only (technically 0555, mkdir_get_executable_mode adds the executable bit) storage directory. This will cause pigeonhole to fail when saving the compiled script, as the directory has permissions 0555:

dovecot[260506]: lmtp([email protected])<260940><3P0ZDyQGaWhM+wMAbxW+ag>: Debug: sieve: Script 'after/84lkfddk8d88ib7zh3zh6hmy5lrvn54x-after' successfully compiled
dovecot[260506]: lmtp([email protected])<260940><3P0ZDyQGaWhM+wMAbxW+ag>: Debug: sieve: storage after: file: Created directory for binaries: /run/dovecot2/sieve/jasper
dovecot[260506]: lmtp([email protected])<260940><3P0ZDyQGaWhM+wMAbxW+ag>: Debug: sieve: storage after: file: script '84lkfddk8d88ib7zh3zh6hmy5lrvn54x-after': Saving binary to '/run/dovecot2/sieve/jasper/84lkfddk8d88ib7zh3zh6hmy5lrvn54x-after.svbin'
dovecot[260506]: lmtp([email protected])<260940><3P0ZDyQGaWhM+wMAbxW+ag>: Error: sieve: binary /run/dovecot2/sieve/jasper/84lkfddk8d88ib7zh3zh6hmy5lrvn54x-after.svbin: save: failed to create temporary file: open(/run/dovecot2/sieve/jasper/84lkfddk8d88ib7zh3zh6hmy5lrvn54x-after.svbin.) failed: Permission denied (euid=986(dovemail) egid=985(dovemail) missing +w perm: /run/dovecot2/sieve/jasper, dir owner missing perms)

Explicitly using 0700 when calling sieve_storage_setup_bin_path fixes this.

Extra context:

if the sieve script being compiled has read-only permissions, using
save_mode in sieve_storage_setup_bin_path will cause the created
directory to have permission bits 0555 (executable bit added by
mkdir_get_executable_mode), resulting in pigeonhole being unable to save
the compiled sieve binary
str_begins_with(path, storage->bin_path) &&
sieve_storage_setup_bin_path(
script->storage, mkdir_get_executable_mode(save_mode)) < 0)
script->storage, 0700) < 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should instead create a new mkdir_get_wx_mode() that adds +w and +x bits for every +r. @stephanbosch do you remember if there's a reason we want to get the mode from the sieve script rather than hardcoding to 0700?

Copy link
Contributor

Choose a reason for hiding this comment

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

No. Likely, this code is borrowed from core/lib-storage somewhere.

@Jappie3
Copy link
Author

Jappie3 commented Aug 9, 2025

@sirainen thank you for the review, do you think this patch would gain more traction on the dovecot mailing list? If so I can try submitting it there

Jappie3 added a commit to Jappie3/nixpkgs that referenced this pull request Aug 10, 2025
This patch fixes a permission issue that occurs when saving compiled
sieve scripts sourced from the nix store. Instead of reusing the
read-only permission bits from the nix store, it explicitly uses `0700`
for the directory in which compiled sieve scripts should be saved.

Additional context:
- NixOS#388463 (comment)
- dovecot/pigeonhole#15
Jappie3 added a commit to Jappie3/nixpkgs that referenced this pull request Oct 14, 2025
This patch fixes a permission issue that occurs when saving compiled
sieve scripts sourced from the nix store. Instead of reusing the
read-only permission bits from the nix store, it explicitly uses `0700`
for the directory in which compiled sieve scripts should be saved.

Additional context:
- NixOS#388463 (comment)
- dovecot/pigeonhole#15
Jappie3 added a commit to Jappie3/nixpkgs that referenced this pull request Oct 14, 2025
This patch fixes a permission issue that occurs when saving compiled
sieve scripts sourced from the nix store. Instead of reusing the
read-only permission bits from the nix store, it explicitly uses `0700`
for the directory in which compiled sieve scripts should be saved.

Additional context:
- NixOS#388463 (comment)
- dovecot/pigeonhole#15
Jappie3 added a commit to Jappie3/nixpkgs that referenced this pull request Nov 21, 2025
This patch fixes a permission issue that occurs when saving compiled
sieve scripts sourced from the nix store. Instead of reusing the
read-only permission bits from the nix store, it explicitly uses `0700`
for the directory in which compiled sieve scripts should be saved.

Additional context:
- NixOS#388463 (comment)
- dovecot/pigeonhole#15
Jappie3 added a commit to Jappie3/nixpkgs that referenced this pull request Nov 21, 2025
This patch fixes a permission issue that occurs when saving compiled
sieve scripts sourced from the nix store. Instead of reusing the
read-only permission bits from the nix store, it explicitly uses `0700`
for the directory in which compiled sieve scripts should be saved.

Additional context:
- NixOS#388463 (comment)
- dovecot/pigeonhole#15
Jappie3 added a commit to Jappie3/nixpkgs that referenced this pull request Nov 21, 2025
This patch fixes a permission issue that occurs when saving compiled
sieve scripts sourced from the nix store. Instead of reusing the
read-only permission bits from the nix store, it explicitly uses `0700`
for the directory in which compiled sieve scripts should be saved.

Additional context:
- NixOS#388463 (comment)
- dovecot/pigeonhole#15
Jappie3 added a commit to Jappie3/nixpkgs that referenced this pull request Nov 21, 2025
This patch fixes a permission issue that occurs when saving compiled
sieve scripts sourced from the nix store. Instead of reusing the
read-only permission bits from the nix store, it explicitly uses `0700`
for the directory in which compiled sieve scripts should be saved.

Additional context:
- NixOS#388463 (comment)
- dovecot/pigeonhole#15
Jappie3 added a commit to Jappie3/nixpkgs that referenced this pull request Nov 21, 2025
This patch fixes a permission issue that occurs when saving compiled
sieve scripts sourced from the nix store. Instead of reusing the
read-only permission bits from the nix store, it explicitly uses `0700`
for the directory in which compiled sieve scripts should be saved.

Additional context:
- NixOS#388463 (comment)
- dovecot/pigeonhole#15
Jappie3 added a commit to Jappie3/nixpkgs that referenced this pull request Nov 21, 2025
This patch fixes a permission issue that occurs when saving compiled
sieve scripts sourced from the nix store. Instead of reusing the
read-only permission bits from the nix store, it explicitly uses `0700`
for the directory in which compiled sieve scripts should be saved.

Additional context:
- NixOS#388463 (comment)
- dovecot/pigeonhole#15
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.

3 participants