Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

dumpuser.c File Reference

#include <os2.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <netcons.h>
#include <neterr.h>
#include <netlib.h>
#include <uascache.h>
#include <access.h>
#include <permit.h>
#include "ssitools.h"

Go to the source code of this file.

Classes

struct  my_group

Defines

#define SECPKG   "[Tmpv1_0]"
#define SERVOP   "D_SERVER "
#define ACCTOP   "D_ACCOUN "
#define COMMOP   "D_COMM_O "
#define PRINTOP   "D_PRINT_ "
#define DISKOP   "D_DISK_O "
#define AUDITOP   "D_AUDIT_ "
#define GADMINS   "D_ADMIN "
#define GUSERS   "D_USERS "
#define GGUESTS   "D_GUESTS "
#define INCL_DOSMEMMGR

Functions

void InitMemStuff (void)
void loadit (void)
void showentries (void)
void doargs (int, char **)
int UserHashVal (char far *uname, int domain) const
unsigned dread (unsigned handle, unsigned long pos, char far *buffer, unsigned length)
unsigned read_object (unsigned handle, unsigned long pos, char FAR *buf)
void printgroups ()
void banner (unsigned longnames)
 main (int argc, char *argv[])

Variables

char FAR * buf1
char FAR * buf2
char FAR * GroupCache
char path [256]
char userbuf [MAX_USER_SIZE]
unsigned short Handle
_ahdr FAR * Header


Define Documentation

#define ACCTOP   "D_ACCOUN "
 

Definition at line 18 of file dumpuser.c.

Referenced by banner(), and showentries().

#define AUDITOP   "D_AUDIT_ "
 

Definition at line 22 of file dumpuser.c.

Referenced by banner().

#define COMMOP   "D_COMM_O "
 

Definition at line 19 of file dumpuser.c.

Referenced by banner(), and showentries().

#define DISKOP   "D_DISK_O "
 

Definition at line 21 of file dumpuser.c.

Referenced by banner().

#define GADMINS   "D_ADMIN "
 

Definition at line 23 of file dumpuser.c.

Referenced by banner().

#define GGUESTS   "D_GUESTS "
 

Definition at line 25 of file dumpuser.c.

Referenced by banner().

#define GUSERS   "D_USERS "
 

Definition at line 24 of file dumpuser.c.

Referenced by banner().

#define INCL_DOSMEMMGR
 

Definition at line 29 of file dumpuser.c.

#define PRINTOP   "D_PRINT_ "
 

Definition at line 20 of file dumpuser.c.

Referenced by banner(), and showentries().

#define SECPKG   "[Tmpv1_0]"
 

Definition at line 4 of file dumpuser.c.

Referenced by banner().

#define SERVOP   "D_SERVER "
 

Definition at line 17 of file dumpuser.c.

Referenced by banner(), and showentries().


Function Documentation

void banner unsigned  longnames  ) 
 

Definition at line 284 of file dumpuser.c.

References ACCTOP, AUDITOP, COMMOP, DISKOP, GADMINS, GGUESTS, GUSERS, path, PRINTOP, SECPKG, and SERVOP.

Referenced by main().

00285 { 00286 00287 printf(SECPKG); 00288 printf("\n\n\t//\n\t// Account Setup information\n"); 00289 printf("\t// This file produced from the LAN Manager 2.0 UAS\n"); 00290 printf("\t// %s\n", path); 00291 00292 printf("\tGroup = 501 %s\n", GADMINS); 00293 printf("\tGroup = 502 %s\n", GUSERS); 00294 printf("\tGroup = 503 %s\n", GGUESTS); 00295 printf("\tGroup = 504 %s\n", ACCTOP); 00296 printf("\tGroup = 505 %s\n", SERVOP); 00297 printf("\tGroup = 506 %s\n", PRINTOP); 00298 printf("\tGroup = 507 %s\n", COMMOP); 00299 printf("\tGroup = 508 %s\n", DISKOP); 00300 printf("\tGroup = 509 %s\n", AUDITOP); 00301 }

void doargs int  ,
char ** 
 

Definition at line 303 of file dumpuser.c.

References exit, and path.

Referenced by main().

00304 { 00305 if (argc != 2 || *argv[1] == '?') { 00306 printf("usage: %s path\\net.acc\n", argv[0]); 00307 printf("\tlists all the users/groups and their hash/serial numbers for a UAS\n"); 00308 exit(0); 00309 } 00310 strcpy(path, argv[1]); 00311 }

unsigned dread unsigned  handle,
unsigned long  pos,
char far *  buffer,
unsigned  length
 

Definition at line 77 of file dumpuser.c.

Referenced by read_object().

00078 { 00079 unsigned short err, bread; 00080 unsigned long newpos; 00081 00082 err = DosChgFilePtr(handle, pos, FILE_BEGIN, &newpos); 00083 if (err) 00084 return err; 00085 if (newpos != pos) 00086 return NERR_ACFFileIOFail; 00087 err = DosRead( handle, buffer, length, &bread); 00088 if (err) 00089 return err; 00090 if (bread != length) 00091 return NERR_ACFFileIOFail; 00092 return 0; 00093 }

void InitMemStuff void   ) 
 

Definition at line 107 of file dumpuser.c.

References buf1, buf2, exit, GroupCache, Handle, Header, L, and path.

Referenced by main().

00108 { 00109 unsigned short err; 00110 unsigned short sel, action; 00111 00112 err = DosAllocSeg(0x8000, &sel, 0); 00113 if (err) { 00114 printf("Could not alloc memory, error %d\n", err); 00115 exit(1); 00116 } 00117 buf1 = MAKEP(sel, 0); 00118 err = DosAllocSeg(0x8000, &sel, 0); 00119 if (err) { 00120 printf("Could not alloc memory, error %d\n", err); 00121 exit(1); 00122 } 00123 buf2 = MAKEP(sel, 0); 00124 err = DosAllocSeg(1024, &sel, 0); 00125 if (err) { 00126 printf("Could not alloc memory, error %d\n", err); 00127 exit(1); 00128 } 00129 Header = MAKEP(sel, 0); 00130 if (err = DosAllocSeg(0x8000, &sel, 0)) { 00131 printf("Could not alloc memory, error %d\n", err); 00132 exit(1); 00133 } 00134 GroupCache = MAKEP(sel, 0); 00135 err = DosOpen(path, &Handle, &action, 0L, 0, FILE_OPEN, 00136 OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, 0L); 00137 if (err) { 00138 printf("Error opening %s, code %d\n", path, err); 00139 exit(1); 00140 } 00141 err = DosRead(Handle, Header, 512, &action); 00142 if (err || action != 512) { 00143 printf("Error reading from file, code %d\n", err); 00144 exit(1); 00145 } 00146 printf("Total users, %d\n", Header->num_users); 00147 }

void loadit void   ) 
 

Definition at line 149 of file dumpuser.c.

References buf1, buf2, exit, FAR, GroupCache, Handle, L, NULL, and UserHashVal().

Referenced by main().

00150 { 00151 unsigned short err; 00152 unsigned short action; 00153 unsigned short i; 00154 unsigned long pos; 00155 struct diskuserhash FAR *diskhashentry; 00156 struct userhash FAR *userhashentry; 00157 struct _grouprec FAR * grec; 00158 struct my_group FAR * mygroup; 00159 00160 err = DosChgFilePtr(Handle, 512L, FILE_BEGIN, &pos); 00161 err = DosRead(Handle, buf1, sizeof(struct _grouprec) * MAXGROUP, &action); 00162 if (err || action != sizeof(struct _grouprec) * MAXGROUP) { 00163 printf("Error reading from file, %d\n", err); 00164 exit(1); 00165 } 00166 mygroup = (struct my_group FAR *) GroupCache; 00167 grec = (struct _grouprec FAR *) buf1; 00168 for (i = 0; i < MAXGROUP ; i++, grec++, mygroup++ ) { 00169 if (grec->name[0] != REC_EMPTY && grec->name[0] != REC_DELETE) { 00170 /* if (strcmpf(grec->name, "ADMINS") == 0) { 00171 strcpyf(mygroup->name, GADMIN); 00172 else if (strcmpf(grec->name, "USERS") == 0) 00173 strcpyf(mygroup->name, GUSERS); 00174 else if (strcmpf(grec->name, "GUESTS") == 0) 00175 strcpyf(mygroup->name, GGUESTS); 00176 else */ 00177 strncpyf(mygroup->name, grec->name, GNLEN); 00178 mygroup->gid = UserHashVal(mygroup->name, MAXGROUP); 00179 mygroup->serial = grec->serial; 00180 } else 00181 mygroup->name[0] = '\0'; 00182 } 00183 00184 err = DosChgFilePtr(Handle, (unsigned long) HASH_TBL_OFFSET, FILE_BEGIN, &pos); 00185 diskhashentry = (struct diskuserhash FAR *) buf1; 00186 if (err = DosRead (Handle, diskhashentry, HASH_TBL_SIZE, &action)) { 00187 printf("Could not read hash table, error %d\n", err); 00188 exit(1); 00189 } 00190 00191 if (action != HASH_TBL_SIZE) { 00192 printf("Could not read hash table\n"); 00193 exit(1); 00194 } 00195 /* 00196 * Copy disk user hash table into memory 00197 */ 00198 userhashentry = (struct userhash FAR *) buf2; 00199 for (i = 0; i < USER_HASH_ENTRIES; i++) { 00200 userhashentry->uh_disk = diskhashentry->dh_disk; 00201 userhashentry->uh_serial = diskhashentry->dh_serial; 00202 userhashentry->uh_cache = NULL; 00203 userhashentry++; 00204 diskhashentry++; 00205 } 00206 }

main int  argc,
char *  argv[]
 

Definition at line 313 of file dumpuser.c.

References banner(), doargs(), InitMemStuff(), loadit(), printgroups(), and showentries().

00314 { 00315 printf(SIGNON); 00316 doargs(argc, argv); 00317 InitMemStuff(); 00318 loadit(); 00319 00320 banner(0); 00321 00322 printgroups(); 00323 showentries(); 00324 }

void printgroups  ) 
 

Definition at line 208 of file dumpuser.c.

References FAR, GroupCache, and L.

Referenced by main().

00209 { 00210 struct my_group FAR * mygroup = (struct my_group FAR *) GroupCache; 00211 unsigned i; 00212 unsigned long relid; 00213 00214 printf("\t// Groups\n"); 00215 for (i = 0; i< MAXGROUP ; i++, mygroup++ ) { 00216 if (mygroup->name[0]) { 00217 relid = ((mygroup->gid | GROUPIDMASK) + (mygroup->serial << 16)) ^ 0x80000000L; 00218 printf("\tGroup = %ld %Fs\n", relid, mygroup->name); 00219 } 00220 } 00221 }

unsigned read_object unsigned  handle,
unsigned long  pos,
char FAR *  buf
 

Definition at line 95 of file dumpuser.c.

References dread(), and FAR.

Referenced by showentries().

00096 { 00097 unsigned err; 00098 struct disk_obj_hdr FAR * dobj; 00099 00100 err = dread(handle, pos, buf, sizeof(struct disk_obj_hdr)); 00101 if (err) 00102 return err; 00103 dobj = (struct disk_obj_hdr FAR *) buf; 00104 return dread(handle, pos, buf, dobj->do_numblocks * 64); 00105 }

void showentries void   ) 
 

Definition at line 222 of file dumpuser.c.

References ACCTOP, buf2, COMMOP, exit, FAR, GroupCache, Handle, Header, PRINTOP, read_object(), SERVOP, and userbuf.

Referenced by main().

00223 { 00224 unsigned i, j, k; 00225 unsigned err; 00226 unsigned long pos, oprights; 00227 signed long relativeid; 00228 unsigned usercount = 0; 00229 struct userhash FAR * entry = (struct userhash FAR *) buf2; 00230 struct user_object FAR * uo = (struct user_object FAR *) userbuf; 00231 struct my_group FAR * mygroup = (struct my_group FAR *) GroupCache; 00232 unsigned char FAR * gmask; 00233 unsigned char test; 00234 char groupnames[256]; 00235 00236 printf("\n\n\t// Users\n"); 00237 for (i = 0; i < USER_HASH_ENTRIES ; i++ ) { 00238 pos = entry->uh_disk; 00239 while (pos) { 00240 if (err = read_object(Handle, pos, userbuf)) { 00241 printf("Failed reading object, code %d\n", err); 00242 exit(1); 00243 } 00244 relativeid = ( ((uo->uo_record.user.uc0_guid.guid_serial) << 16) + 00245 (uo->uo_record.user.uc0_guid.guid_uid) ) ^ 0x80000000; 00246 gmask = uo->uo_record.user.uc0_groups; 00247 groupnames[0] = '\0'; 00248 for (j = 0; j < 32 ; j++ ) { 00249 test = gmask[j]; 00250 k = 0; 00251 while (test) { 00252 if (test & 1) { 00253 strcatf(groupnames, mygroup[j * 8 + k].name); 00254 strcatf(groupnames, " "); 00255 } 00256 test >>= 1; 00257 k++; 00258 } 00259 } 00260 00261 oprights = uo->uo_record.user.uc0_auth_flags; 00262 if (oprights & AF_OP_PRINT) 00263 strcat(groupnames, PRINTOP); 00264 if (oprights & AF_OP_COMM) 00265 strcat(groupnames, COMMOP); 00266 if (oprights & AF_OP_SERVER) 00267 strcat(groupnames, SERVOP); 00268 if (oprights & AF_OP_ACCOUNTS) 00269 strcat(groupnames, ACCTOP); 00270 00271 printf("\tUser = %ld %Fs %Fs\n", relativeid, 00272 (char FAR *) uo->uo_record.name, 00273 (char FAR *) groupnames); 00274 usercount++; 00275 pos = uo->uo_header.do_next; 00276 } 00277 entry++; 00278 } 00279 if (usercount != Header->num_users) { 00280 printf("Huh? Didn't find all the users (found %d)\n", usercount); 00281 } 00282 }

int UserHashVal char far *  uname,
int  domain
const [static]
 

Definition at line 63 of file dumpuser.c.

References c.

Referenced by loadit().

00066 { 00067 register unsigned val=0; 00068 register unsigned char c; 00069 00070 while ((c= (unsigned char) *uname++)) 00071 val += toupper(c); 00072 00073 return (int) (val % domain); 00074 }


Variable Documentation

char FAR* buf1
 

Definition at line 42 of file dumpuser.c.

Referenced by InitMemStuff(), and loadit().

char FAR* buf2
 

Definition at line 43 of file dumpuser.c.

Referenced by InitMemStuff(), loadit(), SelectOutFileName(), and showentries().

char FAR* GroupCache
 

Definition at line 44 of file dumpuser.c.

Referenced by InitMemStuff(), loadit(), printgroups(), and showentries().

unsigned short Handle
 

Definition at line 47 of file dumpuser.c.

struct _ahdr FAR* Header
 

Definition at line 48 of file dumpuser.c.

Referenced by FsRtlAcquireFileExclusive(), FsRtlAcquireFileForCcFlush(), FsRtlAcquireFileForModWrite(), FsRtlCopyRead(), FsRtlCopyWrite(), FsRtlInsertFilterContext(), FsRtlLookupFilterContextInternal(), FsRtlMdlReadDev(), FsRtlPrepareMdlWriteDev(), FsRtlReleaseFile(), FsRtlReleaseFileForCcFlush(), FsRtlRemoveFilterContext(), InitMemStuff(), IopPrepareDriverLoading(), KdDeregisterDebuggerDataBlock(), KdRegisterDebuggerDataBlock(), MiAllocateSpecialPool(), MmFreeSpecialPool(), MmQuerySpecialPoolBlockSize(), ObDeassignSecurity(), ObpDestroySecurityDescriptorHeader(), ObpLogSecurityDescriptor(), showentries(), UdfLoadSparingTables(), VerifierFreeTrackedPool(), and ViPostPoolAllocation().

char path[256]
 

Definition at line 45 of file dumpuser.c.

Referenced by banner(), doargs(), FindPathForDevice(), FsVgaServiceParameters(), InitMemStuff(), IopParseSymbolicLinkName(), LowQueryPathFromComponent(), and UnlinkConvFromOthers().

char userbuf[MAX_USER_SIZE]
 

Definition at line 46 of file dumpuser.c.

Referenced by showentries().


Generated on Sat May 15 19:43:30 2004 for test by doxygen 1.3.7