Skip to content

cifs_mount: add USE_NETBIOS option; when skipping nmblookup, determine ip via nslookup#125

Open
ShoelaceMan wants to merge 1 commit intoMiSTer-devel:masterfrom
ShoelaceMan:master
Open

cifs_mount: add USE_NETBIOS option; when skipping nmblookup, determine ip via nslookup#125
ShoelaceMan wants to merge 1 commit intoMiSTer-devel:masterfrom
ShoelaceMan:master

Conversation

@ShoelaceMan
Copy link

This change adds USE_NETBIOS to control NetBIOS lookups for non-IP SERVER values. When NetBIOS is skipped, the script now resolves an address with nslookup and assigns that address back to SERVER, mirroring the existing nmblookup path. All existing iptables handling and mount paths remain unchanged.

Why
Running nmblookup unconditionally is unreliable with DNS hostnames and FQDNs. Some environments prefer DNS and do not use NetBIOS. Providing a switch and a DNS path improves reliability while keeping the rest of the script intact by continuing to rewrite SERVER to the resolved address.

What changed

  • New option USE_NETBIOS declared alongside the other user options:

    • auto (default): use NetBIOS only when SERVER looks like a NetBIOS name (no dot and length <= 15). Otherwise skip NetBIOS.
    • never: do not use NetBIOS.
    • always: preserve legacy behavior for non-IP values.
  • In the non-IP branch:

    • If NetBIOS is enabled, behavior is unchanged: wait with nmblookup when requested, then set SERVER from nmblookup.
    • If NetBIOS is disabled, reuse the existing ping wait, then set SERVER from nslookup by extracting the last IPv4 “Address:” line. This keeps the downstream code paths identical since SERVER ends up as an address in both cases.

Configuration
Users can override in cifs_mount.ini:

# optional, default is auto
USE_NETBIOS="auto"   # or "never" or "always"

Compatibility

  • Default auto keeps short NetBIOS names working as before.
  • Hostnames and FQDNs follow a simple DNS path without touching the iptables logic.
  • Setting USE_NETBIOS="always" restores prior behavior completely.

Testing

  • SERVER="RETRONAS" (short, no dot): NetBIOS wait runs, SERVER is set from nmblookup, mount proceeds as before.
  • SERVER="retronas.example.local" with default auto or never: ping wait runs, SERVER is set from nslookup to an IPv4 address, mount succeeds.
  • SERVER="192.168.0.50" (IP): unchanged.

Notes

  • The nslookup parse uses awk to select the last IPv4 “Address:” line and assigns it to SERVER, matching the existing pattern used with nmblookup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant