On Wed, 26 Oct 2005, Brian Dessent wrote:
> David Rasmussen wrote:
>
> > Open cygwin. Write 'notepad test.txt'. Notepad opens, write something
> > and then save the file. Now do an ll. The file test.txt has been created
> > and has the executable flag set. I want it to not be set in such cases.
>
> This is really out of Cygwin's control. The permissions that other
> programs choose to create files with is completely up to them. It just
> happens that the Windows default (Full Control to the owner and
> Administrators, Read & Execute to Users) happens to contain the execute
> permission.
>
> However I believe that almost all Windows programs do not specify an ACL
> when creating files, so they end up inheriting the permissions from the
> directory (or from the parent directory or its parent directory, etc.)
>
> If you change this ACL that is the source of this inheritance so that it
> does not contain the 'execute' permission you should be able to get the
> situation you desire. However, you may break some functionality in
> Windows. For example, you will not be able to run any programs in such
> a modified directory tree until you explicitly give all the .dll, .exe,
> .ocx, etc files the Execute permission. (It would be the same as if you
> did "chmod -R 644 /bin" on a unix system.)
I've used the attached script successfully for quite a while...
Enjoy,
Igor
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ [EMAIL PROTECTED]
ZZZzz /,`.-'`' -. ;-;;,_ [EMAIL PROTECTED]
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D.
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
If there's any real truth it's that the entire multidimensional infinity
of the Universe is almost certainly being run by a bunch of maniacs. /DA
#!/bin/sh
#
# A script to fix up executable permissions.
#
# Copyright (c) 2002, 2003, Igor Pechtchanski
#
# Written by Igor Pechtchanski <[EMAIL PROTECTED]>
#
# This program is distributed under the terms of the GNU General Public
# License. For more information see <http://www.gnu.org/licenses/>.
#
PATH="/bin:$PATH"
export PATH
PROGNAME="`basename "$0"`"
USAGE="Usage: $PROGNAME [-v|--verbose] [-n|--dry-run] [-b|--batch] [dirs]"
DASH_PRINT=
ECHO=
TEE=cat
BATCH=
dup2() {
# xargs -r -0 -n 1 perl -e 'exit unless ($a=shift);print STDERR "$a\n";print
"$a\0"'
# xargs -r -0 -n 100 perl -e 'foreach(@ARGV){print STDERR "$_\n";print "$_\0"}'
perl -e '$/="\0";while(<>){chomp();print STDERR "$_\n";print "$_\0"}'
}
while [ -n "$1" ]; do
case "$1" in
-h|--help) echo "$USAGE" >&2 ; exit 0 ;;
-v|--verbose) DASH_PRINT="-print" ; TEE=dup2 ;;
-n|--dry-run) ECHO="echo" ;;
-b|--batch) BATCH="true" ;;
--) shift ; break ;;
-*) echo "Invalid flag: $1" >&2 ; echo "$USAGE" >&2 ; exit 2 ;;
*) break ;;
esac
shift
done
DIRS="${@:-.}"
#EXEEXT="sh exe bat com dll"
EXEEXT="exe bat com dll"
EXTFILTER="$(echo "$EXEEXT" | perl -pe 's/(\w+)/-name \\*.$1 -o/g')"
#DBGPRG='-exec echo CAUGHT ".(++$i)." {} \\;'
EXEPAT='^#! */^: *Use */eval.*exec'
#PATPRG='-exec perl -ne
\"BEGIN{\\\$s=1};\\\$.=1&&/$p/&&exit(\\\$s=0);exit(\\\$s);END{exit(\\\$s)}\" {}
\\;';
PATPRG='-exec awk \"BEGIN{S=1}NR=1&&/$p/{S=0;exit(0)}{exit(S)}END{exit(S)}\" {}
\\;';
PATFILTER="$(echo "$EXEPAT" | perl -pe 's/\n$//;@p=split(//);foreach
$p(@p){$p=~s@(['"'"'"/])@[EMAIL PROTECTED];$p="'"$PATPRG $DBGPRG"'
-o";};$_=join(" ",@p)')"
eval "set -- $EXTFILTER $PATFILTER"
for DIR in $DIRS; do
if [ -d "$DIR" -o -h "$DIR" ]; then
FILTER="-type f"
elif [ -f "$DIR" ]; then
FILTER="-maxdepth 1"
fi
if [ -z "$BATCH" ]; then
find "$DIR" $FILTER -perm -0100 \( "$@" \( $DASH_PRINT -exec $ECHO chmod
a-x {} \; \) \)
else
find "$DIR" $FILTER -perm -0100 \( "$@" -print0 \) | $TEE | xargs -r -0 -n
1000 $ECHO chmod a-x --
fi
done
--
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/