Commit 4d3e9959 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(person_text_read_access): Removed. Integrate the functionality inteo

	text_read_access.
(text_read_access): Use the supplied Connection for all checks.  Don't
	use active_connection, ENA, ACTPERS or ACT_P.  Fail and log an
	error message if the Connection is NULL.  Use is_supervisor()
	instead of is_supervisor_2().
parent 8e1b282b
/*
* $Id: text.c,v 0.114 2003/08/20 08:26:13 ceder Exp $
* $Id: text.c,v 0.115 2003/08/20 10:24:59 ceder Exp $
* Copyright (C) 1991-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -1236,49 +1236,21 @@ send_async_deleted_text(Text_no text_no,
* Functions that are exported to the rest of the server.
*/
/*
* Check if ACTPERS is allowed to read this text.
* Returns TRUE if he is allowed to read it.
*/
Bool
text_read_access(const Connection *conn,
Text_no text_no,
const Text_stat *text_stat)
{
return person_text_read_access(text_no,
text_stat,
conn != NULL ? conn->pers_no : 0,
conn != NULL ? conn->person : NULL);
}
/*
* Check if pers_no has read access to a text
* If pers_no is ACTPERS read access is granted also if
* the cwc is a recipient or privileges are enabled.
* These checks are not performed otherwise
*/
/*
* FIXME (bug 178): This function checks if pers_no is the same as
* ACTPERS in a number of places. This means that this function does
* not quite do the right thing. However, in order to remove these
* tests, additional code may be needed in callers of this function
* (for example, we might have to pass the connection in the
* aux-item-add-triggers so that they can do a proper privilege
* check).
*/
Bool
person_text_read_access(Text_no text_no,
const Text_stat * text_stat,
Pers_no pers_no,
const Person * pers_stat)
{
int i = 0;
Misc_info *misc = NULL;
Conference *recipient = NULL;
Conf_no cwc = 0;
if (conn == NULL)
{
kom_log("ERROR: text_read_access() called with conn==NULL for t=%ld\n",
(unsigned long)text_no);
return FALSE;
}
/* Everyone may read the MOTD of KOM */
......@@ -1288,7 +1260,7 @@ person_text_read_access(Text_no text_no,
if (text_stat == NULL
&& (text_stat = cached_get_text_stat(text_no)) == NULL)
{
if (!pers_no)
if (!conn->pers_no)
{
/* If you are not logged in, you are not allowed to know
if the text exists or not. */
......@@ -1306,7 +1278,7 @@ person_text_read_access(Text_no text_no,
/* Users who are not logged in may not read anything else. */
if (!pers_no)
if (!conn->pers_no)
{
err_stat = 0;
kom_errno = KOM_LOGIN;
......@@ -1315,20 +1287,13 @@ person_text_read_access(Text_no text_no,
/* Some bits let you read everything. */
if (active_connection && pers_no == ACTPERS && ENA(wheel, 10))
if (ENA_C(conn, wheel, 10))
return TRUE;
/* Additional checks on CWC if pers_no is ACTPERS. */
if (active_connection && pers_no == ACTPERS)
{
cwc = active_connection->cwc;
}
if (text_stat->author == pers_no)
if (text_stat->author == conn->pers_no)
return TRUE;
/* Check if pers_no or current working conference is a recipient */
/* Check if conn->pers_no or current working conference is a recipient */
for (i = text_stat->no_of_misc, misc = text_stat->misc_items;
i; i--, misc++)
......@@ -1336,17 +1301,14 @@ person_text_read_access(Text_no text_no,
if ((misc->type == recpt
|| misc->type == cc_recpt
|| misc->type == bcc_recpt)
&& (misc->datum.recipient == cwc
|| misc->datum.recipient == pers_no))
&& (misc->datum.recipient == conn->cwc
|| misc->datum.recipient == conn->pers_no))
{
return TRUE;
}
}
/* Check if pers_no is member in any of the recipients */
if (pers_stat == NULL)
GET_P_STAT(pers_stat, pers_no, FALSE);
/* Check if conn->pers_no is member in any of the recipients */
for (i = text_stat->no_of_misc, misc = text_stat->misc_items;
i > 0;
......@@ -1355,19 +1317,19 @@ person_text_read_access(Text_no text_no,
if ((misc->type == recpt
|| misc->type == cc_recpt
|| misc->type == bcc_recpt)
&& locate_membership(misc->datum.recipient, pers_stat) != NULL)
&& locate_membership(misc->datum.recipient, conn->person) != NULL)
{
return TRUE;
}
}
if (locate_mark(pers_no, pers_stat, text_no) != NULL)
if (locate_mark(conn->pers_no, conn->person, text_no) != NULL)
return TRUE;
/* Check if any of the recipients is an open conference, */
/* or if ACTPERS is a supervisor.(Note: ACTPERS is not */
/* supervisor of anything if he isn't logged in.) */
/* Check if any of the recipients is an open conference, or if the
user of conn is a supervisor. (Note: He is not supervisor of
anything if he isn't logged in.) */
for (i = text_stat->no_of_misc, misc = text_stat->misc_items;
i > 0;
......@@ -1379,14 +1341,8 @@ person_text_read_access(Text_no text_no,
&& (recipient=cached_get_conf_stat(misc->datum.recipient)) != NULL)
{
if (!recipient->type.rd_prot
|| (active_connection && pers_no == ACTPERS && ENA(wheel, 8))
/* FIXME (bug 178): This is the only call to
is_supervisor_2(). When bug 178 is fixed, that
function should be removed. */
|| is_supervisor_2(misc->datum.recipient,
pers_no, pers_stat) == TRUE)
|| (ENA_C(conn, wheel, 8))
|| is_supervisor(misc->datum.recipient, conn) == TRUE)
{
return TRUE;
}
......
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