memo: optional note-gate hook beside the store
A host may place an executable note-gate next to the memory directory to classify or refuse notes before they are written. The gate records accepted notes itself by calling memo with MEMO_UNGATED=1, so the check never recurses.
This commit is contained in:
parent
1fb164cf39
commit
112d66d5ae
1 changed files with 7 additions and 0 deletions
7
memo
7
memo
|
|
@ -838,6 +838,13 @@ def main():
|
||||||
print("No such command: %s\n" % cmd, file=sys.stderr)
|
print("No such command: %s\n" % cmd, file=sys.stderr)
|
||||||
print(usage, file=sys.stderr)
|
print(usage, file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
if cmd == "note" and not os.environ.get("MEMO_UNGATED"):
|
||||||
|
# An optional host hook beside the store may classify or refuse a note
|
||||||
|
# before it is written. It records accepted notes itself by calling
|
||||||
|
# back with MEMO_UNGATED=1, so this check never recurses.
|
||||||
|
gate = os.path.join(os.path.dirname(memory_dir()), "note-gate")
|
||||||
|
if os.access(gate, os.X_OK):
|
||||||
|
os.execv(gate, [gate] + sys.argv[2:])
|
||||||
try:
|
try:
|
||||||
# `init` is the only command that may run without an existing memory:
|
# `init` is the only command that may run without an existing memory:
|
||||||
# it is the one that creates it. Every other command refuses, so a
|
# it is the one that creates it. Every other command refuses, so a
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue