The get_attrib arguments are as follows:
10 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.
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\en"); exit(1); } else { sprintf(cmd, "runcmd %s mount /dev/dsk/qtest3 /qtest3", string); printf("Command = %s\en",cmd); } if ((string = get_attrib("mount", NULL, NULL, NULL, GA_BOTH_OFF))==(char *)NULL) { printf("get_attrib() failed\en"); exit(1); } else { sprintf(cmd, "runcmd %s mount /dev/dsk/qtest3 /qtest3", string); printf("Command = %s\en",cmd); } } .ni 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.ERRORSIf 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)