@@ -17,7 +17,7 @@ import (
1717 "github.com/spicetify/cli/src/cmd"
1818 spotifystatus "github.com/spicetify/cli/src/status/spotify"
1919 "github.com/spicetify/cli/src/utils"
20- "golang.org/x/sys/windows "
20+ "github.com/spicetify/cli/src/utils/isAdmin "
2121)
2222
2323var (
3636 bypassAdminCheck = false
3737)
3838
39- func isAdmin (bypassAdminCheck bool ) bool {
40- if bypassAdminCheck {
41- return false
42- }
43-
44- switch runtime .GOOS {
45- case "windows" :
46- var sid * windows.SID
47- err := windows .AllocateAndInitializeSid (
48- & windows .SECURITY_NT_AUTHORITY ,
49- 2 ,
50- windows .SECURITY_BUILTIN_DOMAIN_RID ,
51- windows .DOMAIN_ALIAS_RID_ADMINS ,
52- 0 , 0 , 0 , 0 , 0 , 0 ,
53- & sid )
54- if err != nil {
55- return false
56- }
57- defer windows .FreeSid (sid )
58-
59- token := windows .Token (0 )
60- member , err := token .IsMember (sid )
61- return err == nil && member
62-
63- case "linux" , "darwin" :
64- return os .Geteuid () == 0
65- }
66- return false
67- }
68-
6939func init () {
7040 if runtime .GOOS != "windows" &&
7141 runtime .GOOS != "darwin" &&
@@ -144,7 +114,7 @@ func init() {
144114 os .Stdout = nil
145115 }
146116
147- if isAdmin (bypassAdminCheck ) {
117+ if isAdmin . Check (bypassAdminCheck ) {
148118 utils .PrintError ("Spicetify should not be run with administrator/root privileges" )
149119 utils .PrintError ("Running as admin can cause Spotify to show a black/blank window after applying spicetify" )
150120 utils .PrintError ("This happens because Spotify (running as a normal user) can't access files modified with admin privileges" )
0 commit comments