@@ -374,7 +374,7 @@ func setupConsole(socket *os.File, config *initConfig, mount bool) error {
374
374
// used to change the owner of the slave path, but since the /dev/pts mount
375
375
// can have gid=X set (at the users' option). So touching the owner of the
376
376
// slave PTY is not necessary, as the kernel will handle that for us. Note
377
- // however, that setupUser (specifically fixStdioPermissions ) *will* change
377
+ // however, that setupUser (specifically FixStdioPermissions ) *will* change
378
378
// the UID owner of the console to be the user the process will run as (so
379
379
// they can actually control their console).
380
380
@@ -503,7 +503,7 @@ func setupUser(config *initConfig) error {
503
503
504
504
// Before we change to the container's user make sure that the processes
505
505
// STDIO is correctly owned by the user that we are switching to.
506
- if err := fixStdioPermissions (execUser ); err != nil {
506
+ if err := FixStdioPermissions (execUser . Uid ); err != nil {
507
507
return err
508
508
}
509
509
@@ -550,10 +550,10 @@ func setupUser(config *initConfig) error {
550
550
return nil
551
551
}
552
552
553
- // fixStdioPermissions fixes the permissions of PID 1's STDIO within the container to the specified user.
553
+ // FixStdioPermissions fixes the permissions of STDIO within the container to the specified user.
554
554
// The ownership needs to match because it is created outside of the container and needs to be
555
555
// localized.
556
- func fixStdioPermissions ( u * user. ExecUser ) error {
556
+ func FixStdioPermissions ( uid int ) error {
557
557
var null unix.Stat_t
558
558
if err := unix .Stat ("/dev/null" , & null ); err != nil {
559
559
return & os.PathError {Op : "stat" , Path : "/dev/null" , Err : err }
@@ -566,7 +566,7 @@ func fixStdioPermissions(u *user.ExecUser) error {
566
566
567
567
// Skip chown if uid is already the one we want or any of the STDIO descriptors
568
568
// were redirected to /dev/null.
569
- if int (s .Uid ) == u . Uid || s .Rdev == null .Rdev {
569
+ if int (s .Uid ) == uid || s .Rdev == null .Rdev {
570
570
continue
571
571
}
572
572
@@ -576,7 +576,7 @@ func fixStdioPermissions(u *user.ExecUser) error {
576
576
// that users expect to be able to actually use their console. Without
577
577
// this code, you couldn't effectively run as a non-root user inside a
578
578
// container and also have a console set up.
579
- if err := file .Chown (u . Uid , int (s .Gid )); err != nil {
579
+ if err := file .Chown (uid , int (s .Gid )); err != nil {
580
580
// If we've hit an EINVAL then s.Gid isn't mapped in the user
581
581
// namespace. If we've hit an EPERM then the inode's current owner
582
582
// is not mapped in our user namespace (in particular,
0 commit comments