From: Matt Jacobs [mjacobs1@twcny.rr.com]
Sent: Sunday, May 07, 2000 3:50 PM
To: Info-VAX@Mvb.Saic.Com
Subject: Re: C routines to access sysuaf

Here's a quick hack I did two weeks ago.  It consists of two files, uafdmp.c
and uafdef.h.

The uafdef.h file on my system from does not quite match the structure of
the 7.1 sysuaf file I was accessing so I added offsets where necessary.

================================================
uafdmp.c

#include "uafdef.h"
#include <descrip.h>
#include <iodef.h>
#include <jpidef.h>
#include <libdef.h>
#include <rms.h>
#include <ssdef.h>
#include <starlet.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <uaidef.h>

#define TMP_SIZE            1000
#define PRINT_LINE_SIZE     5000
#define MAX_FILE_NAME_SIZE   256

int add_to_line (char *line, char *str);

main (int argc, char *argv[]) {
    struct FAB      fab;
    unsigned long   hash[2];
    int             i;
    int             j;
    FILE           *ofp;
    char            output_file_name[MAX_FILE_NAME_SIZE];
    char            print_line[PRINT_LINE_SIZE];
    struct RAB      rab;
    int             stat;
    struct XABSUM   sum;
    struct _uaf     uaf;
    char            usr_buf[31];
    struct XABKEY   xab;
    struct
     {short len;
      short code;
      int *bufadr;
      int *retlen;} UaiItem[2];

    $DESCRIPTOR(usr, usr_buf);

   /*
    * Check to see that both an input and an
    * output file spec have been entered.
    *-----------------------------------------*/
    if (argc != 3) {
        printf("\nUsage: uafdmp sysuaf_file dmp_file");
    }
    else {
        strcpy(output_file_name, argv[2]);

        fab = cc$rms_fab;
        sum = cc$rms_xabsum;
        fab.fab$b_shr = FAB$M_SHRPUT;
        fab.fab$b_fac = FAB$M_GET;
        fab.fab$l_xab = (char *) &sum;
        fab.fab$l_fna = argv[1];
        fab.fab$b_fns = strlen( argv[1] );

        rab = cc$rms_rab;
        rab.rab$l_fab = &fab;
        rab.rab$b_rac = RAB$C_SEQ;
        rab.rab$l_rop = RAB$M_NXT;
        rab.rab$b_krf = 0;
        rab.rab$l_ubf = (char *) &uaf;
        rab.rab$w_usz = UAF$C_LENGTH;

        ofp = fopen(output_file_name, "w+");

        if (ofp == NULL) {
            printf("\nError: dmp_file file open error.");
            printf("\nUsage: uafdmp sysuaf_file dmp_file");
        }
        else {
            stat = sys$open(&fab);
            if (stat != RMS$_NORMAL) {
                printf("\nError: sysuaf_file sys$open error.");
            }
            else {
                stat = sys$connect(&rab);
                if (stat != RMS$_NORMAL) {
                    printf("\nError: sysuaf_file sys$connect error.");
                }
                else {
                    stat = sys$get(&rab);
                    j = 0;
                    while  (stat == RMS$_NORMAL)  {
                        j++;
                        if  (j != 1)   {
                            for (i=0; i<PRINT_LINE_SIZE; i++){
                                print_line[i] = '\0';

                            sprintf(print_line, "%12.12s [%4.4o,%4.4o] ",
                                    uaf.uaf$t_username, uaf.uaf$w_grp,
uaf.uaf$w_mem);
                            add_to_line(print_line, uaf.uaf$t_owner     +
1);   /* offset added */
                            add_to_line(print_line,
af$t_account      );
                            add_to_line(print_line, uaf.uaf$t_defdev    +
1); /* offset added */
                            add_to_line(print_line, uaf.uaf$t_defdir    +
1);   /* offset added */
                            add_to_line(print_line, uaf.uaf$t_lgicmd    +
1); /* offset added */
                            add_to_line(print_line, uaf.uaf$t_defcli    +
1);   /* offset added */
                            fprintf(ofp,"%s\n",print_line);
                        }
                        stat = sys$get (&rab);
                    }
                }
            }
            stat = sys$close(&fab);
            fclose (ofp);
        }
    }
}
int add_to_line (char *line, char *str) {
    int i;
    char tmp1[TMP_SIZE];

    for (i=0; i<TMP_SIZE; i++){tmp1[i] = '\0';}
    i = 0;
    while ((str[i] >= ' ') && (str[i] <= '~')) {
        tmp1[i] = str[i];
        i++;
    }
    strcat(line, tmp1);
    return(i);
}

================================================
uafdef.h

/**/
/***************************************************************************
***/
/**
**/
/**  Copyright (c) 1996
**/
/**  by DIGITAL Equipment Corporation, Maynard, Mass.
**/
/**
**/
/**  This software is furnished under a license and may be used and  copied
**/
/**  only  in  accordance  with  the  terms  of  such  license and with the
**/
/**  inclusion of the above copyright notice.  This software or  any  other
**/
/**  copies  thereof may not be provided or otherwise made available to any
**/
/**  other person.  No title to and ownership of  the  software  is  hereby
**/
/**  transferred.
**/
/**
**/
/**  The information in this software is subject to change  without  notice
**/
/**  and  should  not  be  construed  as  a commitment by DIGITAL Equipment
**/
/**  Corporation.
**/
/**
**/
/**  DIGITAL assumes no responsibility for the use or  reliability  of  its
**/
/**  software on equipment which is not supplied by DIGITAL.
**/
/**
**/
/***************************************************************************
***/
/***************************************************************************
*****************************************************/
/* Created: 25-NOV-1996 18:18:55 by OpenVMS SDL EV1-52     */
/* Source:   2-MAR-1996 17:58:12 $64$DUA2130:[LIB_H.SRC]UAFDEF.SDL;1 */
/***************************************************************************
*****************************************************/
/*** MODULE $UAFDEF ***/
#ifndef __UAFDEF_LOADED
#define __UAFDEF_LOADED 1

#pragma __nostandard             /* This file uses non-ANSI-Standard
features */
#pragma __member_alignment __save
#pragma __nomember_alignment
#ifdef __INITIAL_POINTER_SIZE            /* Defined whenever ptr size
pragmas supported */
#pragma __required_pointer_size __save       /* Save the previously-defined
required ptr size */
#pragma __required_pointer_size __short      /* And set ptr size default to
32-bit pointers */
#endif

#ifdef __cplusplus
    extern "C" {
#define __unknown_params ...
#define __optional_params ...
#else
#define __unknown_params
#define __optional_params ...
#endif

#if !defined(__VAXC)
#define __struct struct
#define __union union
#else
#define __struct variant_struct
#define __union variant_union
#endif

/*++
*/
/* User authorization file format
*/
/* Note: With the exception of the username and account name,
*/
/* all strings are blank padded counted strings. Username and
*/
/* account name are uncounted, blank padded.
*/
/*--
*/
#define UAF$C_USER_ID 1                 /* main user ID record
*/
#define UAF$C_VERSION1 1                /* this version
*/
#define UAF$C_KEYED_PART 52             /* ISAM keys come this far
*/
#define UAF$C_MAX_PWD_LENGTH 32         /* maximum plaintext password length
*/
#define UAF$K_MAX_PWD_LENGTH 32         /* maximum plaintext password length
*/
#define UAF$C_AD_II 0                   /* AUTODIN-II 32 bit crc code
*/
#define UAF$C_PURDY 1                   /* Purdy polynomial over salted
input */
#define UAF$C_PURDY_V 2                 /* Purdy polynomial + variable
length username */
#define UAF$C_PURDY_S 3                 /* PURDY_V folded into password
length */
#define UAF$K_CURRENT_ALGORITHM 3       /* current DEC algorithm number
*/
#define UAF$C_CURRENT_ALGORITHM 3       /* current DEC algorithm number
*/
#define UAF$C_PREFERED_ALGORITHM 127
#define UAF$K_PREFERED_ALGORITHM 127
#define UAF$C_PREFERRED_ALGORITHM 127   /* preferred hash algorithm - use
current */
#define UAF$K_PREFERRED_ALGORITHM 127   /* preferred hash algorithm - use
current */
#define UAF$C_CUST_ALGORITHM 128        /* customer algorithm division
*/
#define UAF$K_CUST_ALGORITHM 128        /* customer algorithm division
*/
#define UAF$K_FIXED 644                 /* length of fixed portion
*/
#define UAF$C_FIXED 644                 /* length of fixed portion
*/
#define UAF$K_LENGTH 1412
#define UAF$C_LENGTH 1412
#define UAF$S_UAFDEF 1412               /* Old size name, synonym for
UAF$S_UAF */

typedef struct _uaf {
    unsigned char uaf$b_rtype;          /* UAF record type
*/
    unsigned char uaf$b_version;        /* UAF format version
*/
    unsigned short int uaf$w_usrdatoff; /* offset of counted string of user
data */
    __union  {
        char uaf$t_username [32];       /* username
*/
        __struct  {
            char uaf$t_fill_0 [31];
            char uaf$t_username_tag;    /* tag to differentiate records
*/
            } uaf$r_fill_1;
        } uaf$r_fill_0;
    __union  {
        unsigned int uaf$l_uic;         /* user ID code
*/
        __struct  {
            unsigned short int uaf$w_mem; /* member subfield
*/
            unsigned short int uaf$w_grp; /* group subfield
*/
            } uaf$r_fill_3;
        } uaf$r_fill_2;
    unsigned int uaf$l_sub_id;          /* user sub-identifier
*/
    unsigned __int64 uaf$q_parent_id;   /* identifier of owner of this
account */
    char uaf$t_account [32];            /* account name
*/
    char uaf$t_owner [32];              /* owner's name
*/
    char uaf$t_defdev [32];             /* default device
*/
    char uaf$t_defdir [64];             /* default directory
*/
    char uaf$t_lgicmd [64];             /* login command file
*/
    char uaf$t_defcli [32];             /* default command interpreter
*/
    char uaf$t_clitables [32];          /* user CLI tables
*/
    __union  {
        unsigned __int64 uaf$q_pwd;     /* hashed password
*/
        __struct  {
            unsigned int uaf$l_pwd;     /* 32 bit subfield
*/
            } uaf$r_fill_5;
        } uaf$r_fill_4;
    unsigned __int64 uaf$q_pwd2;        /* second password
*/
    unsigned short int uaf$w_logfails;  /* count of login failures
*/
    unsigned short int uaf$w_salt;      /* random password salt
*/
    unsigned char uaf$b_encrypt;        /* primary password hash algorithm
*/
/* known hash algorithm indices
*/
    unsigned char uaf$b_encrypt2;       /* secondary password hash algorithm
*/
    unsigned char uaf$b_pwd_length;     /* minimum password length
*/
    char uaf$$$_fill_1 [1];
    unsigned __int64 uaf$q_expiration;  /* expiration date for account
*/
    unsigned __int64 uaf$q_pwd_lifetime; /* password lifetime
*/
    unsigned __int64 uaf$q_pwd_date;    /* date of password change
*/
    unsigned __int64 uaf$q_pwd2_date;   /* date of 2nd password change
*/
    unsigned __int64 uaf$q_lastlogin_i; /* date of last interactive login
*/
    unsigned __int64 uaf$q_lastlogin_n; /* date of last non-interactive
login */
    unsigned __int64 uaf$q_priv;        /* process privilege vector
*/
    unsigned __int64 uaf$q_def_priv;    /* default process privileges
*/
    __struct  {                         /* minimum security class
*/
        char uaf$b_fill_2 [20];
        } uaf$r_min_class;
    __struct  {                         /* maximum security class
*/
        char uaf$b_fill_3 [20];
        } uaf$r_max_class;
    __union  {
        unsigned int uaf$l_flags;       /* user flags longword
*/
        __struct  {
            unsigned uaf$v_disctly : 1; /* no user control-y
*/
            unsigned uaf$v_defcli : 1;  /* only allow user default CLI
*/
            unsigned uaf$v_lockpwd : 1; /* disable SET PASSWORD command
*/
            unsigned uaf$v_restricted : 1; /* restricted account (pre-V5.2
CAPTIVE) */
            unsigned uaf$v_disacnt : 1; /* no interactive login
*/
            unsigned uaf$v_diswelcom : 1; /* skip welcome message
*/
            unsigned uaf$v_dismail : 1; /* skip new mail message
*/
            unsigned uaf$v_nomail : 1;  /* disable mail delivery
*/
            unsigned uaf$v_genpwd : 1;  /* passwords must be generated
*/
            unsigned uaf$v_pwd_expired : 1; /* password has expired
*/
            unsigned uaf$v_pwd2_expired : 1; /* 2nd password has expired
*/
            unsigned uaf$v_audit : 1;   /* audit all actions
*/
            unsigned uaf$v_disreport : 1; /* skip last login messages
*/
            unsigned uaf$v_disreconnect : 1; /* inhibit reconnections
*/
            unsigned uaf$v_autologin : 1; /* auto-login only
*/
            unsigned uaf$v_disforce_pwd_change : 1; /* disable forced
password change */
            unsigned uaf$v_captive : 1; /* captive account (no overrides)
*/
            unsigned uaf$v_disimage : 1; /* disable arbitrary image
activation */
            unsigned uaf$v_dispwddic : 1; /* disable password dictionary
search */
            unsigned uaf$v_dispwdhis : 1; /* disable password history search
*/
            unsigned uaf$v_defclsval : 1; /* default classification is valid
*/
            unsigned uaf$v_extauth : 1; /* external authentication enabled
*/
            unsigned uaf$v_migratepwd : 1; /* migrate UAF pwd to external
auth */
            unsigned uaf$v_fill_10 : 1;
            } uaf$r_fill_7;
        } uaf$r_fill_6;
    unsigned char uaf$b_network_access_p [3]; /* hourly network access,
primary */
    unsigned char uaf$b_network_access_s [3]; /* hourly network access,
secondary */
    unsigned char uaf$b_batch_access_p [3]; /* hourly batch access, primary
*/
    unsigned char uaf$b_batch_access_s [3]; /* hourly batch access,
secondary */
    unsigned char uaf$b_local_access_p [3]; /* hourly local access, primary
*/
    unsigned char uaf$b_local_access_s [3]; /* hourly local access,
secondary */
    unsigned char uaf$b_dialup_access_p [3]; /* hourly dialup access,
primary */
    unsigned char uaf$b_dialup_access_s [3]; /* hourly dialup access,
secondary */
    unsigned char uaf$b_remote_access_p [3]; /* hourly remote access,
primary */
    unsigned char uaf$b_remote_access_s [3]; /* hourly remote access,
secondary */
    char uaf$$$_fill_4 [12];            /* space for 2 more access types
*/
    __union  {
        unsigned char uaf$b_primedays;  /* bits representing primary days
*/
        __struct  {
            unsigned uaf$v_monday : 1;  /* bit clear means this is a primary
day */
            unsigned uaf$v_tuesday : 1; /* bit set means this is an off day
*/
            unsigned uaf$v_wednesday : 1;
            unsigned uaf$v_thursday : 1;
            unsigned uaf$v_friday : 1;
            unsigned uaf$v_saturday : 1;
            unsigned uaf$v_sunday : 1;
            unsigned uaf$v_fill_11 : 1;
            } uaf$r_fill_9;
        } uaf$r_fill_8;
    char uaf$$$_fill_5 [1];
    unsigned char uaf$b_pri;            /* base process priority
*/
    unsigned char uaf$b_quepri;         /* maximum job queuing priority
*/
    unsigned short int uaf$w_maxjobs;   /* maximum jobs for UIC allowed
*/
/* 0 means no limit
*/
    unsigned short int uaf$w_maxacctjobs; /* maximum jobs for account
allowed */
/* 0 means no limit
*/
    unsigned short int uaf$w_maxdetach; /* maximum detached processes for
UIC */
/* 0 means no limit
*/
    unsigned short int uaf$w_prccnt;    /* subprocess creation limit
*/
    unsigned short int uaf$w_biolm;     /* buffered I/O limit
*/
    unsigned short int uaf$w_diolm;     /* direct I/O limit
*/
    unsigned short int uaf$w_tqcnt;     /* timer queue entry limit
*/
    unsigned short int uaf$w_astlm;     /* AST queue limit
*/
    unsigned short int uaf$w_enqlm;     /* enqueue limit
*/
    unsigned short int uaf$w_fillm;     /* open file limit
*/
    unsigned short int uaf$w_shrfillm;  /* shared file limit
*/
    unsigned int uaf$l_wsquota;         /* working set size quota
*/
    unsigned int uaf$l_dfwscnt;         /* default working set size
*/
    unsigned int uaf$l_wsextent;        /* working set size limit
*/
    unsigned int uaf$l_pgflquota;       /* page file quota
*/
    unsigned int uaf$l_cputim;          /* CPU time quota
*/
    unsigned int uaf$l_bytlm;           /* buffered I/O byte count limit
*/
    unsigned int uaf$l_pbytlm;          /* paged buffer I/O byte count limit
*/
    unsigned int uaf$l_jtquota;         /* job-wide logical name table
creation quota */
    unsigned short int uaf$w_proxy_lim; /* number of proxies user can grant
*/
    unsigned short int uaf$w_proxies;   /* number of proxies granted
*/
    unsigned short int uaf$w_account_lim; /* number of sub-accounts allowed
*/
    unsigned short int uaf$w_accounts;  /* number of sub-accounts in use
*/
    __struct  {                         /* default security class
*/
        char uaf$b_fill_6 [20];
        } uaf$r_def_class;
    char uaf$$$_fill_99 [44];           /* spare space
*/
    char uaf$$$_fill_100 [768];         /* user-extensible area
*/
    } UAF;

#if !defined(__VAXC)
#define uaf$t_username uaf$r_fill_0.uaf$t_username
#define uaf$t_username_tag uaf$r_fill_0.uaf$r_fill_1.uaf$t_username_tag
#define uaf$l_uic uaf$r_fill_2.uaf$l_uic
#define uaf$w_mem uaf$r_fill_2.uaf$r_fill_3.uaf$w_mem
#define uaf$w_grp uaf$r_fill_2.uaf$r_fill_3.uaf$w_grp
#define uaf$q_pwd uaf$r_fill_4.uaf$q_pwd
#define uaf$l_pwd uaf$r_fill_4.uaf$r_fill_5.uaf$l_pwd
#define uaf$l_flags uaf$r_fill_6.uaf$l_flags
#define uaf$v_disctly uaf$r_fill_6.uaf$r_fill_7.uaf$v_disctly
#define uaf$v_defcli uaf$r_fill_6.uaf$r_fill_7.uaf$v_defcli
#define uaf$v_lockpwd uaf$r_fill_6.uaf$r_fill_7.uaf$v_lockpwd
#define uaf$v_restricted uaf$r_fill_6.uaf$r_fill_7.uaf$v_restricted
#define uaf$v_disacnt uaf$r_fill_6.uaf$r_fill_7.uaf$v_disacnt
#define uaf$v_diswelcom uaf$r_fill_6.uaf$r_fill_7.uaf$v_diswelcom
#define uaf$v_dismail uaf$r_fill_6.uaf$r_fill_7.uaf$v_dismail
#define uaf$v_nomail uaf$r_fill_6.uaf$r_fill_7.uaf$v_nomail
#define uaf$v_genpwd uaf$r_fill_6.uaf$r_fill_7.uaf$v_genpwd
#define uaf$v_pwd_expired uaf$r_fill_6.uaf$r_fill_7.uaf$v_pwd_expired
#define uaf$v_pwd2_expired uaf$r_fill_6.uaf$r_fill_7.uaf$v_pwd2_expired
#define uaf$v_audit uaf$r_fill_6.uaf$r_fill_7.uaf$v_audit
#define uaf$v_disreport uaf$r_fill_6.uaf$r_fill_7.uaf$v_disreport
#define uaf$v_disreconnect uaf$r_fill_6.uaf$r_fill_7.uaf$v_disreconnect
#define uaf$v_autologin uaf$r_fill_6.uaf$r_fill_7.uaf$v_autologin
#define uaf$v_disforce_pwd_change
uaf$r_fill_6.uaf$r_fill_7.uaf$v_disforce_pwd_change
#define uaf$v_captive uaf$r_fill_6.uaf$r_fill_7.uaf$v_captive
#define uaf$v_disimage uaf$r_fill_6.uaf$r_fill_7.uaf$v_disimage
#define uaf$v_dispwddic uaf$r_fill_6.uaf$r_fill_7.uaf$v_dispwddic
#define uaf$v_dispwdhis uaf$r_fill_6.uaf$r_fill_7.uaf$v_dispwdhis
#define uaf$v_defclsval uaf$r_fill_6.uaf$r_fill_7.uaf$v_defclsval
#define uaf$v_extauth uaf$r_fill_6.uaf$r_fill_7.uaf$v_extauth
#define uaf$v_migratepwd uaf$r_fill_6.uaf$r_fill_7.uaf$v_migratepwd
#define uaf$b_primedays uaf$r_fill_8.uaf$b_primedays
#define uaf$v_monday uaf$r_fill_8.uaf$r_fill_9.uaf$v_monday
#define uaf$v_tuesday uaf$r_fill_8.uaf$r_fill_9.uaf$v_tuesday
#define uaf$v_wednesday uaf$r_fill_8.uaf$r_fill_9.uaf$v_wednesday
#define uaf$v_thursday uaf$r_fill_8.uaf$r_fill_9.uaf$v_thursday
#define uaf$v_friday uaf$r_fill_8.uaf$r_fill_9.uaf$v_friday
#define uaf$v_saturday uaf$r_fill_8.uaf$r_fill_9.uaf$v_saturday
#define uaf$v_sunday uaf$r_fill_8.uaf$r_fill_9.uaf$v_sunday
#endif      /* #if !defined(__VAXC) */


#pragma __member_alignment __restore
#ifdef __INITIAL_POINTER_SIZE            /* Defined whenever ptr size
pragmas supported */
#pragma __required_pointer_size __restore        /* Restore the
previously-defined required ptr size */
#endif
#ifdef __cplusplus
    }
#endif
#pragma __standard

#endif /* __UAFDEF_LOADED */