File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2424 run : |
2525 git config --global user.name 'github-actions'
2626 git config --global user.email 'github-actions@github.com'
27- TAG="v0.0.9 -$(date +'%Y%m%d%H%M%S')"
27+ TAG="v0.0.10 -$(date +'%Y%m%d%H%M%S')"
2828 git tag $TAG
2929 git push origin $TAG
3030 echo "TAG=$TAG" >> $GITHUB_ENV
Original file line number Diff line number Diff line change 11package model
22
3- const SpeedTestVersion = "v0.0.9 "
3+ const SpeedTestVersion = "v0.0.10 "
44
55var EnableLoger = false
66var (
Original file line number Diff line number Diff line change 1+ //go:build !windows
2+ // +build !windows
3+
4+ package sp
5+
6+ import (
7+ "os"
8+ )
9+
10+ // hasRootPermission 检测是否有root权限
11+ func hasRootPermission () bool {
12+ return os .Getuid () == 0
13+ }
Original file line number Diff line number Diff line change 1+ //go:build windows
2+ // +build windows
3+
4+ package sp
5+
6+ import (
7+ "golang.org/x/sys/windows"
8+ )
9+
10+ func hasRootPermission () bool {
11+ sid , err := windows .CreateWellKnownSid (windows .WinBuiltinAdministratorsSid )
12+ if err != nil {
13+ return false
14+ }
15+ token := windows .Token (0 )
16+ member , err := token .IsMember (sid )
17+ if err != nil {
18+ return false
19+ }
20+ return member
21+ }
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ func isSudoAvailable() bool {
2222
2323// 如果sudo可用,则使用sudo执行命令
2424func execCommand (name string , arg ... string ) * exec.Cmd {
25- if isSudoAvailable () {
25+ if hasRootPermission () && isSudoAvailable () {
2626 return exec .Command ("sudo" , append ([]string {name }, arg ... )... )
2727 }
2828 return exec .Command (name , arg ... )
You can’t perform that action at this time.
0 commit comments