Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use NB_USER rather than getpass.getuser() #132

Merged
merged 3 commits into from
Jun 16, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions jupyter_rsession_proxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def rewrite_auth(response, request):

def setup_rserver():
def _get_env(port):
return dict(USER=getpass.getuser())
return dict(USER=os.environ.get('NB_USER'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should go through the following hierarchy:

  1. If JUPYTER_USER is set, use that. That's the logged-in username, if using a JupyterHub
  2. If NB_USER is set, use that. This defaults to jovyan I think?
  3. Use getpass.getuser() if neither of these are set.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is JUPYTER_USER guaranteed to exist as a system user? I only see JUPYTERHUB_USER in PAWS, and that is not a system user in the container.

The args to --server-user and --user-identity need to be a system user, as I understand it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the rsession-proxy use the above order, but have additional logic to verify that it is also a system user?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I meant JUPYTERHUB_USER not JUPYTER_USER.

@vivian-rook I don't think it matters for rsession-proxy that it is a system user. Is that right, @ryanlovett?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yuvipanda I think the problem with #129 is that Chicocvenancio not a system user.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah goddamit, apparently i left my reading comprehension skills at home. Sorry!

In that case, can we try:

  1. pwd.getpwuid(os.getuid())[0], which should return a username that's in the pwd database.
  2. If this fails, then use NB_USER.

How does that sound?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this?


def db_config(db_dir):
'''
Expand Down Expand Up @@ -85,7 +85,7 @@ def _get_cmd(port):
'--www-port=' + str(port),
'--www-verify-user-agent=0',
'--secure-cookie-key-file=' + ntf.name,
'--server-user=' + getpass.getuser(),
'--server-user=' + os.environ.get('NB_USER'),
]
# Support at least v1.2.1335 and up

Expand Down Expand Up @@ -136,7 +136,7 @@ def _get_cmd(port):
'--program-mode=server',
'--log-stderr=1',
'--session-timeout-minutes=0',
'--user-identity=' + getpass.getuser(),
'--user-identity=' + os.environ.get('NB_USER'),
'--www-port=' + str(port)
]

Expand Down