Man Linux: Main Page and Category List

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)  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)