From patchwork Fri Jan 8 14:20:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 1423816 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=2620:52:3:1:0:246e:9693:128c; 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=oPk+R+w8; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4DC4yr3LPDz9sWh for ; Sat, 9 Jan 2021 01:21:08 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DC48B39730C4; Fri, 8 Jan 2021 14:21:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC48B39730C4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610115662; bh=1KIcH26IT0UxX2ouZ7Y5aBsyHaDwdyeFAmJyvWjpw04=; 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=oPk+R+w8gWCjQ8rfs5l9ywNWGUJBLaRWqz970lca3Q0x+kw4a4T96j1i3R+/hdA6d D7eACRCzVig4qrL0l2aLw32VspAcIlr2ZlSfrv6lIfvibgUIAXSxgm2570V5+OZ4+e W/p0uc5IDoWZdbxZvodwG2Ju2Y6QHvSvO+Im6Wbk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 05235397307B for ; Fri, 8 Jan 2021 14:21:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 05235397307B Received: by mail-wr1-x42a.google.com with SMTP id a12so9148750wrv.8 for ; Fri, 08 Jan 2021 06:21:00 -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=1KIcH26IT0UxX2ouZ7Y5aBsyHaDwdyeFAmJyvWjpw04=; b=g2WpRATNZj4f0U6s67VejJBnaSzDOz+YzkUiil3ed1tdsrSojoYp9RlAo/xib3THR5 0fmhQCGm3eSRNPb15ycQhTUtx1qEyu9W5IRMkc6O74+4jZMtJHEt0k9iS7xaRImp3l7P SShVwIpbr0BRvi1xlRcEVK+1/8eJut0DqPYEpmdjtp+9tlXL2+kW67LX7ItIKYeEKV38 tOcnkfCMu3xi8w1kY9PXHLS6Ih9+SJQoekJ8g8d7dpW7THnu7fnNxNbV9MCksTqlzPn8 IWBLMoRJptILBwvZUamOF/G36/me/T6mDubA8Rv+DZksIvkw2iyaaN5L9thsD3mAa45U 865g== X-Gm-Message-State: AOAM533mQPBU6HOj0zZhj+El67tIef9mD9JqgeOOPEue7Q8uBC+NUNe8 tGxH45046OMEpbSvDOKaJ9E= X-Google-Smtp-Source: ABdhPJzSa0p8UQ37nxdwWidu2v353KeSgvdap8nY9lo4dOVZusfaoM7TmoLxHgx8h3vEHxVGTbN4/A== X-Received: by 2002:a05:6000:c9:: with SMTP id q9mr3788114wrx.259.1610115659756; Fri, 08 Jan 2021 06:20:59 -0800 (PST) Received: from debian.vlc ([170.253.51.130]) by smtp.gmail.com with ESMTPSA id r13sm13881945wrs.6.2021.01.08.06.20.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 06:20:59 -0800 (PST) To: mtk.manpages@gmail.com Subject: [PATCH v3] system.3: Document bug and workaround when the command name starts with a hypen Date: Fri, 8 Jan 2021 15:20:52 +0100 Message-Id: <20210108142051.61875-1-alx.manpages@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210104180420.74092-1-alx.manpages@gmail.com> References: <20210104180420.74092-1-alx.manpages@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 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 Complete workaround (it was too long for the page, but it may be useful here): ...... $ sudo ln -s -T /usr/bin/echo /usr/bin/-echo; $ cc -o system_hyphen -x c - ; int main(void) { system(" -echo Hello world!"); exit(EXIT_SUCCESS); } $ ./system_hyphen; Hello world! Reported-by: Ciprian Dorin Craciun Cc: Florian Weimer Signed-off-by: Alejandro Colomar --- Hi Michael, I forgot to remove some escapings in the commit message in v2. I hope it arrives in time :) Cheers, Alex man3/system.3 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/man3/system.3 b/man3/system.3 index 753d46f7d..ead35ab30 100644 --- a/man3/system.3 +++ b/man3/system.3 @@ -255,6 +255,26 @@ 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 to +.BR sh (1).) +To work around this problem, +prepend the command with a space as in the following call: +.PP +.RS 4 +.EX + system(" \-unfortunate\-command\-name"); +.EE +.RE .SH SEE ALSO .BR sh (1), .BR execve (2),