It is currently Wed, 20 Aug 2014 03:41:28 GMT



 
Author Message
 ODM programming help needed
Hello,

I have written a small program that periodically checks a host for
various vulnerabilities. I need one of the modules for this program to
verify that certain fixes have been installed. I figure the best way
to do this is to consult the ODM. Specifically, the
/usr/lib/objrepos/fix file. The problem is: I cannot locate the
structures describing the contents of this file, so there's no way to
access it via the odm_get_* subroutines (since I don't know what to
pass as the ReturnData parameter).

odmget can successfully query this repository, so I know it's possible
to query a file without prior knowledge of its structure. Does anyone
out there know how to do that? Would you please tell me?

Thanks for any help!!
Martin McGreal



 Sat, 04 Jun 2005 23:31:14 GMT   
 ODM programming help needed
query the class product

odmshow product for structure



 Sun, 05 Jun 2005 01:04:26 GMT   
 ODM programming help needed
Holger van Koll <hol...@vankoll.de> wrote in message <news:3DFF591A.9040904@vankoll.de>...

Indeed, that was the answer to the first part of my question. However,
the second part is a little trickier: you need to examine the type of
value for each attribute-value pair in the element. And how to get the
data for those values is even more obscure! I finally tracked down
this usenet message which enlightened me completely:

http://groups.google.com/groups?q=ODM_VCHAR+group:comp.unix.aix&hl=en...

If you can't read the link, here's the example code from the posting,
which is all you need (originally posted by Lucien Van Elsen, MIT
Athena Systems Devlopment):

-------------------------------------------------------------

#include <stdio.h>
#include <odmi.h>

/* this structure generated by `odmshow CuAt` */
struct CuAt {
        char name[16];                               /* offset: 0xc (
12) */
        char attribute[16];                          /* offset: 0x1c (
28) */
        char value[256];                             /* offset: 0x2c (
44) */
        char type[8];                                /* offset: 0x12c
( 300)*/
        char generic[8];                             /* offset: 0x134
( 308)*/
        char rep[8];                                 /* offset: 0x13c
( 316)*/
        short nls_index;                             /* offset: 0x144
( 324)*/
        };
/*
v        columns:        7
        structsize:     0x148 (328) bytes
        data offset:    0x298
*/

char *query="name='sys0' and attribute='realmem'";

void handle_odm_err();
void print_odm_val();

main()
{
  struct Class *cp;
  char *obj; /* pointer to object */
  int i;

  if (odm_initialize() == -1) {
    handle_odm_err("initializing ODM");
    exit(odmerrno);
  }

  cp = odm_mount_class("CuAt");
  if (cp == -1) {
    handle_odm_err("mounting CuAt class");
    exit(odmerrno);
  }

  obj = (char *) odm_get_obj(cp,query,NULL,ODM_FIRST);
  /* now, print the first field (attribute) along with the second
(value) */
  print_odm_val(cp,obj,1);
  print_odm_val(cp,obj,2);

void print_odm_val(cp,obj,field)
     struct Class *cp;
     char *obj;
     int field;
{

  switch((cp->elem)[field].type) {
  case ODM_CHAR:
  case ODM_LONGCHAR:
    printf("%s\n",(char *)(obj + (cp->elem)[field].offset));
    break;
  case ODM_SHORT:
    printf("%d\n",*(short *)(obj + (cp->elem)[field].offset));
    break;
  case ODM_LONG:
    printf("%ld\n",*(long *)(obj + (cp->elem)[field].offset));
    break;
  case ODM_DOUBLE:
    printf("%g\n",*(double *)(obj + (cp->elem)[field].offset));
    break;
/*
  etc...
  case ODM_BINARY:
  case ODM_LINK:
  case ODM_METHOD:
  case ODM_VCHAR:
 */
  } return;

void handle_odm_err(char *msg)
{
  char *error_message;

  if (odm_err_msg(odmerrno, &error_message) < 0)
    fprintf(stderr,"Unknown error %d: %s\n",odmerrno,msg);
  else
    fprintf(stderr,"%s: %s",msg,error_message);

----------------------------------------------------------



 Mon, 06 Jun 2005 04:14:16 GMT   
 
   [ 3 post ] 

Similar Threads

1. ODM class sm_cmd_hdr and others....how do I get them in the ODM

2. need replacement for odme (ODM edit eliminated from rel 4.2 of AIX)

3. NEED HELP WITH PROGRAMMING POP3 MAIL PROGRAM TO RETRIEVE MAIL ON UNIX-TO-UNIX

4. Help for script with programs controlling other programs needed

5. Help: Need Pearl Programming Help

6. Help Rebuilding Kernel and ODM after Cloning

7. Help with ODM and Ethernet adapter definition

8. help: ODM error

9. Help with ODM routines

10. Help with chcons and ODM database


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software