cvs-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Cvs-dev] Re: cvs-passwd patch, hash.c doubt


From: Mark D. Baushke
Subject: [Cvs-dev] Re: cvs-passwd patch, hash.c doubt
Date: Thu, 28 Sep 2006 00:13:23 -0700

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Prasad,

Prasad J Pandit <address@hidden> writes:

> 
>     Hello Mark, hello all :)
> 
> I'm exploring the hash.c stuff; And it is pretty much close to what I 
> want/need. But see, there is a 'key' field in 'struct hashnode', which is 
> used to find a particular node in findnode().

commit.c uses a key of xstrdup (finfo->fullname) and xstrdup (finfo->file)
client.c uses a key of xstrdup (update_dir)
entries.c uses a key of xstrdup (entdata->user)
fileattr.c uses a key of xstrdup (filename)

The find_names.c file uses a number of different keys.

> What, I didn't get is, nowhere(in hash.c) I could find 'key' being 
> assigned a useful value; 

Correct. The client is the one that will assign a value to it for the
entry it has just created.

> I mean, other thatn NULL. Who is suppose to
> assign that value, & how?

Your client code makes the assignment.

> See, I'll get the 'username' from the
> cvs-client, which I'll use to find the node. 

Right. So, you use the username as the key. It
will either be the 'local user' or the 'real user'
as read from the passwd file right?

> But then, what about key? could you please
> through some light on it??

I would probably do soemthing like

    passwdlist = getlist ();
    while (1) 
    {
        ... read a password line and process it...
    }
   

... here is an example of how a given node might
get setup and added to the passwdlist

   newnode = getnode ();
   newnode->type = PASSWDNODE;  /* need to add this to the ntype enum */
   newnode->delproc = passwd_delproc;
   newnode->key = xstrdup (lusr ? lusr : usr);
   newnode->data = datablock;
   newnode->len = datablock_size; /* this may not be needed */

   if (addnode (passwdlist, newnode) != 0)
       freenode (newnode); /* discard duplicates */

You will also need to write a passwd_delproc()
that does the right thing to deallocate a node.

The searches will do the findnode (passwdlist, username)
call as you suggested and you will then be able to find
and opeate on the context block for the node by looking
at the node->data field.

I would expect that the node->data would probably
be a struct that includes the real user, password,
mapped local user and possibly an indication if
the username was found in the CVSROOT/writers
and/or CVSROOT/readers files (if they exist).

This should not really be all that difficult. Look
at the examples of how it is used elsewhere.

        -- Mark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (FreeBSD)

iD8DBQFFG3YSCg7APGsDnFERApJ0AKCh0f6pPIxBaRX2cGpdP+ZsNLFgNQCgqMmS
u6bHvRfXHZZWCta2MrAkOVw=
=j6lg
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]