Your message dated Tue, 05 Jun 2007 08:47:03 +0000
with message-id <[EMAIL PROTECTED]>
and subject line Bug#357091: fixed in dash 0.5.3-8
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--- Begin Message ---
Package: dash
Version: 0.5.2-5

dash does not handle initially closed descriptors in any
way when redirecting, which leads to 'strange' anomalies and
can be the cause of somehwat puzzling script misbehaviour.

Two examples:

Script 1:
----------
exec >&-
exec 3>bork

printf "x\n" >&3

printf 55

----------

Executing this code with dash will lead to bork being
open on stdout after the printf redirection, so the contents
will be

x
55

and not just x.

Script 2:
---------
exec >&-

printf "x\n" >nork

printf 55

----------

Executing this code with dash will lead to nork being open
on stdout after the printf, same effect as above. Both of
this is out-of-spec wrt to SUS, cf

        Utilities other than the special built-ins (see Special
        Built-In Utilities) shall be invoked in a separate environment
        that consists of the following. The initial value of these
        objects shall be the same as that for the parent shell, except
        as noted below.

            * Open files inherited on invocation of the shell, open
              files controlled by the exec special built-in plus any
              modifications, and additions specified by any
              redirections to the utility
              

        [...]

        The environment of the shell process shall not be changed by
        the utility unless explicitly specified by the utility
        description (for example, cd and umask).
        
(<URL:http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_12>)

A patch that corrects this (for me):

diff -ru dash-0.5.2/src/redir.c dash-orig/src/redir.c
--- dash-0.5.2/src/redir.c      2003-09-27 05:45:00.000000000 +0200
+++ dash-orig/src/redir.c       2006-03-15 17:14:17.000000000 +0100
@@ -70,6 +70,7 @@
 #include "error.h"
 
 
+#define CLOSEFD -3             /* fd opened for redir needs to be closed */
 #define EMPTY -2               /* marks an unused slot in redirtab */
 #ifndef PIPE_BUF
 # define PIPESIZE 4096         /* amount of buffering in a pipe */
@@ -148,10 +149,15 @@
                        continue; /* redirect from/to same file descriptor */
 
                newfd = openredirect(n);
-               if (fd == newfd)
-                       continue;
                if (sv && *(p = &sv->renamed[fd]) == EMPTY) {
-                       int i = fcntl(fd, F_DUPFD, 10);
+                       int i;
+
+                       if (fd == newfd) {
+                               *p = CLOSEFD;
+                               continue;
+                       }
+                       
+                       i = fcntl(fd, F_DUPFD, 10);
                        if (i == -1) {
                                i = errno;
                                if (i != EBADF) {
@@ -159,7 +165,7 @@
                                        close(newfd);
                                        error("%d: %s", fd, m);
                                        /* NOTREACHED */
-                               }
+                               } else *p = CLOSEFD;
                        } else {
                                *p = i;
                                close(fd);
@@ -342,7 +348,8 @@
                if (rp->renamed[i] != EMPTY) {
                        if (!drop) {
                                close(i);
-                               copyfd(rp->renamed[i], i);
+                               if (rp->renamed[i] != CLOSEFD)
+                                       copyfd(rp->renamed[i], i);
                        }
                        close(rp->renamed[i]);
                }


--- End Message ---
--- Begin Message ---
Source: dash
Source-Version: 0.5.3-8

We believe that the bug you reported is fixed in the latest version of
dash, which is due to be installed in the Debian FTP archive:

ash_0.5.3-8_all.deb
  to pool/main/d/dash/ash_0.5.3-8_all.deb
dash_0.5.3-8.diff.gz
  to pool/main/d/dash/dash_0.5.3-8.diff.gz
dash_0.5.3-8.dsc
  to pool/main/d/dash/dash_0.5.3-8.dsc



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [EMAIL PROTECTED],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Gerrit Pape <[EMAIL PROTECTED]> (supplier of updated dash package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [EMAIL PROTECTED])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.7
Date: Mon, 04 Jun 2007 18:46:04 +0000
Source: dash
Binary: dash-udeb ash dash
Architecture: all source
Version: 0.5.3-8
Distribution: unstable
Urgency: low
Maintainer: Gerrit Pape <[EMAIL PROTECTED]>
Changed-By: Gerrit Pape <[EMAIL PROTECTED]>
Description: 
 ash        - Compatibility package for the Debian Almquist Shell
 dash       - The Debian Almquist Shell
 dash-udeb  - The Debian Almquist Shell for boot floppies (udeb)
Closes: 357091 415119 418174
Changes: 
 dash (0.5.3-8) unstable; urgency=low
 .
   * debian/diff/0009..0017-*.diff: new; from upstream master branch.
     * 0009-BUILTIN-Fix-mkbuiltin-sort-order.diff: Fix mkbuiltin sort
       order (closes: #415119).
     * 0016-REDIR-Fix-redirect-restore-on-saved-file-descriptor.diff:
       Fix redirect restore on saved file descriptors (closes: #357091).
   * debian/po/it.po: [INTL:it] Italian debconf templates translation
     (thx Luca Monducci; closes: #418174).
Files: 
 24618e3147a453f036422a5eb9241fdf 639 shells optional dash_0.5.3-8.dsc
 3337f54d71d5a1d8b46f3d2e5ca5e5b1 65454 shells optional dash_0.5.3-8.diff.gz
 f1bc68362a50a33a7937abbac61f11b0 17988 shells optional ash_0.5.3-8_all.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGZRfIGJoyQbxwpv8RAr9bAJ9eBMztYImPd3hp9u3xcueI7pHPHACfQHT8
cE5dDWvrKQLjPeAmyWWHRzQ=
=PFZZ
-----END PGP SIGNATURE-----


--- End Message ---

Reply via email to