Commit 0b446180 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

New arguments 'viewer' and 'viewer_p' to is_supervisor() and

access_perm().

Rewrote get_last_text().
parent a56cd720
/*
* $Id: text.c,v 0.12 1991/12/16 17:44:19 ceder Exp $
* $Id: text.c,v 0.13 1991/12/16 23:57:39 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -28,7 +28,7 @@
* All atomic calls that deals with texts.
*/
static char *rcsid = "$Id: text.c,v 0.12 1991/12/16 17:44:19 ceder Exp $";
static char *rcsid = "$Id: text.c,v 0.13 1991/12/16 23:57:39 ceder Exp $";
#include <time.h>
#include <stdlib.h>
......@@ -288,7 +288,7 @@ submit_to(Conf_no conf_no, /* The conference the user is trying to */
for ( i=0; i < MAX_SUPER_CONF_LOOP; i++)
{
acc = access_perm( conf_no, conf_c );
acc = access_perm (conf_no, conf_c, ACTPERS, ACT_P);
if ( acc <= none )
return 0;
......@@ -1086,7 +1086,8 @@ text_read_access(Text_no text_no,
cached_get_conf_stat( misc->datum.recipient )) != NULL )
{
if ( !recipient->type.rd_prot
|| is_supervisor(misc->datum.recipient, recipient))
|| is_supervisor(misc->datum.recipient, recipient,
ACTPERS, ACT_P))
{
return TRUE;
}
......@@ -1097,7 +1098,8 @@ text_read_access(Text_no text_no,
cached_get_conf_stat( misc->datum.cc_recipient )) != NULL )
{
if ( !recipient->type.rd_prot
|| is_supervisor(misc->datum.cc_recipient, recipient))
|| is_supervisor(misc->datum.cc_recipient, recipient,
ACTPERS, ACT_P))
{
return TRUE;
}
......@@ -1889,7 +1891,8 @@ delete_text( Text_no text_no )
CHK_LOGIN(FAILURE);
GET_T_STAT(text_s, text_no, FAILURE);
if ( !is_supervisor(text_s->author, NULL) && !ENA(admin, 5) )
if ( !is_supervisor(text_s->author, NULL, ACTPERS, ACT_P)
&& !ENA(admin, 5) )
{
kom_errno = (text_read_access(text_no, text_s)
? KOM_NOT_AUTHOR : KOM_NO_SUCH_TEXT);
......@@ -1902,47 +1905,47 @@ delete_text( Text_no text_no )
/*
* Lookup a text according to creation-time.
* The text-no of the text created closest before TIME is returned.
* The text text-no must not be readable
* The text text-no might not be readable.
*/
extern Text_no
get_last_text(time_t time, Text_no *text)
extern Success
get_last_text(time_t time,
Text_no *result)
{
Text_no lower = 0;
Text_no higher = query_next_text_num();
Text_no lower = 1;
Text_no higher = query_next_text_num() - 1;
Text_stat *text_stat;
Text_no try;
Text_no middle;
/*
* We search for the text in the interval [lower, higher]
* (inclusive). Middle is set to the middle (rounded towards
* zero), and we search from there and upward until we find a
* text.
*/
while (!(lower + 1 == higher))
while (lower < higher)
{
Text_stat * text;
Text_no try = (lower + higher) / 2; /* Binary search */
int step = 0; /* Patch to accept nonexisting texts */
middle = (lower + higher)/2 + 1; /* Binary search */
try = middle;
text_stat = NULL;
while (text_stat == NULL && try <= higher);
text_stat = cached_get_text_stat (try++);
do
if ( text_stat == NULL )
higher = middle - 1;
else
{
try += step; /* back and forth around the middle as long */
/* until we find an existing text. */
step = (step + ( step > 0 ? 1 : -1)) * (-1);
text = cached_get_text_stat( try );
} while (text == NULL && try > lower && try < higher);
if (try <= lower || try >= higher)
break; /* We did not find any existing text */
if (time > text->creation_time)
lower = try;
else /* The intervall is "halved" */
higher = try;
if (time > text_stat->creation_time)
lower = try;
else /* The intervall is "halved" */
higher = middle - 1;
}
}
if (lower != 0)
{
*text = lower;
return OK; /* We found a text */
}
else
{
kom_errno = KOM_NO_SUCH_TEXT; /* We did not find a text at all */
return FAILURE;
}
*result = lower;
return OK;
}
......@@ -2050,9 +2053,9 @@ sub_recipient( Text_no text_no,
GET_C_STAT(conf_c, conf_no, FAILURE);
if ( !is_supervisor(text_s->author, NULL)
&& !is_supervisor(conf_no, conf_c)
&& !is_sender( text_s, conf_no ) )
if ( !is_supervisor (text_s->author, NULL, ACTPERS, ACT_P)
&& !is_supervisor (conf_no, conf_c, ACTPERS, ACT_P)
&& !is_sender (text_s, conf_no) )
{
kom_errno = KOM_PERM;
return FAILURE;
......@@ -2141,9 +2144,9 @@ sub_comment( Text_no comment, /* 'comment' is no longer a comment */
}
if ( !is_supervisor(text_s->author, NULL)
&& !is_supervisor( parent_s->author, NULL )
&& !is_comm_sender( text_s, parent ) )
if ( !is_supervisor (text_s->author, NULL, ACTPERS, ACT_P)
&& !is_supervisor (parent_s->author, NULL, ACTPERS, ACT_P)
&& !is_comm_sender (text_s, parent) )
{
kom_errno = KOM_PERM;
return FAILURE;
......@@ -2266,7 +2269,7 @@ get_map (Conf_no conf_no,
CHK_LOGIN(FAILURE);
GET_C_STAT(conf_c, conf_no, FAILURE);
acc = access_perm(conf_no, conf_c);
acc = access_perm (conf_no, conf_c, ACTPERS, ACT_P);
if ( acc <= none )
{
......
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