SNMP Subagent Programmer's Guide
Security Checker
2-88 119728—SNMP Subagent Programmer’s Guide
Programming Tutorials
/*************************************************************************
*
* main - hello-world security demo main program.
*
* Calling Sequence:
* status = main(argc, argv);
*
* Inputs:
* argc = number of command line tokens
* argv -> list of addresses of command line tokens
* global helloText anchors the current message for display
* global helloPrintFreq = interval (in seconds)
*
* Outputs:
* returns error status on completion, 0 for normal termination
*
* Notes:
* In most environments, there is actually little benefit
* to doing an orderly shutdown, since the agent knows how
* to deal with the broken pipe that results if a sub-agent
* abruptly exits.
*
************************************************************************/
int main(int argc, char *argv[])
{
short count_xferd = 0;
/*
* handles to the management environment and our group
*/
void *mgmt_hello_handle = NULL;
/*
* detect configuration changes
*/
INTEGER last_freq = helloPrintFreq;
/*
* mgmt_read_nowait stuff
*/
short agent_fileno, event_fileno,
status, error;
/*
* Make sure we were properly invoked
*/
if (argc != 3)
{
(void) fprintf(stderr,
"Usage: run %s $<agent> <password>\n", argv[0]);
return(2);
}
/* store password argument in a global so that authenticate()
function (called from the access functions) can get to it. */
strcpy(password, argv[2]); <-
-4
Example 2-18. Security Checker Main Program (page 2 of 5)