Highley Recommended, Inc.
| NAVIGATION | DDTS ENCLOSURE |
|---|---|
|
CM Home |
Enclosure Edit ControlNow for enclosure edit control. I'm attaching the three files that are used. The first file "editencl.tmpl" is supplied with DDTs, but slightly modified to call the additional small scripts for controlling access to the enclosure. editencl.tmpl
#
# editencl.tmpl
#
# $Log: editencl.tmpl,v $
# Revision 1.4 1994/02/24 23:21:56 carl
# Made the comments more robust and added a real life example to the code.
#
# Revision 1.3 1993/11/18 20:04:30 jb
# Commented out the non benign characteristics .
#
# Revision 1.2 1993/11/18 19:08:58 jb
# Changed the name to editencl.tmpl from editenclok.tmpl 14 chars
# dontcha know
#
# Revision 1.1 1993/10/08 19:20:20 jb
# Initial revision
#
#
# This template demonstrates how to condition the updating of enclosures
# from a template. You have access to copies of all the fields in the
# defect that DON'T have files associated with them (that is, no History
# or Related-file fields). Any changes you
# make to these fields will be in effect for only as long as this template
# is being run. After that, all changes are thrown away.
#
# The only purpose of this template is to tell xddts(1) whether or not the
# CURRENT user is allowed to edit the enclosure. If you wish to NOT have the
# user edit or delete the enclosure, then you must issue an abort command.
# Otherwise, issue a return or do nothing, and the user will be allowed to
# edit it. The name of the current enclosure is in the field
# "Current-Encl-Title", so don't use this name for anything else.
#
# One caveat is that you must know the title of the enclosure you are
# putting this security on. That is, all enclosures forced from the template
# file can be controlled, but user added enclosures are a little harder.
# To control added enclosures, you must restrict the names that they can
# choose from. This can be accomplished by adding a oneof to the add.encl
# template file. Please be sure to add a few general purpose enclosure
# names that anyone can edit so that information about a bug will not be
# suppressed or discouraged.
*********************************************************************
* Note: The above information is not really true if you look at *
* this example we have the enclosure name, PR no., and who is *
* trying to make the modification. *
*********************************************************************
#
# This template is executed twice - once with operation 'f' for the
# puttemp operation and once with operation 'p' for the gettemp operation.
# An abort from operation 'f' causes an extra Fail message telling of
# 'Problems' in the template, so generally you should preface everything
# to occur in OPERATION p. That is, enclose all logic in an "if equals
# $OPERATION p ... fi" set of statements.
#
# A common request is that for a required enclosure called "Problem" added
# at Submission time, allow only the original submitter to be able to edit
# it. The commented code below describes how to do that. If you also want
# to allow the project manager to edit it, then add the following to the
# Whoami field:
#
# if oneof $~/projects/$Project/proj.control Proj-mgrs
# set Me "manager"
# fi
#
# Then add to the Current-Encl-Title field below the equals $Submitter-id:
#
# and not equals "$Me" "manager"
#
# This concept can be extended to any number of enclosure names (with a
# switch-case statement) and any complexity of rule-sets that you wish to
# define.
#
Begin: unset Begin
set Filter-path /usr/bin:/bin:/usr/ucb
set Oneof-path etc/oneofs
set Help-path etc/helps
Whoami: whoami
Current-Encl-Title:
if equals $OPERATION p
and not check_author "$$" $Start $Whoami
>2 echo "Only the Author can modify this enclosure"
abort
fi
End: return
check_author
#!/usr/bin/ksh
# check_author
# $Log: check_author,v $
# Revision 1.0 1995/08/03 07:23:18 dhighley
#
# This script dumps the history enclosure and checks to
# if the user trying to edit and enclosure is the author
# of that enclosure. The script is invoked from the
# editencl.tmpl template file.
ENCLOSURE="$1"
PR_NO=$2
USER=$3
ROOT=`ddtshome`
BUGDIR=$ROOT/allbugs
BDIR=`echo $PR_NO | cut -c9,10`
BUGPATH=$BDIR/$PR_NO
# Check to see if this is an existing PR
if [ -f $BUGDIR/$BUGPATH ]; then
# Check for the enclusure being added by the person trying to
# edit it.
dumpbug -n -t ~ddts/lib/dump_history.tmpl $PR_NO |
grep "Enclosure \"$ENCLOSURE\" added by $USER" >dev/null 2>&1 ||
dumpbug -n -t ~ddts/lib/dump_history.tmpl $PR_NO |
grep "Enclosure $ENCLOSURE added by $USER" >/dev/null 2>&1
if [ $? -ne 0 ]; then
# Did not find enclosure added by user. Now check to see if the
# enclosure exists.
dumpbug -n -t ~ddts/lib/dump_history.tmpl $PR_NO |
grep "Enclosure \"$ENCLOSURE\"" >/dev/null 2>&1 ||
dumpbug -n -t ~ddts/lib/dump_history.tmpl $PR_NO |
grep "Enclosure $ENCLOSURE" >/dev/null 2>&1
if [ $? -eq 0 ]; then
# Enclosure exists, but the author is not the one trying to
# edit it.
exit 1
fi
fi
fi
# Either file does not exist so the PR is not submitted yet
# or the author is trying to edit it. So allow the edit.
exit 0
dump_history.tmpl
# Here is all you need to dump only History enclosure from a bug.
# You may add this code to other templates, or use it by itself via:
#
# % dumpbug -n -t <thisfile> <bugID>
#
# This will cause only the enclosure to print out.
#
History: nobuffer # dump in-memory screen image, do raw output
putfile
|