From: LAURI@DCD00.FNAL.GOV (Laurelin of Middle Earth, x2214)
Newsgroups: comp.os.vms
Subject: SETPQL  7/9
Date: 13 Nov 92 17:15:57 GMT
Distribution: world
Organization: The Internet

-+-+-+-+-+-+-+-+ START OF PART 7 -+-+-+-+-+-+-+-+
X excnam = cc$rms_nam;
X excnam.nam$l_rsa = &excfilename;
X excnam.nam$b_rss = sizeof (excfilename) - 1;
X excnam.nam$l_esa = &excfilenexp;
X excnam.nam$b_ess = sizeof (excfilenexp) - 1;
X
X excrab = cc$rms_rab;`09`09`09`09`09/* and with the record access block */
X excrab.rab$l_fab = &excfab;
X excrab.rab$l_ubf = &exc_record;
X excrab.rab$w_usz = sizeof exc_record;
X
X
X sts = sys$open( &excfab );`09`09`09`09/* Open the file under the first defa
Vult name. */
X if ( sts == RMS$_FNF )`09`09`09`09`09/* If we couldn't find it, try again u
Vnder the second default. */
X `7B
X    excfab.fab$l_dna = &DFLT_EXCLUDE_FILE2;`09`09/* set the default name fie
Vld to our second guess */
X    excfab.fab$b_dns = strlen(DFLT_EXCLUDE_FILE2);`09/* and set the length *
V/
X    sts = sys$open( &excfab );`09`09`09`09/* Try, try again. */
X    if ( sts == RMS$_FNF )`09`09`09`09/* If we *still* didn't find it, signa
Vl this but continue. */
X    `7B
X`09strcpy(fao_p1, exclude_file);`09`09`09/* Set up for signalling the messag
Ve. */
X`09fao_p1_d.dsc$w_length = strlen(exclude_file);
X`09lib$signal(pql_excfnf, 1, &fao_p1_d);`09`09/* Signal this message. */
X
X`09exclude_file`5B0`5D = '\0';`09`09`09`09/* Clear the filename field if no
V file was found. */
X`09return(SS$_NORMAL);`09`09`09`09/* And return a normal status, continue pr
Vocessing. */
X    `7D
X `7D
X RMS_SIGNAL(excfab.fab$l_sts, excfab.fab$l_stv);
X
X sts = sys$connect( &excrab );`09`09`09`09/* Connect with our record stream
V */
X RMS_SIGNAL(excfab.fab$l_sts, excfab.fab$l_stv);
X
X if ( excnam.nam$b_esl != 0 )`09`09`09`09/* Get the actual name of the file
V we opened. */
X `7B
X    excfilenexp`5Bexcnam.nam$b_esl`5D = '\0';
X    strcpy(excfilename, excfilenexp);
X `7D
X else
X    excfilename`5Bexcnam.nam$b_rsl`5D = '\0';
X
X strcpy(exclude_file, excfilename);`09`09`09/* Copy the actual file name int
Vo our holding variable. */
X#ifdef DEBUG
X   printf("\n\nExcludeFile is now open under the name >%s<",exclude_file);
X#endif
X
X /*
X  * Now read the records in the exclude_file.
X  * Strip off comments, strip trailing blanks, compress blanks,
X  * and replace all blanks with commas.  Convert to uppercase.
X  * Then go through this comma-delineated list and add each
X  * element to our linked list of excluded usernames.
X  * NOTE when we pull elements:  if the first character is "`5B",
X  * then we need to get the NEXT element too, as this is a group code.
X  */
X
X while( (sts = sys$get(&excrab)) != RMS$_EOF )`09`09/* Read until the end of
V the file. */
X `7B
X`09RMS_SIGNAL(excfab.fab$l_sts, excfab.fab$l_stv);
X`09exc_record`5Bexcrab.rab$w_rsz`5D = '\0';`09`09/* Set the null-terminator.
V */
X#`09ifdef DEBUG
X`09  printf("\n  exclude_file record: >%s<",exc_record);
X#`09endif
X
X`09comma_tize(strtrim(uncomment(exc_record)));`09/* Strip comments and trail
Ving blanks, compress white space into commas*/
X
X`09exc_record_d.dsc$w_length = strlen(exc_record);`09/* Set up for pulling e
Vlements from the list.  Needs descriptors. */
X
X`09for(  element = 0;
X`09      ( (sts = STR$ELEMENT(&exc_element_d, &element, &comma_d, &exc_recor
Vd_d)) == SS$_NORMAL );
X`09`09element++ )
X`09`7B
X`09   exc_element`5Bexc_element_d.dsc$w_length`5D = '\0';
X`09   strtrim(exc_element);
X
X`09   if ( exc_element`5B0`5D == bracket`5B0`5D )`09`09/* We must be careful
V about UIC's, which themselves contain a comma!! */
X`09   `7B`09`09`09`09`09`09/*  If we see a bracket "`5B", then assume that t
Vhe next element is the */
X`09`09element++;`09`09`09`09/*  second half of this UIC and append it here.
V */
X`09`09sts = STR$ELEMENT(&grp_element_d, &element, &comma_d, &exc_record_d);
X`09`09grp_element`5Bgrp_element_d.dsc$w_length`5D = '\0';
X`09`09strtrim(grp_element);
X
X`09`09sprintf(exc_element,"%s,%s",exc_element,grp_element);
X`09   `7D
X
X#`09   ifdef DEBUG
X`09     printf("\n\telement %d = %s",element,exc_element);
X#`09   endif
X
X`09   link_into_list( &ExcludeUser_Root,`09`09/* And add this new excluded u
Vsername or uic to the linked list. */
X`09`09`09   &ExcludeUser_Cur,
X`09`09`09   &ExcludeUser_Prev,
X`09`09`09   upcase(exc_element), strlen(exc_element) );
X`09`7D
X `7D
X
X sts = sys$close( &excfab );`09`09`09`09/* Close the exclude_file. */
X RMS_SIGNAL(excfab.fab$l_sts, excfab.fab$l_stv);
X
X return(TRUE);
X`7D
X`0C
X
X/*****************************************************************
X * Determine whether or not this username should be              *
X * included in our scan.  Algorithm: using wildcard              *
X * pattern matching (STR$MATCH_WILD):                            *
X * Is USERNAME on the EXCLUDE-USER list?  If so - EXCLUDE.       *
X * Is numerical UIC on the EXCLUDE-USER list?  If so - EXCLUDE.  *
X * Is Ascii UIC on the EXCLUDE-USER list?  If so - EXCLUDE.      *
X * Is USERNAME on the INCLUDE-USER list?  If so - INCLUDE.       *
X * Is numerical UIC on the INCLUDE-USER list?  If so - INCLUDE.  *
X * Is Ascii UIC on the INCLUDE-USER list?  If so - INCLUDE.      *
X * If none of the above, EXCLUDE.                                *
X *****************************************************************/
X
Xshort include_this_user(char *Username, long Uic)
X`7B
X union UicUnion `7B`09`09`09`09`09/* we need to break the longword into it's
V pieces. */
X   struct `7B
X`09short mem;`09`09`09`09`09/* the DECIMAL member number */
X`09short grp;`09`09`09`09`09/* the DECIMAL group number */
X        `7D word;
X   struct `7B
X`09long  both;
X        `7D longword;
X   `7D UicValue;
X
X  char uic_octal`5BNAM$C_MAXRSS + 1`5D;`09`09`09/* in SYSUAF, the numbers ar
Ve presented in OCTAL.  This is what a */
X`09`09`09`09`09`09`09/*  user would try to match!! */
X
X  char ascii_grp`5BNAM$C_MAXRSS + 1`5D;`09`09`09/* We also need to obtain th
Ve ASCII names of these identifiers. */
X  $DESCRIPTOR(ascii_grp_d, ascii_grp);`09`09`09/* For the system service $ID
VTOASC */
X  char uic_ascii`5BNAM$C_MAXRSS + 1`5D;`09`09`09/* And the textual form for
V string matching. */
X  long id_number;`09`09`09`09`09/* We need to convert `5Bgrp,mem`5D to a num
Veric value first. */
X  const long hex_10000 = 65536;`09`09`09`09/* Conversion factor. */
X  const long hex_9999  = 65535;`09`09`09`09/* Also a conversion factor. */
X  long status;
X
X
X /*
X  * Convert the uic longword to strings.  We want all forms that
X  * the user may have entered for pattern matching, that is:
X  * we want the `5B525,7`5D form AND the `5BG023_C,12`5D form.  Then we
X  * can test with the user's list of INCLUDEs and EXCLUDEs.
X  */
X
X  UicValue.longword.both = Uic;`09`09`09`09/* Convert the Uic longword to it
V's octal string group/member numbers. */
X  sprintf(uic_octal, "`5B%o,%o`5D", UicValue.word.grp, UicValue.word.mem);
X
X  id_number = hex_9999 + (hex_10000 * UicValue.word.grp);`09/* Convert to th
Ve ASCII version of the GROUP number */
X
X  status = sys$idtoasc( id_number, 0, &ascii_grp_d, 0, 0, 0 );
X  if ( status == SS$_NOSUCHID )`09`09`09`09`09/* Ooops, this account doesn't
V really have a group code in ASCII. */
X  `7B`09`09`09`09`09`09`09`09/* Use the ASCII equivalent of the user's ident
Vifier.
X      id_number = id_number - hex_9999 + UicValue.word.mem
X      status = sys$idtoasc( id_number, 0, &ascii_grp_d, 0, 0, 0 );
X      if ( status == SS$_NOSUCHID )`09`09`09`09/* Nothing here either?  Then
V blank out the string. */
X`09ascii_grp_d.dsc$w_length = 0;
X  `7D
X
X  ascii_grp`5Bascii_grp_d.dsc$w_length`5D = '\0';
X  strtrim(ascii_grp);
X
X  if ( strlen(ascii_grp) != 0 )
X    sprintf(uic_ascii,"`5B%s,%o`5D",ascii_grp, UicValue.word.mem);`09/* Conv
Vert to our string matching form. */
X  else
X    sprintf(uic_ascii,"`5B%s`5D",Username);`09`09`09`09/* Use the username i
Vf it was empty. */
X
X
X /*
X  * Ok, NOW we are ready to begin deciding whether we should
X  * INCLUDE or EXCLUDE this particular user.
X  */
X  if ( (in_linked_list(Username,  ExcludeUser_Root)) `7C`7C
X       (in_linked_list(uic_octal, ExcludeUser_Root)) `7C`7C
X       (in_linked_list(uic_ascii, ExcludeUser_Root)) )
X  `7B
X#     ifdef DEBUG
X`09printf("\nSpecifically EXCLUDING username >%s<, uic = >%s<", Username, ui
Vc_ascii);
X#     endif
X      return(FALSE);
X  `7D
X
X
X  if ( (in_linked_list(Username,  IncludeUser_Root)) `7C`7C
X       (in_linked_list(uic_octal, IncludeUser_Root)) `7C`7C
X       (in_linked_list(uic_ascii, IncludeUser_Root)) )
X  `7B
X#     ifdef DEBUG
X`09printf("\nSpecifically INCLUDING username >%s<, uic = >%s<", Username, ui
Vc_ascii);
X#     endif
X      return(TRUE);
X  `7D
X
X# ifdef DEBUG
X    printf("\nDefault EXCLUDING username >%s<, uic = >%s<", Username, uic_as
Vcii);
X# endif
X
X  return(FALSE);
X`7D
X
$ CALL UNPACK [.SETPQL_V2_0]SETPQL.C;1 57948660
$ create 'f'
X1 SETPQL
X! This file was created by L. Loebel, R/D Computing, Fermilab.
X!
X!****************************Copyright Notice*******************************
V****
X!*             Copyright `A91990 Universities Research Association, Inc.
V         *
X!*                         All Rights Reserved
V                                 *
X!***************************************************************************
V****
X!***********************Government Sponsorship Notice***********************
V****
X!* This material resulted from work developed under a Government Contract an
Vd  *
X!* is subject to the following license:  The Government retains a paid-up,
V     *
X!* nonexclusive, irrevocable worldwide license to reproduce, prepare derivat
Vive*
X!* works, perform publicly and display publicly by or for the Government,
V      *
X!* including the right to distribute to other Government contractors.  Neith
Ver *
X!* the United States nor the United States Department of Energy, nor any of
V    *
X!* their employees, makes any warrenty, express or implied, or assumes any
V     *
X!* legal liability or responsibility for the accuracy, completeness, or
V        *
X!* usefulness of any information, apparatus, product, or process disclosed,
V or *
X!* represents that its use would not infringe privately owned rights.
V          *
X!***************************************************************************
V****
X!
X `20
X Check and `5Boptionally`5D set process quota limits to specified minimum
X values.
X
X The purpose of this utility is to make sure that over the years and
X through the various software upgrades, the accounts which have been on
X the system for a long long time are not lagging behind in required
X minimum recommended quotas.  The entire SYSUAF database will be
X scanned.  You may choose to generate only a list of which UAF records
X need to be updated but not make any changes (see /MODIFY and
X /NOMODIFY).  You may choose to scan all of the available process quota
X limits (/ALL), or only a certain subset.  You may use the values
X contained within the DEFAULT account UAF record, or you may specify a
X new value for each process quota limit on the command line (e.g.,
X /ASTLM=100).
X
X SETPQL will NEVER reduce a process quota limit for any account.  The
X values in the SYSUAF file will only be raised to the specified or
X implied value.
X
X Usage:
X
X        $ SETPQL :== dev:`5Bdir`5DSETPQL
X        $ SETPQL `5B/qualifiers`5D  `5Buserlist`5D
X
X (at Fermilab, you may $ SETUP SETPQL to get the necessary SETPQL
X symbol).
X
X2 Parameters
X
X username`5B,...`5D
X
X Specifies one or more usernames to be scanned.  If no usernames are
X specified, all users listed in the SYSUAF file will be scanned.
X
X Wildcards are allowed.
X
X2 Qualifiers
X
X/EXCLUDE
X /EXCLUDE=(`5BFILE`5B=exclude-file`5D,`5D`5BUSER=(userlist)`5D)
X /NOEXCLUDE
X
X The /EXCLUDE qualifier allows you to exclude certain usernames from the
X scan.  You may exclude users either by listing them in a file, or by
X specifying their usernames directly on the command line, or both.
X Wildcard specifications are allowed. `20
X
X The default value if you specify nothing is
X
X                /EXCLUDE=FILE=SETPQL_EXCLUDE
X
X where SETPQL_EXCLUDE is one of the following (in this order):
X
X                a) a logical name pointing to your exclude-file,
X                b) the file SETPQL_EXCLUDE.DAT in your current default
X                   directory,
X                c) the file SETPQL_EXCLUDE.DAT in your SYS$LOGIN
X                   directory.
X
X The SETPQL_EXCLUDE file may contain comments and/or wildcard
X charcaters.  You may specify users by username or by UIC group/member
X numbers.
X
X You may choose to list username on the command line itself, e.g.,
X
X        $ SETPQL/EXCLUDE=(USER=( *$SERVER, `5BNETWORK,*`5D, `5B1,*`5D )
X
X To use both a file and a list of usernames,
X
X        $ SETPQL/EXCLUDE=( FILE=SETPQL_EXCLUDE, USER=(SMITH,TOM) )
X
X/LOG
X /LOG           (default)
X /NOLOG
X
X Controls whether or not informational messages are output to the
X screen.
X
X Default is /LOG.
X
X
X/MODIFY
X /MODIFY        (default)
X /NOMODIFY
X
X Controls whether or not the SYSUAF records are modified and set to the
X minimum values.  By default, the $SETPQL command will cause all
X accounts on the system to be brought up to the specified or DEFAULT
X minimum values.  Use /NOMODIFY if you merely want to generate a report
X of what *would* have changed.
X
X
X/ALL
X /ALL
X /NOALL         (default)
X       `20
X Controls whether all of the PQL values are scanned, or only a certain
X subset.
X
X By default, the /NOALL qualifier is in effect and only those PQL values
X specifically listed on the command line will be scanned and/or
X modified.
X
X To scan and/or modify all of the process quota limits, use the /ALL
X qualifier.  This will cause each of the PQL's to be checked against the
X value specified on the command line, or against the DEFAULT account
X values when not listed on the command line.
X
X For example:
X
X                $ SETPQL/ASTLM=100
X
X will set *ONLY* the ASTLM of all accounts to at least 100; other
X process quota limits will not be modified.
X
X                $ SETPQL/ALL/ASTLM=100
X
X will set all of the PQL values to those specified in the DEFAULT
X account; however, for ASTLM, the value of 100 will override the value
X in the DEFAULT account.
X
X                $ SETPQL/ALL/ASTLM=100/NOCPU
X
X will set all PQL values to the minimum specified in the DEFAULT
X account; an ASTLM of 100 will override the ASTLM specified in the
X default account; and CPU will *NOT* be scanned or modified.
+-+-+-+-+-+-+-+-  END  OF PART 7 +-+-+-+-+-+-+-+-