home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / os / vms / 17935 < prev    next >
Encoding:
Internet Message Format  |  1992-11-14  |  14.5 KB

  1. Path: sparky!uunet!ukma!usenet.ins.cwru.edu!agate!dog.ee.lbl.gov!ucbvax!DCD00.FNAL.GOV!LAURI
  2. From: LAURI@DCD00.FNAL.GOV (Laurelin of Middle Earth, x2214)
  3. Newsgroups: comp.os.vms
  4. Subject: SETPQL  3/9
  5. Message-ID: <921113111522.20800159@fndcd.fnal.gov>
  6. Date: 13 Nov 92 17:15:22 GMT
  7. Sender: daemon@ucbvax.BERKELEY.EDU
  8. Distribution: world
  9. Organization: The Internet
  10. Lines: 385
  11.  
  12. -+-+-+-+-+-+-+-+ START OF PART 3 -+-+-+-+-+-+-+-+
  13. Xstruct LinkedListStruct *ExcludeUser_Prev = NULL;`09/* Previous excluded use
  14. Vrname entry */
  15. Xstruct LinkedListStruct *ExcludeUser_Cur  = NULL;`09/* Current excluded user
  16. Vname entry */
  17. X
  18. Xstruct LinkedListStruct *IncludeUser_Root = NULL;`09/* Base address of inclu
  19. Vded username list */
  20. Xstruct LinkedListStruct *IncludeUser_Prev = NULL;`09/* Previous included use
  21. Vrname entry */
  22. Xstruct LinkedListStruct *IncludeUser_Cur  = NULL;`09/* Current included user
  23. Vname entry */
  24. X
  25. X
  26. X
  27. X
  28. X/*
  29. X * external error messages, from the SETPQL_MSG.MSG module
  30. X */
  31. Xextern long pql_excfnf();`09`09/* exclude file wasn't found, continuing. */
  32. Xextern long pql_raise();`09`09/* user's pql has been increased */
  33. Xextern long pql_lowval();`09`09/* default account beats command line value*/
  34. Xextern long pql_nochanges();`09`09/* no changes were made */
  35. Xextern long pql_uafchanged();`09`09/* changes were made */
  36. Xextern long pql_invuafstr();`09`09/* internal structure of the SYSUAF file h
  37. Vas changed -- ABORT!!! */
  38. Xextern long pql_nop();`09`09`09/* nooperation was performed. Bozo entered an
  39. V essentially null cmd string. */
  40. Xextern long pql_nodfltacct();`09`09/* no default account is on this system.
  41. V */
  42. Xextern long pql_insdynmem();`09`09/* insufficient dynamic memory. */
  43. X
  44. X/*
  45. X * FAO parameter structures for any place where we need to pass`20
  46. X * string values to an error message.
  47. X */
  48. Xchar fao_p1`5BNAM$C_MAXRSS + 1`5D;`09`09/* general storage for string parame
  49. Vters. */
  50. Xchar fao_p2`5BNAM$C_MAXRSS + 1`5D;
  51. Xchar fao_p3`5BNAM$C_MAXRSS + 1`5D;
  52. Xchar fao_p4`5BNAM$C_MAXRSS + 1`5D;
  53. Xchar to_be`5BNAM$C_MAXRSS + 1`5D;`09`09/* stores the verb tense, either WAS
  54. V or WOULD HAVE BEEN, for informational message */
  55. X$DESCRIPTOR(fao_p1_d, fao_p1);`09`09/* must be in descriptor format. */
  56. X$DESCRIPTOR(fao_p2_d, fao_p2);
  57. X$DESCRIPTOR(fao_p3_d, fao_p3);
  58. X$DESCRIPTOR(fao_p4_d, fao_p4);
  59. X$DESCRIPTOR(to_be_d,  to_be);
  60. X
  61. X/*
  62. X * internal function templates/declarations
  63. X */
  64. Xlong  parse_cmdline();`09`09`09`09`09`09/* obtain and parse the command line
  65. V, set internal flags */
  66. Xlong  init_data_structures();`09`09`09`09`09/* initialize all data structure
  67. Vs and pointers that we can. */
  68. Xshort we_are_lazy();`09`09`09`09`09`09/* check to make sure that there is so
  69. Vmething for us to do! */
  70. Xlong  open_sysuaf();`09`09`09`09`09`09/* open the SYSUAF file for indexed re
  71. Vad */
  72. Xlong  init_Addr(union Addr *, struct ValueStruct *);`09`09/* point the Addre
  73. Vss structures to the addresses of the Values */
  74. Xlong  init_ItemList(struct ItemListStruct *,union Addr *);`09/* initialize $
  75. VGETUAI/$SETUAI item list pointers/buffers */
  76. Xlong  get_nextuser(char *);`09`09`09`09`09/* get the next user in the sysuaf
  77. V file */
  78. Xshort include_this_user(char *, long);`09`09`09`09/* should this user be INC
  79. VLUDED or EXCLUDED? */
  80. Xlong  set_MasterValue(union Addr *);`09`09`09`09/* set the Master PQL minimu
  81. Vm values which will be used */
  82. Xlong  set_UserValue(union Addr *, union Addr *);`09`09/* make sure the User
  83. V Values meet the minimum Master Values */
  84. Xvoid  test_and_set(long *, long *, short);`09`09`09/* compare two longwords
  85. V and set long1 to the maximum value */
  86. Xshort zero_is_infinite(short);`09`09`09`09`09/* determine if the value 0 imp
  87. Vlies infinite */
  88. Xvoid  cast_to_long(union Addr *, short, long *);`09`09/* cast a WORD/LONG/BY
  89. VTE -> long for the test_and_set comparison */
  90. Xvoid  cast_from_long(union Addr *, short, long *);`09`09/* cast a long -> WO
  91. VRD/LONG/BYTE after test_and_set comparison */
  92. Xchar  *cvtim(unsigned long);`09`09`09`09`09/* cast a long -> dddd-hh:mm:ss.c
  93. Vc form for error messages */
  94. Xchar  *upcase(char *);`09`09`09`09`09`09/* convert a string to upper case */
  95. Xchar  *strtrim(char *);`09`09`09`09`09`09/* strip trailing whitespace from a
  96. V string */
  97. Xchar  *uncomment(char *);`09`09`09`09`09/* strip trailing comments ("!" char
  98. Vacter and beyond) */
  99. Xchar  *comma_tize(char *);`09`09`09`09`09/* convert single blanks to commas
  100. V to make a comma-delineated list*/
  101. Xlong  link_into_list(struct LinkedListStruct **,`09`09/* add next element to
  102. V a linked list */
  103. X`09`09`09struct LinkedListStruct **,
  104. X`09`09`09struct LinkedListStruct **,
  105. X`09`09`09char *, short);
  106. Xshort in_linked_list(char *, struct LinkedListStruct *);`09/* determine if a
  107. V particular string is contained within one */
  108. X`09`09`09`09`09`09`09`09/*  of the linked lists (does a WILDCARD match) */
  109. Xlong  open_and_read_exclude_file();`09`09`09`09/* get list of excluded users
  110. V from the exclude file */
  111. Xvoid  DISPLAY_value(struct ValueStruct *);`09`09`09/* for debugging, display
  112. V the Value structures */
  113. Xvoid  DISPLAY_by_addr(union Addr *);`09`09`09`09/* for debugging, display th
  114. Ve values via the Address structures */
  115. Xvoid  DISPLAY_linked_list(char *,struct LinkedListStruct *);`09/* for debugg
  116. Ving, display the values in a linked list */
  117. X
  118. X/*
  119. X * and plain old global variable definitions
  120. X */
  121. Xshort modify;`09`09`09`09`09`09`09/* do or do not modify the UAF values ? */
  122. Xshort log;`09`09`09`09`09`09`09/* do or do not log things? */
  123. Xshort exclude;`09`09`09`09`09`09`09/* do or do not look at a list of exclude
  124. Vd usernames? */
  125. Xchar  exclude_file`5BNAM$C_MAXRSS + 1`5D;`09`09`09`09/* file whence exclusio
  126. Vns */
  127. Xlong  exit_status = SS$_NORMAL;`09`09`09`09`09/* assume the best until prove
  128. Vn otherwise */
  129. Xlong  shutup;`09`09`09`09`09`09`09/* for SILENT exit, turn on bit 28. */
  130. Xlong  bit28 = 28;`09`09`09`09`09`09/* this is the bit, boys! */
  131. Xshort UAF_wants_modification = FALSE;`09`09`09`09/* not unless proven otherw
  132. Vise.  for exit status reporting. */
  133. Xshort UAF_got_it = FALSE;`09`09`09`09`09/* ditto. */
  134. Xlong  time_conversion = -100000;`09`09`09`09/* for converting quadword inter
  135. Vnal time to longword $SETUAI time */
  136. X
  137. X
  138. X`0C
  139. X/***************************************
  140. X * Main program for SETPQL begins here.*
  141. X ***************************************/
  142. Xmain()
  143. X`7B
  144. X /*
  145. X  * variable declarations
  146. X  */
  147. X long status;
  148. X short i;
  149. X
  150. X /*
  151. X  * Parse the command line.  This routine will:
  152. X  *`09- set global variables based upon the values on the command line, for
  153. X  *`09  modify and log;
  154. X  *`09- set up the value of the IncludeUser list, a linked list containing
  155. X  *`09  all of the usernames entered on the command line to be INCLUDEd in t
  156. Vhe
  157. X  *`09  scan;
  158. X  *`09- determine the name of the exclude_file containing usernames to be
  159. X  *`09  EXCLUDEd from the scan;
  160. X  *`09- set up the value of the ExcludeUser list, a linked list containing
  161. X  *`09  all of the usernames entered on the command line to be EXCLUDEd from
  162. V the
  163. X  *`09  scan, as well as all of the usernames contained in the exclude_file;
  164. X  *`09- determine which UAF parameters are to be examined and set the approp
  165. Vriate
  166. X  *`09  Info`5Bi`5D.shallwe to TRUE for each parameter we want to examine;
  167. X  *`09- determine the value entered on the command line (if any) for each pa
  168. Vrameter
  169. X  *`09  we are supposed to examine and populate the appropriate Info`5Bi`5D.
  170. Vcmdval
  171. X  *`09  (if NOT_DEFINED, then we use the DEFAULT account value)
  172. X  */
  173. X
  174. X status = parse_cmdline();
  175. X SIGNAL(status);
  176. X#ifdef DEBUG
  177. X `7B
  178. X   DISPLAY_linked_list("IncludeUser", IncludeUser_Root);
  179. X   DISPLAY_linked_list("ExcludeUser", ExcludeUser_Root);
  180. X `7D
  181. X#endif
  182. X
  183. X /*
  184. X  * Initialize all data structures and pointers.  This will
  185. X  * set the shutup bits so we can exit silently, point the Address
  186. X  * structures to the appropriate values within the Value structures,
  187. X  * set the verb tense on the to_be variable, loads the MasterValue
  188. X  * username with "DEFAULT".
  189. X  */
  190. X  status = init_data_structures();
  191. X  SIGNAL(status);
  192. X
  193. X /*
  194. X  * Set the ItemList pointers at the MasterAddress, so that
  195. X  * we can store the DEFAULT account values as our preliminary
  196. X  * best guess (we'll check with command line values later).
  197. X  * Then call $GETUAI to read the DEFAULT account values.
  198. X  * Be careful if there is no DEFAULT account!!
  199. X  */
  200. X
  201. X status = init_ItemList( &ItemList, &MasterAddress );`09   `09/* Initialize
  202. V the itemlist pointers so that they point to the */
  203. X SIGNAL(status);`09`09`09`09`09   `09/*  MasterAddress locations.  We will s
  204. Vtore the DEFAULT account */
  205. X`09`09`09`09`09`09`09   `09/*  PQL values here first. */
  206. X status = sys$getuai(0, 0, &Master_d, &ItemList, 0, 0, 0 );`09/* call $GETUA
  207. VI to obtain the default uaf values */
  208. X if ( status == RMS$_RNF )
  209. X `7B`09`09`09`09`09`09`09`09/* no DEFAULT account record!!  We'd better be c
  210. Vareful here. */
  211. X    lib$signal(pql_nodfltacct);`09`09`09`09`09/* Signal this error. */
  212. X    for( i = 0; i < MAX_PARAMS; i++ )`09`09`09`09/* Reset any command line e
  213. Vntries that were planning on */
  214. X    `7B`09`09`09`09`09`09`09`09/*  using DEFAULT account values -- we CAN'T
  215. V USE THEM!! */
  216. X`09if ( Info`5Bi`5D.cmdval == NOT_DEFINED )
  217. X`09  Info`5Bi`5D.shallwe = FALSE;
  218. X    `7D
  219. X `7D
  220. X else
  221. X    SIGNAL(status);
  222. X
  223. X /*
  224. X  * Now check: do we really have anything to do?
  225. X  * There are certainly combinations of input parameters
  226. X  * which would imply that we will not change anything nor
  227. X  * display anything -- so why go through all the bother
  228. X  * for nothing?!
  229. X  */
  230. X if ( we_are_lazy() )`09`09`09`09`09`09/* do we have anything to do? */
  231. X `7B`09`09`09`09`09`09`09`09/* if not, why bother wasting all this CPU time?
  232. V */
  233. X     lib$signal(pql_nop);`09`09`09`09`09/* signal that this was a no-op */
  234. X     exit_status = pql_nodfltacct;`09`09`09`09/* set this as the exit status
  235. V */
  236. X     exit(exit_status `7C shutup);
  237. X `7D
  238. X
  239. X /*
  240. X  * Set the Master values which will be used as minimum quotas.
  241. X  * This will be either the value entered on the command line,
  242. X  * e.g., /ASTLM=100, or the value from the DEFAULT account if
  243. X  * no value was specified on the command line, e.g., /ASTLM.
  244. X  */
  245. X status = set_MasterValue( &MasterAddress );
  246. X SIGNAL(status);
  247. X
  248. X
  249. X /*
  250. X  * Prepare the SYSUAF file for reading, record by record, to get
  251. X  * the list of usernames on this system.
  252. X  * This will also perform a sanity check to make sure that our record
  253. X  * parameters still match the VMS SYSUAF format parameters (at least,
  254. X  * as far as the USERNAME goes).  After all, the format of this file
  255. X  * may change -- let's see if we can figure that out.
  256. X  */
  257. X  status = open_sysuaf();
  258. X  SIGNAL(status);
  259. X
  260. X/*
  261. X * And now we are ready to go.  Loop through each and every username,
  262. X * and make sure that their pql values meet the minimums specified
  263. X * in the MasterValues.
  264. X * Point the ItemList at the UserAddress/UserValue array and then`20
  265. X * we're off!
  266. X */
  267. X status = init_ItemList( &ItemList, &UserAddress );
  268. X SIGNAL(status);
  269. X
  270. X/*
  271. X * And set up the loop.
  272. X */
  273. X while (  (status = get_nextuser( &UserValue.username )) != RMS$_EOF )
  274. X `7B
  275. X#   ifdef DEBUG
  276. X      printf("\n\nnext username = >%s<", UserValue.username );
  277. X#   endif
  278. X
  279. X    SIGNAL(status);
  280. X    User_d.dsc$w_length = strlen( UserValue.username );`09`09/* set up the s
  281. Vtring descriptor for the $GETUAI call. */
  282. X
  283. X    status = sys$getuai(0, 0, &User_d, &ItemList, 0, 0, 0);`09/* get this us
  284. Ver's pql values. */
  285. X    SIGNAL(status);
  286. X
  287. X    if ( include_this_user(UserValue.username, UserValue.uic) )`09/* should
  288. V this username be INCLUDED? or EXCLUDED? */
  289. X    `7B
  290. X
  291. X  `20
  292. X#      ifdef DEBUG`09`09`09`09`09`09/* if we're debugging, let's see the val
  293. Vues in SYSUAF */
  294. X       `7B
  295. X         printf("\nBEFORE set_UserValue:");
  296. X         DISPLAY_by_addr(&UserAddress);
  297. X       `7D
  298. X#      endif
  299. X   `20
  300. X
  301. X       status = set_UserValue( &UserAddress, &MasterAddress );`09/* make sur
  302. Ve this user meets the minimums! */
  303. X       SIGNAL(status);
  304. X
  305. X  `20
  306. X#      ifdef DEBUG`09`09`09`09`09`09/* and let's see what was modified. */
  307. X       `7B
  308. X`09   printf("\nAFTER set_UserValue:");
  309. X`09   DISPLAY_by_addr(&UserAddress);
  310. X       `7D
  311. X#      endif
  312. X
  313. X      /*
  314. X       * If we are NOT modifying, then we're done; the logging
  315. X       * was already accomplished during the set_UserValue phase.
  316. X       * If we ARE modifying, then make the $SETUAI call now:
  317. X       */
  318. X       if ( modify )
  319. X       `7B
  320. X`09   UAF_got_it = TRUE;
  321. X`09   status = sys$setuai(0, 0, &User_d, &ItemList, 0, 0, 0);
  322. X`09   SIGNAL(status);
  323. X       `7D
  324. X    `7D`09`09`09`09`09`09`09`09/* end of loop for DO-THIS-USER. */
  325. X    else
  326. X    `7B
  327. X#      ifdef DEBUG
  328. X`09 printf("\nEXCLUDING username >%s<",UserValue.username);
  329. X#      endif
  330. X    `7D
  331. X
  332. X `7D `09`09`09`09`09`09`09`09/* end of (while) loop */
  333. X
  334. X /*
  335. X  * Close the SYSUAF file.
  336. X  */
  337. X status = sys$close( &uaffab );
  338. X SIGNAL(status);
  339. X
  340. X /*
  341. X  * If we didn't modify anything, remind everybody
  342. X  * that we left our filthy paws off.  Otherwise,
  343. X  * remind them that we were there!
  344. X  */
  345. X if ( UAF_wants_modification && UAF_got_it )
  346. X `7B
  347. X   lib$signal(pql_uafchanged);
  348. X `7D
  349. X else
  350. X `7B `20
  351. X   lib$signal(pql_nochanges);
  352. X `7D
  353. X
  354. X /*
  355. X  * Exit SILENTLY by turning on bit 28.  (We already issued the
  356. X  * appropriate exit messages somewhere else).
  357. X  */
  358. X exit(exit_status `7C shutup);
  359. X`7D
  360. X`0C
  361. X
  362. X/****************************************************
  363. X * Function to obtain the command line and parse for*
  364. X * the parameters entered by the user.              *
  365. X ****************************************************/
  366. X
  367. Xlong parse_cmdline()
  368. X`7B
  369. X extern int LIB$GET_FOREIGN();`09`09`09/* obtain command line */
  370. X extern int CLI$DCL_PARSE();`09`09`09/* check to make sure it is legal */
  371. X extern int CLI$PRESENT();`09`09`09/* check if qualifier/parameter is presen
  372. Vt */
  373. X extern int CLI$GET_VALUE();`09`09`09/* get value of qualifier= or paremeter
  374. V */
  375. X extern int LIB$GET_INPUT();`09`09`09/* prompt for missing parameters/qualif
  376. Viers */
  377. X extern int SETPQL_CLD();`09`09`09/* command definition module */
  378. X
  379. X long status;`09`09`09`09`09/* test status return values */
  380. X char string`5BNAM$C_MAXRSS - 7 + 1`5D;`09`09/* put together the qualifiers/
  381. Vparameters entered on the command line */
  382. X char full_cmd`5BNAM$C_MAXRSS + 1`5D;`09`09/* and add the command verb itsel
  383. Vf */
  384. X $DESCRIPTOR(string_d, string);`09`09`09/* of course, VMS needs these in des
  385. Vcriptor format */
  386. X $DESCRIPTOR(full_cmd_d, full_cmd);
  387. X char verb`5B`5D = "SETPQL ";`09`09`09/* defined in the SETPQL_CLD module */
  388. X short len;`09`09`09`09`09/* cli routines return the number of characters wr
  389. Vitten, we need to null-terminate*/
  390. X short i;
  391. X short do_all;`09`09`09`09`09/* is /ALL on the command line? */
  392. X long dummy;
  393. X
  394. X char qualifier`5BNAM$C_MAXRSS + 1`5D = " ";`09/* set up for looping on the
  395. +-+-+-+-+-+-+-+-  END  OF PART 3 +-+-+-+-+-+-+-+-
  396.  
  397.