Summary: V5.1 problems with putespwnam()

From: Tom Leffingwell <tom_at_sba.miami.edu>
Date: Fri, 01 Jun 2001 23:33:13 -0400 (EDT)

Thanks to those who replied:

J.A. Gutierrez <spd_at_gtc1.cps.unizar.es>
Rochelle Lauer <LAUER_at_hepmail.physics.yale.edu>
Ann Majeske <Ann.Majeske_at_Compaq.com>

It was noted that this doesn't work with NIS, which I'm not using, and
also to call set_auth_parameters() first, which I did, but I didn't
include in the source I posted. The fix was setting the version tag,
which Ann Majeske suggested, I've included her message below, and my
original post after that:

Date: Fri, 25 May 2001 18:32:20 -0400
From: Ann Majeske <Ann.Majeske_at_Compaq.com>
To: Tom Leffingwell <tom_at_sba.miami.edu>
Subject: Re: V5.1 problems with putespwnam()
                                                                                
Hi,
                                                                                
I figured out what your immediate problem is. You need to add the
lines:
                                                                                
pr1->version = AUTH_ESCAP_API_VER;
pr1->source = AUTH_SRC_LOCAL; /* not sure you need this one */
                                                                                
where you're setting up the es_passwd structure. Apparently some
more checking was put in to make sure that this is a "real" es_passwd
struct.

-----------------
My original post:
-----------------

>From tom_at_sba.miami.edu Fri Jun 1 23:32:02 2001
Date: Thu, 24 May 2001 22:36:10 -0400 (EDT)
From: Tom Leffingwell <tom_at_sba.miami.edu>
To: tru64-unix-managers_at_ornl.gov
Subject: V5.1 problems with putespwnam()


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 Sat Jun 02 2001 - 03:34:42 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:42 NZDT