getgrnam (BPX1GGN, BPX4GGN) — Access the group database by name

Function

The getgrnam callable service gets information about a group and its members. You specify the group by name.

Requirements

Operation Environment
Authorization: Supervisor state or problem state, any PSW key
Dispatchable unit mode: Task
Cross memory mode: PASN = HASN
AMODE (BPX1GGN): 31-bit
AMODE (BPX4GGN): 64-bit
ASC mode: Primary mode
Interrupt status: Enabled for interrupts
Locks: Unlocked
Control parameters: All parameters must be addressable by the caller and in the primary address space.

Format

CALL BPX1GGN,(Group_name_length,
              Group_name,
              Return_value,
              Return_code,
              Reason_code)

AMODE 64 callers use BPX4GGN with the same parameters. The address returned is a fullword (below the bar).

Parameters

Group_name_length
Supplied parameter
Type:
Integer
Length:
Fullword

The name of a fullword that contains the length of Group_name.

Group_name
Supplied parameter
Type:
Character string
Character set:
No restriction
Length:
Specified by the Group_name_length parameter

The name of the field that contains the name of the group you want information about.

Return_value
Returned parameter
Type:
Address
Length:
Fullword

The name of a fullword where the getgrnam service returns an address, or 0. If no entry for the specified group name is found, or no GID is specified, Return_value is set to 0. If an entry is found, Return_value is set to the address of the BPXYGIDS macro structure. The first area contains the fullword length of the group name followed by the group name padded with blanks.

If an entry is found and function code ThliEP_GidNameSet was set in ThliEP_FunctionCode prior to making this call, then Return_value is set to the address of the area in the BPXYTHLI where the GID is set, as per the BPXYGIDS macro.

The address returned is 31 bits for both AMODE 31 and AMODE 64 callers. See BPXYGIDS — Map data returned for getgrnam and getgrpid.

Return_code
Returned parameter
Type:
Integer
Length:
Fullword
The name of a fullword in which the getgrnam service stores the return code. The getgrnam service returns Return_code only if Return_value is 0. See z/OS UNIX System Services Messages and Codes for a complete list of possible return code values. The getgrnam service can return one of the following values in the Return_code parameter:
Return_code Explanation
EINVAL Group name length is not valid.
EMVSSAFEXTRERR The system authorization facility (SAF) RACROUTE EXTRACT service had an error.
EMVSSAF2ERR The SAF Get GMAP service had an error.
Reason_code
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword where the getgrnam service stores the reason code. The getgrnam service returns Reason_code only if Return_value is 0. Reason_code further qualifies the Return_code value. For the reason codes, see z/OS UNIX System Services Messages and Codes. The reason code in the case of EMVSSAF2ERR or EMVSSAFEXTRERR contains the RACF® return and reason codes, respectively, in the two low-order bytes.

For a more detailed description of the RACF Get GMAP service return and reason code values, see the following table:
RACF Return Code RACF Reason Code Explanation
8 4 If the search is by GID: the GID is not defined. If the search is by group name: The current group is not defined.
8 8 The group name is not defined.
8 12 There was an internal error during RACF processing.
8 16 Recovery could not be established.
8 20 The current group is incompletely defined.

Usage notes

  1. The return values point to data that can change or go away after the next getgrgid, getgrnam, or getgrent call from that task. Each task manages its own storage separately. Move data to your own dynamic storage if you need it for future reference.
  2. The storage is key 0 nonfetch-protected storage that is managed by z/OS UNIX.
  3. You can request to have just the GID of the specified group name returned without any information about the other group members. This will improve performance because just one group name look-up is done. To request this function, set the ThliEP_FunctionCode field with function code ThliEP_GIDNameSet prior to issuing the syscall. On successful return, the following values are set:
    • ThliEP_GIDNameLen is set to the length of the returned group name; valid values are 1-8.
    • ThliEP_GIDName is set to the specified group name.
    • ThliEP_GIDLen is always set to 4, the length of a GID.
    • ThliEP_GID is the GID associated with the input group name.
    • ThliEP_GroupCount is always set to 0.

    Return_value is set to the output area. This is mapped by both the ThliExtendedGIDName structure in BPXYTHLI — Thread-level information, and by BPXYGIDS — Map data returned for getgrnam and getgrpid. If no entry for the specified group ID is found, Return_value is set to 0.

    The ThliEP_FunctionCode is cleared prior to returning to the caller; so, the invoker will need to set the ThliEp_FunctionCode before each invocation of the BPX1GGI/BPX4GGI service if the ThliEP_GIDNameSet function is to be used.

Related services

Characteristics and restrictions

There are no restrictions on the use of the getgrnam service.

Examples

For an example using this callable service, see BPX1GGN (getgrnam) example.