Skip to content

Commit

Permalink
try sys user first
Browse files Browse the repository at this point in the history
  • Loading branch information
vivian-rook committed Jun 16, 2022
1 parent e451d18 commit 07207f2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions jupyter_rsession_proxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil
import subprocess
import tempfile
import pwd
from textwrap import dedent
from urllib.parse import urlparse, urlunparse

Expand Down Expand Up @@ -43,9 +44,16 @@ def rewrite_auth(response, request):
u = urlparse(request.uri)
response.headers[header] = urlunparse(u._replace(path=u.path+v))

def get_system_user():
try:
user = pwd.getpwuid(os.getuid())[0]
except:
user = os.environ.get('NB_USER')
return(user)

def setup_rserver():
def _get_env(port):
return dict(USER=os.environ.get('NB_USER'))
return dict(USER=get_system_user())

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

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

Expand Down

0 comments on commit 07207f2

Please sign in to comment.