Skip to content

Commit 825b5c0

Browse files
authored
Merge pull request opencontainers#1516 from cyphar/list-casting-unicode
list: fix various problems with owner field
2 parents c4302dd + 7cfb107 commit 825b5c0

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

libcontainer/factory_linux.go

+1-9
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,6 @@ func (l *LinuxFactory) Create(id string, config *configs.Config) (Container, err
162162
if err := l.Validator.Validate(config); err != nil {
163163
return nil, newGenericError(err, ConfigInvalid)
164164
}
165-
uid, err := config.HostRootUID()
166-
if err != nil {
167-
return nil, newGenericError(err, SystemError)
168-
}
169-
gid, err := config.HostRootGID()
170-
if err != nil {
171-
return nil, newGenericError(err, SystemError)
172-
}
173165
containerRoot := filepath.Join(l.Root, id)
174166
if _, err := os.Stat(containerRoot); err == nil {
175167
return nil, newGenericError(fmt.Errorf("container with id exists: %v", id), IdInUse)
@@ -179,7 +171,7 @@ func (l *LinuxFactory) Create(id string, config *configs.Config) (Container, err
179171
if err := os.MkdirAll(containerRoot, 0711); err != nil {
180172
return nil, newGenericError(err, SystemError)
181173
}
182-
if err := os.Chown(containerRoot, uid, gid); err != nil {
174+
if err := os.Chown(containerRoot, unix.Geteuid(), unix.Getegid()); err != nil {
183175
return nil, newGenericError(err, SystemError)
184176
}
185177
if config.Rootless {

list.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func getContainers(context *cli.Context) ([]containerState, error) {
135135
stat := item.Sys().(*syscall.Stat_t)
136136
owner, err := user.LookupUid(int(stat.Uid))
137137
if err != nil {
138-
owner.Name = string(stat.Uid)
138+
owner.Name = fmt.Sprintf("#%d", stat.Uid)
139139
}
140140

141141
container, err := factory.Load(item.Name())

0 commit comments

Comments
 (0)