return MR_SUCCESS;
}
+int access_update_user(struct query *q, char *argv[], client *cl)
+{
+ EXEC SQL BEGIN DECLARE SECTION;
+ int users_id, unix_uid, status, comments, secure;
+ char login[USERS_LOGIN_SIZE], shell[USERS_SHELL_SIZE];
+ char winconsoleshell[USERS_WINCONSOLESHELL_SIZE], last[USERS_LAST_SIZE];
+ char first[USERS_FIRST_SIZE], middle[USERS_MIDDLE_SIZE];
+ char clearid[USERS_CLEARID_SIZE], type[USERS_TYPE_SIZE];
+ char signature[USERS_SIGNATURE_SIZE];
+ EXEC SQL END DECLARE SECTION;
+
+ /* The two fields we let users update themselves didn't appear until
+ * version 11.
+ */
+ if (q->version < 11)
+ return MR_PERM;
+ if (cl->users_id != *(int *)argv[0])
+ return MR_PERM;
+
+ users_id = *(int *)argv[0];
+
+ EXEC SQL SELECT u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last,
+ u.first, u.middle, u.status, u.clearid, u.type, u.comments, u.signature,
+ u.secure INTO :login, :unix_uid, :shell, :winconsoleshell, :last, :first,
+ :middle, :status, :clearid, :type, :comments, :signature, :secure
+ FROM USERS u WHERE u.users_id = :users_id;
+
+ /* None of these things can have changed. */
+ if (strcmp(argv[1], strtrim(login)) ||
+ (unix_uid != atoi(argv[2])) ||
+ strcmp(argv[3], strtrim(shell)) ||
+ strcmp(argv[4], strtrim(winconsoleshell)) ||
+ strcmp(argv[5], strtrim(last)) ||
+ strcmp(argv[6], strtrim(first)) ||
+ strcmp(argv[7], strtrim(middle)) ||
+ (status != atoi(argv[8])) ||
+ strcmp(argv[9], strtrim(clearid)) ||
+ strcmp(argv[10], strtrim(type)) ||
+ (comments != *(int *)argv[11]) ||
+ strcmp(argv[12], strtrim(signature)) ||
+ (secure != atoi(argv[13])))
+ return MR_PERM;
+
+ return MR_SUCCESS;
+}
/* access_login - verify that client name equals specified login name
*
{
EXEC SQL BEGIN DECLARE SECTION;
int list_id, acl_id, flags, gid, users_id, member_id, member_acl_id;
- int memacl_id;
+ int memacl_id, mailman, mailman_id;
char acl_type[LIST_ACL_TYPE_SIZE], name[LIST_NAME_SIZE], *newname;
char member_acl_type[LIST_ACL_TYPE_SIZE], memacl_type[LIST_ACL_TYPE_SIZE];
EXEC SQL END DECLARE SECTION;
- int status;
+ int status, cnt;
list_id = *(int *)argv[0];
member_id = *(int *)argv[2];
EXEC SQL SELECT acl_id, acl_type, memacl_id, memacl_type,
- gid, publicflg, name
+ gid, publicflg, name, mailman, mailman_id
INTO :acl_id, :acl_type, :memacl_id, :memacl_type,
- :gid, :flags, :name
+ :gid, :flags, :name, :mailman, :mailman_id
FROM list
WHERE list_id = :list_id;
newname = argv[1];
- if (!strcmp("ulis", q->shortname))
- {
- /* Check that it doesn't conflict with the Grouper namespace. */
- if (strlen(newname) > 4 && isdigit(newname[2]) &&
- isdigit(newname[3]) && newname[4] == '-')
- {
- if (!strncasecmp(newname, "fa", 2) ||
- !strncasecmp(newname, "sp", 2) ||
- !strncasecmp(newname, "su", 2) ||
- !strncasecmp(newname, "ja", 2))
- return MR_RESERVED;
- }
-
- /* Don't let anyone take owner-foo list names. They interact
- * weirdly with the aliases automatically generated by
- * mailhub.gen.
- */
- if (!strncasecmp(newname, "owner-", 6))
- return MR_RESERVED;
- }
-
+ /* Check that it doesn't conflict with the Grouper namespace. */
+ if (strlen(newname) > 4 && isdigit(newname[2]) &&
+ isdigit(newname[3]) && newname[4] == '-')
+ {
+ if (!strncasecmp(newname, "fa", 2) ||
+ !strncasecmp(newname, "sp", 2) ||
+ !strncasecmp(newname, "su", 2) ||
+ !strncasecmp(newname, "ja", 2))
+ return MR_RESERVED;
+ }
+
+ /* Don't let anyone take owner-foo list names. They interact
+ * weirdly with the aliases automatically generated by
+ * mailhub.gen.
+ */
+ if (!strncasecmp(newname, "owner-", 6))
+ return MR_RESERVED;
+
EXEC SQL SELECT users_id INTO :users_id FROM users
WHERE login = :newname;
if ((sqlca.sqlcode != SQL_NO_MATCH) && strcmp(strtrim(name), newname) &&
(users_id != cl->users_id))
return MR_PERM;
+
+ /* For modern enough clients, don't allow ordinary users to toggle
+ * the mailman bit or change the server.
+ */
+ if (q->version >= 10)
+ {
+ if (mailman != atoi(argv[9]))
+ return MR_PERM;
+
+ if (mailman_id != *(int *)argv[10])
+ return MR_PERM;
+ }
}
/* check for client in access control list and return success right
else
idx = 2;
- if (q->type == RETRIEVE)
- {
- if (strcmp(argv[0], "*") || strcmp(argv[1], "*") ||
- strcmp(argv[2], "*") || strcmp(argv[3], "*"))
- return MR_SUCCESS;
- else
- return MR_PERM;
- }
-
if (q->type == APPEND)
{
/* Non-query owner must set use to zero */