Skip to content

Commit

Permalink
Change the way DebOps checks current user
Browse files Browse the repository at this point in the history
The 'os.getlogin()' function relies on the glibc 'getlogin()' function,
which requires a control terminal (tty, pty) to work. In an environment
without the control terminal (systemd service, remote execution) it
results in the 'OSError: [Errno 6] No such device or address' exception.

Switching to 'getpass.getuser()' function is a recommended alternative.
  • Loading branch information
drybjed committed Oct 11, 2024
1 parent 7a9c8b9 commit 6d2bef7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/debops/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .ansibleplaybookrunner import AnsiblePlaybookRunner
from .envrunner import EnvRunner
import logging
import getpass
import sys
import os

Expand All @@ -23,7 +24,7 @@ def __init__(self, args=None):
self.config = Configuration()
self.parsed_args = Subcommands(self.args)
logger.debug('Command line interpreter initialized')
logger.debug('Control user=' + os.getlogin())
logger.debug('Control user=' + getpass.getuser())

if self.parsed_args.section == 'project':
if self.parsed_args.command == 'init':
Expand Down

0 comments on commit 6d2bef7

Please sign in to comment.