Home | History | Annotate | Download | only in man3

$Id: get_attrib.3,v 1.1 2000/07/27 16:59:03 alaffin Exp $

Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.

This program is free software; you can redistribute it and/or modify it
under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation.

This program is distributed in the hope that it would be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Further, this software is distributed without any warranty that it is
free of the rightful claim of any third person regarding infringement
or the like. Any license provided herein, whether implied or
otherwise, applies only to this software file. Patent licenses, if
any, provided herein do not apply to combinations of this program with
other software, or any other product whatsoever.

You should have received a copy of the GNU General Public License along
with this program; if not, write the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
Mountain View, CA 94043, or:

http://www.sgi.com

For further information regarding this notice, see:

http://oss.sgi.com/projects/GenInfo/NoticeExplan/

GET_ATTRIB 3 07/25/2000 "Linux Test Project"
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:

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.

"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\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.
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)