jupyterhub / sudospawner

Spawn JupyterHub single-user servers with sudo
BSD 3-Clause "New" or "Revised" License
50 stars 41 forks source link

Spawn error - sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges? #59

Open kipstakkr opened 5 years ago

kipstakkr commented 5 years ago

I'm running the JupyterHub with SudoSpawner and PAMAuthentication in my organization K8s environment, where I'm mounting my pod to PVC. PVC does not have root access, so the command used by the SudoSpawner ['sudo', '-u', 'user_1', '-nH', '/opt/conda/bin/sudospawner'] fails as it starts with sudo command.

Following is my Jupyter logs (the logs are from where the user inputs the credentials):

[D 2019-08-29 13:05:15.663 JupyterHub base:482] Setting cookie for user_1: jupyterhub-hub-login
[D 2019-08-29 13:05:15.664 JupyterHub base:478] Setting cookie jupyterhub-hub-login: {'httponly': True, 'path': '/hub/'}
[I 2019-08-29 13:05:15.664 JupyterHub base:663] User logged in: user_1
[D 2019-08-29 13:05:15.664 JupyterHub user:240] Creating <class 'sudospawner.spawner.SudoSpawner'> for user_1:
[W 2019-08-29 13:05:15.669 JupyterHub configurable:168] Config option `mediator_log_level` not recognized by `SudoSpawner`.
[I 2019-08-29 13:05:15.670 JupyterHub log:174] 302 POST /hub/login?next= -> /hub/spawn (user_1@::ffff:10.192.126.0) 75.50ms
[D 2019-08-29 13:05:16.208 JupyterHub pages:165] Triggering spawn with default options for user_1
[D 2019-08-29 13:05:16.209 JupyterHub base:780] Initiating spawn for user_1
[D 2019-08-29 13:05:16.209 JupyterHub base:787] 0/100 concurrent spawns
[D 2019-08-29 13:05:16.209 JupyterHub base:792] 0 active servers
sh: 1: cannot create /run/motd.dynamic.new: Permission denied
[W 2019-08-29 13:05:16.245 JupyterHub auth:941] Failed to open PAM session for user_1: [PAM Error 14] Cannot make/remove an entry for the specified session
[W 2019-08-29 13:05:16.245 JupyterHub auth:942] Disabling PAM sessions from now on.
[D 2019-08-29 13:05:16.253 JupyterHub user:542] Calling Spawner.start for user_1
[D 2019-08-29 13:05:16.254 JupyterHub spawner:63] Spawning ['sudo', '-u', 'user_1', '-nH', '/opt/conda/bin/sudospawner']
sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?
[E 2019-08-29 13:05:16.264 JupyterHub spawner:83] Failed to get JSON result from mediator: ''
[E 2019-08-29 13:05:16.264 JupyterHub user:626] Unhandled error starting user_1's server: substring not found
[D 2019-08-29 13:05:16.264 JupyterHub user:724] Stopping user_1
[D 2019-08-29 13:05:16.273 JupyterHub user:752] Deleting oauth client jupyterhub-user-user_1
[D 2019-08-29 13:05:16.281 JupyterHub user:755] Finished stopping user_1
[I 2019-08-29 13:05:16.287 JupyterHub log:174] 302 GET /hub/spawn -> /hub/spawn-pending/user_1 (user_1@::ffff:10.193.236.0) 85.62ms
ERROR:asyncio:Task exception was never retrieved
future: <Task finished coro=<BaseHandler.spawn_single_user() done, defined at /opt/conda/lib/python3.7/site-packages/jupyterhub/handlers/base.py:697> exception=ValueError('substring not found')>
Traceback (most recent call last):
  File "/opt/conda/lib/python3.7/site-packages/jupyterhub/handlers/base.py", line 889, in spawn_single_user
    timedelta(seconds=self.slow_spawn_timeout), finish_spawn_future
  File "/opt/conda/lib/python3.7/site-packages/jupyterhub/handlers/base.py", line 807, in finish_user_spawn
    await spawn_future
  File "/opt/conda/lib/python3.7/site-packages/jupyterhub/user.py", line 642, in spawn
    raise e
  File "/opt/conda/lib/python3.7/site-packages/jupyterhub/user.py", line 546, in spawn
    url = await gen.with_timeout(timedelta(seconds=spawner.start_timeout), f)
  File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "/opt/conda/lib/python3.7/site-packages/sudospawner/spawner.py", line 92, in start
    reply = yield self.do(action='spawn', args=self.get_args(), env=self.get_env())
  File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
    value = future.result()
  File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 748, in run
    yielded = self.gen.send(value)
  File "/opt/conda/lib/python3.7/site-packages/sudospawner/spawner.py", line 80, in do
    data_str = data_str[data_str.index('{'):data_str.rindex('}')+1]
ValueError: substring not found
[E 2019-08-29 13:05:16.801 JupyterHub pages:284] Previous spawn for user_1 failed: substring not found
[E 2019-08-29 13:05:16.807 JupyterHub log:166] {
      "X-Forwarded-Host": "127.0.0.1:30235",
      "X-Forwarded-Proto": "http",
      "X-Forwarded-Port": "30235",
      "X-Forwarded-For": "::ffff:10.193.236.0",
      "Upgrade-Insecure-Requests": "1",
      "Connection": "close",
      "Dnt": "1",
      "Cookie": "jupyterhub-hub-login=[secret]; jupyterhub-session-id=[secret]",
      "Referer": "http://127.0.0.1:30235/hub/login",
      "Accept-Encoding": "gzip, deflate",
      "Accept-Language": "en-US,en;q=0.5",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
      "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Firefox/60.0",
      "Host": "127.0.0.1:30235"
    }
[E 2019-08-29 13:05:16.807 JupyterHub log:174] 500 GET /hub/spawn-pending/user_1 (user_1@::ffff:10.193.236.0) 13.06ms

Please suggest me a fix for this issue or if it's not being able to fix, a possible alternative for my approach. Thanks in advance.