Skip to content

Commit

Permalink
cmd/unpack: Avoid to maintain original uid/gid
Browse files Browse the repository at this point in the history
Now by default on unpack a tarball the uid/gid
used on new files are the same of the user
running the command.

To maintain the old behavior is possible using
the new option --same-owner=true on unpack command.

Closes: #21
  • Loading branch information
Daniele Rondina committed May 11, 2023
1 parent 9212c7a commit bcd2d21
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/unpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ $> lxd-compose unpack /tmp/myproj.tar.gz --render-file render/default.yaml \

to, _ := cmd.Flags().GetString("to")
renderFile, _ := cmd.Flags().GetString("render-file")
sameOwner, _ := cmd.Flags().GetBool("same-owner")

// Create Instance
composer := loader.NewLxdCInstance(config)
Expand All @@ -117,6 +118,7 @@ $> lxd-compose unpack /tmp/myproj.tar.gz --render-file render/default.yaml \
tarf.SetDefaultTarFormers(t)

s := tarf_specs.NewSpecFile()
s.SameOwner = sameOwner
opts := tarf_tools.NewTarReaderCompressionOpts(true)
err := tarf_tools.PrepareTarReader(args[0], opts)
if err != nil {
Expand Down Expand Up @@ -164,6 +166,8 @@ $> lxd-compose unpack /tmp/myproj.tar.gz --render-file render/default.yaml \
"Render file where update the source base dir.")
flags.StringSliceVar(&renderEnvs, "render-env", []string{},
"Render env variable to replace with the new value.")
flags.Bool("same-owner", false,
"Maintain original uid/gid from the tarball.")

return cmd
}

0 comments on commit bcd2d21

Please sign in to comment.