From a56cd720966ceb53e488766796bd01e6cd6815c7 Mon Sep 17 00:00:00 2001 From: Per Cederqvist <ceder@lysator.liu.se> Date: Mon, 16 Dec 1991 23:56:41 +0000 Subject: [PATCH] New arguments 'viewer' and 'viewer_p' to is_supervisor() and access_perm(). --- src/server/ChangeLog | 12 +++++++---- src/server/conference.c | 43 ++++++++++++++++++++++------------------ src/server/manipulate.h | 16 +++++++++------ src/server/membership.c | 44 +++++++++++++++++++++++++---------------- src/server/person.c | 18 ++++++++--------- src/server/session.c | 8 ++++---- 6 files changed, 82 insertions(+), 59 deletions(-) diff --git a/src/server/ChangeLog b/src/server/ChangeLog index a87efe2fe..4124da8c9 100644 --- a/src/server/ChangeLog +++ b/src/server/ChangeLog @@ -1,5 +1,13 @@ +Tue Dec 17 00:52:11 1991 Per Cederqvist (ceder at lysator) + + * text.c (get_last_text): Rewrote it. + Mon Dec 16 15:32:57 1991 Per Cederqvist (ceder at ruben) + * conference.c (is_supervisor): New arguments: viewer and viewer_p. + + * membership.c (access_perm): New parameters: viewer and viewer_p. + * admin.c (broadcast, send_message): Don't forget to check the length of the message. @@ -11,13 +19,9 @@ Mon Dec 16 15:32:57 1991 Per Cederqvist (ceder at ruben) recipient the asynchronous messages that were sent out did not filter away the secret conference. This has how been fixed. - * conference.c (lookup_name): Use the new fast_access_perm(). - * membership.c manipulate.h (fast_access_perm): New arguments: viewer and viewer_p. - * membership.c (copy_public_confs): Use the new fast_access_perm(). - * send-async.c, text.c (is_member_in_recpt): Moved from send-async.c to text.c. diff --git a/src/server/conference.c b/src/server/conference.c index bf3eb256a..cebfbc122 100644 --- a/src/server/conference.c +++ b/src/server/conference.c @@ -1,5 +1,5 @@ /* - * $Id: conference.c,v 0.14 1991/12/16 16:44:03 ceder Exp $ + * $Id: conference.c,v 0.15 1991/12/16 23:56:38 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 conferences. */ -static char *rcsid = "$Id: conference.c,v 0.14 1991/12/16 16:44:03 ceder Exp $"; +static char *rcsid = "$Id: conference.c,v 0.15 1991/12/16 23:56:38 ceder Exp $"; #include <time.h> @@ -267,20 +267,22 @@ do_create_conf(String name, /* - * Return TRUE if ACTPERS is a supervisor to CONF. + * Return TRUE if viewer is a supervisor to CONF. */ Bool is_supervisor(Conf_no conf, - Conference * conf_c)/* Conference status for CONF, can be NULL */ + Conference * conf_c, /* May be NULL */ + Pers_no viewer, + Person * viewer_p) /* May be NULL */ { - if (!ACTPERS) + if (viewer == 0) /* Not yet logged in. */ return FALSE; if (ENA(wheel, 8)) return TRUE; - if (ACTPERS == conf) /* A person is ALWAYS supervisor to */ + if (viewer == conf) /* A person is ALWAYS supervisor to */ return TRUE; /* his/her own mailbox! */ @@ -290,10 +292,13 @@ is_supervisor(Conf_no conf, if ( !conf_c->supervisor ) return FALSE; - if (ACTPERS == conf_c->supervisor) + if (viewer == conf_c->supervisor) return TRUE; - if ( locate_membership(conf_c->supervisor, ACT_P) != NULL) + if ( viewer_p == NULL ) + GET_P_STAT(viewer_p, viewer, FALSE); + + if ( locate_membership(conf_c->supervisor, viewer_p) != NULL) return TRUE; return FALSE; @@ -318,7 +323,7 @@ change_name (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 ) { @@ -453,7 +458,7 @@ delete_conf (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 != unlimited ) { @@ -526,7 +531,7 @@ get_conf_stat (Conf_no conf_no, 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 == error ) return FAILURE; @@ -552,7 +557,7 @@ get_conf_stat_old (Conf_no conf_no, 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 == error ) return FAILURE; @@ -603,7 +608,7 @@ set_presentation (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 < unlimited ) { @@ -634,7 +639,7 @@ set_etc_motd( Conf_no conf_no, CHK_LOGIN(FAILURE); GET_C_STAT(conf_c, conf_no, FAILURE); - if ( (acc = access_perm(conf_no, conf_c)) < unlimited ) + if ( (acc = access_perm(conf_no, conf_c, ACTPERS, ACT_P)) < unlimited ) { kom_errno = (acc <= none ) ? KOM_UNDEF_CONF : KOM_PERM; BUG(("set_etc_motd failed. Conf %ld Text %ld Acc %ld < %ld (%d).\n", @@ -666,7 +671,7 @@ set_supervisor( Conf_no conf_no, if (new_super != 0) CHK_EXIST(new_super, FAILURE); - if ( !is_supervisor(conf_no, conf_c) + if ( !is_supervisor(conf_no, conf_c, ACTPERS, ACT_P) && !ENA(admin, 6) ) { kom_errno = conf_c->type.secret ? KOM_UNDEF_CONF : KOM_PERM; @@ -708,7 +713,7 @@ set_permitted_submitters (Conf_no conf_no, CHK_EXIST(new_perm_sub, FAILURE); GET_C_STAT(conf_c, conf_no, FAILURE); - if ( !is_supervisor(conf_no, conf_c) + if ( !is_supervisor(conf_no, conf_c, ACTPERS, ACT_P) && !ENA(admin, 6) ) { kom_errno = conf_c->type.secret ? KOM_UNDEF_CONF : KOM_PERM; @@ -738,7 +743,7 @@ set_super_conf (Conf_no conf_no, if (new_super_conf != 0) CHK_EXIST(new_super_conf, FAILURE); - if ( !is_supervisor(conf_no, conf_c) + if ( !is_supervisor(conf_no, conf_c, ACTPERS, ACT_P) && !ENA(admin, 5) ) { kom_errno = conf_c->type.secret ? KOM_UNDEF_CONF : KOM_PERM; @@ -774,7 +779,7 @@ set_conf_type (Conf_no conf_no, return 0; } - acc = access_perm(conf_no, conf_c) ; + acc = access_perm (conf_no, conf_c, ACTPERS, ACT_P) ; if ( acc < unlimited ) { @@ -811,7 +816,7 @@ set_garb_nice( 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 < unlimited ) { diff --git a/src/server/manipulate.h b/src/server/manipulate.h index 0ee929f30..24b05578d 100644 --- a/src/server/manipulate.h +++ b/src/server/manipulate.h @@ -1,5 +1,5 @@ /* - * $Id: manipulate.h,v 0.4 1991/12/16 16:44:00 ceder Exp $ + * $Id: manipulate.h,v 0.5 1991/12/16 23:56:36 ceder Exp $ * Copyright (C) 1991 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -23,7 +23,7 @@ * Please mail bug reports to bug-lyskom@lysator.liu.se. */ /* - * $Id: manipulate.h,v 0.4 1991/12/16 16:44:00 ceder Exp $ + * $Id: manipulate.h,v 0.5 1991/12/16 23:56:36 ceder Exp $ * * manipulate.h * @@ -157,7 +157,7 @@ /* * A value of the following type are returned from access_perm() and - * fast_access_perm(). They are used to see how much ACTPERS is allowed to + * fast_access_perm(). They are used to see how much viewer is allowed to * read/modify the data of a given conference. * * access_perm() alway returns the "highest" from this list. @@ -211,12 +211,14 @@ locate_member(Pers_no pers_no, /* - * Return TRUE if ACTPERS is a supervisor to CONF. + * Return TRUE if viewer is a supervisor to CONF. */ extern Bool is_supervisor(Conf_no conf, - Conference * conf_c);/* Conference status for CONF or NULL */ + Conference * conf_c, /* May be NULL */ + Pers_no viewer, + Person * viewer_p); /* May be NULL */ @@ -373,7 +375,9 @@ do_add_member(Conf_no conf_no, /* Conference to add a new member to. */ extern Access access_perm(Conf_no victim, - Conference * victim_c); /* May be NULL */ + Conference * victim_c, /* May be NULL */ + Pers_no viewer, + Person * viewer_p); /* May be NULL */ /* * Fast version of access_perm. This function does not check if ATCPERS is a diff --git a/src/server/membership.c b/src/server/membership.c index 167b7b59e..ac627c52b 100644 --- a/src/server/membership.c +++ b/src/server/membership.c @@ -1,5 +1,5 @@ /* - * $Id: membership.c,v 0.7 1991/12/16 16:43:58 ceder Exp $ + * $Id: membership.c,v 0.8 1991/12/16 23:56:33 ceder Exp $ * Copyright (C) 1991 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -29,7 +29,7 @@ * (The person/conf relation). */ -static char *rcsid = "$Id: membership.c,v 0.7 1991/12/16 16:43:58 ceder Exp $"; +static char *rcsid = "$Id: membership.c,v 0.8 1991/12/16 23:56:33 ceder Exp $"; #include <time.h> #include <stdlib.h> @@ -604,22 +604,30 @@ do_sub_member(Conf_no conf_no, /* Conf to delete member from. */ Access access_perm(Conf_no victim, - Conference * victim_c) /* May be NULL */ + Conference * victim_c, /* May be NULL */ + Pers_no viewer, + Person * viewer_p) /* May be NULL */ { - if (victim == ACTPERS) + if (victim == viewer) return unlimited; if (victim_c == NULL) GET_C_STAT(victim_c, victim, error); - if ( ACTPERS != 0 && ENA(admin, 2) ) + if ( viewer != 0 && ENA(admin, 2) ) return unlimited; - if ( is_supervisor(victim, victim_c)) + if ( is_supervisor(victim, victim_c, viewer, viewer_p)) return unlimited; - if ( ACTPERS != 0 && locate_membership( victim, ACT_P ) != NULL ) - return member; + if ( viewer != 0 ) + { + if ( viewer_p == NULL ) + GET_P_STAT(viewer_p, viewer, error); + + if ( locate_membership( victim, viewer_p ) != NULL ) + return member; + } if ( victim_c->type.secret ) return none; @@ -660,9 +668,9 @@ fast_access_perm(Conf_no victim, return member; } + /* Only read in conference struct when really necessary. */ if ( (conf_type=cached_get_conf_type( victim )).secret ) - return access_perm(victim, NULL); /* Only read in conference struct - * when really necessary. */ + return access_perm(victim, NULL, viewer, viewer_p); if ( conf_type.rd_prot ) return read_protected; @@ -748,7 +756,8 @@ sub_member( Conf_no conf_no, return FAILURE; } - if ( !is_supervisor(conf_no, conf_c) && !is_supervisor(pers_no, NULL) + if ( !is_supervisor(conf_no, conf_c, ACTPERS, ACT_P) + && !is_supervisor(pers_no, NULL, ACTPERS, ACT_P) && !ENA(admin, 4) ) { kom_errno = conf_c->type.secret ? KOM_UNDEF_CONF : KOM_PERM; @@ -789,7 +798,8 @@ add_member(Conf_no conf_no, GET_C_STAT(conf_c, conf_no, FAILURE); GET_P_STAT(pers_p, pers_no, FAILURE); - if ( access_perm(conf_no, conf_c) < limited && !ENA(admin, 4) ) + if ( access_perm(conf_no, conf_c, ACTPERS, ACT_P) < limited + && !ENA(admin, 4) ) { kom_errno = conf_c->type.secret ? KOM_UNDEF_CONF : KOM_ACCESS; return FAILURE; @@ -802,9 +812,9 @@ add_member(Conf_no conf_no, /* He is already a member. Only change the priority. */ GET_C_STAT(pers_c, pers_no, FAILURE); - if( !is_supervisor( pers_no, pers_c ) ) /* Noone else can change */ - /* one's priorities. */ - { + if( !is_supervisor (pers_no, pers_c , ACTPERS, ACT_P) ) + { + /* Noone else can change one's priorities. */ kom_errno = KOM_PERM; return FAILURE; } @@ -1047,7 +1057,7 @@ get_membership (Pers_no pers_no, GET_P_STAT (p_orig, pers_no, FAILURE); GET_C_STAT (pers_c, pers_no, FAILURE); - acc = access_perm (pers_no, pers_c); + acc = access_perm (pers_no, pers_c, ACTPERS, ACT_P); if (acc == error) return FAILURE; @@ -1114,7 +1124,7 @@ get_members (Conf_no conf_no, 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 == error ) return FAILURE; diff --git a/src/server/person.c b/src/server/person.c index f4fcf1602..8269a5806 100644 --- a/src/server/person.c +++ b/src/server/person.c @@ -1,5 +1,5 @@ /* - * $Id: person.c,v 0.13 1991/09/25 21:25:21 ceder Exp $ + * $Id: person.c,v 0.14 1991/12/16 23:56:30 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 persons. */ -static char *rcsid = "$Id: person.c,v 0.13 1991/09/25 21:25:21 ceder Exp $"; +static char *rcsid = "$Id: person.c,v 0.14 1991/12/16 23:56:30 ceder Exp $"; #include <m-config.h> #include <time.h> @@ -565,7 +565,7 @@ get_person_stat (Pers_no person, GET_P_STAT(p_orig, person, FAILURE); GET_C_STAT(pers_c, person, FAILURE); - acc = access_perm(person, pers_c); + acc = access_perm (person, pers_c, ACTPERS, ACT_P); if ( acc == error ) return FAILURE; @@ -602,7 +602,7 @@ get_person_stat_old (Pers_no person, GET_P_STAT(p_orig, person, FAILURE); GET_C_STAT(pers_c, person, FAILURE); - acc = access_perm(person, pers_c); + acc = access_perm (person, pers_c, ACTPERS, ACT_P); if ( acc == error ) return FAILURE; @@ -642,7 +642,7 @@ get_created_texts(Pers_no pers_no, GET_P_STAT(pers_p, pers_no, FAILURE); - acc = access_perm(pers_no, NULL); + acc = access_perm(pers_no, NULL, ACTPERS, ACT_P); if ( acc == error ) return FAILURE; @@ -717,7 +717,7 @@ set_passwd (Pers_no person, GET_P_STAT(p, person, FAILURE); if ( person != ACTPERS && !ENA(wheel, 7) - && !is_supervisor(person, NULL) ) + && !is_supervisor (person, NULL, ACTPERS, ACT_P) ) { kom_errno = KOM_PERM; return FAILURE; /* Not allowed to change the other persons pwd */ @@ -763,14 +763,14 @@ query_read_texts(Pers_no victim, GET_P_STAT( victim_p, victim, FAILURE); - victim_acc = access_perm(victim, NULL); + victim_acc = access_perm(victim, NULL, ACTPERS, ACT_P); if ( victim_acc <= none ) { kom_errno = KOM_UNDEF_PERS; return FAILURE; } - if ( access_perm(conf_no, NULL) <= none ) + if ( access_perm(conf_no, NULL, ACTPERS, ACT_P) <= none ) { kom_errno = KOM_UNDEF_CONF; return FAILURE; @@ -815,7 +815,7 @@ set_user_area(Pers_no pers_no, CHK_LOGIN(FAILURE); GET_P_STAT(pers_p, pers_no, FAILURE); - if ( access_perm(pers_no, NULL) != unlimited ) + if ( access_perm(pers_no, NULL, ACTPERS, ACT_P) != unlimited ) { kom_errno = KOM_PERM; return FAILURE; diff --git a/src/server/session.c b/src/server/session.c index 4749427ee..fc621300a 100644 --- a/src/server/session.c +++ b/src/server/session.c @@ -1,5 +1,5 @@ /* - * $Id: session.c,v 0.4 1991/09/15 10:29:10 linus Exp $ + * $Id: session.c,v 0.5 1991/12/16 23:56:28 ceder Exp $ * Copyright (C) 1991 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -28,7 +28,7 @@ * Session control and miscellaneous. */ -static char *rcsid = "$Id: session.c,v 0.4 1991/09/15 10:29:10 linus Exp $"; +static char *rcsid = "$Id: session.c,v 0.5 1991/12/16 23:56:28 ceder Exp $"; #include <time.h> @@ -96,7 +96,7 @@ login (Pers_no pers_no, } #endif - if ( !is_supervisor(pers_no, NULL) + if ( !is_supervisor(pers_no, NULL, ACTPERS, ACT_P) && chk_passwd(pers_p->pwd, passwd) == FAILURE ) { kom_errno = KOM_PWD; @@ -344,7 +344,7 @@ disconnect (Session_no session_no) if ( cptr != NULL ) { - if ( is_supervisor(cptr->pers_no, NULL) + if ( is_supervisor(cptr->pers_no, NULL, ACTPERS, ACT_P) || session_no == active_connection->session_no ) { cptr->kill_me = TRUE; -- GitLab