Skip to content

Commit

Permalink
mq-sendmail: handle OSError when calling os.getlogin() in a con…
Browse files Browse the repository at this point in the history
…tainer
  • Loading branch information
FelixSchwarz committed Aug 5, 2024
1 parent b2230fc commit 9f3b27d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion schwarz/mailqueue/cli/mq_sendmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ def mq_sendmail_main(argv=sys.argv, return_rc_code=False):
set_msgid_header = arguments['--set-msgid-header']

msg_bytes = sys.stdin.buffer.read()
try:
username = os.getlogin()
except OSError:
# GitHub Actions: "[Errno 6] No such device or address"
username = 'root'
smtp_sender_domain = platform.uname().node
msg_sender = os.getlogin() + '@' + smtp_sender_domain
msg_sender = f'{username}@{smtp_sender_domain}'

cli_options = {
'verbose': verbose,
Expand Down

0 comments on commit 9f3b27d

Please sign in to comment.