From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 78FD55A004E for ; Thu, 08 Aug 2024 12:17:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723112225; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uX/mIHz5Q6m0I9bmq8CYosoalxMgB9H+xHGLU03SXDM=; b=HxsUvP/C7X+rqYiPfSC6exUrSdUn7WabrFKYjpLYdCEFPZp6kXJ13u/sJ0QdURgEGTigHV 8pNY0Db0Z///JyHwX7/BQZAYehamUpGZ6xc24YvZkWPr7zb6GXiF/vbFhL32H6tXDFl7P/ 0mwbYmukeKOE3fwpIRHlrx+LzYv1Lgc= Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-66-gOQQROqBPu-PQBYqzm6rNg-1; Thu, 08 Aug 2024 06:17:03 -0400 X-MC-Unique: gOQQROqBPu-PQBYqzm6rNg-1 Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-2cb4bcd9671so1094630a91.1 for ; Thu, 08 Aug 2024 03:17:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723112222; x=1723717022; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=uX/mIHz5Q6m0I9bmq8CYosoalxMgB9H+xHGLU03SXDM=; b=RNwT3k6CQ7Z7HuxPKhgXGmdUkWu4peIJb91nJa2lDABpwqwHEcKBgxANfBUpx9kekf SE2Orc6QvIABC+Z6lkf9X0j+JLNc7Rrg14UGTDBhDDNjzyEwgx38RGOQzFycR6w8u/WS Lva1Ai7j7A3TQ1OvFyO+rAVpLpF9t7Oq6h8SyWrWD4JCNzLQR2Miq1FFX7ATolIyVH5V aAXNOIvEk0hJJgh1wKv40IGOR4KvVPWkRjY5X/UuRNRdbLsOLTHx0kLIm4r4kAhjvXAv XUsJX7p+uOtqkc92WizaTkntJvo85YUzMWiBBtb1z6w/+m9HSYqggxuUI/FdaI3V061r LBWQ== X-Gm-Message-State: AOJu0Yygp8UQ3jq/GjfGnDg8PgzlPNGeLjIxkmQahTajcWWuv74JIHY5 hwnLsJ6aWUQHtlDIJoSM3t0UXxsndThAuul5opW35L+vJZVjy8OsJ161PmTT3SU4IgywByHAthb rY81dfI4xdFbwe3DBiJG2x1VSipl9kmx3acuELiBzmzq+gOMisw== X-Received: by 2002:a17:902:ec91:b0:1fc:719c:5f0 with SMTP id d9443c01a7336-200952bf10emr14747685ad.49.1723112222351; Thu, 08 Aug 2024 03:17:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGPd+pJy075bIEOV9GH5ek9L1ez/dEk3jqkM+VZgo/GCIKvRwaHz5SI6RNVCLCwnu9yL6ZqMQ== X-Received: by 2002:a17:902:ec91:b0:1fc:719c:5f0 with SMTP id d9443c01a7336-200952bf10emr14747485ad.49.1723112221866; Thu, 08 Aug 2024 03:17:01 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ff592b5413sm121047095ad.291.2024.08.08.03.17.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 03:17:01 -0700 (PDT) Date: Thu, 8 Aug 2024 12:16:58 +0200 From: Stefano Brivio To: Paul Holzinger Subject: Re: [PATCH v3] conf: Stop parsing options at first non-option argument Message-ID: <20240808121658.6574ef4c@elisabeth> In-Reply-To: References: <20240808040251.2568850-1-sbrivio@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: FG3JA54URYEGVYDOQ5IIPSLVP23AO2WL X-Message-ID-Hash: FG3JA54URYEGVYDOQ5IIPSLVP23AO2WL X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Thu, 8 Aug 2024 11:37:38 +0200 Paul Holzinger wrote: > On 08/08/2024 06:02, Stefano Brivio wrote: > > Given that pasta supports specifying a command to be executed on the > > command line, even without the usual -- separator as long as there's > > no ambiguity, we shouldn't eat up options that are not meant for us. > > > > Paul reports, for instance, that with: > > > > pasta --config-net ip -6 route > > > > -6 is taken by pasta to mean --ipv6-only, and we execute 'ip route'. > > That's because getopt_long(), by default, shuffles the argument list > > to shift non-option arguments at the end. > > > > Avoid that by adding '+' at the beginning of 'optstring'. > > > > Reported-by: Paul Holzinger > > Signed-off-by: Stefano Brivio > > --- > > v3: Use '+' in optstring and drop first non-option tracking > > > > v2: Instead of overriding 'name' in the getopt_long() loop, to force > > exiting the loop, adjust the exit condition > > > > conf.c | 4 ++-- > > util.c | 2 +- > > 2 files changed, 3 insertions(+), 3 deletions(-) > > > I like this change but I like to point out that this is a breaking > change for any user that sets options after the main argument, i.e. pid. Oh, right, that actually happens to work, even if we never really supported that, the man page has only this form: pasta [OPTION]... PID I could go back to v2, and, on top of that, if we find a single non-option argument that looks like a PID (a number), we would push it to the end of argv and continue parsing. If we find any other number, including one that's after all the other options but before the presumed PID we just pushed, we'll report error. We have anyway the following problem, which we won't make any worse (it can't be done without an actual file with POSIX shell, Bash only): $ 1() { echo a; } $ pasta 1; echo Couldn't open user namespace /proc/1/ns/user: Permission denied $ pasta echo; 1 a > I can tell you that this will not effect podman but I don't know what > other users exists out there... As far as I know, the only other tool using pasta(1) at the moment is rootless-containers (Docker, Usernetes): https://github.com/rootless-containers/rootlesskit/blob/master/pkg/network/pasta/pasta.go which is also fine. Other users are developers and people who try out network topologies and namespaces stuff without root, but I suppose adding the PID at the end is pretty natural anyway. On the other hand, if we can make sure we avoid this kind of breakage at a small cost, why not. I'll try. > I am not sure if it is worth the risk just to improve the UX for the > command use case but I guess you already decided it is otherwise you > would have not posted this patch. No, not really, I wasn't actually aware of the fact that adding the PID before options worked. Thanks for pointing that out. -- Stefano