Subject: Re: cannot create temp file for here document
From: Barry Demchak <[email-masked]>
To: Eric Blake <[email-masked]>
Cc: [email-masked]
Date: Fri, 15 Jul 2005 18:48:08 -0700

Hi, Eric --

OK ... thanks ... I see your point about following the directions ... 
there's a lot of useful information there.

Please find attached my cygcheck.out file.

Please find attached the "ls -l / /tmp /cygdrive/c" output you requested. 
Note that the error message "ls: /cygdrive/c/pagefile.sys: No such file or 
directory" was printed to stderr immediately after listing the "/" directory.

Please find attached the "getfacl / /tmp /cygdrive/c" output you requested.

Please find attached the "bash -xv" output you requested.

There's more, though ... as I collected this information, I noticed a very 
peculiar effect that I'm betting has something to do with this. If I 
"ls >foo", I'm fine. If I "unlink foo", foo gets deleted, but I also get a 
spurious error message:

bdemchak@malex ~
$ unlink foo
unlink foo
+ unlink foo
unlink: cannot unlink `foo': No such file or directory

Like I said, foo gets deleted, but then there's the error message. This 
smells like it's all tied together, but I can't quite put my finger on it.

FYI, I *can* create files in tmp using "cat >foo" ... no permission 
violation or any other error ... works fine.

I appreciate your help!

At 03:28 PM 7/15/2005, Eric Blake wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>According to Barry Demchak on 7/15/2005 11:52 AM:
> > Hi, Dave --
> >
> > Pretty simple and interesting. It seems like "sort" is failing ... as if
> > there's problems with the temp directory (???).
>
>- From the error message, it is not the sort that is failing, but this
>compound statement in /etc/profile:
>
>while read f; do
>...
>done <<- EOF
>`/bin/find /etc/profile.d -iname '*.sh' -type f | sort`
>EOF
>
>where bash is trying to create a temporary file to collect the output of
>the sort in order to pass it to the read loop.
>
> >
> > Here's what it looks to me:
> >
> > A) The TEMP and TMP environment variables are
> > both /cygdrive/c/DOCUME~1/BARRYD~1/LOCALS~1/Temp
>
>Unix programs, if they look at the environment, tend to favor $TMPDIR and
>$TMP, not $TEMP.  I could not find it in the documentation, but by reading
>the source (/usr/src/bash-3.0/lib/sh/tmpfile.c, if you install the
>source), bash does check $TMPDIR (sometimes), then /tmp, /var/tmp,
>/usr/tmp, then . until it finds a directory that it thinks is writable.
>But its check is not using the access() method, so it may be getting
>confused by ACLs and selecting the wrong directory as writable.
>
> >
> > B) The !C environment variable (which I suppose must be the same
> > as /cygdrive/c) is C:\Cygwin\bin
>
>!C is Windows way to remember the current directory per drive letter (yes,
>Windows really does have up to 27 current working directories, 26 for use
>with relative drive prefixes, and the last for when there is no drive
>prefix).  But cygwin does not use that variable, and only tracks a single
>current working directory.
>
> >
> > If that's all true, then the temp directory it must be trying to use 
> would be
> > C:\Cygwin\bin\DOCUME~1/BARRYD~1/LOCALS~1/Temp ... which does not exist
>
>Nope, since you don't define TMPDIR, bash is trying to use /tmp.  And the
>location of /tmp is probably c:\cygwin\tmp, although you didn't follow the
>directions to attach cygcheck output, so I can't prove that.
>
>Please show the output of:
>
>$ ls -l / /tmp /cygdrive/c
>$ getfacl / /tmp /cygdrive/c
>
>My guess is that there are ACLs at play, so that even though ls shows the
>directory as writable, an ACL is preventing your user id from actually
>creating the temp file.
>
> > So, I'm out to lunch here ... below is the -x dump:
>
>Actually, a combination -xv dump is nicer, because it shows commands in
>context both before and after all parameters are expanded.  But what you
>provided was okay.
>
>- --
>Life is short - so eat dessert first!
>
>Eric Blake             [email-masked]
>volunteer cygwin bash maintainer
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v1.4.1 (Cygwin)
>Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
>Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
>
>iD8DBQFC2DiQ84KuGfSFAYARAt+ZAJ9v3C59UHyCYgW3kii8B7t3XlB7/gCdGEtk
>kf6lS3zuJpa5+t07ujnlnNk=
>=cJZB
>-----END PGP SIGNATURE-----
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/