[1693] in Moira
Re: sidhistory in moira
daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Tue Oct 31 18:56:42 2000
Message-Id: <200010312356.SAA02984@riff-raff.mit.edu>
To: Qing Dong <dongq@MIT.EDU>
cc: moiradev@MIT.EDU
In-Reply-To: Your message of "Tue, 31 Oct 2000 13:31:24 EST."
<200010311829.NAA00915@melbourne-city-street.MIT.EDU>
Date: Tue, 31 Oct 2000 18:56:38 -0500
From: Garry Zacheiss <zacheiss@MIT.EDU>
>> 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_server.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.pc,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,
};