Hello,
I recently updated a system from V4.0D to V5.1. Actually, V5.1
was a clean install. I wrote a program in V4.0 to automate some of our
account creation needs, and it worked great, however, in 5.1 putespwnam()
returns 0, and fails. I tried recompiling, but that didn't help. The
source chunk below shows the what we did with the structure, pr1. I can
include more if anyone is interested. The program hasn't been touched
between versions. Anyway, there is some change in behaviour between 4.0D
and V5.1 that seems to be causing the problem. Has anyone had similiar
problems?
Source:
/* Set tcb tags for user */
pr1=malloc(sizeof(*pr1));
pr1->ufld=malloc(sizeof(*pr1->ufld));
pr1->uflg=malloc(sizeof(*pr1->uflg));
pr1->sfld=NULL;
pr1->sflg=NULL;
pr1->ubuf=NULL;
pr1->fieldlen=sizeof(*pr1->ufld);
pr1->ufld->fd_name=malloc(sizeof(username));
bzero((char *) pr1->ufld,sizeof(*pr1->ufld));
bzero((char *) pr1->uflg,sizeof(*pr1->uflg));
pr1->ufld->fd_name=malloc(sizeof(username));
strcpy(pr1->ufld->fd_name,username); /* Set username */
pr1->uflg->fg_name=1;
pr1->ufld->fd_uid=uid; /* Set uid */
pr1->uflg->fg_uid=1;
pr1->ufld->fd_encrypt=big_crypt(password); /* Set password */
pr1->uflg->fg_encrypt=1;
pr1->ufld->fd_lock=0; /* Unlock account */
pr1->uflg->fg_lock=1;
pr1->ufld->fd_psw_chg_reqd=1; /* Require password change */
pr1->uflg->fg_psw_chg_reqd=1;
pr1->ufld->fd_restrict=1; /* Prevent user from using */
pr1->uflg->fg_restrict=1; /* stupid passwords */
/* Add user account to protected password database. */
printf("%s\n",username);
if (0 == putespwnam(username, pr1))
{
fprintf(stderr, "Failed to add %s to the protected password database.\n",username);
endprpwent();
exit(1);
}
else
{
fprintf(stdout, "Added %s to the protected password database.\n",username);
endprpwent();
}
Thanks,
Tom
Received on Fri May 25 2001 - 02:42:04 NZST