Skip to content

Commit

Permalink
Support Raspbian
Browse files Browse the repository at this point in the history
  • Loading branch information
knqyf263 committed Feb 13, 2017
1 parent 0066048 commit bee25f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions scan/debian.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func newDebian(c config.ServerInfo) *debian {
return d
}

// Ubuntu, Debian
// Ubuntu, Debian, Raspbian
// https://github.com/serverspec/specinfra/blob/master/lib/specinfra/helper/detect_os/debian.rb
func detectDebian(c config.ServerInfo) (itsMe bool, deb osTypeInterface, err error) {
deb = newDebian(c)
Expand All @@ -60,6 +60,20 @@ func detectDebian(c config.ServerInfo) (itsMe bool, deb osTypeInterface, err err
return false, deb, nil
}

// Raspbian
// lsb_release in Raspbian Jessie returns 'Distributor ID: Raspbian'.
// However, lsb_release in Raspbian Wheezy returns 'Distributor ID: Debian'.
if r := exec(c, "cat /etc/issue", noSudo); r.isSuccess() {
// e.g.
// Raspbian GNU/Linux 7 \n \l
result := strings.Fields(r.Stdout)
if len(result) > 2 && result[0] == "Raspbian" {
distro := strings.ToLower(trim(result[0]))
deb.setDistro(distro, trim(result[2]))
return true, deb, nil
}
}

if r := exec(c, "lsb_release -ir", noSudo); r.isSuccess() {
// e.g.
// root@fa3ec524be43:/# lsb_release -ir
Expand Down Expand Up @@ -125,7 +139,7 @@ func (o *debian) checkIfSudoNoPasswd() error {

func (o *debian) checkDependencies() error {
switch o.Distro.Family {
case "ubuntu":
case "ubuntu", "raspbian":
return nil

case "debian":
Expand Down Expand Up @@ -534,7 +548,7 @@ func (o *debian) getChangelogCache(meta *cache.Meta, pack models.PackageInfo) st
func (o *debian) scanPackageCveIDs(pack models.PackageInfo) ([]string, error) {
cmd := ""
switch o.Distro.Family {
case "ubuntu":
case "ubuntu", "raspbian":
cmd = fmt.Sprintf(`apt-get changelog %s | grep '\(urgency\|CVE\)'`, pack.Name)
case "debian":
cmd = fmt.Sprintf(`env PAGER=cat aptitude changelog %s | grep '\(urgency\|CVE\)'`, pack.Name)
Expand Down
2 changes: 1 addition & 1 deletion scan/serverapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ func setupCangelogCache() error {
needToSetupCache := false
for _, s := range servers {
switch s.getDistro().Family {
case "ubuntu", "debian":
case "ubuntu", "debian", "raspbian":
needToSetupCache = true
break
}
Expand Down

0 comments on commit bee25f5

Please sign in to comment.