From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96078715811861.tru64-unix-managers.marc@archive.invalid> From: "Douglas B. Jones" Date: Wed, 22 Jul 1998 19:48:05 +0000 To: tru64-unix-managers Subject: putespwent() & copyespwent() X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96078715811861 Hi, Hopefully these is ok to post here. I am worried about the copyespwent() routine and memory allocation or actually freeing. I do not have a man page for it (for some reason), but according to the Security book the call is: copypr = copyespwent(origpr); then when you are free, you have: free(copypr); Well, origpr and copypr are es_passwd which have a lot of pointers in them. Just to do free(copypr) worries me. This says free what copypr points to, not what its' elements point to. The only way it would free all the memory is if getespw*() or copyespwent() created a block of memory with all of the elements in it. Or - am I missing something. My other concern is putespwent() with a new id that does not exist yet. If I am creating ids, it is easy to gen. for putpwent() the passwd structure. Do I need to fill in all of the fields for the es_passwd structure, or is there a way to get a default for it an change the fd_name, fd_uid and fd_encrypt. Maybe also fd_oldcrypt and any other site specific entries. My guess is: while ((x = morelogins()) != NULL) { def = getesdfnam("default"); /* called each time we want a new def. */ pr->sfld = def->sfld; pr->sflg = def->sflg; pr->ufld = def->prd; pr->uflg = def->prg; pr->ufld->fd_name = x->loginname; pr->uflg->fg_name = 1; pr->ufld->fd_uid = x->loginuid; pr->uflg->fg_uid = 1; pr->ufld->fd_encrypt = x->cryptedpw; pr->uflg->fg_encrypt = 1; pr->ufld->fd_oldcrypt = 0; pr->uflg->fg_oldcrypt = 1; /* any other fields.....*/ putespwnam(loginname,pr); /* of course we check return here */ }; I guess I don't really need to get the default each time, in which case I could take out some of the code above: uflg ones, fd_oldcypt and fetesdfnam() since they only need to be called once. Is this the best way to do it, or is there a better way? Are there other factors I should consider? I will be glad to summarize on both. Thanks for any help, Cheers, Douglas