Index: ossp-pkg/rc/00TODO
RCS File: /v/ossp/cvs/ossp-pkg/rc/00TODO,v
rcsdiff -q -kk '-r1.9' '-r1.10' -u '/v/ossp/cvs/ossp-pkg/rc/00TODO,v' 2>/dev/null
--- 00TODO 2002/01/25 16:04:41 1.9
+++ 00TODO 2002/01/29 15:35:05 1.10
@@ -25,3 +25,70 @@
Error handling
Classic error, give 'restart' command in place of 'start' to stopped prog
+
+Pseudocode
+ ***********************************
+ * psoudocode implementation of rc *
+ ***********************************
+
+parse command line options
+read and merge all "rc.conf" files
+
+parse "Locate"
+
+ Locate /cw/etc/rc.d/rc.%{RCFILE:s/^all$/*/}
+ Locate /cw/local/etc/rc.d/rc.%{RCFILE:s/^all$/*/}
+ Locate %{RCFILE}/.duerc
+ Locate ${HOME}/.duerc:m/^
(.*)<\/dir>/i
+ Locate ${HOME}/.duerc.%{RCFILE:s/^\///:s/[\/]/-/g}
+ Locate path/file/regex:regex_inside_file
+
+foreach given locate {
+ for each (locate all possible rcfiles working out the regex) {
+ continue if (absolute path seen previously) //avoid duplicates
+ if (filename matches given rcfile && securitycheck(RequireUmask, RequireOwner, RequireGroup))
+ load file and grab only a part of the file according to info after colon given in "locate"
+ }
+}
+
+foreach located_rcfile_fraction {
+ parse rcfile into blocks according to --ParseSectionDef
+ take out %config section according to --NameConfig
+ take out %common section according to --NameCommon
+ take out any sections given on command line
+}
+
+foreach section {
+ if (multiple rcfiles, i.e. all)
+ sort rcfiles by section priority.
+ foreach rcfile {
+ script = "";
+ script += %config from rcfile
+ script += %env from rc.env and override it
+ create_script_for_rcfile(script, section, parent=no)
+ expand our internal variables
+ execute, print or printeval script with user & group priveleges
+ and command interpreter according to options or section header
+ }
+}
+EXIT
+
+
+create_script_for_rcfile(script, section, parent)
+{
+ script += "${body}" //start with a pseudo value
+
+ if (!parent) { //only one rc.func!?
+ replace ${body} with %common from rc.func
+ if no ${body} assume prepend
+ }
+ replace ${body} with %common from rcfile
+ if no ${body} assume prepend
+ if (!parent) { //only one rc.func!?
+ replace ${body} with %section from rc.func
+ if no ${body} assume prepend
+ }
+ replace ${body} with %section from rcfile
+
+ expand references using --ParseSectionRef and calling create_script_for_rcfile(section, parent=yes);
+}
Index: ossp-pkg/rc/rc.conf
RCS File: /v/ossp/cvs/ossp-pkg/rc/rc.conf,v
rcsdiff -q -kk '-r1.3' '-r1.4' -u '/v/ossp/cvs/ossp-pkg/rc/rc.conf,v' 2>/dev/null
--- rc.conf 2002/01/28 16:01:23 1.3
+++ rc.conf 2002/01/29 15:35:05 1.4
@@ -11,17 +11,17 @@
debug
#raw
-defaultsection config #name for config section in rcfile
+configsection config #name for config section in rcfile
commonsection common #name for common section in rcfile
rcfile 'rc.%s' #'rc.' followed by the program name
rcumask 002 #mask checked against rcfile permissions
deactivate OSSP_RC_DEACT #environment variable controls activation
interpreter /usr/bin/perl #command interpreter to use for script code
-regex-sec '(?<=^|\n)%%%s\s*\n(.+?)(?=\n%\S+|$)'
-regex-ref '(?<=^|\n)%%%s\s*(.+?)(?=\n|;)'
-regex-assign '(\s+)=(.*)$'
-regex-param '..' #needs explanation
+regexsection '(?<=^|\n)%%%s\s*\n(.+?)(?=\n%\S+|$)'
+#RSE what about ${begin} regexref '(?<=^|\n)%%%s\s*(.+?)(?=\n|;)'
+regexassign '(\s+)=(.*)$'
+regexparam '..' #needs explanation
@@ -29,23 +29,25 @@
-#conf it's not possible to set the conf file in the conf file
+
+usage #flag
+debug #flag
+force #flag
+version #flag
+#conf #it's too late to set the conf file in the conf file
+dirs /cw/etc/rc.d:/etc/rc.d
+eval #flag
func rc.iofunc \
rc.dbgfunc \
rc.exfunc
-force #flag
-dirs /cw/etc/rc.d:/etc/rc.d
-tmp /var/tmp
-verbose #flag
-silent #flag
-debug #flag
-raw #flag
help #flag
-usage #flag
-version #flag
+info #flag
+labels start
print #flag
-eval #flag
-exec #flag
query ${foovar:-foodefault}
-labels start
-info #flag
+silent #flag
+raw #flag
+tmp /var/tmp
+verbose #flag
+exec #flag
+
Index: ossp-pkg/rc/rc.pod
RCS File: /v/ossp/cvs/ossp-pkg/rc/rc.pod,v
rcsdiff -q -kk '-r1.22' '-r1.23' -u '/v/ossp/cvs/ossp-pkg/rc/rc.pod,v' 2>/dev/null
--- rc.pod 2002/01/29 09:14:38 1.22
+++ rc.pod 2002/01/29 15:35:05 1.23
@@ -40,10 +40,9 @@
@l_prefix@/etc/rc
[B<-?>|B<--usage>]
[B<-D>|B<--debug>]
-[B<-F>|B<--force>]
+[B<-L>|B<--locate> I[C<:>I[...]]]
[B<-V>|B<--version>]
[B<-c>|B<--conf> I[C<:>I[...]]]
-[B<-d>|B<--dirs> I[C<:>I[...]]]
[B<-e>|B<--eval>]
[B<-f>|B<--func> I[C<:>I[...]]]
[B<-h>|B<--help>]
@@ -56,6 +55,13 @@
[B<-t>|B<--tmp> I]
[B<-v>|B<--verbose>]
[B<-x>|B<--exec>]
+[B<--RequireUmask umask>]
+[B<--RequireOwner uid|name>]
+[B<--RequireGroup gid|name>]
+[B<--ParseSectionDef regex>]
+[B<--ParseSectionRef regex>]
+[B<--NameConfig> name]
+[B<--NameCommon> name]
I
I
@@ -97,12 +103,11 @@
don't remove temporary files, and output debug messages to stderr
-=item B<-F>|B<--force>
+=item B<-L>|B<--locate> I[C<:>I]
-Usually F is a fraction of a filename and the run command facility
-prefixes this name with ${OSSP_RC_PREFIX} and appends ${OSSP_RC_SUFFIX} to it,
-then searches the file in directories given using --dirs. If the initial
-F matches the regex '^\.{0,2}/', --force is automagically assumed.
+locations to search for Fs where I can contain regex patterns to
+filter files and the optional part is a regex to filter out parts of a file.
+This option can be specified more than once.
=item B<-V>|B<--version>
@@ -113,10 +118,6 @@
specify the location of the configuration file. If omitted, the fallback is
to look for C<$OSSP_RC_CONF>, and "@l_prefix@/etc/rc.conf", in that order.
-=item B<-d>|B<--dirs> I[C<:>I[...]]
-
-directories to search for Fs.
-
=item B<-e>|B<--eval>
output the commands text in a format suitable for shell evaluation, but do not run it.
@@ -175,6 +176,34 @@
If neither B<--print>, B<--eval>, or B<-exec> is given, the default is
B<--exec> anyway.
+=item B<--RequireUmask umask>
+
+umask a F has to have, otherwise it's ignored.
+
+=item B<--RequireOwner uid|name>
+
+owner of the F must match uid|name, otherwise it's ignored.
+
+=item B<--RequireGroup gid|name>
+
+group of the F must match gid|name, otherwise it's ignored.
+
+=item B<--ParseSectionDef regex>
+
+regex matching a section within a F.
+
+=item B<--ParseSectionRef regex>
+
+regex matching a reference within a F.
+
+=item B<--NameConfig> name
+
+name of the config section, defaults to %config.
+
+=item B<--NameCommon> name
+
+name of the common section, defaults to %common.
+
=back 4
=head1 ENVIRONMENT