[1694] in Moira

home help back first fref pref prev next nref lref last post

Re: sidhistory in moira

daemon@ATHENA.MIT.EDU (Qing Dong)
Tue Oct 31 19:31:21 2000

Message-Id: <200011010031.TAA06612@melbourne-city-street.MIT.EDU>
Date: Tue, 31 Oct 2000 19:33:00 -0500
To: Garry Zacheiss <zacheiss@mit.edu>
From: Qing Dong <dongq@MIT.EDU>
Cc: moiradev@mit.edu
In-Reply-To: <200010312356.SAA02984@riff-raff.mit.edu>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"

Thanks for the patch. 

I thought that the "field" and "qual" in the validate structure do
the row validation to make sure a specified row doesn't already
exist in the table. What do they do then?

Qing
At 06:56 PM 10/31/2000 -0500, Garry Zacheiss wrote:
>>> Hi, Garry. add_user_sid_by_login shouldn't allow duplicate
>>> sids. However during Dave's testing, it inserts duplicate sids. I
>>> looked at the code and couldn't figure out why. I think I probably
>>> did something wrong in the validate structure.  Can you take a look
>>> when you have a chance and let me know how to correct the problem?
>>> Thanks a lot.
>
>   alsn and ausl were using VOlist0 and VOuser0 as their valobjs,
>respectively, which means they were validating that the listname or
>username provided existed and that's all.  Checking for uniqueness of
>a (username, sid) pair is something that should be done in a setup
>function for the query instead of in the validation structure anyway.
>Here's a patch that enforces uniqueness for user sids and list sids.
>
>Garry
>
>Index: mr_server.h
>===================================================================
>RCS file:
/afs/athena.mit.edu/astaff/project/moiradev/repository/moira/server/mr_serve
r.h,v
>retrieving revision 1.55
>diff -c -r1.55 mr_server.h
>*** mr_server.h	2000/09/25 22:48:48	1.55
>--- mr_server.h	2000/10/31 23:32:29
>***************
>*** 231,236 ****
>--- 231,238 ----
>  int setup_uhha(struct query *q, char *argv[], client *cl);
>  int setup_aprn(struct query *q, char *argv[], client *cl);
>  int setup_dpsv(struct query *q, char *argv[], client *cl);
>+ int setup_ausl(struct query *q, char *argv[], client *cl);
>+ int setup_alsn(struct query *q, char *argv[], client *cl);
>  
>  /* prototypes from qsupport.pc */
>  int set_pobox(struct query *q, char *argv[], client *cl);
>Index: qsetup.pc
>===================================================================
>RCS file:
/afs/athena.mit.edu/astaff/project/moiradev/repository/moira/server/qsetup.p
c,v
>retrieving revision 2.41
>diff -c -r2.41 qsetup.pc
>*** qsetup.pc	2000/10/18 19:02:36	2.41
>--- qsetup.pc	2000/10/31 23:35:21
>***************
>*** 1252,1257 ****
>--- 1252,1293 ----
>    return MR_SUCCESS;
>  }
>  
>+ int setup_ausl(struct query *q, char **argv, client *cl)
>+ {
>+   int id;
>+   EXEC SQL BEGIN DECLARE SECTION;
>+   char *sid = argv[1];
>+   int count;
>+   EXEC SQL END DECLARE SECTION;
>+ 
>+   id = *(int *)argv[0];
>+ 
>+   EXEC SQL SELECT COUNT(sid) INTO :count 
>+     FROM usersids WHERE sid = :sid AND users_id = :id;
>+   if (count)
>+     return MR_NOT_UNIQUE;
>+ 
>+   return MR_SUCCESS;
>+ }
>+ 
>+ int setup_alsn(struct query *q, char **argv, client *cl)
>+ {
>+   int id;
>+   EXEC SQL BEGIN DECLARE SECTION;
>+   char *sid = argv[1];
>+   int count;
>+   EXEC SQL END DECLARE SECTION;
>+ 
>+   id = *(int *)argv[0];
>+ 
>+   EXEC SQL SELECT COUNT(sid) INTO :count
>+     FROM listsids WHERE sid = :sid AND list_id = :id;
>+   if (count)
>+     return MR_NOT_UNIQUE;
>+ 
>+   return MR_SUCCESS;
>+ }
>+ 
>  /* hostname_check()
>   * validate the rfc1035/rfc1123-ness of a hostname
>   */
>Index: queries2.c
>===================================================================
>RCS file:
/afs/athena.mit.edu/astaff/project/moiradev/repository/moira/server/queries2
.c,v
>retrieving revision 2.79
>diff -c -r2.79 queries2.c
>*** queries2.c	2000/10/25 20:38:43	2.79
>--- queries2.c	2000/10/31 23:32:45
>***************
>*** 2994,3001 ****
>    1,
>    0,
>    0,
>    0,
>-   0,
>  };
>  
>  static char *alsn_fields[] = {
>--- 2994,3001 ----
>    1,
>    0,
>    0,
>+   setup_ausl,
>    0,
>  };
>  
>  static char *alsn_fields[] = {
>***************
>*** 3010,3017 ****
>    "sid = '%s'",
>    1,
>    0,
>-   0,
>    0,
>    0,
>  };
>  
>--- 3010,3017 ----
>    "sid = '%s'",
>    1,
>    0,
>    0,
>+   setup_alsn,
>    0,
>  };
>  
> 


home help back first fref pref prev next nref lref last post