@@ -379,6 +379,32 @@ def test_terminal_zero_size():
379379 return - 1
380380
381381
382+ def test_terminal_readonly_rootfs_no_dev_tmpfs ():
383+ """Test terminal with readonly rootfs and no /dev tmpfs (issue #1745)."""
384+ if os .isatty (1 ) == False :
385+ return (77 , "requires TTY" )
386+
387+ conf = base_config ()
388+ add_all_namespaces (conf , userns = True )
389+ conf ['process' ]['terminal' ] = True
390+ conf ['process' ]['args' ] = ['/init' , 'true' ]
391+ conf ['root' ]['readonly' ] = True
392+
393+ # Remove the /dev tmpfs mount so /dev/console lives on the read-only rootfs.
394+ # Keep /dev/pts which is needed for terminal allocation.
395+ conf ['mounts' ] = [m for m in conf ['mounts' ]
396+ if m ['destination' ] != '/dev'
397+ and m ['destination' ] != '/dev/shm'
398+ and m ['destination' ] != '/dev/mqueue' ]
399+
400+ try :
401+ out , _ = run_and_get_output (conf , hide_stderr = True )
402+ return 0
403+ except Exception as e :
404+ logger .info ("test failed: %s" , e )
405+ return - 1
406+
407+
382408all_tests = {
383409 "terminal-allocation" : test_terminal_allocation ,
384410 "terminal-size" : test_terminal_size ,
@@ -392,6 +418,7 @@ def test_terminal_zero_size():
392418 "terminal-exec" : test_terminal_exec ,
393419 "terminal-exec-no-tty" : test_terminal_exec_no_tty ,
394420 "terminal-env-term" : test_terminal_env_term ,
421+ "terminal-readonly-rootfs-no-dev-tmpfs" : test_terminal_readonly_rootfs_no_dev_tmpfs ,
395422}
396423
397424if __name__ == "__main__" :
0 commit comments