X-Loop: help-debbugs@HIDDEN Subject: bug#6323: Enhancement request: Add wronly to Coreutils Resent-From: Daniel Trebbien <dtrebbien@HIDDEN> Original-Sender: debbugs-submit-bounces <at> debbugs.gnu.org Resent-To: owner <at> debbugs.gnu.org Resent-CC: bug-coreutils@HIDDEN Resent-Date: Tue, 01 Jun 2010 12:07:02 +0000 Resent-Message-ID: <handler.6323.B.127539396225343 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: report 6323 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 6323 <at> debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@HIDDEN Received: via spool by submit <at> debbugs.gnu.org id=B.127539396225343 (code B ref -1); Tue, 01 Jun 2010 12:07:02 +0000 Received: (at submit) by debbugs.gnu.org; 1 Jun 2010 12:06:02 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1OJQEK-0006aX-TU for submit <at> debbugs.gnu.org; Tue, 01 Jun 2010 08:06:01 -0400 Received: from mail.gnu.org ([199.232.76.166] helo=mx10.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from <dtrebbien@HIDDEN>) id 1OJQ8B-0006Wm-Ua for submit <at> debbugs.gnu.org; Tue, 01 Jun 2010 07:59:40 -0400 Received: from lists.gnu.org ([199.232.76.165]:51506) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from <dtrebbien@HIDDEN>) id 1OJQ87-0003nb-0b for submit <at> debbugs.gnu.org; Tue, 01 Jun 2010 07:59:35 -0400 Received: from [140.186.70.92] (port=42021 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJQ85-00064X-Pf for bug-coreutils@HIDDEN; Tue, 01 Jun 2010 07:59:34 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID, T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from <dtrebbien@HIDDEN>) id 1OJQ84-0004Qa-Hc for bug-coreutils@HIDDEN; Tue, 01 Jun 2010 07:59:33 -0400 Received: from mail-yx0-f169.google.com ([209.85.213.169]:46618) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from <dtrebbien@HIDDEN>) id 1OJQ84-0004QO-FR for bug-coreutils@HIDDEN; Tue, 01 Jun 2010 07:59:32 -0400 Received: by yxs7 with SMTP id 7so601708yxs.0 for <bug-coreutils@HIDDEN>; Tue, 01 Jun 2010 04:59:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=ic9zHNtQiHqP6PucN7M16bc4DbmcRwZUCned+E2soGI=; b=pz+u6mgvo18/OpuWHZBoceb6l6Mm+DMYaspQZ2lAmZjaYcuY/E5uhpnXeZdT66ObqK fL18yPcuA4/RPqQH9MgIlI0uzXIibpowYmiztISRU+Fg/2raZFI2bZwb6imfJh1cbzTv veaywcwjLBv+/zW/3VQLE+8IF3xdbf+SMy92w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=HorOuqhfkiZNn7WvlMUEE+2MnVBLFwJQ+gcOR/f4JjDqWeGw6HoFB/7HHQx/t3HKSz Tx4we98dkAAevaEnvA7lBl02NWboZFyjV1JYQ0Zv+hixExvIdUDa3lYtsxlVCfOG03eW qDNtRV7gs2M0ReSSKShE5PE3VlETbWFlmuVk8= MIME-Version: 1.0 Received: by 10.90.42.24 with SMTP id p24mr2616577agp.159.1275393570877; Tue, 01 Jun 2010 04:59:30 -0700 (PDT) Received: by 10.90.96.13 with HTTP; Tue, 1 Jun 2010 04:59:30 -0700 (PDT) Date: Tue, 1 Jun 2010 07:59:30 -0400 Message-ID: <AANLkTikPE6RjYxEJxoAzrpiRE534dnQ8CIFqeYpC8B1F@HIDDEN> From: Daniel Trebbien <dtrebbien@HIDDEN> Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -3.5 (---) X-Mailman-Approved-At: Tue, 01 Jun 2010 08:05:58 -0400 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Sender: debbugs-submit-bounces <at> debbugs.gnu.org Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org X-Spam-Score: -4.7 (----) Over the past few days I have been working on a new Linux command-line utility which I'm calling `wronly` (https://launchpad.net/wronly). Basically what it does is copy its standard input to a file that is specified on the command line, but also closes its standard out and standard error if parsing of the command line options succeeds. It also supports a `--no-follow` option, the code for which I'm pretty proud of. I am aware of the similar `tee` program that is already part of GNU Coreutils, but I did not think that it would be wise for me to write a patch for `tee` that just causes `tee` to similarly close its standard error. I needed a program like `tee` that would close the standard error stream, so I figured that there might be uses if such a program were to close standard out as well. Of course, closing standard out in `tee` would fundamentally break the utility, but I'm also not sure if closing standard error in `tee` would cause problems for existing scripts that depend on it. Instead of my developing this project independently, a friend suggested that I ask on the GNU Coreutils mailing list whether there is interest in possibly adding `wronly` to the Coreutils project. Hence my question: is there a place for `wronly` in GNU Coreutils? If so, I would be more than happy to work with maintainers to integrate it into the Coreutils build process, standardize its source, and even attempt to write a Windows port. Writing a Windows port is not absolutely necessary, I know, but it's nice to be able to use all Coreutils utilities in a Windows environment. Let me know your thoughts, Daniel
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.427 (Entity 5.427) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Daniel Trebbien <dtrebbien@HIDDEN> Subject: bug#6323: Acknowledgement (Enhancement request: Add wronly to Coreutils) Message-ID: <handler.6323.B.127539396225343.ack <at> debbugs.gnu.org> References: <AANLkTikPE6RjYxEJxoAzrpiRE534dnQ8CIFqeYpC8B1F@HIDDEN> X-Gnu-PR-Message: ack 6323 X-Gnu-PR-Package: coreutils Reply-To: 6323 <at> debbugs.gnu.org Date: Tue, 01 Jun 2010 12:07:02 +0000 Thank you for filing a new bug report with GNU. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): bug-coreutils@HIDDEN If you wish to submit further information on this problem, please send it to 6323 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 6323: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D6323 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
X-Loop: help-debbugs@HIDDEN Subject: bug#6323: Enhancement request: Add wronly to Coreutils Resent-From: Eric Blake <eblake@HIDDEN> Original-Sender: debbugs-submit-bounces <at> debbugs.gnu.org Resent-To: owner <at> debbugs.gnu.org Resent-CC: bug-coreutils@HIDDEN Resent-Date: Tue, 01 Jun 2010 15:58:02 +0000 Resent-Message-ID: <handler.6323.B6323.12754078341577 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 6323 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Daniel Trebbien <dtrebbien@HIDDEN> Cc: 6323 <at> debbugs.gnu.org Received: via spool by 6323-submit <at> debbugs.gnu.org id=B6323.12754078341577 (code B ref 6323); Tue, 01 Jun 2010 15:58:02 +0000 Received: (at 6323) by debbugs.gnu.org; 1 Jun 2010 15:57:14 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1OJTq5-0000PO-I0 for submit <at> debbugs.gnu.org; Tue, 01 Jun 2010 11:57:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from <eblake@HIDDEN>) id 1OJTq3-0000PI-A7 for 6323 <at> debbugs.gnu.org; Tue, 01 Jun 2010 11:57:12 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o51Fv6t6011967 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 1 Jun 2010 11:57:06 -0400 Received: from [10.3.242.3] (vpn-242-3.phx2.redhat.com [10.3.242.3]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o51Fv5jm018371; Tue, 1 Jun 2010 11:57:06 -0400 Message-ID: <4C052DB6.4030703@HIDDEN> Date: Tue, 01 Jun 2010 09:56:38 -0600 From: Eric Blake <eblake@HIDDEN> Organization: Red Hat User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100430 Fedora/3.0.4-3.fc13 Lightning/1.0b2pre Mnenhy/0.8.2 Thunderbird/3.0.4 MIME-Version: 1.0 References: <AANLkTikPE6RjYxEJxoAzrpiRE534dnQ8CIFqeYpC8B1F@HIDDEN> In-Reply-To: <AANLkTikPE6RjYxEJxoAzrpiRE534dnQ8CIFqeYpC8B1F@HIDDEN> X-Enigmail-Version: 1.0.1 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigB04C6EDF03DD25CD5A1EC0F4" X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Spam-Score: -10.1 (----------) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Sender: debbugs-submit-bounces <at> debbugs.gnu.org Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org X-Spam-Score: -10.1 (----------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB04C6EDF03DD25CD5A1EC0F4 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 06/01/2010 05:59 AM, Daniel Trebbien wrote: > Over the past few days I have been working on a new Linux command-line > utility which I'm calling `wronly` (https://launchpad.net/wronly). > Basically what it does is copy its standard input to a file that is > specified on the command line, but also closes its standard out and > standard error if parsing of the command line options succeeds. It > also supports a `--no-follow` option, the code for which I'm pretty > proud of. Would you mind showing actual command line examples of how you envision using this? >=20 > I am aware of the similar `tee` program that is already part of GNU > Coreutils, but I did not think that it would be wise for me to write a > patch for `tee` that just causes `tee` to similarly close its standard > error. I needed a program like `tee` that would close the standard > error stream, so I figured that there might be uses if such a program > were to close standard out as well. Of course, closing standard out in > `tee` would fundamentally break the utility, but I'm also not sure if > closing standard error in `tee` would cause problems for existing > scripts that depend on it. Actually, there's nothing wrong with patching tee to add another command line option, if it really does make sense to add this functionality. But right now, without a demonstration of why this is needed, and why: cmd | tee file >&- 2>&- does not already do what you want, it's hard to make any decisions. > so, I would be more than happy to work with maintainers to integrate > it into the Coreutils build process, standardize its source, and even > attempt to write a Windows port. Actually, the mere act of getting a patch into coreutils is sufficient for writing a windows port, since the cygwin project is pretty reliable at porting coreutils to windows. --=20 Eric Blake eblake@HIDDEN +1-801-349-2682 Libvirt virtualization library http://libvirt.org --------------enigB04C6EDF03DD25CD5A1EC0F4 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJMBS22AAoJEKeha0olJ0NqRfwIAIZKu/CraAFaGZB5726QZUdc 0Vxy6Jq/5kBW0zYOuLDCwD7MF7H+YvDCluNfugk+Qz9BkXViIunWRvVHrgIpznJK 2ymyJmCrR8ZtDWHjmymruyVykncbIkeq5rpNzJR+0WNhtXzbLYVi79M5yR4vrl1w zuF4enUTSojD4Lp6xcAPh3rh/K7ZxGnEF5PCmcrm4pSuMHgw0+DyhF4AteE6Rd8h ta1HLrY3m+9bfCeSkI4rfkqY2sg/SQyEKiJxLh9ZOcifE480k7AwIv4ztc4+o718 fXbXWptIiVPS2F82eZpX+JOkFcnNDgwTIskWxDSBeY2WjomJOdYUvZ+qg2xlOFA= =HbTe -----END PGP SIGNATURE----- --------------enigB04C6EDF03DD25CD5A1EC0F4--
X-Loop: help-debbugs@HIDDEN Subject: bug#6323: Enhancement request: Add wronly to Coreutils Resent-From: Daniel Trebbien <dtrebbien@HIDDEN> Original-Sender: debbugs-submit-bounces <at> debbugs.gnu.org Resent-To: owner <at> debbugs.gnu.org Resent-CC: bug-coreutils@HIDDEN Resent-Date: Tue, 01 Jun 2010 23:57:02 +0000 Resent-Message-ID: <handler.6323.B6323.127543657216599 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 6323 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Eric Blake <eblake@HIDDEN> Cc: 6323 <at> debbugs.gnu.org Received: via spool by 6323-submit <at> debbugs.gnu.org id=B6323.127543657216599 (code B ref 6323); Tue, 01 Jun 2010 23:57:02 +0000 Received: (at 6323) by debbugs.gnu.org; 1 Jun 2010 23:56:12 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1OJbJb-0004Jg-BB for submit <at> debbugs.gnu.org; Tue, 01 Jun 2010 19:56:11 -0400 Received: from mail-gw0-f44.google.com ([74.125.83.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from <dtrebbien@HIDDEN>) id 1OJbCT-0004GP-3n for 6323 <at> debbugs.gnu.org; Tue, 01 Jun 2010 19:48:49 -0400 Received: by gwj19 with SMTP id 19so3937932gwj.3 for <6323 <at> debbugs.gnu.org>; Tue, 01 Jun 2010 16:48:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=evb4BDxtlgX2A/CsWoPqqQK3FVqBL+hrnclkxeTpa98=; b=DYcENcwDDxXZiddSUftGdU3S5HmyFm/yJKicO9MVYoxAMpbyu9DSc3T4l3v7Zt8dKy 8qbhT1vSH9lgz9TyzZ3DwloOeDtX80dllcc5z7s0ErpqLy2btx6u+ykjI2ErilXWY0jH Lq+SuGTtXgR0Av9Yn3tOeq5dTVQJ/SOdIVVis= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=kgi+YWCKIQUcp5biiEyJdac00Mv7nq2L3Sa3/5CUezPdkpSuBN/Q4autF/5hmmGck2 OV5R12/Zr0CF/3J9SXmS6VC2Jnoud7wZIqg9mA+B8+oo0H8g92A1OgMQq6o7rhGHpMcT VGPD7EsplXMevZ3tMDMFlghBZeK4TN8BINpVM= MIME-Version: 1.0 Received: by 10.91.48.1 with SMTP id a1mr3346206agk.9.1275436124867; Tue, 01 Jun 2010 16:48:44 -0700 (PDT) Received: by 10.90.96.13 with HTTP; Tue, 1 Jun 2010 16:48:44 -0700 (PDT) In-Reply-To: <4C052DB6.4030703@HIDDEN> References: <AANLkTikPE6RjYxEJxoAzrpiRE534dnQ8CIFqeYpC8B1F@HIDDEN> <4C052DB6.4030703@HIDDEN> Date: Tue, 1 Jun 2010 19:48:44 -0400 Message-ID: <AANLkTikMTygx6Lhj8lBn1Xv83um0JC4q60iJBVcBp7U_@HIDDEN> From: Daniel Trebbien <dtrebbien@HIDDEN> Content-Type: multipart/mixed; boundary=001485f7d82c280ca70488009d5f X-Spam-Score: 0.0 (/) X-Mailman-Approved-At: Tue, 01 Jun 2010 19:56:10 -0400 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Sender: debbugs-submit-bounces <at> debbugs.gnu.org Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org X-Spam-Score: -1.3 (-) --001485f7d82c280ca70488009d5f Content-Type: text/plain; charset=UTF-8 On 2010-06-01, Eric Blake <eblake@HIDDEN> wrote: > On 06/01/2010 05:59 AM, Daniel Trebbien wrote: >> Over the past few days I have been working on a new Linux command-line >> utility which I'm calling `wronly` (https://launchpad.net/wronly). >> Basically what it does is copy its standard input to a file that is >> specified on the command line, but also closes its standard out and >> standard error if parsing of the command line options succeeds. It >> also supports a `--no-follow` option, the code for which I'm pretty >> proud of. > > Would you mind showing actual command line examples of how you envision > using this? I don't intend to use `wronly` from the command line, but rather in a C program that basically execs `sudo wronly FILE` *in the background*. I can already exec `sudo`, of course, but because it uses `/dev/tty` by default, it kind of takes over. `sudo` with the `-S` option causes it to write the password prompt (if it requires a password at that time) to standard error and read the password from standard in. The problem is: how do I know if `sudo` requires a password? I need to try to read the password prompt from standard error, but if the password is not required, then the parent process will wait for data on standard error while the child process (`wronly` by this time) waits for data on standard in. My first thought was to create a `tee_wrapper` program that closes its standard error, creates a pipe for a "dummy" standard error stream, execs `tee` with the write end of this dummy pipe and duplicate descriptors of standard in and out, and reads from the dummy pipe into a trash buffer continually until the `tee` child process exits (to prevent deadlock if `tee` manages to write enough data to the pipe that it reaches the end of the OS buffer and blocks). All of this seemed silly. I could ask the `sudo` maintainers for a new option to make *it* close its standard error, but then they would be adding in the same steps that I outlined for the `tee_wrapper` program. Therefore, I thought about submitting a patch for `tee`. Looking into the code for `tee`, I then thought that it would be better if I just wrote a slightly different variant of the utility for the reason that I outlined in paragraph two of my first email. Also, the variant could support additional options such as `--no-follow`, `--no-atime`, `--no-create`, and `--executable` which would require substantial changes to `tee` in order to implement these features the "right way". (By this, I mean that different combinations of `--no-follow`, `--no-atime`, `--no-create`, and `--executable` could be used with all of the files that are specified on the command line.) Please see the attached C file for a proof-of-concept of exec'ing sudo "in the background". I wrote it rather quickly, so don't make fun of it too much :) You can test it with: sudo rm TEST.txt sudo -k ./exec_sudo_wronly sudo rm TEST.txt ./exec_sudo_wronly >> >> I am aware of the similar `tee` program that is already part of GNU >> Coreutils, but I did not think that it would be wise for me to write a >> patch for `tee` that just causes `tee` to similarly close its standard >> error. I needed a program like `tee` that would close the standard >> error stream, so I figured that there might be uses if such a program >> were to close standard out as well. Of course, closing standard out in >> `tee` would fundamentally break the utility, but I'm also not sure if >> closing standard error in `tee` would cause problems for existing >> scripts that depend on it. > > Actually, there's nothing wrong with patching tee to add another command > line option, if it really does make sense to add this functionality. > But right now, without a demonstration of why this is needed, and why: > > cmd | tee file >&- 2>&- > > does not already do what you want, it's hard to make any decisions. > Looking back at what I thought versus what I think now, I realize that the `tee_wrapper` program can be made a lot less "silly" if instead of creating a pipe for `tee`'s standard error, `tee_wrapper` opened a writable handle to `/dev/null`. Even then, though, `tee_wrapper` could not add support for `--no-follow`, `--no-atime`, `--no-create`, and `--executable`. I am not sure what is preferred for bringing support for `--no-follow`, `--no-atime`, `--no-create`, and `--executable` to a `tee`-like program in Coreutils: adding a separate utility such as `wronly` or trying to update `tee`. Either way, I am happy to help. --001485f7d82c280ca70488009d5f Content-Type: application/octet-stream; name="exec_sudo_wronly.c" Content-Disposition: attachment; filename="exec_sudo_wronly.c" Content-Transfer-Encoding: base64 X-Attachment-Id: file1 I2luY2x1ZGUgPGFzc2VydC5oPgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHN0ZGxpYi5o PgojaW5jbHVkZSA8c3RyaW5nLmg+CiNpbmNsdWRlIDx1bmlzdGQuaD4KCnN0YXRpYyB2b2lkIGNs b3NlX3BpcGUoaW50IHBpcGVmZHNbMl0pCnsKCWNsb3NlKHBpcGVmZHNbMV0pOwoJY2xvc2UocGlw ZWZkc1swXSk7Cn0KCmludCBtYWluKGludCBhcmdjLCBjaGFyICoqYXJndikKewoJLy8gc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NoYXIgKnBhc3MgPSBnZXRwYXNzKHByb21wdCk7CgkJCWZwdXRzKHBhc3MsIGNoaWxkX3N0ZGlu KTsKCQkJZnB1dGMoJ1xuJywgY2hpbGRfc3RkaW4pOwoJCX0KCQkKCQlmcHV0YygnYScsIGNoaWxk X3N0ZGluKTsKCQlmcHV0YygnYicsIGNoaWxkX3N0ZGluKTsKCQlmcHV0YygnYycsIGNoaWxkX3N0 ZGluKTsKCQlmY2xvc2UoY2hpbGRfc3RkaW4pOwoJCQoJCWludCBzdGF0OwoJCXdhaXRwaWQoY2hp bGRfcGlkLCAmc3RhdCwgMCk7Cgl9CgkKCXJldHVybiBFWElUX1NVQ0NFU1M7Cn0KCg== --001485f7d82c280ca70488009d5f--
X-Loop: help-debbugs@HIDDEN Subject: bug#6323: Enhancement request: Add wronly to Coreutils Resent-From: Bob Proulx <bob@HIDDEN> Original-Sender: debbugs-submit-bounces <at> debbugs.gnu.org Resent-To: owner <at> debbugs.gnu.org Resent-CC: bug-coreutils@HIDDEN Resent-Date: Wed, 02 Jun 2010 16:06:02 +0000 Resent-Message-ID: <handler.6323.B6323.127549476115314 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 6323 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Daniel Trebbien <dtrebbien@HIDDEN> Cc: 6323 <at> debbugs.gnu.org Received: via spool by 6323-submit <at> debbugs.gnu.org id=B6323.127549476115314 (code B ref 6323); Wed, 02 Jun 2010 16:06:02 +0000 Received: (at 6323) by debbugs.gnu.org; 2 Jun 2010 16:06:01 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1OJqS9-0003yv-MG for submit <at> debbugs.gnu.org; Wed, 02 Jun 2010 12:06:01 -0400 Received: from joseki.proulx.com ([216.17.153.58]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from <bob@HIDDEN>) id 1OJqS7-0003yq-Tb for 6323 <at> debbugs.gnu.org; Wed, 02 Jun 2010 12:06:00 -0400 Received: from dementia.proulx.com (dementia.proulx.com [192.168.230.115]) by joseki.proulx.com (Postfix) with ESMTP id 7374921378; Wed, 2 Jun 2010 10:05:54 -0600 (MDT) Received: by dementia.proulx.com (Postfix, from userid 1000) id 6B4023CC399; Wed, 2 Jun 2010 10:05:54 -0600 (MDT) Date: Wed, 2 Jun 2010 10:05:54 -0600 From: Bob Proulx <bob@HIDDEN> Message-ID: <20100602160554.GA14757@HIDDEN> References: <AANLkTikPE6RjYxEJxoAzrpiRE534dnQ8CIFqeYpC8B1F@HIDDEN> <4C052DB6.4030703@HIDDEN> <AANLkTikMTygx6Lhj8lBn1Xv83um0JC4q60iJBVcBp7U_@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <AANLkTikMTygx6Lhj8lBn1Xv83um0JC4q60iJBVcBp7U_@HIDDEN> User-Agent: Mutt/1.5.18 (2008-05-17) X-Spam-Score: -2.4 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Sender: debbugs-submit-bounces <at> debbugs.gnu.org Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org X-Spam-Score: -2.4 (--) Daniel Trebbien wrote: > `sudo` with the `-S` option causes it to write the password prompt (if > it requires a password at that time) to standard error and read the > password from standard in. The problem is: how do I know if `sudo` > requires a password? I need to try to read the password prompt from > standard error, but if the password is not required, then the parent > process will wait for data on standard error while the child process > (`wronly` by this time) waits for data on standard in. There is always the sudo -k option. If the user isn't configured with NOPASSWD then sudo -k ignores the timestamp file and will always ask for a password. That would make it more consistent. Newish sudo commands include a -A option along with a SUDO_ASKPASS variable. It will invoke a helper program to read the password. I would probably go that route myself. Bob
X-Loop: help-debbugs@HIDDEN Subject: bug#6323: Enhancement request: Add wronly to Coreutils Resent-From: Daniel Trebbien <dtrebbien@HIDDEN> Original-Sender: debbugs-submit-bounces <at> debbugs.gnu.org Resent-To: owner <at> debbugs.gnu.org Resent-CC: bug-coreutils@HIDDEN Resent-Date: Wed, 02 Jun 2010 17:06:03 +0000 Resent-Message-ID: <handler.6323.B6323.127549834217050 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 6323 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Bob Proulx <bob@HIDDEN> Cc: 6323 <at> debbugs.gnu.org Received: via spool by 6323-submit <at> debbugs.gnu.org id=B6323.127549834217050 (code B ref 6323); Wed, 02 Jun 2010 17:06:03 +0000 Received: (at 6323) by debbugs.gnu.org; 2 Jun 2010 17:05:42 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1OJrNt-0004Qw-Nj for submit <at> debbugs.gnu.org; Wed, 02 Jun 2010 13:05:42 -0400 Received: from mail-gw0-f44.google.com ([74.125.83.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from <dtrebbien@HIDDEN>) id 1OJrNs-0004Qq-Np for 6323 <at> debbugs.gnu.org; Wed, 02 Jun 2010 13:05:41 -0400 Received: by gwj19 with SMTP id 19so4560129gwj.3 for <6323 <at> debbugs.gnu.org>; Wed, 02 Jun 2010 10:05:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=/YZKRzQhWQd1dit89xkGrM2YdvoJ0kfHmuh9SYLEYgY=; b=MDiAjpfFD5XZWgPn+WwZYbUg6O3lyEBxaL3X/BrM25Kf/wD742DOuRQwoDJ9r+gOJW AdoQqQSov7f8ahQpcUh89m7XGraYyTCeZK0iAsPvpdcJoOvj/Zcqn7l4REwIsxPsGbA0 PMexH//2Nyo00cJcJcB0ZUfDvxbh8C43POQWY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=Ln1GiEB+9KJwF1BM11tJDjskqHEPh9BMU+95E8+K/VyK6d99VH/khePVysmxprnAMb 65CDyn/S/dbayIkkwyiwQRgBbIcHpgtjbquA0yVqMnlw7Fhe3P9JfwpcL3SvNFUqhbK+ xVtaJ8nvuYIuT8PGtqXglMODWWxWdbW69YJUo= MIME-Version: 1.0 Received: by 10.90.18.20 with SMTP id 20mr3410238agr.125.1275497991697; Wed, 02 Jun 2010 09:59:51 -0700 (PDT) Received: by 10.90.96.13 with HTTP; Wed, 2 Jun 2010 09:59:51 -0700 (PDT) In-Reply-To: <20100602160554.GA14757@HIDDEN> References: <AANLkTikPE6RjYxEJxoAzrpiRE534dnQ8CIFqeYpC8B1F@HIDDEN> <4C052DB6.4030703@HIDDEN> <AANLkTikMTygx6Lhj8lBn1Xv83um0JC4q60iJBVcBp7U_@HIDDEN> <20100602160554.GA14757@HIDDEN> Date: Wed, 2 Jun 2010 12:59:51 -0400 Message-ID: <AANLkTimxgqosBld98WeZUd5XMmORjPiJaw5wFNCZEozB@HIDDEN> From: Daniel Trebbien <dtrebbien@HIDDEN> Content-Type: text/plain; charset=UTF-8 X-Spam-Score: -1.2 (-) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Sender: debbugs-submit-bounces <at> debbugs.gnu.org Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org X-Spam-Score: -1.9 (-) On 2010-06-02, Bob Proulx <bob@HIDDEN> wrote: > Daniel Trebbien wrote: >> `sudo` with the `-S` option causes it to write the password prompt (if >> it requires a password at that time) to standard error and read the >> password from standard in. The problem is: how do I know if `sudo` >> requires a password? I need to try to read the password prompt from >> standard error, but if the password is not required, then the parent >> process will wait for data on standard error while the child process >> (`wronly` by this time) waits for data on standard in. > > There is always the sudo -k option. If the user isn't configured with > NOPASSWD then sudo -k ignores the timestamp file and will always ask > for a password. That would make it more consistent. > > Newish sudo commands include a -A option along with a SUDO_ASKPASS > variable. It will invoke a helper program to read the password. I > would probably go that route myself. > > Bob > I had considered these options, but I cannot assume that sudo is *not* configured with NOPASSWD, and I can't use an external program to get the password. Also, I didn't want to store the user's password in the program's memory (outside of the stack and OS buffers), and the timeout might expire in between "refreshing" (`sudo -v`) and running the write command with `sudo`. I am working on enhancement 26000 to `nano` that would allow it to write through as root (http://savannah.gnu.org/bugs/?26000).
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.