Skip to content

Commit

Permalink
to-be-squashed: addressing first batch of @dt's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Omer Preminger committed Apr 25, 2023
1 parent 90cdec3 commit 2a08f3f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 73 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
`/var/singularity`) to store local state files.
- `--cwd` is now the preferred form of the flag for setting the container's
working directory, though `--pwd` is still supported for compatibility.
- The way --home is handled when running as root (e.g. `sudo singularity`) or
with `--fakeroot` has changed. Previously, we were only modifying the `HOME`
environment variable in these cases, while leaving the container's
`/etc/passwd` file unchanged (with its homedir field pointing to `/root`,
regardless of the value passed to `--home`). With this change, both value of
`HOME` and the contents of `/etc/passwd` in the container will reflect the
value passed to `--home`.

### New Features & Functionality

Expand Down
54 changes: 6 additions & 48 deletions LICENSE_DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,6 @@ The dependencies and their licenses are as follows:

**License URL:** <https://github.com/prometheus/procfs/blob/master/LICENSE>

## github.com/revel/log15

**License:** Apache-2.0

**License URL:** <https://github.com/revel/log15/blob/master/LICENSE>

## github.com/rootless-containers/proto/go-proto

**License:** Apache-2.0
Expand Down Expand Up @@ -455,12 +449,6 @@ The dependencies and their licenses are as follows:

**Project URL:** <https://gopkg.in/square/go-jose.v2>

## gopkg.in/stack.v0

**License:** Apache-2.0

**Project URL:** <https://gopkg.in/stack.v0>

## gopkg.in/yaml.v2

**License:** Apache-2.0
Expand Down Expand Up @@ -701,12 +689,6 @@ The dependencies and their licenses are as follows:

**Project URL:** <https://golang.org/x/text>

## golang.org/x/tools

**License:** BSD-3-Clause

**Project URL:** <https://golang.org/x/tools>

## google.golang.org/protobuf

**License:** BSD-3-Clause
Expand Down Expand Up @@ -773,6 +755,12 @@ The dependencies and their licenses are as follows:

**License URL:** <https://github.com/asaskevich/govalidator/blob/master/LICENSE>

## github.com/astromechza/etcpwdparse

**License:** MIT

**License URL:** <https://github.com/astromechza/etcpwdparse/blob/master/LICENSE.md>

## github.com/beorn7/perks/quantile

**License:** MIT
Expand Down Expand Up @@ -845,12 +833,6 @@ The dependencies and their licenses are as follows:

**License URL:** <https://github.com/go-log/log/blob/master/LICENSE>

## github.com/inconshreveable/log15/term

**License:** MIT

**License URL:** <https://github.com/inconshreveable/log15/blob/master/term/LICENSE>

## github.com/josharian/intern

**License:** MIT
Expand Down Expand Up @@ -923,12 +905,6 @@ The dependencies and their licenses are as follows:

**License URL:** <https://github.com/pelletier/go-toml/blob/master/v2/LICENSE>

## github.com/revel/cmd

**License:** MIT

**License URL:** <https://github.com/revel/cmd/blob/master/LICENSE>

## github.com/rivo/uniseg

**License:** MIT
Expand Down Expand Up @@ -959,12 +935,6 @@ The dependencies and their licenses are as follows:

**License URL:** <https://github.com/sirupsen/logrus/blob/master/LICENSE>

## github.com/stat0s2p/etcpwdparse

**License:** MIT

**License URL:** <https://github.com/stat0s2p/etcpwdparse/blob/master/LICENSE.md>

## github.com/titanous/rocacheck

**License:** MIT
Expand All @@ -989,12 +959,6 @@ The dependencies and their licenses are as follows:

**Project URL:** <https://go.mozilla.org/pkcs7>

## gopkg.in/natefinch/lumberjack.v2

**License:** MIT

**Project URL:** <https://gopkg.in/natefinch/lumberjack.v2>

## gopkg.in/yaml.v3

**License:** MIT
Expand Down Expand Up @@ -1043,12 +1007,6 @@ The dependencies and their licenses are as follows:

**Project URL:** <https://github.com/garyburd/redigo/redis>

## github.com/revel/config

**License:** Unknown

**Project URL:** <https://github.com/revel/config>

## github.com/vbauerster/mpb

**License:** The Unlicense
Expand Down
8 changes: 1 addition & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8
github.com/adigunhammedolalekan/registry-auth v0.0.0-20200730122110-8cde180a3a60
github.com/apex/log v1.9.0
github.com/astromechza/etcpwdparse v0.0.0-20170319193008-f0e5f0779716
github.com/blang/semver/v4 v4.0.0
github.com/buger/goterm v1.0.4
github.com/buger/jsonparser v1.1.1
Expand Down Expand Up @@ -34,15 +35,13 @@ require (
github.com/opencontainers/umoci v0.4.7
github.com/pelletier/go-toml/v2 v2.0.7
github.com/pkg/errors v0.9.1
github.com/revel/cmd v1.1.2
github.com/samber/lo v1.38.1
github.com/seccomp/libseccomp-golang v0.10.0
github.com/shopspring/decimal v1.3.1
github.com/sigstore/sigstore v1.6.3
github.com/sirupsen/logrus v1.9.0
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/stat0s2p/etcpwdparse v0.0.0-20170319193008-f0e5f0779716
github.com/sylabs/json-resp v0.8.2
github.com/sylabs/scs-build-client v0.7.7
github.com/sylabs/scs-key-client v0.7.2
Expand Down Expand Up @@ -117,7 +116,6 @@ require (
github.com/gosimple/unidecode v1.0.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/inconshreveable/log15 v0.0.0-20201112154412-8562bdadbbac // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand Down Expand Up @@ -148,8 +146,6 @@ require (
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/revel/config v1.1.0 // indirect
github.com/revel/log15 v2.11.20+incompatible // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rootless-containers/proto v0.1.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
Expand Down Expand Up @@ -187,9 +183,7 @@ require (
google.golang.org/grpc v1.54.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/go-jose/go-jose.v2 v2.6.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/stack.v0 v0.0.0-20141108040640-9b43fcefddd0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
16 changes: 2 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ github.com/aphistic/sweet v0.2.0/go.mod h1:fWDlIh/isSE9n6EPsRmC0det+whmX6dJid3st
github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
github.com/astromechza/etcpwdparse v0.0.0-20170319193008-f0e5f0779716 h1:MWNxJj2HIBx5Skyz30rxjHkXwGCr05O2bAz0VrwgADM=
github.com/astromechza/etcpwdparse v0.0.0-20170319193008-f0e5f0779716/go.mod h1:gk3YG2Kpl+fXEmCqzKOgaISssbqJ0o1AN1qazRtbP+w=
github.com/aws/aws-sdk-go v1.20.6/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
Expand Down Expand Up @@ -298,8 +300,6 @@ github.com/honeycombio/libhoney-go v1.16.0 h1:kPpqoz6vbOzgp7jC6SR7SkNj7rua7rgxvz
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM=
github.com/inconshreveable/log15 v0.0.0-20201112154412-8562bdadbbac h1:n1DqxAo4oWPMvH1+v+DLYlMCecgumhhgnxAPdqDIFHI=
github.com/inconshreveable/log15 v0.0.0-20201112154412-8562bdadbbac/go.mod h1:cOaXtrgN4ScfRrD9Bre7U1thNq5RtJ8ZoP4iXVGRj6o=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
Expand Down Expand Up @@ -471,12 +471,6 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT
github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI=
github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY=
github.com/revel/cmd v1.1.2 h1:6Fjd+VrvSorVwtdRydlooMGCJWcO46J+M1nW0NCQazc=
github.com/revel/cmd v1.1.2/go.mod h1:ssxs07425ETZjJp3PdcGnzpcH7AzuFO5sS1N3+UvTGk=
github.com/revel/config v1.1.0 h1:2V8CkHHs5JS7Px8KG3MklTvDkFXpjTrM4tKoCYAGjWg=
github.com/revel/config v1.1.0/go.mod h1:GT4a9px5kDGRqLizcw/md0QFErrhen76toz4qS3oIoI=
github.com/revel/log15 v2.11.20+incompatible h1:JkA4tbwIo/UGEMumY50zndKq816RQW3LQ0wIpRc+32U=
github.com/revel/log15 v2.11.20+incompatible/go.mod h1:l0WmLRs+IM1hBl4noJiBc2tZQiOgZyXzS1mdmFt+5Gc=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
Expand Down Expand Up @@ -529,8 +523,6 @@ github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRM
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stat0s2p/etcpwdparse v0.0.0-20170319193008-f0e5f0779716 h1:FVA7cRdrZi6k1KcYSV34EgNB0ANzA67k+AXbsHG0OpM=
github.com/stat0s2p/etcpwdparse v0.0.0-20170319193008-f0e5f0779716/go.mod h1:NF4E/IXhcAE5Uk8yF4grAx3Uq2ZPB/HjIijR9ZmUcAI=
github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980 h1:lIOOHPEbXzO3vnmx2gok1Tfs31Q8GQqKLc8vVqyQq/I=
github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down Expand Up @@ -799,13 +791,9 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/go-jose/go-jose.v2 v2.6.1 h1:qEzJlIDmG9q5VO0M/o8tGS65QMHMS1w01TQJB1VPJ4U=
gopkg.in/go-jose/go-jose.v2 v2.6.1/go.mod h1:zzZDPkNNw/c9IE7Z9jr11mBZQhKQTMzoEEIoEdZlFBI=
gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI=
gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/stack.v0 v0.0.0-20141108040640-9b43fcefddd0 h1:lMH45EKqD8Nf6LwoF+43YOKjOAEEHQRVgDyG8RCV4MU=
gopkg.in/stack.v0 v0.0.0-20141108040640-9b43fcefddd0/go.mod h1:kl/bNzW/jgTgUOCGDj3XPn9/Hbfhw6pjfBRUnaTioFQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
16 changes: 12 additions & 4 deletions internal/pkg/util/fs/files/passwd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
package files

import (
"bufio"
"fmt"
"os"
"strings"

"github.com/revel/cmd/utils"
pwd "github.com/stat0s2p/etcpwdparse"
pwd "github.com/astromechza/etcpwdparse"

"github.com/sylabs/singularity/internal/pkg/util/fs"
"github.com/sylabs/singularity/internal/pkg/util/user"
Expand All @@ -26,10 +27,17 @@ func Passwd(path string, home string, uid int) (content []byte, err error) {
}

sylog.Verbosef("Creating passwd content")
lines, err := utils.ReadLines(path)
file, err := os.Open(path)
if err != nil {
return content, fmt.Errorf("failed to read passwd file content in container: %s", err)
return content, fmt.Errorf("error opening passwd file %#v for reading: %v", path, err)
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
lines := []string{}
for scanner.Scan() {
lines = append(lines, scanner.Text())
}
file.Close()

pwInfo, err := user.GetPwUID(uint32(uid))
if err != nil {
Expand Down

0 comments on commit 2a08f3f

Please sign in to comment.