---
name: "get_attrib"
section: "3"
platform: "linux"
package: "ltp-dev"
version: "20091231+dfsg-1"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/get_attrib"
---

# get\_attrib(3)

Returns needed attributes to execute a command successfully on any system.

## NAME

**get\_attrib** - Returns needed attributes to execute a command successfully on any system.

## SYNOPSIS

**#include "get\_attrib.h"**

**char \*get\_attrib (char \****command\_name***, char \****permits***, char \****active\_categories***, char \****authorized\_categories***, long** *flag*);

## DESCRIPTION

The **get\_attributes** routine is designed to determine the system type currently running and return the needed **[runcmd(1)](/runcmd/1.md)** string to run the command specified successfully on any 7.0 and above systems.  On systems with TFM configured 'ON' some commands need special attributes that can't be determined easily, this routine then uses an internal table to return the needed attributes to run the command.  On other system types the needed attributes are easily determined without use of this table.

The **get\_attrib** arguments are as follows:

- *command\_name*

  Pointer to the command the attributes are to be returned about.

- *permits*

  Pointer to either an octal or name string of permits to be added to string returned.

- *active\_category*

  Pointer to either an octal or name string of active categories to be added to string returned.

- *authorized\_categories*

  Pointer to either an octal or name string of categories to be added to string returned.

- *flag*

  Long set to any combination of values defined in get\_attrib.h.  These values are used to specify that the string returned should be for the specified system type.

  	**GA\_BOTH\_OFF**   	PRIV\_SU and PRIV\_TFM off.

  	**GA\_SU\_ON**      	PRIV\_SU on.

  	**GA\_TFM\_ON**     	PRIV\_TFM on.

  	**GA\_BOTH\_ON**    	PRIV\_SU and PRIV\_TFM on.

  	**GA\_CURRENT\_SYS**	Current system type.

## EXAMPLE

The following example shows how **get\_attrib** can be used to determine the needed attributes to run a command successfully:

```
#include <stdio.h>
#include "get_attrib.h"
main()
{
 char cmd[256];
 char *string;
 if ((string =
      get_attrib("mount",NULL,NULL,NULL,GA_CURRENT_SYS)) == (char *)NULL) {
    printf("get_attrib() failed\n");
    exit(1);
 } else {
    sprintf(cmd, "runcmd %s mount /dev/dsk/qtest3 /qtest3", string);
    printf("Command = %s\n",cmd);
 }
 if ((string =
      get_attrib("mount", NULL, NULL, NULL, GA_BOTH_OFF))==(char *)NULL) {
    printf("get_attrib() failed\n");
    exit(1);
 } else {
    sprintf(cmd, "runcmd %s mount /dev/dsk/qtest3 /qtest3", string);
    printf("Command = %s\n",cmd);
 }
}
On an MLS system with PRIV_SU ON the first sprintf would return,
runcmd -u root mount /dev/dsk/qtest3 /qtest3.
On the same system the second sprintf would return, runcmd -J secadm -j
secadm  mount /dev/dsk/qtest3 /qtest3  Which is as if PRIV_TFM and PRIV_SU
were OFF.
```

## RETURN VALUE

If **get\_attrib()** completes successfully, a pointer to a string containing the options of the runcmd string is returned; otherwise NULL is returned.

## ERRORS

If **get\_attrib()** has problems, an error message will be put in GA\_Err\_Msg and NULL will be returned.

## SEE ALSO

**get\_attrib**(1)

[**runcmd**(1)](/runcmd/1.md)
