Skip to content

fix: use 770 permissions instead of 700, fixes multi user installs #3356 #3357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ func AdditionalOptions(appsFolderPath string, flags Flag) {
// To use default color scheme, set `scheme` to `nil`
func UserCSS(appsFolderPath, themeFolder string, scheme map[string]string) {
colorsDest := filepath.Join(appsFolderPath, "xpui", "colors.css")
if err := os.WriteFile(colorsDest, []byte(getColorCSS(scheme)), 0700); err != nil {
if err := os.WriteFile(colorsDest, []byte(getColorCSS(scheme)), 0770); err != nil {
utils.Fatal(err)
}
cssDest := filepath.Join(appsFolderPath, "xpui", "user.css")
if err := os.WriteFile(cssDest, []byte(getUserCSS(themeFolder)), 0700); err != nil {
if err := os.WriteFile(cssDest, []byte(getUserCSS(themeFolder)), 0770); err != nil {
utils.Fatal(err)
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func refreshThemeCSS() {
os.WriteFile(
filepath.Join(appDestPath, "xpui", "spicetify-config.json"),
configJsonBytes,
0700)
0770)
}
}

Expand Down Expand Up @@ -300,7 +300,7 @@ func RefreshApps(list ...string) {
os.WriteFile(
filepath.Join(appDestPath, "xpui", appName+".json"),
manifestFileContent,
0700)
0770)

var manifestJson utils.AppManifest
if err = json.Unmarshal(manifestFileContent, &manifestJson); err == nil {
Expand Down Expand Up @@ -368,7 +368,7 @@ func RefreshApps(list ...string) {
os.WriteFile(
filepath.Join(appDestPath, "xpui", appName+".js"),
[]byte(jsTemplate),
0700)
0770)

cssFile := filepath.Join(customAppPath, "style.css")
cssFileContent, err := os.ReadFile(cssFile)
Expand All @@ -378,7 +378,7 @@ func RefreshApps(list ...string) {
os.WriteFile(
filepath.Join(appDestPath, "xpui", appName+".css"),
[]byte(cssFileContent),
0700)
0770)
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/cmd/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,17 @@ func clearBackup() {
if err := os.RemoveAll(backupFolder); err != nil {
utils.Fatal(err)
}
os.Mkdir(backupFolder, 0700)
os.Mkdir(backupFolder, 0770)

if err := os.RemoveAll(rawFolder); err != nil {
utils.Fatal(err)
}
os.Mkdir(rawFolder, 0700)
os.Mkdir(rawFolder, 0770)

if err := os.RemoveAll(themedFolder); err != nil {
utils.Fatal(err)
}
os.Mkdir(themedFolder, 0700)
os.Mkdir(themedFolder, 0770)

backupSection.Key("version").SetValue("")
backupSection.Key("with").SetValue("")
Expand Down
18 changes: 9 additions & 9 deletions src/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
func CheckExistAndCreate(dir string) {
_, err := os.Stat(dir)
if err != nil {
os.MkdirAll(dir, 0700)
os.MkdirAll(dir, 0770)
}
}

Expand Down Expand Up @@ -52,20 +52,20 @@ func Unzip(src, dest string) error {

fpath := filepath.Join(dest, f.Name)
if f.FileInfo().IsDir() {
os.MkdirAll(fpath, 0700)
os.MkdirAll(fpath, 0770)
} else {
var fdir string
if lastIndex := strings.LastIndex(fpath, string(os.PathSeparator)); lastIndex > -1 {
fdir = fpath[:lastIndex]
}

err = os.MkdirAll(fdir, 0700)
err = os.MkdirAll(fdir, 0770)
if err != nil {
log.Fatal(err)
return err
}
f, err := os.OpenFile(
fpath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0700)
fpath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0770)
if err != nil {
return err
}
Expand All @@ -87,15 +87,15 @@ func Copy(src, dest string, recursive bool, filters []string) error {
return err
}

os.MkdirAll(dest, 0700)
os.MkdirAll(dest, 0770)

for _, file := range dir {
fileName := file.Name()
fSrcPath := filepath.Join(src, fileName)

fDestPath := filepath.Join(dest, fileName)
if file.IsDir() && recursive {
os.MkdirAll(fDestPath, 0700)
os.MkdirAll(fDestPath, 0770)
if err = Copy(fSrcPath, fDestPath, true, filters); err != nil {
return err
}
Expand All @@ -122,7 +122,7 @@ func Copy(src, dest string, recursive bool, filters []string) error {
defer fSrc.Close()

fDest, err := os.OpenFile(
fDestPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0700)
fDestPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0770)
if err != nil {
return err
}
Expand All @@ -148,7 +148,7 @@ func CopyFile(srcPath, dest string) error {
CheckExistAndCreate(dest)
destPath := filepath.Join(dest, filepath.Base(srcPath))
fDest, err := os.OpenFile(
destPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0700)
destPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0770)
if err != nil {
return err
}
Expand Down Expand Up @@ -220,7 +220,7 @@ func ModifyFile(path string, repl func(string) string) {

content := repl(string(raw))

os.WriteFile(path, []byte(content), 0700)
os.WriteFile(path, []byte(content), 0770)
}

// CreateFile creates a file with given path and content.
Expand Down