From fce76f44de14c0a38951b1a2b71185cd93ab6fba Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Sat, 20 Jun 2020 13:15:43 +1000 Subject: [PATCH] umoci config: disable flag argument re-ordering It turns out that urfave/cli hasn't been happy with parsing command-lines like [--config.cmd -c] for quite some time, and only just exposed the issue in a test-case[1]. There are loads of more subtle cases where you could see this happened even in the version of urfave/cli we have vendored. Until it's fixed upstream (which might not happen), we have to work around this by disabling argument reordering for 'umoci config' (which is the only command that usually has to deal with such flag arguments, and luckily doesn't take any positional arguments). [1]: https://github.com/urfave/cli/issues/1152 Signed-off-by: Aleksa Sarai --- CHANGELOG.md | 6 +++++- cmd/umoci/config.go | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba787f16f..c6908ac0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,8 +13,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ## +### Fixed ### - Suppress repeated xattr warnings on destination filesystems that do not - support xattrs. + support xattrs. opencontainers/umoci#311 +- Work around a long-standing issue in our command-line parsing library (see + urfave/cli#1152) by disabling argument re-ordering for `umoci config`, which + often takes `-`-prefixed flag arguments. opencontainers/umoci#328 ## [0.4.5] - 2019-12-04 ## ### Added ### diff --git a/cmd/umoci/config.go b/cmd/umoci/config.go index 71165eddb..e2f548976 100644 --- a/cmd/umoci/config.go +++ b/cmd/umoci/config.go @@ -59,6 +59,18 @@ image.`, return nil }, + // Do not re-order arguments. + // + // It turns out that urfave/cli incorrectly handles cases like + // [--config.cmd -c] during argument re-ordering for subcommands, causing + // us a fair number of issues when users are trying to pass a flag an + // argument that starts with a dash. Luckily 'umoci config' doesn't take + // positional arguments, so disabling argument re-ordering has no other + // real effect. + // + // See for more details. + SkipArgReorder: true, + Flags: []cli.Flag{ cli.StringFlag{Name: "config.user"}, cli.StringSliceFlag{Name: "config.exposedports"},