Skip to content

Commit 694ca6b

Browse files
author
lichangze
committed
fix: 移除硬编码的公网 url
移除硬编码的公网 url Log: 移除硬编码的公网 url Bug: https://pms.uniontech.com/bug-view-321337.html Influence: 安全基线
1 parent f3a7fab commit 694ca6b

13 files changed

Lines changed: 16 additions & 139 deletions

File tree

src/internal/config/config.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,11 +499,7 @@ func getConfigFromDSettings() *Config {
499499
} else {
500500
url = v.Value().(string)
501501
}
502-
if len(url) == 0 {
503-
c.PlatformUrl = "https://update-platform.uniontech.com"
504-
} else {
505-
c.PlatformUrl = url
506-
}
502+
c.PlatformUrl = url
507503

508504
v, err = c.dsLastoreManager.Value(0, dSettingsKeyPlatformRepoComponents)
509505
if err != nil {

src/internal/config/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestConfig(t *testing.T) {
2626
require.NoError(t, err)
2727
defer tmpfile.Close()
2828

29-
data := []byte(`{"Version":"0.1","AutoCheckUpdates":true,"DisableUpdateMetadata":false,"AutoDownloadUpdates":false,"AutoClean":true,"MirrorSource":"default","UpdateNotify":true,"CheckInterval":604800000000000,"CleanInterval":604800000000000,"UpdateMode":3,"CleanIntervalCacheOverLimit":86400000000000,"AppstoreRegion":"","LastCheckTime":"2021-06-17T14:10:21.896021304+08:00","LastCleanTime":"2021-06-17T09:18:31.515019638+08:00","LastCheckCacheSizeTime":"2021-06-17T09:18:31.5151104+08:00","Repository":"desktop","MirrorsUrl":"http://packages.deepin.com/mirrors/community.json","AllowInstallRemovePkgExecPaths":null}`)
29+
data := []byte(`{"Version":"0.1","AutoCheckUpdates":true,"DisableUpdateMetadata":false,"AutoDownloadUpdates":false,"AutoClean":true,"MirrorSource":"default","UpdateNotify":true,"CheckInterval":604800000000000,"CleanInterval":604800000000000,"UpdateMode":3,"CleanIntervalCacheOverLimit":86400000000000,"AppstoreRegion":"","LastCheckTime":"2021-06-17T14:10:21.896021304+08:00","LastCleanTime":"2021-06-17T09:18:31.515019638+08:00","LastCheckCacheSizeTime":"2021-06-17T09:18:31.5151104+08:00","Repository":"desktop","MirrorsUrl":"","AllowInstallRemovePkgExecPaths":null}`)
3030
err = os.WriteFile(tmpfile.Name(), data, 0777)
3131
require.NoError(t, err)
3232

src/internal/dstore/dstore.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ func (s *Store) GetMetadataServer() string {
4343
if s.sysCfg != nil {
4444
metadataServer = s.sysCfg.Section("General").Key("Server").String()
4545
}
46-
if metadataServer == "" {
47-
metadataServer = "https://store.chinauos.com"
48-
}
4946
return metadataServer
5047
}
5148

src/internal/mirrors/mirrors.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import (
99
"fmt"
1010
"net/http"
1111
"os"
12+
"path"
1213
"path/filepath"
1314
"sort"
1415

16+
"github.com/linuxdeepin/lastore-daemon/src/internal/config"
1517
"github.com/linuxdeepin/lastore-daemon/src/internal/system"
1618
"github.com/linuxdeepin/lastore-daemon/src/internal/utils"
1719
)
@@ -92,6 +94,7 @@ func getUnpublishedMirrorSources(url string) ([]system.MirrorSource, error) {
9294

9395
// LoadMirrorSources return supported MirrorSource from remote server
9496
func LoadMirrorSources(url string) ([]system.MirrorSource, error) {
97+
config := config.NewConfig(path.Join("/var/lib/lastore", "config.json"))
9598
var mirrorsUrl string
9699
if url != "" {
97100
mirrorsUrl = url
@@ -100,14 +103,14 @@ func LoadMirrorSources(url string) ([]system.MirrorSource, error) {
100103
data, err := os.ReadFile(filepath.Join(system.VarLibDir, "config.json"))
101104
if err != nil {
102105
if os.IsNotExist(err) {
103-
mirrorsUrl = system.DefaultMirrorsUrl
106+
mirrorsUrl = config.MirrorsUrl
104107
} else {
105108
return nil, err
106109
}
107110
} else {
108111
cfg := struct {
109112
MirrorsUrl string
110-
}{system.DefaultMirrorsUrl}
113+
}{config.MirrorsUrl}
111114

112115
err = json.Unmarshal(data, &cfg)
113116
if err != nil {

src/internal/system/system.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
)
1212

1313
const VarLibDir = "/var/lib/lastore"
14-
const DefaultMirrorsUrl = "http://packages.deepin.com/mirrors/community.json"
1514

1615
type Status string
1716

src/internal/system/system_apt.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -358,16 +358,10 @@ func SystemArchitectures() ([]Architecture, error) {
358358
return r, nil
359359
}
360360

361-
var defaultRepoInfo = RepositoryInfo{
362-
Name: "desktop",
363-
Url: "http://packages.deepin.com/deepin",
364-
Mirror: "http://cdn.packages.deepin.com/deepin",
365-
}
366-
367361
func init() {
368362
err := DecodeJson(path.Join(VarLibDir, "repository_info.json"), &RepoInfos)
369363
if err != nil {
370-
RepoInfos = []RepositoryInfo{defaultRepoInfo}
364+
RepoInfos = []RepositoryInfo{}
371365
}
372366
_ = os.Setenv("DEBIAN_FRONTEND", "noninteractive")
373367
_ = os.Setenv("DEBIAN_PRIORITY", "critical")
@@ -378,7 +372,7 @@ func init() {
378372
func DetectDefaultRepoInfo(rInfos []RepositoryInfo) RepositoryInfo {
379373
f, err := os.Open("/etc/apt/sources.list")
380374
if err != nil {
381-
return defaultRepoInfo
375+
return RepositoryInfo{}
382376
}
383377
defer func() {
384378
_ = f.Close()
@@ -401,7 +395,7 @@ func DetectDefaultRepoInfo(rInfos []RepositoryInfo) RepositoryInfo {
401395
}
402396
}
403397
}
404-
return defaultRepoInfo
398+
return RepositoryInfo{}
405399
}
406400

407401
func guestBasePackageName(pkgId string) string {

src/internal/updateplatform/message_report.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ func NewUpdatePlatformManager(c *Config, updateToken bool) *UpdatePlatformManage
106106
platformUrl := c.PlatformUrl
107107
if len(platformUrl) == 0 {
108108
platformUrl = os.Getenv("UPDATE_PLATFORM_URL")
109-
if len(platformUrl) == 0 {
110-
platformUrl = "https://update-platform.uniontech.com"
111-
}
112109
}
113110

114111
if !utils.IsFileExist(CacheVersion) {

src/lastore-daemon/manager_unit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const (
6464

6565
type lastoreUnitMap map[UnitName][]string
6666

67-
// 定时任务和文件监听
67+
// 定时任务和文件监听map
6868
func (m *Manager) getLastoreSystemUnitMap() lastoreUnitMap {
6969
unitMap := make(lastoreUnitMap)
7070
if (m.config.GetLastoreDaemonStatus()&config.DisableUpdate) == 0 && !m.ImmutableAutoRecovery { // 更新禁用未开启且无忧还原未开启时

src/lastore-smartmirror-daemon/lastore_smartmirror_daemon_test.go

Lines changed: 0 additions & 109 deletions
This file was deleted.

src/lastore-tools/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func main() {
112112
cli.StringFlag{
113113
Name: "dstoreapi",
114114
Usage: "the dstore api server url. There has many jobs would use the to fetch data",
115-
Value: "http://api.appstore.deepin.org",
115+
Value: "",
116116
},
117117
}
118118
app.Commands = []cli.Command{CMDUpdater, CMDTester, CMDSmartMirror, CMDMetadata, CMDQueryDesktop, CMDCheckPolicy, CMDPostUpgrade}

0 commit comments

Comments
 (0)