mirror of
https://github.com/taigrr/systemctl.git
synced 2026-03-09 00:14:38 -07:00
fix(errors): prioritize permission errors over 'does not exist' warnings (#11)
filterErr checked 'does not exist' before 'Interactive authentication required', so when systemd printed both (common for mask/unmask on non-installed units as a non-root user), the wrong error was returned. Reorder checks so permission, bus, and masked errors take priority over existence warnings. Add tests covering mixed-stderr scenarios. Also: - CI: install and start nginx so user + root tests pass - CI: run tests as both user and root for full coverage - Bump Go 1.26 → 1.26.1
This commit is contained in:
@@ -61,6 +61,21 @@ func TestFilterErr(t *testing.T) {
|
||||
stderr: "Failed to do something unknown",
|
||||
want: ErrUnspecified,
|
||||
},
|
||||
{
|
||||
name: "does not exist with auth required prioritizes permission error",
|
||||
stderr: "Unit nginx.service does not exist, proceeding anyway.\nFailed to mask unit: Interactive authentication required.",
|
||||
want: ErrInsufficientPermissions,
|
||||
},
|
||||
{
|
||||
name: "does not exist with access denied prioritizes permission error",
|
||||
stderr: "Unit foo.service does not exist, proceeding anyway.\nAccess denied",
|
||||
want: ErrInsufficientPermissions,
|
||||
},
|
||||
{
|
||||
name: "does not exist with bus failure prioritizes bus error",
|
||||
stderr: "Unit foo.service does not exist, proceeding anyway.\n$DBUS_SESSION_BUS_ADDRESS not set",
|
||||
want: ErrBusFailure,
|
||||
},
|
||||
{
|
||||
name: "unrecognized warning",
|
||||
stderr: "Warning: something benign happened",
|
||||
|
||||
Reference in New Issue
Block a user