extern struct query Queries[];
/* Put this in a variable so that we can patch it if necessary */
-int max_row_count = 4096;
+int max_row_count = 8192;
int mr_verify_query(client *cl, struct query *q, int argc, char *argv_ro[]);
int do_retrieve(struct query *q, char *pqual,
sqlglm(err_msg, &bufsize, &msglength);
err_msg[msglength] = 0;
com_err(whoami, 0, "SQL error text = %s", err_msg);
- critical_alert("MOIRA", "Moira server encountered DBMS ERROR %d\n%s",
+ critical_alert(whoami, "MOIRA", "Moira server encountered DBMS ERROR %d\n%s",
dbms_errno, err_msg);
}
switch (q->type)
{
- case RETRIEVE:
+ case MR_Q_RETRIEVE:
/* for queries that do not permit wildcarding, check if row
uniquely exists */
if (v && v->field)
break;
- case UPDATE:
+ case MR_Q_UPDATE:
/* see if row already exists */
if (v->field)
{
break;
- case APPEND:
+ case MR_Q_APPEND:
/* see if row already exists */
if (v->field)
{
status = (*v->post_rtn)(q, Argv, cl);
break;
- case DELETE:
+ case MR_Q_DELETE:
/* see if row already exists */
if (v->field)
{
status = (*v->post_rtn)(q, Argv, cl);
break;
- case SPECIAL:
+ case MR_Q_SPECIAL:
break;
}
status = mr_errcode;
}
- if (q->type == RETRIEVE)
+ if (q->type == MR_Q_RETRIEVE)
EXEC SQL COMMIT WORK;
else
{
while (*fmt)
{
- if (!like && !arg)
+
+ if ((!like && !arg) || argc == 0)
{
/* only plain text remains */
strcpy(res, fmt);
/* check argument count */
argreq = q->argc;
- if (q->type == UPDATE || q->type == APPEND)
+ if (q->type == MR_Q_UPDATE || q->type == MR_Q_APPEND)
argreq += q->vcnt;
if (argc != argreq)
return MR_ARGS;
if (*fr)
return MR_ARG_TOO_LONG;
*to = '\0';
-
- if (to > Argv[i] && *--to == '\\')
- return MR_BAD_CHAR;
}
- /* check initial query access, unless we're acting as a proxy */
- if (!cl->proxy_id)
- {
- status = check_query_access(q, Argv, cl);
- if (status != MR_SUCCESS && status != MR_PERM)
- return status;
- if (status == MR_SUCCESS)
- privileged++;
- }
+ /* Check initial query access. If we're acting as a proxy, only allow
+ * access if the query has "default" as a capacl.
+ */
+ status = check_query_access(q, Argv, cl);
+ if (status != MR_SUCCESS && status != MR_PERM)
+ return status;
+ if (status == MR_SUCCESS && (!cl->proxy_id || q->everybody))
+ privileged++;
/* validate arguments */
if (v && v->valobj)
if (!strcmp(strtrim(list_type), "KERBEROS") && list_id == -cl->client_id)
return 1;
- /* see if client is a member of list */
- flag = 0;
- users_id = cl->users_id;
- client_id = -cl->client_id;
- EXEC SQL SELECT COUNT(member_id) INTO :flag FROM imembers
- WHERE list_id = :list_id
- AND ( ( member_type = 'USER' AND member_id = :users_id )
- OR (member_type = 'KERBEROS' AND member_id = :client_id ) );
- if (sqlca.sqlcode == 0)
- return flag;
+ if (!strcmp(strtrim(list_type), "LIST"))
+ {
+ /* see if client is a member of list */
+ flag = 0;
+ users_id = cl->users_id;
+ client_id = -cl->client_id;
+ EXEC SQL SELECT COUNT(member_id) INTO :flag FROM imembers
+ WHERE list_id = :list_id
+ AND ( ( member_type = 'USER' AND member_id = :users_id )
+ OR (member_type = 'KERBEROS' AND member_id = :client_id ) );
+ if (sqlca.sqlcode == 0)
+ return flag;
+ }
+
return 0;
}
** table - name of table objects are found in
** limit - should the ID be range limited
**
- ** - called before an APPEND operation to set the next object id to
+ ** - called before an MR_Q_APPEND operation to set the next object id to
** be used for the new record to the next free value
**
**/
return mr_errcode;
if (rowcount == max_row_count)
{
- critical_alert("moirad", "attempted query with too many rows");
+ critical_alert(whoami, "moirad", "attempted query with too many rows");
return MR_NO_MEM;
}
else if (rowcount == 0)
}
EXEC SQL SELECT string_id INTO :j FROM strings WHERE string = :iname;
break;
+ case CONTAINERS_TABLE:
+ EXEC SQL SELECT cnt_id INTO :j FROM containers WHERE LOWER(name) =
+ LOWER(:iname);
+ break;
default:
return MR_INTERNAL;
}
case STRINGS_TABLE:
EXEC SQL SELECT string INTO :iname FROM strings WHERE string_id = :j;
break;
+ case CONTAINERS_TABLE:
+ EXEC SQL SELECT name INTO :iname FROM containers WHERE cnt_id = :j;
+ break;
default:
return MR_INTERNAL;
}