(PYVMS LOGO) Python on OpenVMS

(go to: table of contents, index, list of vms_sys, prev: GETUTC, next: HIBER)


GRANTID - Grant Identifier to Process


Adds the specified identifier record to the rights list of the process or the system.

Format:

    setflg, targpid, id, prvatr = vms_sys.grantid \
                          ([pidadr] [,prcnam] [,id] [,name])
Returns:
setflg
The system service returns SS$_WASSET or SS$_WASCLR to indicate if the rightslist did or did not contain the identifier before. The Python function does not return the status code - it returns 0 if the identifier did not exist in the rightslist before and returns 1 if it did. Any other code returned from the system service results in a Python exception.
targpid
Process identification of process to be affected. A value of -1 indicates the system rights list.
The targed PID (targpid) is always returned - it is as if you have specified a '0' value for the 'pidadr' argument. If an error happens, then vms_sys.grantid() raises a Python exception.
id
Identifier and attributes which have been granted. These are even returned when the programmer specifies 'None' as argument 3.
The Python function returns a tuple of 2 integers - not a quadword represented by a Python long integer. The first element contains the binary identifier code. The second element contains the attributes. Bitmask values for these attributes are defined in module 'vms_kgbdef'.
prvatr
Previous attributes of the identifier if it was previously present in the rights list.
Arguments:
pidadr
Process identification of process to be affected.
prcnam
Process name of process to be affected.
id
Identifier and attributes to be granted.
The Python function only accepts a tuple of 2 integers - not a quadword represented by a Python long integer. The first element contains the binary identifier code. The second element contains the attributes. Bitmask values for these attributes are defined in module 'vms_kgbdef'.
name
Name of the identifier to be granted - this is a string.
Examples:
$ show process /rights

 2-SEP-1998 21:20:58.18   User: ZESSIN       Process ID:   0000005B
                          Node: HERE         Process name: "ZESSIN_FTA9"

Process rights:
 INTERACTIVE
 LOCAL

System rights:
 SYS$NODE_HERE
$

>>> import vms_sys
>>> import vms_kgbdef

>>> pid  = 91
>>> id   = 0x80010011    # ID_1
>>> attr = vms_kgbdef.KGB_M_RESOURCE

>>> # show grant by ID (process identification and binary identifier)
>>> vms_sys.grantid (pid, None, (id,attr), None)
(0, 91, (-2147418095, 1), 0)
>>> print vms_kgbdef.KGB_M_RESOURCE
1
>>>

$ show process /rights

 2-SEP-1998 21:33:41.94   User: ZESSIN       Process ID:   0000005B
                          Node: HERE         Process name: "ZESSIN_FTA9"

Process rights:
 INTERACTIVE
 LOCAL
 ID_1                              resource     <--

System rights:
 SYS$NODE_HERE
$


>>> # show grant by name (process name and identifier name)
>>> vms_sys.grantid (None, 'ZESSIN_FTA9', None, 'ID_2')
(0, 91, (-2147418094, 2), 0)
>>> id = -2147418094 # check
>>> namlen, nambuf, resid, attrib, id_ctx = vms_sys.idtoasc (id,0)
>>> nambuf
'ID_2'
>>>

$ show process /rights

 2-SEP-1998 21:43:26.73   User: ZESSIN       Process ID:   0000005B
                          Node: HERE         Process name: "ZESSIN_FTA9"

Process rights:
 INTERACTIVE
 LOCAL
 ID_1                              resource
 ID_2                              dynamic      <--

System rights:
 SYS$NODE_HERE
$


>>> # put an identifier into the system rights list
>>> #  -- requires SYSNAM privilege
>>> id   = 0x80010011    # ID_1
>>> attr = vms_kgbdef.KGB_M_RESOURCE
>>> vms_sys.grantid (-1, None, (id,attr), None)
Traceback (innermost last):
  File "<stdin>", line 1, in ?
vms_sys.error: (10260, '%SYSTEM-F-NOSYSNAM, operation requires SYSNAM \
  privilege')
[...]
>>> vms_sys.grantid (-1, None, (id,attr), None)
(0, -1, (-2147418095, 1), 0)
>>> 

>>> attr = attr + vms_kgbdef.KGB_M_DYNAMIC
>>> vms_sys.grantid (-1, None, (id,attr), None)
(1, -1, (-2147418095, 3), 1)
 |  |    |            |   |- old attributes (KGB_M_RESOURCE)
 |  |    |            |----- current attributes
 |  |    |------------------ identifier value
 |  |----------------------- PID, -1 = system rights list
 |-------------------------- setflg = 1 -- identifier was already
                                           in the system rights list
>>> 

$ show process /rights

 2-SEP-1998 21:46:06.84   User: ZESSIN         Process ID:   0000005B
                          Node: HERE           Process name: "ZESSIN_FTA9"

Process rights:
 INTERACTIVE
 LOCAL
 ID_1                              resource
 ID_2                              dynamic

System rights:
 SYS$NODE_HERE
 ID_1                              resource, dynamic     <--
$
@@ GRANTID - more examples
>>>

(go to: table of contents, index, list of vms_sys, prev: GETUTC, next: HIBER)

28-SEP-1998 ZE.