Open SoarinFerret opened 1 year ago
In the meantime, for anyone interested, the following patch file does allow scripts to run correctly on agent v2.5.0 in NixOS. This sends the scripts to /opt/tacticalrmm
(only accessible by the user running the agent, which is by default root)
diff --git a/agent/utils.go b/agent/utils.go
index 6eacaca..e731088 100644
--- a/agent/utils.go
+++ b/agent/utils.go
@@ -351,12 +351,17 @@ func getCwd() (string, error) {
func createNixTmpFile() (*os.File, error) {
var f *os.File
- cwd, err := getCwd()
- if err != nil {
- return f, err
+
+ dirPath := "/opt/tacticalrmm"
+
+ if _, err := os.Stat(dirPath); os.IsNotExist(err) {
+ err := os.MkdirAll(dirPath, 0750)
+ if err != nil {
+ return f, err
+ }
}
- f, err = os.CreateTemp(cwd, "trmm")
+ f, err := os.CreateTemp(dirPath, "trmm")
if err != nil {
return f, err
}
+1, that would also allow diskless linux machines to be used with read-only rootfs.
https://github.com/amidaware/rmmagent/blob/db17e3e28ec0351597c02c7049255f90c85c9e7a/agent/utils.go#L342:L365
NixOS is a Linux distribution built on top of the Nix package manager. Its declarative configuration allows reliable system upgrades via several official channels. One of the features it has is the location where all the binaries are stored are a read-only filesystem.
I am able to successfully build and use the rmmagent on NixOS, except my scripts fail to run due to them trying to run in the same directory where the executable is located. Would the maintainers be open to a pull request adding a runtime feature flag allowing the tmp directory to be changed to a specific location (like
--tmpdir /opt/trmm/scripts
)? This would not change the default functionality, and could be easily specified in the systemd unit file that my nix package creates.