Commit ad4c9102 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(access_perm_helper): Use new API of is_supervisor(). Simplify and

	reindent code.
(sub_member): Ditto.
(add_member_common): Ditto.
(do_get_members): Ditto.
parent 706ea4f7
/*
* $Id: membership.c,v 0.91 2003/08/16 11:29:00 ceder Exp $
* $Id: membership.c,v 0.92 2003/08/17 11:09:14 ceder Exp $
* Copyright (C) 1991-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -961,8 +961,6 @@ access_perm_helper(Conf_no victim,
const Connection *conn,
enum access wanted_access)
{
Pers_no viewer;
Person * viewer_p;
Conf_type victim_type;
int victim_type_known = 0;
static int maxwarnings = 10;
......@@ -974,10 +972,7 @@ access_perm_helper(Conf_no victim,
return error;
}
viewer = conn->pers_no;
viewer_p = conn->person;
if (victim == viewer)
if (victim == conn->pers_no)
return unlimited;
if (ENA_C(conn, admin, 2) || ENA_C(conn, wheel, 8))
......@@ -1000,38 +995,38 @@ access_perm_helper(Conf_no victim,
}
}
if (is_supervisor(victim, viewer, viewer_p))
if (is_supervisor(victim, conn))
return unlimited;
if ( viewer != 0 )
if (conn->pers_no != 0)
{
/* viewer_p should never be NULL here. Log a warning
if the GET_P_STAT is ever executed. */
if ( viewer_p == NULL )
if (conn->person == NULL)
{
if (maxwarnings > 0)
{
kom_log("WNG: viewer_p unexpectedly NULL in "
kom_log("WNG: conn->person unexpectedly NULL in "
"access_perm_helper()\n");
if (--maxwarnings == 0)
kom_log("WNG: Won't log the above warning any more.\n");
}
GET_P_STAT(viewer_p, viewer, error);
kom_errno = KOM_INTERNAL_ERROR;
err_stat = 0;
return error;
}
/* FIXME (bug 155): no need to call the expensive
locate_membership if supervisor(victim) == victim. */
if ( locate_membership( victim, viewer_p ) != NULL )
if (locate_membership(victim, conn->person) != NULL)
return member;
}
if (victim_type_known == 0)
victim_type = cached_get_conf_type(victim);
if ( victim_type.secret )
if (victim_type.secret)
return none;
if ( victim_type.rd_prot )
if (victim_type.rd_prot)
return read_protected;
return limited;
......@@ -1184,10 +1179,10 @@ sub_member( Conf_no conf_no,
return FAILURE;
}
if ( !is_supervisor(conf_no, ACTPERS, ACT_P) &&
!is_supervisor(pers_no, ACTPERS, ACT_P) &&
!ENA(wheel,8) && /* OK -- In an RPC call */
!ENA(admin, 4) ) /* OK -- in an RPC call */
if (!is_supervisor(conf_no, active_connection)
&& !is_supervisor(pers_no, active_connection)
&& !ENA(wheel,8) /* OK -- In an RPC call */
&& !ENA(admin, 4) ) /* OK -- in an RPC call */
{
set_conf_errno(active_connection, conf_no, KOM_PERM);
return FAILURE;
......@@ -1232,9 +1227,9 @@ add_member_common(Conf_no conf_no,
GET_P_STAT(pers_p, pers_no, FAILURE);
/* Force invitation bit if not adding as admin or supervisor */
if (param.invite_by_default &&
!is_supervisor(pers_no, ACTPERS, ACT_P) &&
!ENA(admin, 2)) /* OK -- Guarded */
if (param.invite_by_default
&& !is_supervisor(pers_no, active_connection)
&& !ENA(admin, 2)) /* OK -- Guarded */
{
type->invitation = 1;
}
......@@ -1264,8 +1259,8 @@ add_member_common(Conf_no conf_no,
Bool pers_supervisor;
Bool conf_supervisor;
pers_supervisor = is_supervisor(pers_no, ACTPERS, ACT_P);
conf_supervisor = is_supervisor(conf_no, ACTPERS, ACT_P);
pers_supervisor = is_supervisor(pers_no, active_connection);
conf_supervisor = is_supervisor(conf_no, active_connection);
/* Already a member, but a secret member? */
if (mship->type.secret &&
......@@ -1976,7 +1971,7 @@ do_get_members(Conf_no conf_no,
members->members = tmp_alloc(members->no_of_members * sizeof(Member));
is_supervisor_of_conf = is_supervisor(conf_no, ACTPERS, ACT_P);
is_supervisor_of_conf = is_supervisor(conf_no, active_connection);
for (src = first, dst = 0; dst < members->no_of_members; src++, dst++)
{
const Member *current = &conf_c->members.members[src];
......
Supports Markdown
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