Skip to content

Patches for inclusion in distributions #79

@kpcyrd

Description

@kpcyrd

hi!

I uploaded androidqf-1.8.1-1-x86_64.pkg.tar.zst to Arch Linux. :) I have the following patch to replace the adb binary in this git repository with /usr/bin/adb, and read the agent binaries from /usr/lib/androidqf/android-collector/collector_*:

diff --git a/acquisition/acquisition.go b/acquisition/acquisition.go
index 09e1d90..446b5a6 100644
--- a/acquisition/acquisition.go
+++ b/acquisition/acquisition.go
@@ -20,7 +20,6 @@ import (
 	rt "github.com/botherder/go-savetime/runtime"
 	"github.com/google/uuid"
 	"github.com/mvt-project/androidqf/adb"
-	"github.com/mvt-project/androidqf/assets"
 	"github.com/mvt-project/androidqf/log"
 	"github.com/mvt-project/androidqf/utils"
 )
@@ -177,7 +176,6 @@ func (a *Acquisition) Complete() {
 
 	// Stop ADB server before trying to remove extracted assets
 	adb.Client.KillServer()
-	assets.CleanAssets()
 }
 
 func (a *Acquisition) GetSystemInformation() error {
diff --git a/adb/adb_linux.go b/adb/adb_linux.go
index 8d2a9e7..1df2878 100644
--- a/adb/adb_linux.go
+++ b/adb/adb_linux.go
@@ -10,15 +10,9 @@ import (
 	"path/filepath"
 
 	saveRuntime "github.com/botherder/go-savetime/runtime"
-	"github.com/mvt-project/androidqf/assets"
 )
 
 func (a *ADB) findExe() error {
-	err := assets.DeployAssets()
-	if err != nil {
-		return err
-	}
-
 	adbPath, err := exec.LookPath("adb")
 	if err == nil {
 		a.ExePath = adbPath
diff --git a/adb/collector.go b/adb/collector.go
index 7baedd3..b39de6e 100644
--- a/adb/collector.go
+++ b/adb/collector.go
@@ -14,8 +14,6 @@ import (
 	"strings"
 
 	"github.com/mvt-project/androidqf/log"
-
-	"github.com/mvt-project/androidqf/assets"
 )
 
 type Collector struct {
@@ -112,7 +110,7 @@ func (c *Collector) Install() error {
 	}
 
 	log.Debugf("Deploying collector binary '%s' for architecture '%s'.", collectorName, c.Architecture)
-	collectorBinary, err := assets.Collector.ReadFile(collectorName)
+	collectorBinary, err := os.ReadFile(filepath.Join("/usr/lib/androidqf/android-collector", collectorName))
 	if err != nil {
 		// Somehow the file doesn't exist
 		return errors.New("couldn't find the collector binary")

Before starting the build I run rm -r assets/ to get rid of the pre-built binaries, so I needed to make sure no Go files from that directory are used.

I also noticed, when running /usr/bin/androidqf it tries to write it's results to /usr/bin/..., which fails unless you run it as root (but even then it's probably not what should be happening), so I applied this patch as well:

diff --git a/acquisition/acquisition.go b/acquisition/acquisition.go
index 446b5a6..8a8f041 100644
--- a/acquisition/acquisition.go
+++ b/acquisition/acquisition.go
@@ -17,7 +17,6 @@ import (
 	"time"
 
 	"github.com/botherder/go-savetime/hashes"
-	rt "github.com/botherder/go-savetime/runtime"
 	"github.com/google/uuid"
 	"github.com/mvt-project/androidqf/adb"
 	"github.com/mvt-project/androidqf/log"
@@ -51,7 +50,7 @@ func New(path string) (*Acquisition, error) {
 	}
 
 	if path == "" {
-		acq.StoragePath = filepath.Join(rt.GetExecutableDirectory(), acq.UUID)
+		acq.StoragePath = acq.UUID
 	} else {
 		acq.StoragePath = path
 	}

I'm posting this in an issue instead of a pull-request because those changes can't be applied as-is, as they would break the non-distribution use of the binary.

These patches are to be considered MVT-1.1 regardless of course.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions