PROCEDURE rap$change_config_file_access (
  configuration_file_access, cfa: boolean = $required
  family_name, fn: name = $required
  user_name, un: name = $required
  status)

*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"
"  Creates the catalogs $SYSTEM.SITE_OS_MAINTENANCE and
"$SYSTEM.SITE_OS_MAINTENANCE.DEADSTART_COMMANDS.
"
"  This procedure changes access for the user_name to the catalogs
"$SYSTEM.MAINFRAME.CONFIGURATION and $SYSTEM.SITE_OS_MAINTENANCE.

"  The configuration_file_access parameter allows
"these permissions to either be turned on or off.
"
*IFEND


  "$FORMAT=OFF
  VAR
    command_file: file = $unique($local)
    ignore_status: status
    local_status: status
  VAREND
  "$FORMAT=ON"


  IF NOT $job(system) THEN
    text = 'CHANGE_CONFIG_FILE_ACCESS' // $char(31) // 'except from the console'
    EXIT_PROC WITH $status(false, 'RA', rae$illegal_command_call, text)
  IFEND


COLLECT_TEXT o=command_file until='**'
  IF configuration_file_access THEN
    $system.create_file_permit $system.mainframe.configuration g=user fn=family_name u=user_name ..
          am=read
    $system.create_catalog $system.site_os_maintenance status=ignore_status
    $system.create_catalog $system.site_os_maintenance.deadstart_commands status=ignore_status
    $system.create_catalog_permit $system.site_os_maintenance ..
      g=user fn=family_name u=user_name am=(all cycle control)
  ELSE
    $system.delete_file_permit $system.mainframe.configuration g=user fn=family_name u=user_name
    $system.delete_catalog_permit $system.site_os_maintenance.deadstart_commands ..
      g=user fn=family_name u=user_name
  IFEND
**

  $system.include_file f=command_file status=local_status
  $system.delete_file f=command_file status=ignore_status

  EXIT procedure WITH local_status WHEN NOT local_status.normal

PROCEND rap$change_config_file_access

