extern int ingres_errno, mr_errcode;
EXEC SQL BEGIN DECLARE SECTION;
-int idummy;
-extern char cdummy[];
extern char stmt_buf[];
+int idummy;
+extern char cdummy[]; /** Routines which need these vars should use mr_select_any() **/
EXEC SQL END DECLARE SECTION;
/* Specialized Access Routines */
EXEC SQL END DECLARE SECTION;
build_qual(q->qual, q->argc, argv, qual);
- EXEC SQL SELECT users_id INTO :id FROM users WHERE :qual;
-
+ if(!strcmp(q->shortname,"guau") ||
+ !strcmp(q->shortname,"gual")) {
+ EXEC SQL SELECT users_id INTO :id FROM users u, strings str WHERE :qual;
+ } else {
+ EXEC SQL SELECT users_id INTO :id FROM users WHERE :qual;
+ }
+
if (sqlca.sqlerrd[2] != 1 || id != cl->users_id)
return(MR_PERM);
else
struct query *q;
char *argv[];
{
- EXEC SQL BEGIN DECLARE SECTION;
- int flag, id;
- EXEC SQL END DECLARE SECTION;
+ int flag, id, ec;
id = *(int *)argv[0];
- EXEC SQL REPEATED SELECT member_id INTO :idummy FROM imembers
- WHERE member_id = :id AND member_type='LIST';
- if (sqlca.sqlerrd[2] > 0)
- return(MR_IN_USE);
- EXEC SQL REPEATED SELECT member_id INTO :idummy FROM imembers
- WHERE list_id = :id;
- if (sqlca.sqlerrd[2] > 0)
- return(MR_IN_USE);
- EXEC SQL REPEATED SELECT label INTO :cdummy FROM filesys
- WHERE owners = :id;
- if (sqlca.sqlerrd[2] > 0)
- return(MR_IN_USE);
- EXEC SQL REPEATED SELECT tag INTO :cdummy FROM capacls
- WHERE list_id = :id;
- if (sqlca.sqlerrd[2] > 0)
- return(MR_IN_USE);
- EXEC SQL REPEATED SELECT name INTO :cdummy FROM list
- WHERE acl_id = :id AND acl_type='LIST' AND list_id = :id;
- if (sqlca.sqlerrd[2] > 0)
- return(MR_IN_USE);
- EXEC SQL REPEATED SELECT name INTO :cdummy FROM servers
- WHERE acl_id = :id AND acl_type='LIST';
- if (sqlca.sqlerrd[2] > 0)
- return(MR_IN_USE);
- EXEC SQL REPEATED SELECT entity_id INTO :idummy FROM quota
- WHERE entity_id = :id AND type='GROUP';
- if (sqlca.sqlerrd[2] > 0)
- return(MR_IN_USE);
- EXEC SQL REPEATED SELECT acl_id INTO :idummy FROM hostaccess
- WHERE acl_id = :id AND acl_type='LIST';
- if (sqlca.sqlerrd[2] > 0)
- return(MR_IN_USE);
- EXEC SQL REPEATED SELECT class INTO :cdummy FROM zephyr z
- WHERE z.xmt_type = 'LIST' AND z.xmt_id = :id
- OR z.sub_type = 'LIST' AND z.sub_id = :id
- OR z.iws_type = 'LIST' AND z.iws_id = :id
- OR z.iui_type = 'LIST' AND z.iui_id = :id;
- if (sqlca.sqlerrd[2] > 0)
- return(MR_IN_USE);
- if (ingres_errno)
- return(mr_errcode);
+ sprintf(stmt_buf,"SELECT member_id FROM imembers WHERE member_id = %d AND member_type='LIST'",id);
+ if(ec=mr_select_any(stmt_buf)) {
+ if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
+ }
+
+ sprintf(stmt_buf,"SELECT member_id FROM imembers WHERE list_id = %d",id);
+ if(ec=mr_select_any(stmt_buf)) {
+ if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
+ }
+
+ sprintf(stmt_buf,"SELECT label FROM filesys WHERE owners = %d",id);
+ if(ec=mr_select_any(stmt_buf)) {
+ if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
+ }
+
+ sprintf(stmt_buf,"SELECT tag FROM capacls WHERE list_id = %d",id);
+ if(ec=mr_select_any(stmt_buf)) {
+ if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
+ }
+
+ sprintf(stmt_buf,"SELECT name FROM list WHERE acl_id = %d AND acl_type='LIST' AND list_id != %d",id,id);
+ if(ec=mr_select_any(stmt_buf)) {
+ if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
+ }
+
+ sprintf(stmt_buf,"SELECT name FROM servers WHERE acl_id = %d AND acl_type='LIST'",id);
+ if(ec=mr_select_any(stmt_buf)) {
+ if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
+ }
+
+ sprintf(stmt_buf,"SELECT entity_id FROM quota WHERE entity_id = %d AND type='GROUP'",id);
+ if(ec=mr_select_any(stmt_buf)) {
+ if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
+ }
+
+ sprintf(stmt_buf,"SELECT acl_id FROM hostaccess WHERE acl_id = %d AND acl_type='LIST'",id);
+ if(ec=mr_select_any(stmt_buf)) {
+ if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
+ }
+
+ sprintf(stmt_buf,"SELECT class FROM zephyr z \
+WHERE z.xmt_type = 'LIST' AND z.xmt_id = %d \
+OR z.sub_type = 'LIST' AND z.sub_id = %d \
+OR z.iws_type = 'LIST' AND z.iws_id = %d \
+OR z.iui_type = 'LIST' AND z.iui_id = %d",id,id,id,id);
+ if(ec=mr_select_any(stmt_buf)) {
+ if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
+ }
+
return(MR_SUCCESS);
}
struct query *q;
char **argv;
{
- EXEC SQL BEGIN DECLARE SECTION;
- char *name;
- EXEC SQL END DECLARE SECTION;
- char *c;
+ int ec;
+
+ sprintf(stmt_buf,"SELECT service FROM serverhosts WHERE service = UPPERCASE('%s')",argv[0]);
+ if(ec=mr_select_any(stmt_buf)) {
+ if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
+ }
+
+ sprintf(stmt_buf,"SELECT inprogress FROM servers WHERE name = UPPERCASE('%s')",argv[0]);
+ if(ec=mr_select_any(stmt_buf)) {
+ if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
+ }
- name = argv[0];
- for(c=name;*c;c++) if(islower(*c)) *c = toupper(*c);
- EXEC SQL REPEATED SELECT service INTO :cdummy FROM serverhosts
- WHERE service = :name;
- if (sqlca.sqlerrd[2] > 0)
- return(MR_IN_USE);
- EXEC SQL REPEATED SELECT inprogress INTO :idummy FROM servers
- WHERE name = :name;
- if (sqlca.sqlerrd[2] > 0)
- return(MR_IN_USE);
- if (ingres_errno)
- return(mr_errcode);
return(MR_SUCCESS);
}
char **argv;
{
EXEC SQL BEGIN DECLARE SECTION;
- int id;
- char *name, *c;
+ int id, ec;
EXEC SQL END DECLARE SECTION;
- name = argv[0];
- for(c=name;*c;c++) if(islower(*c)) *c = toupper(*c); /* to uppercase */
id = *(int *)argv[1];
- EXEC SQL REPEATED SELECT inprogress INTO :idummy FROM serverhosts
- WHERE service = :name AND mach_id = :id;
- if (sqlca.sqlerrd[2] > 0)
- return(MR_IN_USE);
- if (ingres_errno)
- return(mr_errcode);
+
+ sprintf(stmt_buf,"SELECT inprogress FROM serverhosts \
+WHERE service = UPPERCASE('%s') AND mach_id = %d",argv[0],id);
+ if(ec=mr_select_any(stmt_buf)) {
+ if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
+ }
+
return(MR_SUCCESS);
}
sprintf(ftype, "fs_access_%s", type);
EXEC SQL SELECT trans INTO :cdummy FROM alias
- WHERE name = :ftype AND type = 'TYPE' and trans = :access;
+ WHERE name = :ftype AND type = 'TYPE' and trans = :access; /** Use mr_select_any() */
if (ingres_errno) return(mr_errcode);
if (sqlca.sqlerrd[2] == 0) return(MR_FILESYS_ACCESS);
client *cl;
{
EXEC SQL BEGIN DECLARE SECTION;
- int quota, fs, id;
+ int quota, fs, id, physid;
char *qtype;
EXEC SQL END DECLARE SECTION;
EXEC SQL REPEATED SELECT quota INTO :quota FROM quota
WHERE type = :qtype AND entity_id = :id AND filsys_id = :fs;
- EXEC SQL REPEATED UPDATE nfsphys
- SET allocated = nfsphys.allocated - :quota
- WHERE nfsphys_id = filesys.physid AND filesys.filsys_id = :fs;
+ EXEC SQL REPEATED SELECT phys_id INTO :physid FROM filesys
+ WHERE filsys_id = :fs;
+ EXEC SQL REPEATED UPDATE nfsphys SET allocated = allocated - :quota
+ WHERE nfsphys_id = :physid;
if (ingres_errno) return(mr_errcode);
return(MR_SUCCESS);
char **argv;
client *cl;
{
+#ifdef notdef
#ifsql INGRES
EXEC SQL set lockmode session where readlock = system;
#endsql
+#endif
}
login = argv[U_NAME];
EXEC SQL REPEATED SELECT sigdate, sigwho
INTO :timestamp, :who FROM users
- WHERE login = :login; /** Use LEFT(...,SIZE(...)) here? **/
+ WHERE login = LEFT(:login,SIZE(login));
/** What about (INGRES) error handling? **/
- /** Is this guaranteed to be a singleton select? **/
kname = malloc(1);
status = id_to_name(who, "STRING", &kname);
si.timestamp = timestamp;
/* skip bytes for timestamp & kname */
si.rawsig = (unsigned char *) rawsig;
status = GDSS_Verify(databuf, strlen(databuf), argv[U_SIGNATURE], &si);
+ if (strlen(rawsig) > mr_sig_length) {
+ com_err(whoami, 0, "GDSS signature would be truncated."); /** untested **/
+ return(MR_INTERNAL);
+ }
if (status == 0) {
name = kname_unparse(si.pname, si.pinst, si.prealm);
status = name_to_id(name, "STRING", &sigwho);
who = cl->client_id;
entity = cl->entity;
- /* create finger entry, pobox & set modtime on user */
+ /* create finger entry & pobox, set modtime on user, and update search fields */
#ifdef GDSS
EXEC SQL REPEATED UPDATE users
SET modtime='now', modby=:who, modwith = :entity,
fullname = :fullname, affiliation = type,
+ searchfirst = UPPERCASE(first), searchlast = UPPERCASE(last),
signature = :rawsig, sigdate = :timestamp, sigwho = :sigwho,
fmodtime='now', fmodby = :who, fmodwith = :entity,
potype='NONE', pmodtime='now', pmodby = :who, pmodwith = :entity
EXEC SQL REPEATED UPDATE users
SET modtime='now', modby=:who, modwith = :entity,
fullname = :fullname, affiliation = type,
+ searchfirst = UPPERCASE(first), searchlast = UPPERCASE(last),
fmodtime='now', fmodby = :who, fmodwith = :entity,
potype='NONE', pmodtime='now', pmodby = :who, pmodwith = :entity
WHERE login = :login;
/* skip bytes for timestamp & kname */
si.rawsig = (unsigned char *) rawsig;
status = GDSS_Verify(databuf, strlen(databuf), argv[U_SIGNATURE+1], &si);
+ if (strlen(rawsig) > mr_sig_length) {
+ com_err(whoami, 0, "GDSS signature would be truncated."); /** untested **/
+ return(MR_INTERNAL);
+ }
if (status == 0) {
name = kname_unparse(si.pname, si.pinst, si.prealm);
status = name_to_id(name, "STRING", &sigwho);
}
#endif /* GDSS */
- /* create finger entry, pobox & set modtime on user */
+ /* set modtime on user and update search fields */
#ifdef GDSS
EXEC SQL REPEATED UPDATE users SET modtime='now', modby = :who, modwith = :entity,
- signature = :rawsig, sigdate = :timestamp, sigwho = :sigwho
+ signature = :rawsig, sigdate = :timestamp, sigwho = :sigwho,
+ searchfirst = UPPERCASE(first), searchlast = UPPERCASE(last)
WHERE users_id = :id;
#else /* GDSS */
- EXEC SQL REPEATED UPDATE users SET modtime='now', modby = :who, modwith = :entity
+ EXEC SQL REPEATED UPDATE users SET modtime='now', modby = :who, modwith = :entity,
+ searchfirst = UPPERCASE(first), searchlast = UPPERCASE(last)
WHERE users_id = :id;
#endif /* GDSS */
return(MR_SUCCESS);
client *cl;
{
EXEC SQL BEGIN DECLARE SECTION;
- int quota, id, fs, who;
+ int quota, id, fs, who, physid;
char *entity, *qtype;
EXEC SQL END DECLARE SECTION;
EXEC SQL REPEATED UPDATE quota
SET modtime = 'now', modby = :who, modwith = :entity
WHERE filsys_id = :fs and type = :qtype and entity_id = :id;
- EXEC SQL REPEATED UPDATE nfsphys
- SET allocated = allocated + :quota
- WHERE nfsphys_id = filesys.phys_id AND filesys.filsys_id = :fs;
+ EXEC SQL REPEATED SELECT phys_id INTO :physid FROM filesys
+ WHERE filsys_id = :fs;
+ EXEC SQL REPEATED UPDATE nfsphys SET allocated = allocated + :quota
+ WHERE nfsphys_id = :physid;
if (ingres_errno) return(mr_errcode);
return(MR_SUCCESS);
}
if (sqlca.sqlerrd[2] > 0) {
if (a == 0 && d == 0) {
EXEC SQL UPDATE imembers
- SET ref_count = ref_count+ref, direct=1
+ SET ref_count = ref_count+:ref, direct=1
WHERE list_id = :lid AND member_id = :mid
AND member_type = :mtype;
} else {
EXEC SQL UPDATE imembers
- SET ref_count = ref_count+ref
+ SET ref_count = ref_count+:ref
WHERE list_id = :lid AND member_id = :mid
AND member_type = :mtype;
}
incremental_clear_after();
} else if (a == 0 && d == 0) {
EXEC SQL UPDATE imembers
- SET ref_count = refcount - :ref, direct = 0
+ SET ref_count = ref_count - :ref, direct = 0
WHERE list_id = :lid AND member_id = :mid
AND member_type = :mtype;
} else {
EXEC SQL UPDATE imembers
- SET ref_count=refcount-:ref
+ SET ref_count = ref_count - :ref
WHERE list_id = :lid AND member_id = :mid
AND member_type = :mtype;
}
rargv[0] = "HOSTACCESS";
EXEC SQL DECLARE csr115 CURSOR FOR
SELECT name FROM machine, hostaccess
- WHERE mach_id = hostaccess.mach_id AND hostaccess.acl_type = :atype
+ WHERE machine.mach_id = hostaccess.mach_id
+ AND hostaccess.acl_type = :atype
AND hostaccess.acl_id = :aid;
EXEC SQL OPEN csr115;
while(1) {
* where clause based on the arguments, then doing a retrieve.
*/
-static char *lflags[5] = { "active", "publicflg", "hidden", "maillist", "group" };
+static char *lflags[5] = { "active", "publicflg", "hidden", "maillist", "grouplist" };
int qualified_get_lists(q, argv, cl, action, actarg)
struct query *q;
}
rargv[0] = SQLDA->sqlvar[0].sqldata;
- sprintf(stmt_buf,"SELECT %s.%s FROM %s %s WHERE %s",q->rtable,field,q->rtable,q->rvar,qual);
+ sprintf(stmt_buf,"SELECT %s.%s FROM %s %s WHERE %s",range,field,q->rtable,range,qual);
EXEC SQL PREPARE stmt INTO :SQLDA USING NAMES FROM :stmt_buf;
if(sqlca.sqlcode)
return(MR_INTERNAL);
aargv[0] = login;
aargv[1] = "ANY";
aargv[2] = login;
- sprintf(buffer, "q.entity_id = 0 and q.filsys_id = %d and q.type = 'ANY'", fsidval);
+ sprintf(buffer, "quota.entity_id = 0 and quota.filsys_id = %d and quota.type = 'ANY'", fsidval);
incremental_after("quota", buffer, aargv);
com_err(whoami, 0, "quota of %d assigned", def_quota);
if (ingres_errno) return(mr_errcode);
return(MR_EXISTS);
}
+
+/* Looks like it's time to build an abstraction barrier, Yogi */
+mr_select_any(stmt)
+ EXEC SQL BEGIN DECLARE SECTION;
+ char *stmt;
+ EXEC SQL END DECLARE SECTION;
+{
+ int result=0;
+
+ EXEC SQL PREPARE stmt FROM :stmt;
+ EXEC SQL DESCRIBE stmt INTO :SQLDA;
+ if(SQLDA->sqld==0) /* Not a SELECT */
+ return(MR_INTERNAL);
+ EXEC SQL DECLARE csr CURSOR FOR stmt;
+ EXEC SQL OPEN csr;
+ EXEC SQL FETCH csr USING DESCRIPTOR :SQLDA;
+ if(sqlca.sqlcode==0)
+ result=MR_EXISTS;
+ else if((sqlca.sqlcode<0) && mr_errcode)
+ result=mr_errcode;
+ else
+ result=0;
+ EXEC SQL CLOSE csr;
+ return(result);
+}
+
+
/* eof:qsupport.dc */