nixys / nxs-backup

The tool for creating, delivering and rotating backups for GNU/Linux distributions.
https://nxs-backup.io
Apache License 2.0
233 stars 13 forks source link

nil pointer dereference when misconfigured storage used #70

Closed Elchinchel closed 2 months ago

Elchinchel commented 2 months ago

nxs-backup 3.8.2

Given following /etc/nxs-backup/nxs-backup.conf:

server_name: PristineAbobus

notifications:
  mail:
    enabled: false
  webhooks: []

storage_connects:
  - name: pivo
    scp_params:
      user: backup
      host: 10.11.12.13
      port: 22
      password: my_ssh_password
      key_file: "not_existing_file"

jobs:
  - job_name: some-files
    type: desc_files

    sources:
      - name: desc_files
        targets: [ /etc/nxs-backup ]
        excludes: []

    storages_options:
      - storage_name: pivo
        backup_path: backups/
        retention:
          days: 7
          weeks: 5
          months: 5

logfile: stdout

Running nxs-backup start outputs:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xeb9d04]

goroutine 1 [running]:
github.com/nixys/nxs-backup/modules/storage/sftp.(*SFTP).Clone(0x0)
        .../nxs-backup/modules/storage/sftp/sftp.go:432 +0x24
github.com/nixys/nxs-backup/ctx.jobsInit({0xc00042a9b0, 0xc000050ee0, {0xc00017e870, 0x1, 0x1}, 0xc00067a810})
        .../nxs-backup/ctx/jobs_init.go:102 +0x952
github.com/nixys/nxs-backup/ctx.appInit(0xc00042a2d0, {0x1002293, 0x1f})
        .../nxs-backup/ctx/context.go:223 +0x694
github.com/nixys/nxs-backup/ctx.AppCtxInit()
        .../nxs-backup/ctx/context.go:110 +0x293
github.com/nixys/nxs-go-appctx/v3.(*AppCtx).Run(0xc00048de30)
        /root/go/pkg/mod/github.com/nixys/nxs-go-appctx/v3@v3.0.0/appctx.go:65 +0x36
main.main()
        .../nxs-backup/main.go:38 +0x4d6
randreev1321 commented 2 months ago

Hi, @Elchinchel.

Thanks for the suggested solution, the changes are merged and will be added in the upcoming release.

New ideas and suggestions are welcome.