mirror of
https://github.com/mudler/luet.git
synced 2025-07-31 23:05:03 +00:00
Drop duplicate code for general.same_owner
This commit is contained in:
parent
341293c403
commit
1d8a6174bb
12
cmd/root.go
12
cmd/root.go
@ -159,17 +159,13 @@ func init() {
|
|||||||
pflags.StringP("logfile", "l", config.LuetCfg.GetLogging().Path,
|
pflags.StringP("logfile", "l", config.LuetCfg.GetLogging().Path,
|
||||||
"Logfile path. Empty value disable log to file.")
|
"Logfile path. Empty value disable log to file.")
|
||||||
|
|
||||||
sameOwner := false
|
// os/user doesn't work in from scratch environments.
|
||||||
u, err := user.Current()
|
// Check if i can retrieve user informations.
|
||||||
// os/user doesn't work in from scratch environments
|
_, err := user.Current()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Warning("failed to retrieve user identity:", err.Error())
|
Warning("failed to retrieve user identity:", err.Error())
|
||||||
sameOwner = true
|
|
||||||
}
|
}
|
||||||
if u != nil && u.Uid == "0" {
|
pflags.Bool("same-owner", config.LuetCfg.GetGeneral().SameOwner, "Maintain same owner on uncompress.")
|
||||||
sameOwner = true
|
|
||||||
}
|
|
||||||
pflags.Bool("same-owner", sameOwner, "Maintain same owner on uncompress.")
|
|
||||||
pflags.Int("concurrency", runtime.NumCPU(), "Concurrency")
|
pflags.Int("concurrency", runtime.NumCPU(), "Concurrency")
|
||||||
|
|
||||||
config.LuetCfg.Viper.BindPFlag("logging.color", pflags.Lookup("color"))
|
config.LuetCfg.Viper.BindPFlag("logging.color", pflags.Lookup("color"))
|
||||||
|
@ -231,7 +231,7 @@ func GenDefault(viper *v.Viper) {
|
|||||||
|
|
||||||
u, err := user.Current()
|
u, err := user.Current()
|
||||||
// os/user doesn't work in from scratch environments
|
// os/user doesn't work in from scratch environments
|
||||||
if err != nil || u.Uid == "0" {
|
if err != nil || (u != nil && u.Uid == "0") {
|
||||||
viper.SetDefault("general.same_owner", true)
|
viper.SetDefault("general.same_owner", true)
|
||||||
} else {
|
} else {
|
||||||
viper.SetDefault("general.same_owner", false)
|
viper.SetDefault("general.same_owner", false)
|
||||||
|
Loading…
Reference in New Issue
Block a user