Bug 15755 - CTDB events, including monitor events, can fail if an event script is disabled
Summary: CTDB events, including monitor events, can fail if an event script is disabled
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: CTDB (show other bugs)
Version: 4.21.1
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Jule Anger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-20 05:23 UTC by Martin Schwenke
Modified: 2024-12-09 08:33 UTC (History)
1 user (show)

See Also:


Attachments
Patch for v4-21-test and v4-20-test (4.24 KB, patch)
2024-11-21 03:17 UTC, Martin Schwenke
amitay: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Schwenke 2024-11-20 05:23:11 UTC
When running an event, eventd (via run_event) builds a list of scripts to run.  

run_event gracefully handles the case where it attempts to run a script that has was disabled after the script list was build, provided the script is not a symlink and has been disabled via thee equivalent of chmod -x.  In this case, it marks any script that fails with ENOEXEC as DISABLED and it is skipped.

However, when working with standard event scripts, CTDB enables them by creating a symlink to a standard installation location.  "ctdb event script disable" will unlink a script that was previously linked.  When the above race is lost, run_event does not gracefully handle the case where it encounters ENOENT.

run_event already maps EACCES to ENOEXEC, so it is easy to also map ENOENT to ENOEXEC.
Comment 1 Samba QA Contact 2024-11-21 01:43:04 UTC
This bug was referenced in samba master:

fee31b6cb2b8f7dd111bdd9d2ff5479c31cbca37
Comment 2 Martin Schwenke 2024-11-21 03:17:52 UTC
Created attachment 18501 [details]
Patch for v4-21-test and v4-20-test

Patch for v4-21-test and v4-20-test.  Cherry-picks cleanly into v4-21-test.  Generated patch applies cleanly to v4-20-test.

There may be warnings about introducing trailing whitespace when applying the patch.  This is because the test needs to match command output, which has trailing whitespace.

Note that I did change/finish a comment line (with trailing whitespace), which is incomplete in the version in master.  Sorry about that - I only noticed it when "git am" warned about trailing whitespace... 2 made sense, 1 didn't.  I don't think that warrants tagging it as a backport instead of a cherry-pick, since there are no code differences.
Comment 3 Amitay Isaacs 2024-11-29 15:01:46 UTC
Hi Jule,

This is ready for v4-20 and v4-21 branches.

Amitay.
Comment 4 Jule Anger 2024-12-03 13:24:21 UTC
Pushed to autobuild-v4-{21,20}-test.
Comment 5 Samba QA Contact 2024-12-03 18:05:12 UTC
This bug was referenced in samba v4-21-test:

9a7047e8cca28605c87536f5085b699d79842432
Comment 6 Samba QA Contact 2024-12-06 15:20:04 UTC
This bug was referenced in samba v4-20-test:

622bcc55181d4a57266aa659c479ae2e494d6a93
Comment 7 Jule Anger 2024-12-09 08:33:27 UTC
Closing out bug report.

Thanks!