mirror of
				https://github.com/opencontainers/runc.git
				synced 2025-10-31 11:06:21 +08:00 
			
		
		
		
	 59e5b61c5c
			
		
	
	59e5b61c5c
	
	
	
		
			
			This fixes a bug in the console package for big-endian architectures. When creating a new pty the returned path to the new pty slave was wrong for the second und all subsequent ptys. In runc the exec subcommand failed with an runtime error such as `container_linux.go:265: starting container process caused "open /dev/pts/4294967296: no such file or directory"`. The number is shifted by 32. Signed-off-by: Peter Morjan <peter.morjan@de.ibm.com>
		
			
				
	
	
		
			34 lines
		
	
	
		
			820 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			820 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package console
 | |
| 
 | |
| import (
 | |
| 	"fmt"
 | |
| 	"os"
 | |
| 	"unsafe"
 | |
| 
 | |
| 	"golang.org/x/sys/unix"
 | |
| )
 | |
| 
 | |
| const (
 | |
| 	cmdTcGet = unix.TCGETS
 | |
| 	cmdTcSet = unix.TCSETS
 | |
| )
 | |
| 
 | |
| // unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f.
 | |
| // unlockpt should be called before opening the slave side of a pty.
 | |
| func unlockpt(f *os.File) error {
 | |
| 	var u int32
 | |
| 	if _, _, err := unix.Syscall(unix.SYS_IOCTL, f.Fd(), unix.TIOCSPTLCK, uintptr(unsafe.Pointer(&u))); err != 0 {
 | |
| 		return err
 | |
| 	}
 | |
| 	return nil
 | |
| }
 | |
| 
 | |
| // ptsname retrieves the name of the first available pts for the given master.
 | |
| func ptsname(f *os.File) (string, error) {
 | |
| 	var u uint32
 | |
| 	if _, _, err := unix.Syscall(unix.SYS_IOCTL, f.Fd(), unix.TIOCGPTN, uintptr(unsafe.Pointer(&u))); err != 0 {
 | |
| 		return "", err
 | |
| 	}
 | |
| 	return fmt.Sprintf("/dev/pts/%d", u), nil
 | |
| }
 |