Commit 0d029b10 authored by David Byers's avatar David Byers

(check_delete_aux_item_list): Rewrote

check for delete permissions as multiple if-elseif statements
instead of a compound expression, 'cause the compound expression
was getting just a little bit difficult to understand.
(empty_aux_item_definition): Added value for owner_delete.
(simple_aux_item): Ditto.
(check_delete_aux_item_list): Add owner parameter. Check
owner_delete to see if object owner may delete item.
parent ee871d2b
/*
* $Id: aux-items.c,v 1.26 2000/09/06 19:54:29 ceder Exp $
* $Id: aux-items.c,v 1.27 2001/09/22 13:41:25 byers Exp $
* Copyright (C) 1994-2000 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -123,7 +123,8 @@ Aux_item_definition empty_aux_item_definition =
0, /* Supervisor only */
0, /* System only */
0, /* Unique */
0, /* Can't delete */
0, /* Can't delete */
0, /* Owner delete */
0, /* Inherit limit */
FALSE, /* Texts */
0,
......@@ -158,7 +159,8 @@ static Aux_item_definition simple_aux_item =
0, /* Supervisor only */
0, /* System only */
0, /* Unique */
0, /* Can't delete */
0, /* Can't delete */
0, /* Owner delete */
0, /* Inherit limit */
TRUE, /* Texts */
0,
......@@ -1334,7 +1336,8 @@ filter_aux_item_list(const Aux_item_list *original,
Success
check_delete_aux_item_list(const Number_list *items_to_delete,
const Aux_item_list *list_to_delete_from)
const Aux_item_list *list_to_delete_from,
const Conf_no owner)
{
long i;
const Aux_item *item;
......@@ -1360,19 +1363,32 @@ check_delete_aux_item_list(const Number_list *items_to_delete,
/* Check all sorts of permissions */
def = find_aux_item_definition(item);
if ((def == NULL) ||
(def->may_not_delete) ||
(item->creator == 0 && !ENA(wheel, 8)) || /* NOT OK! */
(item->creator != ACTPERS && /* NOT OK! */
!is_supervisor(item->creator, ACTPERS, NULL) && /* NOT OK! */
!ENA(wheel,8))) /* NOT OK! */
{
if (def == NULL) {
kom_errno = KOM_AUX_PERM;
err_stat = i;
return FAILURE;
} else if (def->may_not_delete) {
kom_errno = KOM_AUX_PERM;
err_stat = i;
return FAILURE;
} else if (item->creator == 0) {
if (!ENA(wheel, 8)) {
kom_errno = KOM_AUX_PERM;
err_stat = i;
return FAILURE;
}
} else if (item->creator != ACTPERS) {
if (!ENA(wheel, 8) &&
!is_supervisor(item->creator, ACTPERS, NULL) &&
(!def->owner_delete || !is_supervisor(owner, ACTPERS, NULL))) {
kom_errno = KOM_AUX_PERM;
err_stat = i;
return FAILURE;
}
}
/* For already deleted items, clear them out of the list */
if (item->flags.deleted)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment