mirror of
https://github.com/containers/podman.git
synced 2025-10-12 08:45:37 +08:00
Make ':' a restricted character for file names
file names for podman load, save, export, and import cannot contain ":" in them. It is a reserved character for parsing filenames. Signed-off-by: umohnani8 <umohnani@redhat.com> Closes: #694 Approved by: rhatdan
This commit is contained in:
@ -56,6 +56,9 @@ func exportCmd(c *cli.Context) error {
|
|||||||
return errors.Errorf("refusing to export to terminal. Use -o flag or redirect")
|
return errors.Errorf("refusing to export to terminal. Use -o flag or redirect")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err := validateFileName(output); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
ctr, err := runtime.LookupContainer(args[0])
|
ctr, err := runtime.LookupContainer(args[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -75,6 +75,10 @@ func importCmd(c *cli.Context) error {
|
|||||||
return errors.Errorf("too many arguments. Usage TARBALL [REFERENCE]")
|
return errors.Errorf("too many arguments. Usage TARBALL [REFERENCE]")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := validateFileName(source); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
changes := v1.ImageConfig{}
|
changes := v1.ImageConfig{}
|
||||||
if c.IsSet("change") {
|
if c.IsSet("change") {
|
||||||
changes, err = util.GetImageConfig(c.StringSlice("change"))
|
changes, err = util.GetImageConfig(c.StringSlice("change"))
|
||||||
|
@ -93,6 +93,9 @@ func loadCmd(c *cli.Context) error {
|
|||||||
input = outFile.Name()
|
input = outFile.Name()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err := validateFileName(input); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
var writer io.Writer
|
var writer io.Writer
|
||||||
if !c.Bool("quiet") {
|
if !c.Bool("quiet") {
|
||||||
|
@ -816,3 +816,12 @@ func getLoggingPath(opts []string) string {
|
|||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validateFileName returns an error if filename contains ":"
|
||||||
|
// as it is currently not supported
|
||||||
|
func validateFileName(filename string) error {
|
||||||
|
if strings.Contains(filename, ":") {
|
||||||
|
return errors.Errorf("invalid filename (should not contain ':') %q", filename)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -87,6 +87,9 @@ func saveCmd(c *cli.Context) error {
|
|||||||
return errors.Errorf("refusing to save to terminal. Use -o flag or redirect")
|
return errors.Errorf("refusing to save to terminal. Use -o flag or redirect")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err := validateFileName(output); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
var dst, manifestType string
|
var dst, manifestType string
|
||||||
switch c.String("format") {
|
switch c.String("format") {
|
||||||
|
@ -15,6 +15,7 @@ podman export - Export container's filesystem contents as a tar archive
|
|||||||
**podman export** exports the filesystem of a container and saves it as a tarball
|
**podman export** exports the filesystem of a container and saves it as a tarball
|
||||||
on the local machine. **podman export** writes to STDOUT by default and can be
|
on the local machine. **podman export** writes to STDOUT by default and can be
|
||||||
redirected to a file using the **output flag**.
|
redirected to a file using the **output flag**.
|
||||||
|
Note: `:` is a restricted character and cannot be part of the file name.
|
||||||
|
|
||||||
**podman [GLOBAL OPTIONS]**
|
**podman [GLOBAL OPTIONS]**
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ podman\-import - Import a tarball and save it as a filesystem image
|
|||||||
and saves it as a filesystem image. Remote tarballs can be specified using a URL.
|
and saves it as a filesystem image. Remote tarballs can be specified using a URL.
|
||||||
Various image instructions can be configured with the **--change** flag and
|
Various image instructions can be configured with the **--change** flag and
|
||||||
a commit message can be set using the **--message** flag.
|
a commit message can be set using the **--message** flag.
|
||||||
|
Note: `:` is a restricted character and cannot be part of the file name.
|
||||||
|
|
||||||
**podman [GLOBAL OPTIONS]**
|
**podman [GLOBAL OPTIONS]**
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ podman\-load - Load an image from docker archive
|
|||||||
**podman load** copies an image from either **docker-archive** or **oci-archive** stored
|
**podman load** copies an image from either **docker-archive** or **oci-archive** stored
|
||||||
on the local machine. **podman load** reads from stdin by default or a file if the **input** flag is set.
|
on the local machine. **podman load** reads from stdin by default or a file if the **input** flag is set.
|
||||||
The **quiet** flag suppresses the output when set.
|
The **quiet** flag suppresses the output when set.
|
||||||
|
Note: `:` is a restricted character and cannot be part of the file name.
|
||||||
|
|
||||||
**podman [GLOBAL OPTIONS]**
|
**podman [GLOBAL OPTIONS]**
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ podman\-save - Save an image to docker-archive or oci-archive
|
|||||||
with oci manifest type), or **docker-dir** (directory with v2s2 manifest type) on the local machine,
|
with oci manifest type), or **docker-dir** (directory with v2s2 manifest type) on the local machine,
|
||||||
default is **docker-archive**. **podman save** writes to STDOUT by default and can be redirected to a
|
default is **docker-archive**. **podman save** writes to STDOUT by default and can be redirected to a
|
||||||
file using the **output** flag. The **quiet** flag suppresses the output when set.
|
file using the **output** flag. The **quiet** flag suppresses the output when set.
|
||||||
|
Note: `:` is a restricted character and cannot be part of the file name.
|
||||||
|
|
||||||
**podman [GLOBAL OPTIONS]**
|
**podman [GLOBAL OPTIONS]**
|
||||||
|
|
||||||
|
@ -3,9 +3,10 @@ package integration
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"path/filepath"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Podman export", func() {
|
var _ = Describe("Podman export", func() {
|
||||||
@ -43,4 +44,14 @@ var _ = Describe("Podman export", func() {
|
|||||||
err = os.Remove(outfile)
|
err = os.Remove(outfile)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman export bad filename", func() {
|
||||||
|
_, ec, cid := podmanTest.RunLsContainer("")
|
||||||
|
Expect(ec).To(Equal(0))
|
||||||
|
|
||||||
|
outfile := filepath.Join(podmanTest.TempDir, "container:with:colon.tar")
|
||||||
|
result := podmanTest.Podman([]string{"export", "-o", outfile, cid})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result.ExitCode()).To(Not(Equal(0)))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -93,4 +93,12 @@ var _ = Describe("Podman save", func() {
|
|||||||
Expect(save.ExitCode()).To(Equal(0))
|
Expect(save.ExitCode()).To(Equal(0))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman save bad filename", func() {
|
||||||
|
outdir := filepath.Join(podmanTest.TempDir, "save:colon")
|
||||||
|
|
||||||
|
save := podmanTest.Podman([]string{"save", "--compress", "--format", "docker-dir", "-o", outdir, ALPINE})
|
||||||
|
save.WaitWithDefaultTimeout()
|
||||||
|
Expect(save.ExitCode()).To(Not(Equal(0)))
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user