profanity icon indicating copy to clipboard operation
profanity copied to clipboard

eval_password no longer works as expected

Open mrmalachai opened this issue 8 months ago • 6 comments

Expected Behavior

eval_password should correctly echo back an application-scoped environment variable

Current Behavior

profanity displays "Login failed." as if the password that was passed via the PROFANITY_P environment variable via eval_password was not correctly echoed.

Possible Solution

Revert recent change to account_eval_password from two days ago?

Steps to Reproduce (for bugs)

  1. set an alias to profanity: PROFANITY_P=$(<command to retrieve password>) \profanity --account <accountname>
  2. set eval_password to echo ${PROFANITY_P}
  3. start profanity via alias
  4. "Login failed."

Environment

  • Give us the version and build information output generated by profanity -v
    • Profanity, version 0.17.0
  • If you could not yet build profanity, mention the revision you try to build from
  • Operating System/Distribution
    • CachyOS, rolling release
  • glib version
    • glibc: 2.43+r5+g856c426a7534-3
    • glib2: 2.86.4-1.3
  • libstrophe version
    • libstrophe: 1:0.14.0-1.2
  • Some bugs might be due to specific implementation in the server. /serversoftware example.domain can be helpful

mrmalachai avatar Mar 28 '26 18:03 mrmalachai

Revert recent change to account_eval_password from two days ago?

Which git commit?

jubalh avatar Mar 28 '26 21:03 jubalh

To be entirely honest I'm not sure. That wasn't a sarcastic question mark but an honest one. I only noticed a comment in the changelog regarding account_eval_password and glib

On Sat, Mar 28, 2026, 2:14 PM Michael Vetter @.***> wrote:

jubalh left a comment (profanity-im/profanity#2138) https://github.com/profanity-im/profanity/issues/2138#issuecomment-4148824808

Revert recent change to account_eval_password from two days ago?

Which git commit?

— Reply to this email directly, view it on GitHub https://github.com/profanity-im/profanity/issues/2138?email_source=notifications&email_token=ANESBGZFHMI54V2BJ3KEBLL4TA6CPA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMJUHA4DENBYGA4KM4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-4148824808, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANESBG56ZDLEZ7PJNCSMLQL4TA6CPAVCNFSM6AAAAACXDMYCI6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DCNBYHAZDIOBQHA . You are receiving this because you authored the thread.Message ID: @.***>

mrmalachai avatar Mar 28 '26 21:03 mrmalachai

Probably f5787fb31. I'll try to take a look.

jubalh avatar Mar 28 '26 21:03 jubalh

Earlier we used popen() which executes the command within a shell environment. So variable expansion works there.

Now we use g_spawn_command_line_sync() which does not do shell expansion. It is safer, has better error handling and better resource management. popen() could cause leaks in case reading from the stream failed for example.

Honestly I was not even aware that people use eval_password like you do here. I thought everybody is just calling a keyring tool. For example /account set myaccount eval_password "pass xmpp/myaccount". Is there a specific reason why you don't do that?

If you want to keep on using shell expansion you can wrap your command in a shell: /account set <accountname> eval_password "sh -c 'echo ${PROFANITY_P}'"

Just closing this since it's not a bug but desired behaviour. Let me know if you need more help solving your problem.

jubalh avatar Mar 28 '26 21:03 jubalh

The reason I don't do that directly is because I have regular disconnects which causes me to re-enter my key's encryption passphrase again. This regularly happens when afk, resulting in a timeout. My solution was to move the pass call to the alias, passing the result to a variable which is scoped to the profanity startup, then eval that. Hacky, but has the desired effect of persisting the password without leaving it written to disk.

Edit: I meant to add: Thank you for helping out. Much appreciated. :)

On Sat, Mar 28, 2026, 2:38 PM Michael Vetter @.***> wrote:

jubalh left a comment (profanity-im/profanity#2138) https://github.com/profanity-im/profanity/issues/2138#issuecomment-4148860479

Earlier we used popen() which executes the command within a shell environment. So variable expansion works there.

Now we use g_spawn_command_line_sync() which does not do shell expansion. It is safer, has better error handling and better resource management. popen() could cause leaks in case reading from the stream failed for example.

Honestly I was not even aware that people use eval_password like you do here. I thought everybody is just calling a keyring tool. For example /account set myaccount eval_password "pass xmpp/myaccount". Is there a specific reason why you don't do that?

If you want to keep on using shell expansion you can wrap your command in a shell: /account set eval_password "sh -c 'echo ${PROFANITY_P}'"

— Reply to this email directly, view it on GitHub https://github.com/profanity-im/profanity/issues/2138?email_source=notifications&email_token=ANESBGYI22OJOHFSQ64IUCD4TBA6VA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMJUHA4DMMBUG442M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-4148860479, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANESBG5HCUKYNQJG2PFXX2L4TBA6VAVCNFSM6AAAAACXDMYCI6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DCNBYHA3DANBXHE . You are receiving this because you authored the thread.Message ID: @.***>

mrmalachai avatar Mar 28 '26 22:03 mrmalachai

Profanity should handle this as well. After the first successful connect the password is cached in memory. All automatic reconnects will use it. So unlike you do a manual /disconnect it should be there. Maybe check yout /reconnect setting. It shouldn't be 0. If you call /connect manually again then it will also require to run eval password again.

In any case the solution above with running sh -c should solve your problem as well. So everything is fine, yes?

jubalh avatar Mar 28 '26 22:03 jubalh