On Fri, 26 Sep 2003, Christopher Faylor wrote:
> On Fri, Aug 16, 2002 at 03:42:21PM -0400, Igor Pechtchanski wrote:
> >I've tried submitting this twice before, and had gotten no reaction. I'm
> >trying to find out what the proper procedure is and which list should this
> >be sent to. I'd also like to discuss the appropriate name for this little
> >app, as well as get your comments on its usefulness. To avoid retyping
> >and clogging up the list, I'm providing a link to the latest submission
> >below.
> >
> >http://www.cygwin.com/ml/cygwin-patches/2002-q3/msg00261.html
>
> I know it's amazingly late to be responding to this but I'd like to reconsider
> it, although I'm not wild about the 'cygtweak' name.
>
> Maybe cygoption would be better? And, if you're still interested in submitting
> this (and I wouldn't blame you if you weren't given that it's been more than
> a year) we'd need this to be added to the utils.sgml file, also.
>
> cgf
Well, I think I've gotten the hang of the procedures by now (that was one
of my first submissions -- WOW, time flies). No, it's not too late, and I
still think this would be useful.
Yep, the message actually says that "cygtweak" should be renamed. I think
"cygprogctl" is even better than "cygoption", so that's the name I used.
I've also changed the headers and copyrights appropriately.
Attached is a patch against the latest CVS that adds the "cygprogctl"
script with a description in utils.sgml and the appropriate rules in
Makefile.in. The only thing I didn't test were the rules in the Makefile,
so if someone could please double-check them, it'd be great. As usual,
the ChangeLog is below.
Igor
=============================================================================
ChangeLog:
2003-09-27 Igor Pechtchanski <[EMAIL PROTECTED]>
* cygprogctl: New shell script.
* Makefile.in: Add rules for cygprogctl.
* utils.sgml: Add section on cygprogctl.
--
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!
"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster." -- Patrick Naughton
Index: winsup/utils/cygprogctl
===================================================================
RCS file: winsup/utils/cygprogctl
diff -N winsup/utils/cygprogctl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ winsup/utils/cygprogctl 27 Sep 2003 16:24:54 -0000
@@ -0,0 +1,154 @@
+#!/bin/sh
+#
+# cygprogctl -- add or remove program-specific values for the CYGWIN
+# environment variable.
+#
+# Copyright (c) 2003, Red Hat, Inc
+#
+# Written by Igor Pechtchanski <[EMAIL PROTECTED]>
+#
+# This file is part of Cygwin.
+#
+# This software is a copyrighted work licensed under the terms of the
+# Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+# details.
+#
+
+if [ "$1" = debug ]; then
+ set -x
+ shift
+fi
+
+progname=`basename $0`
+version='$Revision: 1.29 $'
+version="`echo "$version" | sed -e 's/^\$Revision: //' -e 's/ \$$//'`"
+
+REGTOOL=/usr/bin/regtool
+REGKEY="/HKLM/SOFTWARE/Cygnus Solutions/Cygwin/Program Options"
+
+if [ ! -x $REGTOOL ]; then
+ echo "$progname: Can't find $REGTOOL, exiting." 1>&2
+ exit 1
+fi
+
+while [ $# -ne 0 ]; do
+ case $1 in
+ -v | --verbose)
+ verbose="YES" ;;
+
+ -n | --noexec)
+ verbose="YES"
+ noexec="YES" ;;
+
+ -a | --add-program-override)
+ if [ -n "$action" ]; then
+ echo "$progname: Please specify only one action." 1>&2
+ exit 0
+ fi
+ action="ADD"
+ program="$2"
+ cygwin="$3"
+ shift
+ shift;;
+
+ -r | --remove-program-override)
+ if [ -n "$action" ]; then
+ echo "$progname: Please specify only one action." 1>&2
+ exit 0
+ fi
+ action="REMOVE"
+ program="$2"
+ shift;;
+
+ -e | --export)
+ if [ -z "$action" ]; then
+ echo "$progname: Please specify an action first." 1>&2
+ elif [ "$action" != ADD ]; then
+ echo "$progname: Warning: -e ignored for -r." 1>&2
+ else
+ export="YES"
+ fi;;
+
+ -V | -version | --version)
+ echo $progname: version $version 1>&2
+ exit 0 ;;
+
+ -h | -help | --help)
+ echo "Usage: $progname [-v|-n] action action-specific-params" 1>&2
+ echo " where action is one of" 1>&2
+ echo " -a|--add-program-override program \$CYGWIN-value [-e|--export]"
1>&2
+ echo " adds an override for the value of the CYGWIN
variable" 1>&2
+ echo " when invoking the program" 1>&2
+ echo " --export exports the value to all children of the
given program" 1>&2
+ echo " -r|--remove-program-override program" 1>&2
+ echo " removes an override for a given program" 1>&2
+ echo 1>&2
+ echo "If --verbose or -v is specified, the registry modification actions
are printed" 1>&2
+ echo "If --noexec or -n is specified, no commands that change the
registry will be run" 1>&2
+ echo " Note that --noexec implies --verbose" 1>&2
+ echo 1>&2
+ echo "Examples: $progname -v --add-program-override /usr/sbin/inetd 'tty'
--export" 1>&2
+ echo " $progname --remove-program-override /usr/sbin/sshd" 1>&2
+ exit 0 ;;
+
+ *)
+ echo "$progname: Invalid argument(s)." 1>&2
+ echo "Try '$progname --help' for more information." 1>&2
+ exit 1 ;;
+ esac
+ shift
+done
+
+if [ -z "$action" ]; then
+ echo "$progname: Missing argument(s)." 1>&2
+ echo "Try '$progname --help' for more information." 1>&2
+ exit 1
+fi
+
+case $program in
+/*) program=`cygpath -w "$program" | sed 's/\\\\/\\\\\\\\/g'` ;;
+esac
+
+case $action in
+ADD)
+ # First check if the key exists
+ if ! $REGTOOL -q check "$REGKEY"; then
+ if [ -n "$verbose" ]; then
+ echo "$progname: \"$REGKEY\" not found, adding."
+ fi
+ if [ -z "$noexec" ]; then
+ $REGTOOL add "$REGKEY"
+ else
+ echo "$REGTOOL add \"$REGKEY\""
+ fi
+ fi
+ # Tack on "export" if needed
+ if [ -n "$export" ]; then
+ cygwin="$cygwin export"
+ fi
+ # Now add the corresponding value
+ if [ -n "$verbose" ]; then
+ echo "$progname: Setting \"$REGKEY/$program\" to \"$cygwin\"."
+ fi
+ if [ -z "$noexec" ]; then
+ $REGTOOL -K@ -s set "[EMAIL PROTECTED]" "$cygwin"
+ exit $?
+ else
+ echo "$REGTOOL -K@ -s set \"[EMAIL PROTECTED]" \"$cygwin\""
+ fi
+ ;;
+
+REMOVE)
+ # Remove the corresponding value
+ if [ -n "$verbose" ]; then
+ echo "$progname: Removing \"$REGKEY/$program\"."
+ fi
+ if [ -z "$noexec" ]; then
+ $REGTOOL -K@ unset "[EMAIL PROTECTED]"
+ exit $?
+ else
+ echo "$REGTOOL -K@ unset \"[EMAIL PROTECTED]""
+ fi
+ ;;
+esac
+
Index: winsup/utils/Makefile.in
===================================================================
RCS file: /cvs/src/src/winsup/utils/Makefile.in,v
retrieving revision 1.53
diff -u -p -r1.53 Makefile.in
--- winsup/utils/Makefile.in 12 Sep 2003 01:51:21 -0000 1.53
+++ winsup/utils/Makefile.in 27 Sep 2003 16:24:54 -0000
@@ -84,12 +84,17 @@ PROGS:=warn_dumper $(PROGS)
CLEAN_PROGS+=dumper.exe
endif
+PROGS+=cygprogctl
+
.SUFFIXES:
.NOEXPORT:
.PHONY: all install clean realclean warn_dumper
all: Makefile $(PROGS)
+
+cygprogctl: $(srcdir)/cygprogctl
+ cp -p $< $@
strace.exe: strace.o path.o $(MINGW_DEP_LDLIBS)
ifdef VERBOSE
Index: winsup/utils/utils.sgml
===================================================================
RCS file: /cvs/src/src/winsup/utils/utils.sgml,v
retrieving revision 1.43
diff -u -p -r1.43 utils.sgml
--- winsup/utils/utils.sgml 5 Aug 2003 01:06:22 -0000 1.43
+++ winsup/utils/utils.sgml 27 Sep 2003 16:24:54 -0000
@@ -176,6 +176,57 @@ other formats.</para>
</sect2>
+<sect2 id="cygprogctl"><title>cygprogctl</title>
+
+<screen>
+Usage: cygprogctl [-v|-n] action action-specific-params
+ where action is one of
+ -a|--add-program-override program $CYGWIN-value [-e|--export]
+ adds an override for the value of the CYGWIN variable
+ when invoking the program
+ --export exports the value to all children of the given program
+ -r|--remove-program-override program
+ removes an override for a given program
+
+If --verbose or -v is specified, the registry modification actions are printed
+If --noexec or -n is specified, no commands that change the registry will be run
+ Note that --noexec implies --verbose
+
+Examples: cygprogctl -v --add-program-override /usr/sbin/inetd 'tty' --export
+ cygprogctl --remove-program-override /usr/sbin/sshd
+</screen>
+
+<para>The <command>cygprogctl</command> program is a wrapper around
+<command>regtool</command> to allow manipulating program-specific values
+of the <emphasis>CYGWIN</emphasis> variable in the registry. Cygwin
+allows overriding the value of the <emphasis>CYGWIN</emphasis> variable for
+individual programs (and their children).
+This is useful for server programs, for example, <command>sshd</command>
+or <command>inetd</command>.</para>
+
+<para>To add a program-specific <emphasis>CYGWIN</emphasis> value override,
+specify the <literal>-a</literal> flag, followed by the program name and the
+value of the <emphasis>CYGWIN</emphasis> variable for that program. The
+program name should be an absolute path to the executable. The value of the
+<emphasis>CYGWIN</emphasis> variable should be <emphasis>one</emphasis>
+parameter, so it needs to be properly quoted. If the <literal>-e</literal>
+option is specified, the <emphasis>CYGWIN</emphasis> value will
+also be exported to all child processes that the program spawns.</para>
+
+<para>To remove a previously specified override, specify the
+<literal>-r</literal> flag, followed by the program name. The next time
+the program runs, the value of <emphasis>CYGWIN</emphasis> will be taken
+from the environment.</para>
+
+<para>The <literal>-v</literal> option causes <command>cygprogctl</command>
+to print out the exact <command>regtool</command> invocations to set the
+<emphasis>CYGWIN</emphasis> override before they are executed. Use the
+<literal>-n</literal> option to print out the invocations without actually
+modifying the registry.
+Note that <literal>-n</literal> implies <literal>-v</literal>.</para>
+
+</sect2>
+
<sect2 id="dumper"><title>dumper</title>
<screen>