Skip to content

Bug: quickstart generates invalid smartd.conf with missing -n parameter #43

@ntbowen

Description

@ntbowen

Bug: quickstart generates invalid smartd.conf with missing -n parameter

Description

The quickstart binary generates an invalid /etc/smartd.conf configuration file. The -n directive is missing its required POWERMODE argument, causing smartd to fail on startup.

Error Message

smartd 7.5 2025-04-30 r5714 [aarch64-linux-6.12.67] (localbuild)
File /etc/smartd.conf line 3 (drive DEFAULT): Missing argument to -n Directive
Valid arguments to -n Directive are: never[,N][,q], sleep[,N][,q], standby[,N][,q], idle[,N][,q]
Configuration file /etc/smartd.conf has fatal syntax errors.
smartd is exiting (exit status 2)

Generated Config (Invalid)

# Autogenerated, do not edit!
# smartd state false
DEFAULT -n

Expected Config

# Autogenerated, do not edit!
# smartd state false
DEFAULT -n standby

Root Cause

Found in binary via strings /usr/sbin/quickstart:

printf "DEFAULT -n %v
" >> %v

The Go format string %v should contain a POWERMODE value (never, sleep, standby, or idle), but the variable appears to be empty when the config is generated.

Environment

  • Platform: aarch64 (RK3576)
  • OpenWrt: ImmortalWrt SNAPSHOT r37561
  • quickstart version: 0.11.13

Suggested Fix

In the Go source code, ensure the POWERMODE variable has a default value (e.g., standby) when it's empty:

// Pseudocode
powerMode := config.PowerMode
if powerMode == "" {
    powerMode = "standby"  // Default value
}
fmt.Fprintf(file, "DEFAULT -n %v\n", powerMode)

Workaround

Create a uci-defaults script to fix the config after generation:

#!/bin/sh
if [ -f /etc/smartd.conf ] && grep -q "^DEFAULT -n$" /etc/smartd.conf; then
    sed -i 's/^DEFAULT -n$/DEFAULT -n standby/' /etc/smartd.conf
fi

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions