diff --git a/internal/app/wwctl/overlay/chmod/chmod_test.go b/internal/app/wwctl/overlay/chmod/chmod_test.go new file mode 100644 index 00000000..717f7ebd --- /dev/null +++ b/internal/app/wwctl/overlay/chmod/chmod_test.go @@ -0,0 +1,21 @@ +package chmod + +import ( + "testing" +) + +// TestArgsOverlayChmod is a regression test for 260. +// Two arguments should fail, three should succeed. +func TestArgsOverlayChmod(t *testing.T) { + command := GetCommand() + + err := command.Args(command, []string{"overlay_name", "file_name"}) + if err == nil { + t.Errorf("two arguments to overlay chmod should fail") + } + + err = command.Args(command, []string{"overlay_name", "file_name", "0755"}) + if err != nil { + t.Errorf("three arguments to overlay chmod should succeed") + } +} diff --git a/internal/app/wwctl/overlay/chmod/main.go b/internal/app/wwctl/overlay/chmod/main.go index 0fb6e888..3cc140b8 100644 --- a/internal/app/wwctl/overlay/chmod/main.go +++ b/internal/app/wwctl/overlay/chmod/main.go @@ -17,7 +17,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error { overlayName := args[0] fileName := args[1] - permissionMode, err := strconv.ParseInt(args[3], 8, 32) + permissionMode, err := strconv.ParseUint(args[2], 8, 32) if err != nil { wwlog.Printf(wwlog.ERROR, "Could not convert requested mode: %s\n", err) os.Exit(1)