From patchwork Mon Jan 4 18:04:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 1422212 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=sourceware.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=sMXRZqWX; dkim-atps=neutral Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D8k8B55jWz9sVb for ; Tue, 5 Jan 2021 05:06:02 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0D60138708E7; Mon, 4 Jan 2021 18:05:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0D60138708E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1609783558; bh=5rKDud63D/LlAcCaYHwUDZhnvMnVq2qTO5WjsGNouGA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=sMXRZqWXpF+PHYC08GKw6FnIEMxEzUfwWVQVU64pCuG7MiRoxLnnOduIVd8O94ysp 645ZZ5uOJiuyXQuO6OwDFh5Y3tNGxrLn+TPeDStZJB6/Y7fB73kAzYhDObfFUEZ34j XM0SoXS1swN9W+mCZuIU6q1HUfn0ByKzrmPMUoRs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id 6C62138708DD for ; Mon, 4 Jan 2021 18:05:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6C62138708DD Received: by mail-wm1-x32f.google.com with SMTP id y23so110621wmi.1 for ; Mon, 04 Jan 2021 10:05:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5rKDud63D/LlAcCaYHwUDZhnvMnVq2qTO5WjsGNouGA=; b=eBuAqhUKrqL08G/0ohi3vOgciol6dtcXauRToPglQO765lV3dV5ld2C3VMKwFbSth0 dzsJcWjNJR0aC+1+IzN3O2wi35WHJO5iGM8CI6iWDvbn/CeAM99O2pXphdd1n0aiGvtP TbVc5p4O5ps9YMj+gyQ8hHOvJ8q543O96VjPqA/r6B/0tc8x+8HU5GU58u3OiaPPj+wd Lpsg8GEVMj3yxv9sRgcYmYDLnh12/Cs1UP4hI6G8H3OEXWwT/cLATvp4k6kzQICHTyYf 6QLpaKqdK3rXmCy7v/yp/uwTMOKZADVhL1Er1S0Kds8+o4rX+NZpEGO0dlic5lxgNW++ oCyw== X-Gm-Message-State: AOAM532MXmX6rO0S4Li9gX1BqMgKil3PV2J5K/PyKId7ysYzOEQZH6E0 BxZ89YWFwy8kHk9VxCf1kfw= X-Google-Smtp-Source: ABdhPJy6lzCLUcXloijpyrUVrlR4VkFV1tl4/z8dF9rNL9JtGzAk0CtmBH75H1qyleDCEe4ckUs18g== X-Received: by 2002:a1c:6506:: with SMTP id z6mr79058wmb.55.1609783554631; Mon, 04 Jan 2021 10:05:54 -0800 (PST) Received: from debian.vlc ([170.253.51.130]) by smtp.gmail.com with ESMTPSA id h29sm103578929wrc.68.2021.01.04.10.05.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jan 2021 10:05:54 -0800 (PST) To: mtk.manpages@gmail.com Subject: [PATCH] system.3: Document bug and workaround when the command name starts with a hypen Date: Mon, 4 Jan 2021 19:04:21 +0100 Message-Id: <20210104180420.74092-1-alx.manpages@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alejandro Colomar via Libc-alpha From: Alejandro Colomar Reply-To: Alejandro Colomar Cc: Alejandro Colomar , linux-man@vger.kernel.org, Ciprian Dorin Craciun , libc-alpha@sourceware.org, Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" man-pages bug: 211029 https://bugzilla.kernel.org/show_bug.cgi?id=211029 Reported-by: Ciprian Dorin Craciun Cc: Florian Weimer Signed-off-by: Alejandro Colomar --- man3/system.3 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/man3/system.3 b/man3/system.3 index aef40417a..0310d9a04 100644 --- a/man3/system.3 +++ b/man3/system.3 @@ -250,6 +250,40 @@ are not executed. Such risks are especially grave when using .BR system () from a privileged program. +.SH BUGS +./" [BUG 211029](https://bugzilla.kernel.org/show_bug.cgi?id=211029) +./" [Glibc bug](https://sourceware.org/bugzilla/show_bug.cgi?id=27143) +./" [POSIX bug](https://www.austingroupbugs.net/view.php?id=1440) +If the command name starts with a hyphen, +.BR sh (1) +interprets the command name as an option, +and the behavior is undefined +(See the +.B \-c +option in +.BR sh (1).). +To work around this problem, +prepend the command with a space as below: +.PP +.RS 4 +.EX +/* system_hyphen.c */ + +#include + +int +main(void) +{ + system(" -echo Hello world!"); + exit(EXIT_SUCCESS); +} +.PP +.RB "$" " sudo ln \-s \-T /usr/bin/echo /usr/bin/\-echo;" +.RB "$" " cc \-o system_hyphen system_hyphen.c;" +.RB "$" " ./system_hyphen;" +Hello world! +.EE +.RE .SH SEE ALSO .BR sh (1), .BR execve (2),