Conversation
| substituteAllInPlace $out/bin/disable-breaking-updates.py | ||
| chmod +x $out/bin/disable-breaking-updates.py | ||
| ''; | ||
| fixKrisp = runCommand "fix-krisp.py" |
keysmashes
left a comment
There was a problem hiding this comment.
I have no objections to this getting upstreamed. I did not in fact write krisp-patcher.py, though – that was @Stary2001 – so it's not really my call.
I don't expect the patcher part to need much maintenance; I had to make one change (tweaking a symbol name) in the last year or more.
I am slightly dubious about the approach. I realise that in the normal case, this will run discord by hand for exactly long enough to download krisp, then kill it, apply the patch, and let the normal wrapper script launch it again, but in the case where the patcher doesn't see installed-module discord_krisp – maybe one day discord decides to change their logging format – then the getKrisp discord instance will presumably run forever.
Then, until someone notices that krisp is broken and figures out what to do about it, it seems entirely possible that anyone relying on things like the --enable-speech-dispatcher flag that the wrapper script adds will be very confused about why their TTS isn't working, even though they definitely enabled withTTS.
| from capstone.x86 import * | ||
|
|
||
| def getKrisp(): | ||
| process = subprocess.Popen(sys.argv[1], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False, universal_newlines=True, preexec_fn=os.setsid) |
There was a problem hiding this comment.
stderr=subprocess.STDOUTseems dubious – presumably this should search either stdout or stderr, whichever this log goes to, and pass the other one through?shell=Falseis the default- I would be inclined to drop
universal_newlines=Trueand search for bytes in the output instead (b"installed-module ..."), but shrug - pass
start_new_session=Truerather than usingpreexec_fn=os.setsid
| try: | ||
| for line in iter(process.stdout.readline, ''): | ||
| print(line, end='') | ||
| if re.search("installed-module discord_krisp", line): |
There was a problem hiding this comment.
re.search doesn't seem necessary given the needle is a fixed string – would if "..." in line be sufficient?
|
|
||
| krisp_initialize_address = symtab.get_symbol_by_name("_ZN7discord15KrispInitializeEv")[0].entry.st_value | ||
| isSignedByDiscord_address = symtab.get_symbol_by_name("_ZN7discord4util17IsSignedByDiscordERKNSt2Cr12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE")[0].entry.st_value |
There was a problem hiding this comment.
a note about how these were derived could be useful in the future:
| krisp_initialize_address = symtab.get_symbol_by_name("_ZN7discord15KrispInitializeEv")[0].entry.st_value | |
| isSignedByDiscord_address = symtab.get_symbol_by_name("_ZN7discord4util17IsSignedByDiscordERKNSt2Cr12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE")[0].entry.st_value | |
| # see e.g. `objdump -t | grep IsSignedByDiscord` | |
| krisp_initialize_address = symtab.get_symbol_by_name("_ZN7discord15KrispInitializeEv")[0].entry.st_value | |
| isSignedByDiscord_address = symtab.get_symbol_by_name("_ZN7discord4util17IsSignedByDiscordERKNSt2Cr12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE")[0].entry.st_value |
|
|
||
| executable = f"{XDG_CONFIG_HOME}/@configDirName@/@version@/modules/discord_krisp/discord_krisp.node" | ||
|
|
||
| if (not os.path.exists(Path(executable))): |
There was a problem hiding this comment.
| if (not os.path.exists(Path(executable))): | |
| if not Path(executable).exists(): |
|
I got mentioned in a review comment - I wrote the initial version of that patching script, I'm ok with it being included under whatever license. |
|
Need to rethink my approach to fix this. The more I think about, the flakier it looks. |
|
Just a note that the |
|
@nezia1 I would gently suggest that discussion about this PR happen on this PR (particularly since I can't reply to your discord message, for unclear reasons). |
I'm okay with that. As the PR went stale, I've been looking to pick it back up especially considering the amount of work that has been done from your side and from @jopejoe1's. I've mostly been wondering about the values in the krisp patcher script; specifically the long strings of characters that seem derived from something:
|
They don't change much (I haven't needed to update the script since October last year), but when they do it will typically need human intervention.
They can change for two reasons:
The former is usually relatively easy to fix: run The latter can be more difficult to fix and requires inspecting the disassembled binary to see how to patch out the signature check, usually using a tool like Ghidra or Binary Ninja. |
|
Hey, I looked at #424232 and it seemed to be a way more maintainable solution to our problem. Wdyt @keysmashes? It'd allow us to never worry about updating the symbols |
Description of changes
This includes a modified version of @sersorrel's krips-patcher.py to fix krisp not working.
If it's okay with you @sersorrel that we included it in nixpkgs.
Closes #195512
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.