Commit 4d07f229 authored by Per Cederqvist's avatar Per Cederqvist

(access_perm_helper): New argument: wanted_access. All callers

	updated.  Avoid calling is_supervisor or is_member if not needed.
(get_unread_confs): Minor performance improvement: there is no
 	need to call access_perm if pers_no is the logged-in person.
parent e9d33cbb
/*
* $Id: membership.c,v 0.53 1999/07/05 07:00:57 ceder Exp $
* $Id: membership.c,v 0.54 1999/07/05 21:17:42 ceder Exp $
* Copyright (C) 1991-1999 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -38,7 +38,7 @@
#define DEBUG_MARK_AS_READ
static const char *
rcsid = "$Id: membership.c,v 0.53 1999/07/05 07:00:57 ceder Exp $";
rcsid = "$Id: membership.c,v 0.54 1999/07/05 21:17:42 ceder Exp $";
#include "rcs.h"
USE(rcsid);
......@@ -718,11 +718,13 @@ do_sub_member(Conf_no conf_no, /* Conf to delete member from. */
static Access
access_perm_helper(Conf_no victim,
Connection *conn)
Connection *conn,
Access wanted_access)
{
Pers_no viewer;
Person * viewer_p;
Conf_type victim_type;
int victim_type_known = 0;
if (!cached_conf_exists(victim))
{
......@@ -740,6 +742,23 @@ access_perm_helper(Conf_no victim,
if (ENA_C(conn, admin, 2) || ENA_C(conn, wheel, 8))
return unlimited;
if (wanted_access <= limited)
{
victim_type = cached_get_conf_type(victim);
victim_type_known = 1;
if (victim_type.secret == 0)
{
if (victim_type.rd_prot)
{
if (wanted_access <= read_protected)
return read_protected;
}
else
return limited;
}
}
if (is_supervisor(victim, viewer, viewer_p))
return unlimited;
......@@ -756,7 +775,8 @@ access_perm_helper(Conf_no victim,
return member;
}
victim_type = cached_get_conf_type(victim);
if (victim_type_known == 0)
victim_type = cached_get_conf_type(victim);
if ( victim_type.secret )
return none;
......@@ -790,7 +810,7 @@ access_perm(Conf_no victim,
}
}
result = access_perm_helper(victim, viewer_conn);
result = access_perm_helper(victim, viewer_conn, wanted_access);
if (wanted_access < result)
return wanted_access;
......@@ -1527,7 +1547,9 @@ get_unread_confs(Pers_no pers_no,
if ((confs->type.passive == 0) &&
(confs->last_text_read <
cached_get_highest_local_no(confs->conf_no)) &&
(access_perm(confs->conf_no, active_connection, limited) >
(ACTPERS == pers_no || /* No need to check permissions
when fetching ones own info. */
access_perm(confs->conf_no, active_connection, limited) >
read_protected))
{
result->conf_nos[ result->no_of_confs++ ] = confs->conf_no;
......
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