Skip to content

Defects in MAC handling, scanner process tracking, resolver, device actions and OUI import #399

Open

Description

@somethingwithproof

Found while reviewing develop for test coverage. These are separate from #351, #355, #356 and #359. All items are still present on develop at 5fa4c6d (2026-10-21).

Items 1 and 10 to 13 were reproduced by running develop against a test agent on Cacti 1.2.31 and 1.2.25, and item 15 has a regression test in #400. The rest were found by reading the code and still need confirming on a live install.

1. Unpadded MACs are dropped to an empty string (lib/mactrack_functions.php:2393)

Since #354, xform_mac_address() keeps a value only if it is exactly 12 hex digits once the : are removed. When net-snmp formats a MAC with its display hint, the value arrives unpadded, for example 0:c:29:1a:2b:3c. format_snmp_string('STRING: 0:c:29:1a:2b:3c') returns that value unchanged on 1.2.25 and on 1.2.31, and xform_mac_address() then returns ''. Padding each octet to two digits before the length check would keep these. Whether an install sees this form depends on whether net-snmp loads the MIBs. The display fix in #398 changed mactrack_format_mac() only, so this path is unchanged.

Separately, Cacti/cacti#8463 (still open) stops Hex-STRING: values decoding on core 1.2.x. MacTrack depends on that path for most MACs.

2. The poller spins a core while it waits for the resolver (poller_mactrack.php:871-890)

The while (!$exit_mactrack) loop that waits for the resolver has no sleep().

3. pcntl_signal_dispatch() is called without a guard (mactrack_resolver.php:189, poller_mactrack.php:619)

The signal handlers are installed only if (function_exists('pcntl_signal')), but the dispatch calls are unconditional. Without pcntl (Windows, and some CLI builds) both are undefined-function fatals.

4. Resolver settings that have no effect (mactrack_resolver.php)

  • -sid builds $sql_where (:158-163), which is never used, so the resolver always works across all sites.
  • mt_dns_timeout (:140) is read but never passed to Net_DNS2_Resolver.
  • The process timeout (:151) is $max_run_duration - 300, where $max_run_duration = timing*60 - 270. With a 5 minute collection timing that is -270 seconds.

5. A web rescan can race the poller's scan of the same device (lib/mactrack_functions.php:2635)

mac_track_processes is keyed on device_id and written with REPLACE. A rescan from the UI replaces the poller's row for that device, and whichever scanner finishes first deletes it, so the poller treats the device as done early.

6. Process bookkeeping (poller_mactrack.php)

  • clear_old_processes() (:442-483) signals the PID from the table without checking that it is still a MacTrack scanner.
  • Its DELETE ... WHERE process_id = ? with PID 0 removes every row that has no PID, not just the one it meant.
  • The concurrency budget (:677-680) counts the master's -1 marker row as a worker, so the poller runs one fewer scanner than mt_processes. Item 10 is the worst case.

7. Arpwatch correlation never matches when a MAC delimiter is set (poller_mactrack.php:566-578)

The keys are built with mt_mac_delim, but MACs have been stored without separators since 695e3cc.

8. OUI database import (lib/mactrack_functions.php:3012-3020)

  • When a proxy user is set, the proxy options are replaced by the auth header alone. The proxy is then not used, and the Proxy-Authorization header goes straight to the IEEE server.
  • The web import path holds the whole batch (about 38,000 rows) until the end instead of flushing as it goes.
  • The last vendor is dropped when the file has no trailing blank line.

9. Two behaviour changes from #342 are not in the CHANGELOG

  • The MacAuth report e-mail now honours its frequency setting (poller_mactrack.php:1085-1094). Installs that set a frequency long ago start receiving mail after upgrade.
  • Binary SNMP MACs now decode to real hex. Existing mac_track_ports, mac_track_aggregated_ports and mac_track_macauth rows stored in the old format stop matching new scans.

Both deserve a release note.

10. With mt_processes = 1 only the first device is scanned (poller_mactrack.php)

The poller counts its own -1 row as a running scanner (item 6), launches the first device, then waits until the time limit (601 s here) and logs "Mactrack timed out".

11. Enable and disable never update the device row (js/mactrack.js:74, :84)

The reply is written to #line_<id>, but mactrack_devices.php:1287 renders the rows as id="line<id>".

12. The disable log line prints 0 for the hostname (lib/mactrack_functions.php:3913)

The message formats the hostname with %d.

13. Device strings are altered before they are saved

o'brien is stored as obrien, zoë@corp is stored as hex text, and sysLocation loses its apostrophes.

14. The built-in Aruba 6300 and 6200 device types point at functions that don't exist (includes/database.php:513, :517, :1438, :1442)

They name get_oscx_switch_ports and get_oscx_arp_table, but lib/mactrack_aruba_oscx.php defines get_aruba_oscx_switch_ports and get_aruba_oscx_arp_table.

15. Interface rates and graph ids are stored in the wrong columns (lib/mactrack_functions.php, fix in #400)

build_InterfacesTable() and mactrack_find_host_graphs() build their INSERT values in a different order from the column list. In the Interfaces view the per-second error, discard and unknown-protocol columns show other counters, and mac_track_interface_graphs has snmp_query_id and graph_template_id swapped.

I'm adding tests for these paths as a separate series, starting with the formatters and CI packaging checks, so the fixes can land with regression tests.

Activity

  1. TheWitness commented on Oct 23, 2026

    @TheWitness
    Member

    I fixed the oid display a few days ago.

  2. TheWitness commented on Oct 23, 2026

    @TheWitness
    Member

    So broken. Nobody using arpwarch I guess. I never used it either.

  3. somethingwithproof commented on Oct 23, 2026

    @somethingwithproof
    MemberAuthor

    A few more from running develop against a test agent on 1.2.31 and 1.2.25. Items 10 to 13 were reproduced there; item 14 is from reading the code.

    10. With mt_processes = 1 only the first device is scanned (poller_mactrack.php)

    This is the worst case of the -1 marker row in item 6. The poller counts its own row as a running scanner, launches the first device, then waits until the time limit (601 s here) and logs "Mactrack timed out".

    11. Enable and disable never update the device row (js/mactrack.js:74, :84)

    The reply is written to #line_<id>, but the rows are rendered as id="line<id>".

    12. The disable log line prints 0 for the hostname

    The message formats the hostname with %d.

    13. Device strings are altered before they are saved

    o'brien is stored as obrien, zoë@corp is stored as hex text, and sysLocation loses its apostrophes.

    14. The built-in Aruba 6300 and 6200 device types point at functions that don't exist (includes/database.php:513, :517, :1438, :1442)

    They name get_oscx_switch_ports and get_oscx_arp_table, but lib/mactrack_aruba_oscx.php defines get_aruba_oscx_switch_ports and get_aruba_oscx_arp_table.

  4. changed the title [-]Defects in MAC formatting, resolver, process tracking and OUI import found during test review[/-] [+]Defects in MAC handling, scanner process tracking, resolver, device actions and OUI import[/+] on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions