diff --git a/ChangeLog b/ChangeLog index 42614078e10a0a32e1a16226dc2335acc6933b29..19f94ab4c884d99e084facf511bdb7604100965c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,234 @@ +1999-05-12 David Byers + + Stuff I forgot to add below + + * Renamed log to kom_log since log is a function in math.h. + + * src/include/services.h (set_pers_flags): New prototype. + (create_person): Added flags parameter. + + * run-support/config: Set defaults for max texts and max + conferences. + + * run-support/aux-items.conf (faq-text): Removed all triggers. Set + add-trigger to link-faq, added validator. + (faq-for-conf): New item definition. + + * doc/lyskomd.texi (Parameters): Added Max conferences, Max texts, + Max client data length, Nologin fle. Updated some other parameter + descriptions. + (Aux-Item Definition File): Added system-only. Rewrote validate to + allow function identifiers. Added list of validator functions and + triggers. + (Files): Document /etc/nologin. + + * doc/hacking.texi: Correct minor typos. Change some @code into + @file. + (Linking Pairs of Aux Items): New section. + + * doc/Protocol-A.texi: Correct minor typos + (Predefined Aux-Item Types): Rephrase some + of the text. Remove statement that faq-text item marks a text. + Document faq-for-conf. Specify formate for mx-message-id. + (Simple Data Types): Removed documentation for INTEGER. + (set-etc-motd): Change too-many-marks to mark-limit + (mark-text-old): Change too-many-marks to mark-limit + (set-conf-type): Correct documentation for secret-public error. + Correct spelling in invalid-membership-type documentation. + (add-recipient): Add documentation for access-denied error + (add-comment): Define error-status in index-out-of-range. + (sub-comment): Change no-comment to not-comment. + (send-message): Complete documentation of message-not-sent error. + (create-text): Add index-out-of-range as possible error. + (create-conf): Complete doc of permission-denied error. + (create-person): Added personal-flags parameter. + (create-person): Document person-exists error. + (set-pers-flags): New call. + (Error Codes): Clarify message-not-sent and index-out-of-range. + + * configure.in: Added flag --with-insure++. Define AVOID_ABORTS + when compiling with support for gcov. + + * src/server/testsuite/tcpconnect.py: Added #hose socket to hose + the socket with lots of zeroes. + + * src/server/testsuite/config/prot-a.exp: New functions + kom_set_permitted_submitters, kom_set_super_conf, kom_login_old, + kom_mark_text, kom_sub_recipient, kom_set_conf_type, + kom_change_conference, kom_set_priv_bits. + (kom_create_person): Send the pers_flags field. + + * src/server/testsuite/config/unix.exp: Print a dot for every test + case in verbose mode. + (lyskomd_start): New parameters extra_config for additional config + file contents and base_config for basic config file contents + (defaults will not be used.) Don't print defaults for max + conferences or max texts if they are in extra_config. It is + possible to start lyskomd with arbitrary arguments. + (lyskomd_fail_start): Function to use when lyskomd is supposed to + not start properly (like lyskomd_start, but server failue is + expected.) + (client_start_fail): New function like client_start, but failure + is expected. + (kill_client): Unset expect_active and expect_always instead of + setting to the empty string. + (hose_client): New function + + * src/server/testsuite/lyskomd.0/00.exp: Send pers-flags in calls + to create-person. + + * src/server/testsuite/lyskomd.0/01.exp: Update expected results + in query-predefined-aux-items. Send pers-flags in call to + create-person. Add test for set-pers-flags. Add test for + nonexistent call 107. + + * src/server/testsuite/lyskomd.0/02.exp: Send pers-flags in call + to create-person. + + * src/server/testsuite/lyskomd.0/03.exp: Expect aux-item 28 in + query-predefined-aux-items. Send pers-flags in call to + create-person. Expect the faq-for-conf aux-item in test 1327. + Expect failure attempting to set nonexistent text as faq (test + 1342.) Remove the now failed faq item in subsequent tests. Add + test for set-pers-flags. + + * src/server/testsuite/lyskomd.0/04.exp: Send pers-flags in calls + to kom_create_person. + + * src/server/testsuite/lyskomd.0/05.exp: Send pers-flags in calls + to kom_create_person. Be more flexible when expecting time + corresponding to time_t zero. Set garb and sync interval to + something really high to avoid spurious async messages while + running the tests. + + * src/server/testsuite/lyskomd.0/06.exp: Send pers-flags in calls + to kom_create_person. + + * src/server/testsuite/lyskomd.0/admin-cov.exp: More setup to + support new tests. Test that we can't send messages to secret + confs. Test that messages are filtered for passive members. + + * src/server/testsuite/lyskomd.0/aux-items-cov.exp: Send + pers-flags in calls to kom_create_person. Attempt to create + aux-items with broken validation regexp. Test the system-only + attribute. Test a broken aux-item config file. + + * src/server/testsuite/lyskomd.0/aux-items.cov: Add an item + definition with system-only property. + + * src/server/prot-a-parse.h: Added prototype for + prot_a_parse_pers_flags + + * src/server/prot-a-parse.c (prot_a_parse_pers_flags): New + function to parse pers flags. + + * src/server/prot-a-output.c (prot_a_output_text_mapping): + Initialize the fields of iter to avoid warnings from tools that + detect access to uninitialize memory. + + * src/server/local-to-global.c: Use kom_log instead of log. + + * src/server/kom-memory.c: Added prototypes for init_aux_item and + init_aux_item_link. + + * src/server/aux-items.c (system_check_add_aux_item_list): Call + aux_item_add_perm with INFO_OBJECT_TYPE for the object_type + parameter. + + * src/server/admin.c: Use kom_log instead of log everywhere. + (send_message): Do not permit sending group messages to secret + conferences. Set errno to KOM_MESSAGE_NOT_SENT if there are no + appropriate recipients. + + * src/server/aux-item-def-parse.y: Parse validation functions in + addition to validation regexps. Use kom_log instead of log. Parse + the system-only property. + (aux_item_def_check_validate): New function. + + * src/server/aux-items.c: Add the aux-item being involved item + itself to aux-item trigger data. + (aux_item_validate_existing_text): New validation function. + (aux_item_trigger_mirror_faq): New add trigger function + (aux_item_trigger_unmark_text): Modified to work for aux-items on + texts and conferences, not just conferences. Do not unmark an + unmarked text. + (aux_item_trigger_mark_text): Do not add more marks than + permitted. + (find_aux_item_index): New function to find the index of an item + with a particular number in an aux item list. + (commit_aux_item_list): Renamed to commit_aux_item_list_internal. + (commit_aux_item_list_internal): Delete linked aux items. + (commit_aux_item_list): Wrapper for commit_aux_item_list_internal. + (delete_aux_item_list): Manage deletion of linked items. + (undelete_aux_item_list): Manage undeletion of linked items. + (mark_linked_object_as_changed): New function to mark the object + containing a linked aux item as changed. + (find_linked_aux_item): New function to find the aux item that is + linked to a given aux item. + (find_linked_aux_item_list): New function to find the aux item + list containing the aux item that is linked to a given aux item. + (aux_item_validate): New function for validating aux items. Deals + with regexps and validation functions. + (aux_item_add_perm): Handle the system-only property of aux item + definitions. + + +1999-05-09 David Byers + + * src/server/aux-items.c (prepare_aux_item): Clear the linked_item + field properly. + + * src/server/memory.c (init_aux_item_link): New function. + (init_aux_item): Use init_aux_item_link + (init_aux_item): New function added earlier. + + * src/server/prot-a-parse.c (prot_a_parse_aux_item): Clear the + parsed aux_item to get good defaults for fields that are not read + in the parser. + + * src/server/admin.c (modify_server_info): Pass INFO_OBJECT_TYPE + to delete_aux_item_list and undelete_aux_item_list. + + * src/server/aux-items.h: Changed all declarations of object_type + from short to Object_type. + + * src/server/aux-items.c: Changed all declarations of object_type + from short to Object_type. + + * src/server/ram-parse.c (fparse_aux_item_link): New function. + (fparse_aux_item): Parse the link as well. + + * src/include/kom-types.h (Object_type): New type (moved defs from + aux-items.h) + (Aux_item_link): New type + (Aux_item): Added linked_item field. + + * src/server/ram-output.c (foutput_aux_item): Output linked_item + field. + (foutput_aux_item_link): New function to output a link to another + aux item. + + * src/server/aux-items.c: Added handling of item field in aux item + trigger calls. + + * src/server/aux-items.h (Aux_item_trigger_data_s): Added item + field. + + * src/server/aux-items.c (system_check_add_aux_item_list): Set + owner_check to TRUE in call to aux_item_add_perm so system-only + restriction works on system-info aux-item list. + + * src/server/testsuite/lyskomd.0/admin-cov.exp: Added tests for + sending messages to secret confs and to conf with passive member + logged in. + + * doc/Protocol-A.texi (send-message): Document that + message-not-sent is returned when there are no recipients for a + group message. + + * src/server/com-h.awk: Set illegal_fnc to -1 (was cnt) since cnt + might be a legal function. + 1999-05-02 Per Cederqvist "make check" in the top directory failed in some environments. @@ -155,6 +386,27 @@ set. * src/server/testsuite/test-l2g.c (main): Set the block size to 10. +1999-04-23 David Byers + + * src/server/standalone.c (kom_info): Initialize the + aux_item_list too. + + * src/server/ramkomd.c (initialize): Use kom_log instead of log. + + * src/server/local-to-global.c (l2g_read): Use kom_log instead of + log. + + * src/server/text.c (text_read_access): Call + person_text_read_access to do the work. + (person_text_read_access): New function generalizes + text_read_access. + + * src/server/manipulate.h: Prototype for person_text_read_access. + +1999-04-21 David Byers + + * src/server/aux-items.c (aux_item_find_validator): New function. + 1999-04-20 Per Cederqvist Two file descriptors were leaked during startup. @@ -632,6 +884,16 @@ * TODO: Updated according to priorization made by me and David Byers. +1999-03-28 David Byers + + * src/server/simple-cache.c (cached_conf_exists): Test existance + in small_conf_arr. Don't go to disk. + (cached_delete_conf): Free the associated small_conf_stat and set + small_conf_arr[x] to NULL. + + * run-support/aux-items.conf: Restrict creation of mx-author to + creation time. + 1999-02-06 Per Cederqvist * configure.in: Fixed a syntax error introduced yesterday. @@ -672,9 +934,200 @@ * src/include/kom-types.h (L2g_iterator_as_text_list): Typedef removed. -1999-01-18 David Byers +1999-02-02 David Byers + + * src/server/aux-items.h (Aux_item_validation_data): New type. + (Aux_item_validation_function): New type. + (Aux_item_validator): New type. + +1999-01-28 David Byers + + * src/server/prot-a-parse.c (prot_a_parse_aux_item_list): Check + array size for -1. Check allocation of result. + + * src/server/person.c (mark_text): Return no-such-text if the user + is not allowed to read the text (just like get-text-stat) + (set_user_area): Return UNDEF_PERS, not UNDEF_CONF. + + * src/include/kom-errno.h (enum kom_errno): Define + KOM_PERS_EXISTS. + + * src/server/person.c (create_person_generic): Return + KOM_PERS_EXISTS instead of KOM_CONF_EXISTS + +1999-01-27 David Byers + + * src/server/conference.c (do_create_conf): Don't just DIE if we + fail to create a conference. Log a message and return an error. + + * src/server/person.c (create_person_generic): Don't just DIE if + we fail to create a conference. Log a message and return an error. - * src/server/testsuite/tcpconnect.py (fdset): Accep + * src/server/ram-output.c (foutput_conference_2): Output a space + before the l2g mapping. + (foutput_person_2): Same thing here. + +1999-01-26 David Byers + + * src/server/person.c (create_person_old): Add parameter in call + to create_person. + (create_person): Added flags parameter. + (create_person_generic): Set the personal flags from the + parameter. + (set_pers_flags): New function to set the personal flags of a + person. + + * src/server/fncdef.txt: Added set_pers_flags and added pers_flags + argument to create_person. + +1999-01-25 David Byers + + * doc/hacking.texi (Parsing Bit Fields): New section. + + * src/server/prot-a-parse.c (prot_a_parse_priv_bits): New + function. New model for parsing bit fields that's really tolerant + about the token length. Anything from one bit and up is cool. + + * src/server/prot-a-parse.h: Added prot_a_parse_priv_bits. + + * src/server/connections.h: Added pers_flags to Connection. + + * src/server/internal-connections.c (init_connection): Initializer + pers_flags field. + + * src/server/prot-a-parse-arg-c.awk: Added pers_flags. + + * src/server/call-switch.awk: Added pers_flags. + + * src/server/person.c (set_user_area): Return KOM_UNDEF_CONF if + the person is secret. + + * src/server/conference.c (get_conf_stat_old): Check access with + <= none and not == none. + (get_conf_stat_older): Same here. + + * src/server/person.c (get_person_stat): Check access with <= none + and not == none + (get_person_stat_old): Same here. + (get_created_texts): Same here. + (map_created_texts): Same here. + +1999-01-24 David Byers + + * src/server/connections.c (login_request): Use param.nologin_file + instead of hard-coded path. + + * doc/lyskomd.texi (Parameters): Documented Nologin file + + * src/server/server-config.c: Added "Nologin file" + + * src/server/param.h: Added nologin_file. + + * src/server/conference.c (legal_name): Return bad-name on attempt + to use null string. + + * src/server/log.c (restart_kom): Do normal exit if AVOID_ABORTS + is defined. + + * acconfig.h: Added AVOID_ABORTS + + * configure.in: Define AVOID_ABORTS when the user says --with-gcov + + * src/server/conf-file.c (configure_line): Complain about too many + assignments at one too many assignments, not two too many. + + * src/server/simple-cache.c (sync_part): Don't save if + param.never_save is set. + + * src/server/server-config.c: Compile in never_save always. + +1999-01-23 David Byers + + * src/server/session.c (set_client_version): Use client_data_len + as max length for client version and client name. + + * doc/lyskomd.texi (Parameters): Documented max client data + length. + + * src/server/param.h: Added client_data_len. + + * src/server/server-config.c: Added max client data length. + + * src/server/text.c (submit_to): Set err-stat to the last conf in + the chain, not zero, if we hit the top of the super-conf chain + without finding something we can write to. + (sub_recipient): Check for access to the supposed recipient before + checking if it is a recipient. This plugs two leaks of secret + information. + (add_footnote): Set err-stat to footnote when failing because of + not being author to footnote. + (check_comm): Don't set err-stat. The caller will. + +1999-01-22 David Byers + + * src/server/text.c (create_text_check_misc): Return no-such-text + if no read access to footnoted text. Check read access before + checking anything else to avoid leaking secret information. + + * src/server/membership.c (fast_access_perm): fast_access_perm + always returned read_protected for rd_prot conferences, even if + the viewer was the supervisor. Fixed. + + * src/server/text.c (text_read_access): If an open conf is a bcc + recpt, anyone can see the text. + + * doc/Protocol-A.texi (add-recipient): Added error code + access-denied. + + * src/server/text.c (create_text_check_misc): Don't set + kom_errno if it was set in submit_to. + (submit_to): Set kom_errno here instead of in the caller. + (add_recipient): Return KOM_ACCESS if we are not allowed to write + to the target conference. + + * doc/Protocol-A.texi (Error Codes): Fxied speling error + +1999-01-21 David Byers + + * src/server/text.c (recp_sent_by): Fixed error message. + (do_create_text): Fixed speling erorr + + * doc/lyskomd.texi (Parameters): Added documentation for max + conferences and max texts. + +1999-01-19 David Byers + + * src/server/text.c (do_create_text): Pass time to + create_text_add_miscs to ensure correct timestamp. + (create_text_add_miscs): Set last_written to correct + timestamp. + + * src/server/conf-file.c (assign_ulong): New function. + + * run-support/config: Added max_confs and max_texts to default + config file. + + Remove compiled-in size limits. + * src/server/dbck-cache.c (init_cache): Dynamically allocate + pers_arr, conf_arr, text_arr and name_list. + + * src/server/dbck.c: Dynamically alloc person_scratchpad in + init_person_scratchpad. + + * src/server/simple-cache.c (init_cache): Allocate the + small_conf_arr. + (cached_create_conf): Use param.max_conf, not MAX_CONF + (cached_create_text): Use param.max_text, not MAX_TEXT + (init_cache): Use param.max_conf and param.max_text, not MAX_CONF + and MAX_TEXT + + * src/server/aux-items.c: Moved initialization of sent_at to + prepare_aux_item_list from other functions. + + * src/server/log.h: Changed names from log to kom_log to avoid + shadowing log in math.h. + +1999-01-18 David Byers * src/server/testsuite/config/unix.exp (suspend_client): New function. Suspends reading from lyskomd. diff --git a/NEWS b/NEWS index bc184425d0093ee1797e6884a12a9dfb79595d44..09c9be93584d8261054d77836862330f921d6c15 100644 --- a/NEWS +++ b/NEWS @@ -34,8 +34,15 @@ Changes in lyskomd 2.0.0 (Release date TBD) * There is a call to get the collate table being used by the server. -* The error status field is now set to something semi-useful in all - calls. +* A call to set the flags field in a person structure has been added. + The new version of create-person also takes flags as a parameter. + +* Error reporting from the server has been improved. The possible + error codes from each call have been checked and documented. In the + process some calls now return errors they previously did not. Since + the error returns were never defined, this should not present a + problem for existing clients. The error-status field is set to + something semi-useful in all cases. * There is a new parameter (keep_commented) on conferences for tuning the garbage collection process. This tuning is not implemented in diff --git a/TODO b/TODO index 4faed47ecc577af5037c0137915412dbe93a1e60..336871e91f9c701abbe583ebd5ddd2e7e6905cdd 100644 --- a/TODO +++ b/TODO @@ -4,6 +4,9 @@ server. Before the next release ======================= +Dokumentera vad sessionsnummer 0 betyder. +Testfall för sända meddelande till hemligt möte + * Showstoppers ** Make sure that there are no "expected failures" in the test suite. @@ -26,6 +29,10 @@ Before the next release ** Documentation Issues +*** Document "%%Unsupported protocol" message + +*** Document "%% No connections left" message + *** Remove the text "In all likelihood, the implementation of this flag is screwed up." from lyskomd.texi after checking that supervisor-only works properly. @@ -82,18 +89,97 @@ Before the next release ** Testing +*** In prot_a_get_token, what is an insane token length? + *** Test validation of regexps containing groups. Try "X\\(YZ\\)?X". I will do this. --DCB +*** Statement coverage tests for the aux-item-def parser + ** Known Bugs +*** Should anyone be able to set their letterbox to secret? + +*** There is no way to set the Personal_flags. It's not even obvious + where it gets its initial value! This is Not Good At All. + +*** If we try to create a pers or conf and have reached the limit + of how many confs we can create, lyskomd just dies. Nasty. It + should return index-out-of-range, like create-text. + +*** Timestamps of various things are not synchronized. + This is seen easily when lyskomd executes really slowly. + Known cases: last-written does not match text-stat (FIXED) + aux-item sent-at don't match created in text&conf + (FIXED) + There might be others. + + +*** Fixa s{kerhetsbuggen vid read_texts et c. Det b|r vara s} att man + inte f}r veta mappningen s} ofta som nu. Vilka texter som {r l{sta + b|r ocks} vara mer hemligt. Ett nytt anrop, query_unread(), b|r + inf|ras. Resultatet {r antalet ol{sat brev och _kanske_ + Local_text_no f|r det h|gsta nummret. + + (Det var l{nge sen jag skrev det h{r, och jag minns inte riktigt + vad jag menar, men man borde nog titta p} det h{r s} sm}ningom). + + *** Asynchronous messages may not be censored enough. Check all messages that contain conf-nos. +*** difftime is not used everywhere where it should be used. There are + a few places where '-' is still used to get a diff in seconds. ** Improvements +*** We have to be able to limit creation of certain aux-items to users + with special privileges. Most of the import/export items need + this. Put in a new flag in the aux-item-definition file, add it to + the parser, check it in aux_item_check_add_perm or whatever the + hell the function was named. Test it. The biggest problem is to + figure out what permissions should be needed. I suppose it's + possible that we could let the user specify level and bits in the + aux-items.conf file, but that would mean mucking more with the + parser. + I will do this. --DCB + +*** We have to be able to specify that some aux-items can only be + created by the server. It's possible that admins should be allowed + to create them as well. Perhaps this point and the previous point + can be solved as one. + +*** When creating an FAQ item create a reverse item on the text. Make + sure that they are always added and removed as a pair. Accomplish + this with the add, delete and undelete triggers. + +*** Add triggers have to have the capability of preventing addition. + This is difficult since we check the validity of addition before + adding the items. The prevention would have to happen in the check + phase, when the triggers are not called. The correct solution is + probably to implement validation functions in addition to + validation strings and let the validation function take care of + checking if the item can be added. + +*** The mark text trigger has to cause add failure if the text does + not exist. + +*** Fine-tune the Text_mapping data type (3623903, 3624144, 3624179, 3624173). + +*** The Info structure should contain statistics about the server + (uptime, other interesting stuff.) (from 1991) Implement, reject + or postpone. + +*** Read all texts in LysKOM (-) Systemet, protokollet mm created + after 1991 (start at text 170527) and incorporate selected + information in this document. + +*** Improve the file format for local-to-global.c. + +*** Improve the file format for local-to-global.c. Warning: this will + cause an incompatible change in the database format. + *** Use libisc 1.0. I will do this --ceder @@ -115,6 +201,21 @@ Before the next release * High priority, but they can wait until after the next release. +** Fix all bitfield parsers to deal with arbitrary lengths. Maybe... + +** Call to s_fcrea_str in prot_a_get_token should be removed. There is + really no reason why we can't us a statically allocated string + instead (I know, this is microoptimization, but this function gets + called a *lot*) + +** Change log.c to something better. + +** Look over all places where restart_kom is called. Frequently the + error is not severe enough to warrant panicing (or so I think.) For + example, if cached_create_person fails it is very serious, but all + code that calls this function is prepared to deal with the + problems. + ** Actually remove all man pages. This must wait till after the next release. ** We have to be able to limit creation of certain aux-items to users @@ -479,6 +580,10 @@ Before the next release *** Integrate doc/Bugrapporter into this document. DONE. +*** Get rid of tmp-limits.h + I'll do this --DCB + DONE. + ** Let the author of a text add other people's texts as footnotes. (from 1991) REJECT. (ceder & DCB 1999-03-28) @@ -566,6 +671,7 @@ Before the next release removed. (1108039). REJECT: too much work to be worth it. + * In progress ** Document aux-items for mail import/export. (3229403) @@ -662,8 +768,8 @@ Before the next release eller något väsensskillt?) (3228045) ------------------------------------------ - Local variables: mode: outline End: + diff --git a/acconfig.h b/acconfig.h index bf5163a9e44c09f80a8a0d652c398b15ca4a97f5..3eed355ee1ef4399cee1c42d326ddd0af8342293 100644 --- a/acconfig.h +++ b/acconfig.h @@ -1,5 +1,5 @@ /* - * $Id: acconfig.h,v 1.2 1999/01/14 11:49:07 byers Exp $ + * $Id: acconfig.h,v 1.3 1999/05/12 13:24:00 byers Exp $ * Copyright (C) 1998 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -24,6 +24,11 @@ */ +/* This should be defined if you want gcov statistics. + It replaces some aborts with exits so coverage data + is output */ +#undef AVOID_ABORTS + /* Define if you want to define special debugging calls. If you don't know if you need this, you don't. */ #undef DEBUG_CALLS diff --git a/configure.in b/configure.in index 6a80b375c4b3214efece1c2e7336bfdd3e1946a0..447bd94da550ca531d9e13a3efb0c7ff5676908f 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -dnl $Id: configure.in,v 1.58 1999/04/28 22:04:50 ceder Exp $ +dnl $Id: configure.in,v 1.59 1999/05/12 13:24:01 byers Exp $ dnl Configuration for LysKOM dnl Copyright (C) 1993, 1994, 1995, 1996 Lysator Academic Computer Association. dnl @@ -18,7 +18,7 @@ dnl Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. dnl dnl Please mail bug reports to bug-lyskom@lysator.liu.se. dnl -AC_REVISION($Revision: 1.58 $) +AC_REVISION($Revision: 1.59 $) AC_INIT(src/server/lyskomd.h) AM_CONFIG_HEADER(config.h) AC_CONFIG_AUX_DIR(scripts) @@ -34,6 +34,11 @@ AC_ARG_WITH([efence], [use_efence=$withval], [use_efence=no]) +AC_ARG_WITH([insure++], + [ --with-insure++ compile with ParaSoft Insure++], + [use_insure=$withval], + [use_insure=no]) + AC_ARG_WITH([checker], [ --with-checker compile with Gnu Checker], [use_checker=$withval], @@ -110,6 +115,7 @@ then] [if test "$use_gcov" = "yes" -a -n "$GCC"; then] CMOD_COMPILER_CC_ACCEPTS([-ftest-coverage]) CMOD_COMPILER_CC_ACCEPTS([-fprofile-arcs]) + AC_DEFINE(AVOID_ABORTS) [fi] [if test -n "$opt_level" -a "$opt_level" != "yes" ; then @@ -241,6 +247,13 @@ dnl dnl Check for use of Gnu checker dnl +[if test "$use_insure" = "yes" +then] + AC_CHECK_PROGS(INSURE, insure) + [ CC="insure" + LDFLAGS="-Zsl $LDFLAGS" ] +[fi] + [if test "$use_checker" = "yes" then] AC_CHECK_PROGS(CHECKER, checker) diff --git a/doc/Protocol-A.texi b/doc/Protocol-A.texi index 7a0cffb72be8bb9b8ef8aa3f363d91538cc711bd..0589aa33853b51f0442609a8a9c6455e2196e237 100644 --- a/doc/Protocol-A.texi +++ b/doc/Protocol-A.texi @@ -2,7 +2,7 @@ @c @c FIXME: Explain how the garb works with nice and keep-commented @c -@c $Id: Protocol-A.texi,v 1.61 1999/05/10 16:39:30 mirar Exp $ +@c $Id: Protocol-A.texi,v 1.62 1999/05/12 13:24:12 byers Exp $ @c %**start of header @setfilename protocol-a.info @settitle LysKOM Protocol A @@ -751,21 +751,21 @@ no understanding of the contents can successfully parse the item anyway @node Predefined Aux-Item Types @subsection Predefined Aux-Item Types -Predefined Aux-Item types are part of Protocol A, and clients are -encouraged to support all of them. As with other parts of the protocol, -changes to these item types will probably always be -backwards-compatible. +Predefined Aux-Item types are part of Protocol A, and clients should +support all of them. As with other parts of the protocol, changes to +these definitions will be made backwards-compatible, if possible. -Predefined types can case serious magic to be invoked in the server. -There is no limit to the strangeness that may be associated with this -type of item. The server may also place limits on who may create -predefined items, might verify the data field, and can force any field -in the item to a specific value, no matter what the client specified. +Creation and deletion of items with a predefined type can cause +arbitrarily complex and wonderous behavior in the server. Furthermore, +the server may place constraints on the items with regard to content, +flags, who can create them, to what objects they can be attached to and +so forth. The server may also silently enforce specific values for any +field of an item, regardless of what the client requests. All items with tags in the range 1-9999 and 30000 and up are considered predefined. If a client attempts to create an item with a tag in this range, but the server has no idea what that tag means, the server will -return an error (KOM_ILL_AUX.) +return an error (illegal-aux-item.) @@ -920,9 +920,8 @@ server administrator. The creator cannot be hidden. @item faq-text [14] (conference, server) Data is a decimal text number, which is a FAQ for the conference (or -server). This aux-item can only be set by the administrator. Adding -this item to a conference or to the server automatically marks the text. -Deleting the item unmarks the text. +server). Creating an item of this type automatically causes creation of +a faq-for-conf item. This item can only be set by the supervisor or server administrator. The hide-creator, secret, and inherit bits are automatically cleared. @@ -997,7 +996,9 @@ the imported text will have been created at a later date. @item mx-message-id [22] (text) Data is the @code{Message-ID} header of an imported e-mail. This is used -by e-mail importers. +by e-mail importers. LysKOM exporters should set the message ID to +@code{ ( Pers-No ); @end example @@ -6781,13 +6803,14 @@ This call requests that the server create a new person with the name and password given as arguments. To create a person the session must be logged in as a person with sufficient privileges. The list @code{aux-items} contains the aux items that are to be attached to the -new person's mailbox conference. +new person's mailbox conference. The person flags are set to +@code{flags}. The new person will be a member of exactly one conference: the associated mailbox. That membership will have priority 255 and (of course) position 0. All flags of the membership will be 0. -Unlike call number 5, this call does not automatically do a visible +Unlike call number 5, this call does not automatically do an automatic login. @@ -6803,8 +6826,8 @@ creation before logging in. The server does not allow anyone to create person and the person currently logged on does not have the @code{create-pers} bit set. -@item conference-exists -There is already a conference named @code{name}. +@item person-exists +There is already a person named @code{name}. @item invalid-password The string @code{passwd} is not a valid password. @@ -7456,6 +7479,7 @@ ever existed in the conference. The conference exists, but the client is not allowed to retrieve information about the texts in the conference. + @end table @node set-keep-commented @@ -7485,6 +7509,34 @@ complete the call anyway. @end table +@node set-pers-flags, , set-keep-commented, Protocol Requests +@subsection set-pers-flags (10) Recommended + +@findex set-pers-flags +@example + set-pers-flags [106] (( pers-no : Pers-no; + flags : Personal-Flags; )) + -> ( ); +@end example + +Set the flags field of person @code{pers-no} to @code{flags}. This call +can only be issued by the person supervisor or a privileged user. + +@unnumberedsubsubsec Error Codes + +@table @code +@item login-first +Login required before issuing this call. +@item conference-zero +The @code{pers-no} parameter is zero. +@item undefined-person +The person does not exist, or the session does not have permission to +know about the person. +@item permission-denied +Person exists, but the session does not have permission to change the +flags. +@end table + @node Asynchronous Messages @chapter Asynchronous Messages @@ -7930,7 +7982,7 @@ characters. @code{error-status} is undefined. @item index-out-of-range (19) Attempt to use a number that's out of range. The range and meaning of the numbers depends on the call issued. @code{error-status} is -undefined. +undefined unless stated otherwise in the call documentation. @item conference-exists (20) Attempt to create a conference or person with a name that's already @@ -7999,7 +8051,7 @@ comments. @item footnote-limit (35) Attempt to add a footnote to a text that already has the maximum number of footnote. @code{error-status} is the text with the maximum number of -footnote. +footnotes. @item mark-limit (36) Attempt to add a mark to a text that already has the maximum number @@ -8075,7 +8127,8 @@ server. @code{error-status} is undefined. @item message-not-sent (53) Attempt to send an asynchronous message failed for some reason. Perhaps -the recipient is not accepting messages at the moment. +the recipient is not accepting messages at the moment or there are no +viable recipients for a group message. @code{error-status} is undefined. @item invalid-membership-type (54) @@ -8284,10 +8337,10 @@ to answer some questions that seem to come up over and over again. @node Only read the most recent N texts @subsection Only read the most recent N texts + @node Review the last N by FOO to BAR @subsection Review the last N by FOO to BAR - @node Client Conventions @section Client Conventions @@ -8388,10 +8441,11 @@ The date should be set to the date the text was created, not the date the text was exported. @item Message-ID -The message ID is to have the format ``T@i{textno}@@@i{server}'', where -@i{textno} is the text number in the server and @i{server} is the name -of the LysKOM server. This allows the importer to figure out how to -thread e-mail replies to exported messages. +The message ID is to have the format +@code{}, where @i{textno} is the text +number in the server and @i{server} is the name of the LysKOM server. +This allows the importer to figure out how to thread e-mail replies to +exported messages. @item From If the message originates with the LysKOM server, the exporter @@ -8507,7 +8561,7 @@ function exporter () if (text text_no is not imported or text text_no has an mx-to item created after the text) message = get-text text_no - message-ID = text_no@@server + message-ID = date = creation-date of message to = mx-to item of text text_no cc = mx-cc item of text text_no diff --git a/doc/hacking.texi b/doc/hacking.texi index 0a03037bd30e8ff6843cc4040ebe7da93f559318..8db8376df907a717dfa746ff62fdf1be09aaac6a 100644 --- a/doc/hacking.texi +++ b/doc/hacking.texi @@ -1,5 +1,5 @@ \input texinfo -@c $Id: hacking.texi,v 1.5 1999/01/18 11:55:13 byers Exp $ +@c $Id: hacking.texi,v 1.6 1999/05/12 13:24:14 byers Exp $ @c %**start of header @setfilename hacking.info @settitle Hacking lyskomd @@ -430,18 +430,20 @@ in the protocol. @item Bump the database version number by one for the next release of the server. -@item Write a function in @code{ram-output.c} to output the new format. -Update all old functions in @code{ram-output.c} that are database +@item Write a function in @file{ram-output.c} to output the new format. +Update all old functions in @file{ram-output.c} that are database version dependent so that they can deal with the new database format. -@item Write a function in @code{ram-parse.c} to read the new format. -Update all old functions in @code{ram-parse.c} that are database version +@item Write a function in @file{ram-parse.c} to read the new format. +Update all old functions in @file{ram-parse.c} that are database version dependent so that they can deal with the new database format. -@item Set the default database format in @code{ram-parse.c} and +@item Set the default database format in @file{ram-parse.c} and @code{ram-output.c}. The variables to change are @code{input_format} and @code{output_format}, respectively. +@item Don't forget to update the functions in @file{memory.c} + @end enumerate @menu @@ -569,12 +571,62 @@ case 1. @chapter Notes @menu +* Parsing Bit Fields:: * Membership Notes:: +* Linking Pairs of Aux Items:: * Notes for fncdef.txt:: * Traversing Connections:: @end menu -@node Membership Notes, Notes for fncdef.txt, Notes, Notes + +@node Parsing Bit Fields, Membership Notes, Notes, Notes +@comment node-name, next, previous, up +@section Parsing Bit Fields + +The parser for a bit field parameter type should be very tolerant of the +length of the token. Anything from a single bit and up should be +permitted. The parser should use default values for bits that are not +provided and ignore extra bits. + +Here is a model function: + +@example +void +prot_a_parse_bitfield(Connection *client, + Bitfield *res) +@{ + String token; + String_size len; + + token = prot_a_get_token(client); + len = s_strlen(token); + if (len <= 0) + longjmp(parse_env, ISC_PROTOCOL_ERR); + + init_bitfield(res); + switch (len = s_strlen(token)) + @{ + default: + case 8: res->bit_8 = token.string[ 7 ]; + case 7: res->bit_7 = token.string[ 6 ]; + case 6: res->bit_6 = token.string[ 5 ]; + case 5: res->bit_5 = token.string[ 4 ]; + case 4: res->bit_4 = token.string[ 3 ]; + case 3: res->bit_3 = token.string[ 2 ]; + case 2: res->bit_2 = token.string[ 1 ]; + case 1: res->bit_1 = token.string[ 0 ]; + @} +@} +@end example + +The function gets the token, checks the sanity of the length, then +initialized the result to its default values. Then it does a switch on +all token lengths that are equal to or smaller than the number of bits +the server knows about. The fall-through ensures that all bits in the +token are read. + + +@node Membership Notes, Linking Pairs of Aux Items, Parsing Bit Fields, Notes @comment node-name, next, previous, up @section Membership Notes @@ -582,7 +634,52 @@ The @code{position} field in the membership is @i{not} stored. It has to be set every time a membership is requested for transmission to the client. -@node Notes for fncdef.txt, Traversing Connections, Membership Notes, Notes + + +@node Linking Pairs of Aux Items, Notes for fncdef.txt, Membership Notes, Notes +@comment node-name, next, previous, up +@section Linking Pairs of Aux Items + +Sometimes two aux items need to work in tandem. The first instance of +this was the FAQ and FAQ-for-conference items. The FAQ item contains the +text number of a text that is a FAQ for a conference. The +FAQ-for-conference item contains the conference for which a text is a +FAQ. This is needed so that deletion of the text properly removes the +aux-item on the conf (plus, it's nice to be able to see that a text is a +FAQ.) + +The @code{linked_item} field in the Aux_item structure is for linking +items. The linking must be managed through the use of triggers. This +field is not visible in the protocol. It is saved in the database. It is +not possible to have more than one link per item. + +Please remember the following points. + +@itemize + +@item The target of a link should have a link back. All links need to go +both ways. + +@item In the add trigger for one end, create the other end of the link +and set the @code{linked_item} field in both items. Don't forget to mark +the objects at both ends as changed. + +@item Deletion and undeletion of the other side of the link will be +managed automatically. You don't need delete and undelete triggers +simply to destroy the other side of a link. + +@item Don't kill the server because one end is missing. It is possible +for the administrator to remove an item manually. Log a message and +continue working. + +@end itemize + + + + + + +@node Notes for fncdef.txt, Traversing Connections, Linking Pairs of Aux Items, Notes @comment node-name, next, previous, up @section Notes for fncdef.txt diff --git a/doc/lyskomd.texi b/doc/lyskomd.texi index ceab5b2833dc227c2b4517ef94387eedc332aed9..8201e74fafb5fe42d2d2d724ff08c80311e87544 100644 --- a/doc/lyskomd.texi +++ b/doc/lyskomd.texi @@ -1,5 +1,5 @@ \input texinfo -@c $Id: lyskomd.texi,v 1.13 1999/04/28 22:14:44 ceder Exp $ +@c $Id: lyskomd.texi,v 1.14 1999/05/12 13:24:15 byers Exp $ @c %**start of header @setfilename lyskomd.info @include version.texi @@ -200,6 +200,16 @@ text number or perhaps a timeout. @table @code +@item Max conferences: @var{int} +The maximum number of conferences possible in the server. This number +must be larger than the number of conferences in the database. This +parameter is required. There is no default. + +@item Max texts: @var{int} +The maximum number of texts possible in the server. This number +must be larger than the number of texts in the database. This +parameter is required. There is no default. + @item Locale: @var{string} Use @var{string} as the locale to run in. This parameter is only available om systems which support the @code{setlocale} call. If this @@ -271,10 +281,9 @@ Should the database be automatically purged of old texts? The default is on. @item Never save: @var{bool} -Do not use unless you know what you are doing. (Note: there is currently -no-one in the LysKOM development group which knows exactly what this -option does, so if you @i{do} know what you're doing, by all means let -us know!) The default is off. +Completely disables saving the database while the server is running. Do +not use this unless you really know what you're doing. The default is +@code{false}. @item Log accesses: @var{path} This parameter can only be set if the server has been compiled with @@ -337,15 +346,19 @@ should handle them. @xref{Aux-Item Definition File} for more details. The path is relative to the installation prefix. Default is @file{etc/aux-items.conf}. +@item Core directory: @var{path} +The Directory where core dumps are written. This path is relative to the +installation prefix. Default is @file{cores}. + @item Status file: @var{path} This file is created by @code{komrunning} to indicate that lyskomd should currently not be running. When this file exists @code{updateLysKOM} will send it a @code{SIGHUP} signal, so that it saves the database and dies. Default is @file{etc/status}. -@item Core directory: @var{path} -The Directory where core dumps are written. This path is relative to the -installation prefix. Default is @file{cores}. +@item Nologin file: @var{path} +If this file exists, the server will not allow any connections at all. +Default is @code{/etc/nologin}. @item Idle timeout: @var{int} Number of milliseconds to sleep when there is nothing for lyskomd @@ -380,6 +393,10 @@ If anything goes wrong while trying to dump the data base (such as if the disk is full), lyskomd will wait for this many minutes before trying again. Default is @code{1}. +@item Max client data length: @var{int} +The maxiumum allowed length for client name and version data. The +default is @code{60}. + @item Max conference name length: @var{int} The maximum length of conference names. The default is @code{60}. @@ -420,7 +437,6 @@ The maximum number of recipients of a text. The default is 512. @item Max comments per text: @var{int} The maximum number of comments a text can have. The default is 128. - @item Max footnotes per text: @var{int} The maximum number of footnotes a text can have. The default is 32. @@ -668,7 +684,12 @@ supervisor of a conference can create items with this tag. @item supervisor-only Boolean, default false. When true, only the supervisors of the author or letterbox can create items with this tag. In all likelihood, the -implementation of this flag is screwed up. +implementation of this flag is screwed up in version 2.0 of lyskomd. + +@item system-only +Boolean, default false. When true, only the server can initiate creation +of items with this tag. This is normally used for items that are created +automatically in response to events in the system. @item permanent Boolean, default false. When true, aux-items with this tag cannot be @@ -710,10 +731,24 @@ bits in the aux-item flags field. These should only be used by lyskomd developers, and then only very carefully. @item validate -String, default none. When set, this specifies a regexp that must match -the data field in newly created items with this tag. If the regexp fails -to match, then the item will not be created. The syntax for strings is -essentially the same as the syntax used in C files. + +String or function, default none. When set to a string, this specifies a +regexp that must match the data field in newly created items with this +tag. If the regexp fails to match, then the item will not be created. +The syntax for strings is essentially the same as the syntax used in C +files. When set to a function, this specified a built-in validation +function to call. + +The following validator functions are currently implemented: + +@table @code + +@item existing-readable-text +Creation is only allowed if the item contains the number of an existing +text that the item creator has permission to read. + +@end table + @end table @@ -739,6 +774,28 @@ deletion is unscheduled. It should undo the effects of the delete trigger. @end table +The following trigger functions are currently defined: + +@table @code +@item mark-text +Increase the mark count for the text the item refers to. The item must +contain the number of a text. This trigger should be combined with the +existing-readable-text validation function. + +@item unmark-text +Decrease the mark count for the text the item refers to. The item must +contain the number of a text. This trigger should be combined with the +existing-readable-text validation function. + +@item link-faq +Create a faq-for-conf item linked to a faq-text item. This trigger is +used exclusively for faq-text items. The item must contain the number of +a text. This trigger must be combined with the existing-readable-text +validation function. + +@end table + + @node Running lyskomd, Administration, Configuration, Top @@ -837,6 +894,11 @@ It can be used for detecting memory leaks. This file contains definitions of the aux-items that the server should support. It is read by @code{lyskomd} at startup. +@item /etc/nologin +If this file exists, lyskomd will not allow anyone to connect to the +server. This path can be set with the @code{Nologin file} parameter in +the server configuration file. + @end table diff --git a/run-support/aux-items.conf b/run-support/aux-items.conf index 00117e47d259da443bd4d51a9c60975d99fd1c1b..228d7f4c49d8aa7349709ab5b69fd43834b10590 100644 --- a/run-support/aux-items.conf +++ b/run-support/aux-items.conf @@ -1,5 +1,5 @@ # -# $Id: aux-items.conf,v 1.6 1999/01/14 11:49:08 byers Exp $ +# $Id: aux-items.conf,v 1.7 1999/05/12 13:24:20 byers Exp $ # Copyright (C) 1994, 1995, 1996 Lysator Academic Computer Association. # # This file is part of the LysKOM server. @@ -220,13 +220,11 @@ author-only = true; hide-creator = false; secret = false; - dont-garb = false; inherit = false; inherit-limit = 1; - add-trigger = mark-text(); - delete-trigger = unmark-text(); - undelete-trigger= mark-text(); + add-trigger = link-faq(); validate = "^[0-9][0-9]*$"; + validate = existing-readable-text(); } # @@ -244,10 +242,10 @@ } # -# Name of actual author. This should require some special privileges. +# Name of actual author. # -16 : mx-author (text) +16 : mx-author (create text) { author-only = true; unique = true; @@ -369,4 +367,15 @@ { author-only = true; validate = "^[0-9]+$"; + validate = existing-readable-text(); +} + +# +# Mirror of FAQ-text +# + +28 : faq-for-conf (text) +{ + system-only = true; + dont-garb = true; } diff --git a/run-support/config b/run-support/config index efeaea17206c83cd389584cb390a43efe3b99ab8..659dc18ff4308cf5fffeabd2d1f2eafa67fbed3f 100644 --- a/run-support/config +++ b/run-support/config @@ -1,10 +1,12 @@ # Sample config file for lyskomd. -# $Id: config,v 1.3 1996/08/02 23:45:48 ceder Exp $ +# $Id: config,v 1.4 1999/05/12 13:24:21 byers Exp $ # This file is placed in the public domain. # Mandatory options: Client port: 4894 Mux port: 4895 +Max conferences: 4765 +Max texts: 2000000 # Default overrides: Log login: yes diff --git a/src/include/kom-errno.h b/src/include/kom-errno.h index 2543a5cf0449873145bf078ce1a297ce7b2e2214..62c3c8da50ba5524b6e14f86611a12a62b110002 100644 --- a/src/include/kom-errno.h +++ b/src/include/kom-errno.h @@ -1,5 +1,5 @@ /* - * $Id: kom-errno.h,v 0.16 1998/10/22 22:03:37 ceder Exp $ + * $Id: kom-errno.h,v 0.17 1999/05/12 13:24:26 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -56,8 +56,7 @@ typedef enum KOM_BAD_NAME = 18, /* Too short/long or contains illegal chars */ KOM_INDEX_OUT_OF_RANGE = 19, /* */ KOM_CONF_EXISTS = 20, /* Already exists */ - /* This is not used. - KOM_PERS_EXISTS = 21, Already exists */ + KOM_PERS_EXISTS = 21, /* Already exists */ KOM_SECRET_PUBLIC = 22, /* Cannot be secret and !rd_prot */ KOM_LETTER_BOX = 23, /* Cannot change letter_box flag */ KOM_LDB_ERR = 24, /* Database is corrupted. */ diff --git a/src/include/kom-types.h b/src/include/kom-types.h index a92524d7c391536dd8aa9cdad4c5d830adfadc4e..5a1c2d3f6947b25ed840e3f41949876d46eb723c 100644 --- a/src/include/kom-types.h +++ b/src/include/kom-types.h @@ -1,5 +1,5 @@ /* - * $Id: kom-types.h,v 0.33 1999/04/05 16:05:53 ceder Exp $ + * $Id: kom-types.h,v 0.34 1999/05/12 13:24:27 byers Exp $ * Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -60,6 +60,20 @@ # error This file no longer supports CLIENT #endif +/* Some objects in LysKOM need a type field. + These are the valid values */ + +typedef enum { + NO_OBJECT_TYPE = 0, /* No object at all */ + TEXT_OBJECT_TYPE = 1, /* Text object */ + CONF_OBJECT_TYPE = 2, /* Conference object */ + PERS_OBJECT_TYPE = 3, /* Person object */ + INFO_OBJECT_TYPE = 4 /* System info object */ +} Object_type; + + + + typedef unsigned short Pers_no; typedef unsigned short Conf_no; typedef unsigned long Text_no; @@ -231,6 +245,16 @@ typedef struct { } Aux_item_flags; +typedef struct { + Object_type target_type; + unsigned long target_item; + union { + Conf_no conf; + Text_no text; + } target_object; +} Aux_item_link; + + typedef struct { unsigned long aux_no; Pers_no creator; @@ -239,6 +263,7 @@ typedef struct { unsigned long inherit_limit; unsigned long tag; String data; + Aux_item_link linked_item; } Aux_item; typedef struct { diff --git a/src/include/services.h b/src/include/services.h index 70084ca0fedd6df629b9c56e7f22dfc4d0e0e67c..46c0412afa3323d00c0c7741157e8fde8858b787 100644 --- a/src/include/services.h +++ b/src/include/services.h @@ -1,5 +1,5 @@ /* - * $Id: services.h,v 0.43 1999/02/05 21:39:53 ceder Exp $ + * $Id: services.h,v 0.44 1999/05/12 13:24:28 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -154,9 +154,14 @@ KOM_( create_person_old (const String name, extern Pers_no KOM_( create_person (const String name, const String passwd, + Personal_flags flags, Aux_item_list *conf_aux )); +extern Success +set_pers_flags(Pers_no pers_no, + Personal_flags flags); + /* Obsolete call; use get_person_stat instead. */ extern Success KOM_( get_person_stat_old (Pers_no person, @@ -727,7 +732,6 @@ extern Success KOM_ (backdate_text(Text_no text_no, unsigned long seconds)); - #endif diff --git a/src/server/admin.c b/src/server/admin.c index f9f145376a4df9d3d92b193b02d1f65133c84220..05e381e979997122283d24ba7bd5b39bb7d41b08 100644 --- a/src/server/admin.c +++ b/src/server/admin.c @@ -1,5 +1,5 @@ /* - * $Id: admin.c,v 0.34 1999/04/03 22:23:20 ceder Exp $ + * $Id: admin.c,v 0.35 1999/05/12 13:24:53 byers Exp $ * Copyright (C) 1991, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -33,7 +33,7 @@ #endif static const char * -rcsid = "$Id: admin.c,v 0.34 1999/04/03 22:23:20 ceder Exp $"; +rcsid = "$Id: admin.c,v 0.35 1999/05/12 13:24:53 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -188,7 +188,7 @@ set_motd_of_lyskom (Text_no motd) GET_T_STAT(new_motd, motd, FAILURE); if ( new_motd->no_of_marks >= param.max_marks_text ) { - log("LIMIT: set_motd_of_lyskom(%lu): New motd has %d marks.\n", + kom_log("LIMIT: set_motd_of_lyskom(%lu): New motd has %d marks.\n", (unsigned long)motd, new_motd->no_of_marks); err_stat = motd; kom_errno = KOM_MARK_LIMIT; @@ -208,7 +208,7 @@ set_motd_of_lyskom (Text_no motd) } else { - log("ERROR: do_set_motd(): Old motd not marked\n"); + kom_log("ERROR: do_set_motd(): Old motd not marked\n"); } } @@ -252,6 +252,8 @@ send_message (Conf_no recipient, CHK_LOGIN(FAILURE); + /* Check that the message is not too long */ + if (s_strlen(message) > param.broadcast_len) { err_stat = param.broadcast_len; @@ -259,32 +261,37 @@ send_message (Conf_no recipient, return FAILURE; } - if (recipient != 0 && cached_conf_exists(recipient) == FALSE) - { - err_stat = recipient; - kom_errno = KOM_UNDEF_CONF; - return FAILURE; - } - - if (recipient == 0 || cached_get_conf_type(recipient).letter_box == 1) - return async_send_message(recipient, - ACTPERS, - message, - ( recipient != 0 || - ENA(admin, 1) )); - else + /* If the recipient is not everyone, send it to all members */ + + if (recipient != 0) { - /* The recipient is a conference. Send the message to all - members of that conference. */ + GET_C_STAT(conf_c, recipient, FAILURE); + + /* Check that the conference is not secret */ + + if (access_perm(recipient, conf_c, ACTPERS, ACT_P) <= none) + { + err_stat = recipient; + kom_errno = KOM_UNDEF_CONF; + return FAILURE; + } + + /* Conference is not secret. Traverse its members */ - GET_C_STAT(conf_c, recipient, FAILURE); end = conf_c->members.no_of_members; retval = FAILURE; + err_stat = 0; + kom_errno = KOM_MESSAGE_NOT_SENT; + for (ix = 0; ix < end; ix++) { + /* Don't send messages to passive members */ + if (conf_c->members.members[ix].type.passive) continue; + /* Send message to appropriate sessions */ + if (async_send_group_message(conf_c->members.members[ix].member, recipient, ACTPERS, @@ -294,8 +301,16 @@ send_message (Conf_no recipient, retval = OK; } } - return retval; } + else + { + /* Attempting to broadcast */ + + retval = async_send_message(recipient, ACTPERS, + message, ENA(admin, 1)); + } + + return retval; } @@ -342,7 +357,7 @@ shutdown_kom (int UNUSED(exit_val)) name = s_crea_c_str (active_connection->username); user = s_crea_c_str (active_connection->ident_user); host = s_crea_c_str (active_connection->hostname); - log ("shutdown initiated by person %d (%s) via %s@%s.\n", + kom_log("shutdown initiated by person %d (%s) via %s@%s.\n", ACTPERS, name, user, host); string_free(host); string_free(user); @@ -364,20 +379,20 @@ modify_server_info(Number_list *items_to_delete, return FAILURE; } - prepare_aux_item_list(items_to_add, ACTPERS); + prepare_aux_item_list(items_to_add, ACTPERS, time(NULL)); if (check_delete_aux_item_list(items_to_delete, &kom_info.aux_item_list)!=OK) return FAILURE; delete_aux_item_list(items_to_delete, &kom_info.aux_item_list, - OTHER_OBJECT_TYPE, + INFO_OBJECT_TYPE, 0, NULL); if (system_check_add_aux_item_list(&kom_info, items_to_add, ACTPERS) != OK) { undelete_aux_item_list(items_to_delete, &kom_info.aux_item_list, - OTHER_OBJECT_TYPE, + INFO_OBJECT_TYPE, 0, NULL); return FAILURE; } diff --git a/src/server/aux-item-def-parse.y b/src/server/aux-item-def-parse.y index 04a86ea7fc9ed0faeb532542f0c8794600613161..2516bcccaf6f6c73ede8cf04cbfef5c43283cea2 100644 --- a/src/server/aux-item-def-parse.y +++ b/src/server/aux-item-def-parse.y @@ -1,6 +1,6 @@ %{ /* - * $Id: aux-item-def-parse.y,v 1.4 1999/04/20 20:44:42 ceder Exp $ + * $Id: aux-item-def-parse.y,v 1.5 1999/05/12 13:24:55 byers Exp $ * Copyright (C) 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -149,6 +149,12 @@ short aux_item_def_check_trigger(const char *check_name, unsigned long *counter, Aux_item_trigger **triggers); +short aux_item_def_check_validate(const char *check_name, + String field_name, + int type, + String data, + Aux_item_definition *def); + #define YYERROR_VERBOSE %} @@ -198,8 +204,8 @@ head : NUMBER ':' ID '(' targets ')' def.name = s_crea_c_str($3); if (buglevel) { - log("Parsing definition of aux-iem %ld (%s)\n", - def.tag, def.name); + kom_log("Parsing definition of aux-iem %ld (%s)\n", + def.tag, def.name); } s_clear(&($3)); $3 = EMPTY_STRING; @@ -250,12 +256,12 @@ assign : ID '=' value ';' $1, $3, @3.first_line); CHK_ASSIGN("supervisor-only", supervisor_only, BOOLEAN, $1, $3, @3.first_line); + CHK_ASSIGN("system-only", system_only, + BOOLEAN, $1, $3, @3.first_line); CHK_ASSIGN("inherit-limit", inherit_limit, NUMBER, $1, $3, @3.first_line); CHK_ASSIGN("unique", one_per_person, BOOLEAN, $1, $3, @3.first_line); - CHK_ASSIGN("validate", validate_regexp, STRING, - $1, $3, @3.first_line); CHK_ASSIGN("permanent", may_not_delete, BOOLEAN, $1, $3, @3.first_line); CHK_FLAG_A("inherit", inherit, $1, $3, @3.first_line); @@ -268,6 +274,13 @@ assign : ID '=' value ';' CHK_FLAG_A("reserved-4", reserved5, $1, $3, @3.first_line); + found = found ? 1 : + aux_item_def_check_validate("validate", + $1, + $3.type, + $3.val.str, + &def); + found = found ? 1 : aux_item_def_check_trigger("delete-trigger", $3.type, @@ -432,17 +445,15 @@ short aux_item_def_check_trigger(const char *check_name, tmp_string = s_crea_c_str(function_name); trigger = aux_item_find_trigger(tmp_string); + sfree(tmp_string); if (trigger == NULL) { yyerror("undefined function: %s", tmp_string); - sfree(tmp_string); return 1; } - sfree(tmp_string); - *counter += 1; *triggers = srealloc(*triggers, @@ -522,3 +533,73 @@ void parse_aux_item_definitions(char *file) } */ } + + +short aux_item_def_check_validate(const char *check_name, + String field_name, + int type, + String data, + Aux_item_definition *def) +{ + Aux_item_validation_function validator; + char *tmp_string; + + if (s_strcmp(s_fcrea_str(check_name), field_name) == 0) + { + /* + * Validator is a function + */ + + if (type == ID) + { + tmp_string = s_crea_c_str(data); + validator = aux_item_find_validator(tmp_string); + sfree(tmp_string); + + if (validator == NULL) + { + yyerror("undefined function: %s", + tmp_string); + return 1; + } + + def->num_validators += 1; + def->validators = srealloc(def->validators, + def->num_validators * + sizeof(*def->validators)); + + def->validators[def->num_validators-1].type = AUX_VALIDATE_FUNCTION; + def->validators[def->num_validators-1].v.fn.function = validator; + + return 1; + + } + else if (type == STRING) + { + /* + * Validator is a string (regexp) + */ + + def->num_validators += 1; + def->validators = srealloc(def->validators, + def->num_validators * + sizeof(*def->validators)); + + + def->validators[def->num_validators-1].type = AUX_VALIDATE_REGEXP; + def->validators[def->num_validators-1].v.re.regexp = s_crea_c_str(data); + def->validators[def->num_validators-1].v.re.cached_re_buf = NULL; + } + else + { + yyerror("invalid type: expected %s or %s, got %s", + aux_item_def_typename(ID), + aux_item_def_typename(STRING), + aux_item_def_typename(type)); + return 0; + } + + return 1; + } + return 0; +} diff --git a/src/server/aux-item-def.tab.c b/src/server/aux-item-def.tab.c index b7184b20e9d81a3e13d3e9c192ce27e33fe9740c..4cdfff8676df6828b9579c7426c5b04c6b8ac67e 100644 --- a/src/server/aux-item-def.tab.c +++ b/src/server/aux-item-def.tab.c @@ -31,7 +31,7 @@ #line 1 "./aux-item-def.y" /* - * $Id: aux-item-def.tab.c,v 1.5 1999/01/15 11:16:13 byers Exp $ + * $Id: aux-item-def.tab.c,v 1.6 1999/05/12 13:24:56 byers Exp $ * Copyright (C) 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -140,10 +140,16 @@ short aux_item_def_check_trigger(const char *check_name, unsigned long *counter, Aux_item_trigger **triggers); +short aux_item_def_check_validate(const char *check_name, + String field_name, + int type, + String data, + Aux_item_definition *def); + #define YYERROR_VERBOSE -#line 116 "./aux-item-def.y" +#line 122 "./aux-item-def.y" typedef union { String str; @@ -243,9 +249,9 @@ static const short yyrhs[] = { 24, #if YYDEBUG != 0 static const short yyrline[] = { 0, - 141, 142, 145, 155, 168, 178, 179, 182, 183, 184, - 186, 187, 196, 197, 198, 200, 201, 202, 205, 280, - 281, 282, 283, 284 + 147, 148, 151, 161, 174, 184, 185, 188, 189, 190, + 192, 193, 202, 203, 204, 206, 207, 208, 211, 293, + 294, 295, 296, 297 }; #endif @@ -311,7 +317,7 @@ static const short yycheck[] = { 1, 20 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/lib/bison.simple" +#line 3 "/sw/gnu/share/bison.simple" /* Skeleton output parser for bison, Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. @@ -504,7 +510,7 @@ __yy_memcpy (char *to, char *from, int count) #endif #endif -#line 196 "/usr/lib/bison.simple" +#line 196 "/sw/gnu/share/bison.simple" /* The user can define YYPARSE_PARAM as the name of an argument to be passed into yyparse. The argument should have type void *. @@ -809,7 +815,7 @@ yyreduce: switch (yyn) { case 3: -#line 146 "./aux-item-def.y" +#line 152 "./aux-item-def.y" { if (def.tag != 0) { @@ -819,14 +825,14 @@ case 3: ; break;} case 4: -#line 156 "./aux-item-def.y" +#line 162 "./aux-item-def.y" { def.tag = yyvsp[-5].num; def.name = s_crea_c_str(yyvsp[-3].str); if (buglevel) { - log("Parsing definition of aux-iem %ld (%s)\n", - def.tag, def.name); + kom_log("Parsing definition of aux-iem %ld (%s)\n", + def.tag, def.name); } s_clear(&(yyvsp[-3].str)); yyvsp[-3].str = EMPTY_STRING; @@ -834,7 +840,7 @@ case 4: ; break;} case 5: -#line 169 "./aux-item-def.y" +#line 175 "./aux-item-def.y" { def.tag = 0; def.name = s_crea_c_str(yyvsp[-4].str); @@ -844,24 +850,24 @@ case 5: ; break;} case 8: -#line 182 "./aux-item-def.y" +#line 188 "./aux-item-def.y" { def.texts = TRUE; def.text_a = yyvsp[-1].num; ; break;} case 9: -#line 183 "./aux-item-def.y" +#line 189 "./aux-item-def.y" { def.confs = TRUE; def.conf_a = yyvsp[-1].num; ; break;} case 10: -#line 184 "./aux-item-def.y" +#line 190 "./aux-item-def.y" { def.letterboxes = TRUE; def.conf_a = yyvsp[-1].num; ; break;} case 11: -#line 186 "./aux-item-def.y" +#line 192 "./aux-item-def.y" { def.system = TRUE; ; break;} case 12: -#line 188 "./aux-item-def.y" +#line 194 "./aux-item-def.y" { def.texts = TRUE; def.text_a = yyvsp[-1].num; def.confs = TRUE; def.conf_a = yyvsp[-1].num; @@ -870,19 +876,19 @@ case 12: ; break;} case 13: -#line 196 "./aux-item-def.y" +#line 202 "./aux-item-def.y" { yyval.num = yyvsp[-1].num | AUX_ITEM_ADD_ON_CREATE; ; break;} case 14: -#line 197 "./aux-item-def.y" +#line 203 "./aux-item-def.y" { yyval.num = yyvsp[-1].num | AUX_ITEM_ADD_ON_MODIFY; ; break;} case 15: -#line 198 "./aux-item-def.y" +#line 204 "./aux-item-def.y" { yyval.num = 0; ; break;} case 19: -#line 206 "./aux-item-def.y" +#line 212 "./aux-item-def.y" { int found = 0; @@ -890,12 +896,12 @@ case 19: yyvsp[-3].str, yyvsp[-1].value, yylsp[-1].first_line); CHK_ASSIGN("supervisor-only", supervisor_only, BOOLEAN, yyvsp[-3].str, yyvsp[-1].value, yylsp[-1].first_line); + CHK_ASSIGN("system-only", system_only, + BOOLEAN, yyvsp[-3].str, yyvsp[-1].value, yylsp[-1].first_line); CHK_ASSIGN("inherit-limit", inherit_limit, NUMBER, yyvsp[-3].str, yyvsp[-1].value, yylsp[-1].first_line); CHK_ASSIGN("unique", one_per_person, BOOLEAN, yyvsp[-3].str, yyvsp[-1].value, yylsp[-1].first_line); - CHK_ASSIGN("validate", validate_regexp, STRING, - yyvsp[-3].str, yyvsp[-1].value, yylsp[-1].first_line); CHK_ASSIGN("permanent", may_not_delete, BOOLEAN, yyvsp[-3].str, yyvsp[-1].value, yylsp[-1].first_line); CHK_FLAG_A("inherit", inherit, yyvsp[-3].str, yyvsp[-1].value, yylsp[-1].first_line); @@ -908,6 +914,13 @@ case 19: CHK_FLAG_A("reserved-4", reserved5, yyvsp[-3].str, yyvsp[-1].value, yylsp[-1].first_line); + found = found ? 1 : + aux_item_def_check_validate("validate", + yyvsp[-3].str, + yyvsp[-1].value.type, + yyvsp[-1].value.val.str, + &def); + found = found ? 1 : aux_item_def_check_trigger("delete-trigger", yyvsp[-1].value.type, @@ -957,28 +970,28 @@ case 19: ; break;} case 20: -#line 280 "./aux-item-def.y" +#line 293 "./aux-item-def.y" { yyval.value.val.num = yyvsp[0].num; yyval.value.type = BOOLEAN; ; break;} case 21: -#line 281 "./aux-item-def.y" +#line 294 "./aux-item-def.y" { yyval.value.val.str = yyvsp[0].str; yyval.value.type = STRING; ; break;} case 22: -#line 282 "./aux-item-def.y" +#line 295 "./aux-item-def.y" { yyval.value.val.num = yyvsp[0].num; yyval.value.type = NUMBER; ; break;} case 23: -#line 283 "./aux-item-def.y" +#line 296 "./aux-item-def.y" { yyval.value.val.str = yyvsp[-2].str; yyval.value.type = ID;; break;} case 24: -#line 284 "./aux-item-def.y" +#line 297 "./aux-item-def.y" { YYERROR; ; break;} } /* the action file gets copied in in place of this dollarsign */ -#line 498 "/usr/lib/bison.simple" +#line 498 "/sw/gnu/share/bison.simple" yyvsp -= yylen; yyssp -= yylen; @@ -1174,7 +1187,7 @@ yyerrhandle: yystate = yyn; goto yynewstate; } -#line 287 "./aux-item-def.y" +#line 300 "./aux-item-def.y" extern FILE *yyin; @@ -1283,17 +1296,15 @@ short aux_item_def_check_trigger(const char *check_name, tmp_string = s_crea_c_str(function_name); trigger = aux_item_find_trigger(tmp_string); + sfree(tmp_string); if (trigger == NULL) { yyerror("undefined function: %s", tmp_string); - sfree(tmp_string); return 1; } - sfree(tmp_string); - *counter += 1; *triggers = srealloc(*triggers, @@ -1374,3 +1385,70 @@ void parse_aux_item_definitions(char *file) } +short aux_item_def_check_validate(const char *check_name, + String field_name, + int type, + String data, + Aux_item_definition *def) +{ + Aux_item_validation_function validator; + char *tmp_string; + + if (s_strcmp(s_fcrea_str(check_name), field_name) == 0) + { + /* + * Validator is a function + */ + + if (type == ID) + { + tmp_string = s_crea_c_str(data); + validator = aux_item_find_validator(tmp_string); + sfree(tmp_string); + + if (validator == NULL) + { + yyerror("undefined function: %s", + tmp_string); + return 1; + } + + def->num_validators += 1; + def->validators = srealloc(def->validators, + def->num_validators * + sizeof(*def->validators)); + + def->validators[def->num_validators-1].type = AUX_VALIDATE_FUNCTION; + def->validators[def->num_validators-1].v.fn.function = validator; + + return 1; + + } + else if (type == STRING) + { + /* + * Validator is a string (regexp) + */ + + def->num_validators += 1; + def->validators = srealloc(def->validators, + def->num_validators * + sizeof(*def->validators)); + + + def->validators[def->num_validators-1].type = AUX_VALIDATE_REGEXP; + def->validators[def->num_validators-1].v.re.regexp = s_crea_c_str(data); + } + else + { + yyerror("invalid type: expected %s or %s, got %s", + aux_item_def_typename(ID), + aux_item_def_typename(STRING), + aux_item_def_typename(type)); + return 0; + } + + return 1; + } + return 0; +} diff --git a/src/server/aux-items.c b/src/server/aux-items.c index 05a07a4b54982250dae2f2c47321bac3da6f9e97..7302285cfdcdc85dfaf872a5832130dc735962ec 100644 --- a/src/server/aux-items.c +++ b/src/server/aux-items.c @@ -1,5 +1,5 @@ /* - * $Id: aux-items.c,v 1.8 1998/12/30 17:39:34 byers Exp $ + * $Id: aux-items.c,v 1.9 1999/05/12 13:24:58 byers Exp $ * Copyright (C) 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -54,27 +54,60 @@ #include "regex.h" #include "log.h" #include "services.h" +#include "admin.h" +#include "param.h" #define AUX_ADJUST_FLAG(flg) item->flags.flg = (def->clear_flags.flg)?0:((def->set_flags.flg)?1:item->flags.flg) +/* Externally accessible variables (used by the parser) */ + Aux_item_definition *aux_item_definition_list = NULL; -unsigned long num_aux_item_definitions = 0; +unsigned long num_aux_item_definitions = 0; + +/* Variables local to this file */ + static Aux_item_definition compiled_aux_items[] = { }; +/* Forward declaration of triggers */ + void aux_item_trigger_mark_text(Aux_item_trigger_data *); void aux_item_trigger_unmark_text(Aux_item_trigger_data *); +void aux_item_trigger_mirror_faq(Aux_item_trigger_data *); + + +/* Forward declarations of validators */ + +Bool aux_item_validate_existing_text(Aux_item_validation_data *data); + + + +/* Symbol table for the triggers */ static Aux_item_trigger_mapping aux_item_triggers [] = { { "mark-text", aux_item_trigger_mark_text }, { "unmark-text", aux_item_trigger_unmark_text }, + { "link-faq", aux_item_trigger_mirror_faq }, { NULL, NULL } }; + +/* Symbol table for the validators */ + +static Aux_item_validator_mapping +aux_item_validators [] = +{ + { "existing-readable-text", aux_item_validate_existing_text }, + { NULL, NULL } +}; + + +/* Use this to initialize an empty definition */ + Aux_item_definition empty_aux_item_definition = { NULL, /* Name */ @@ -83,6 +116,7 @@ Aux_item_definition empty_aux_item_definition = { 0,0,0,0,0,0,0,0 }, /* Set flags */ 0, /* Author only */ 0, /* Supervisor only */ + 0, /* System only */ 0, /* Unique */ 0, /* Can't delete */ 0, /* Inherit limit */ @@ -92,8 +126,8 @@ Aux_item_definition empty_aux_item_definition = 0, FALSE, /* Letterbox */ FALSE, /* System */ - NULL, /* Validate */ - NULL, /* Cached regexp */ + 0, /* Number of validators */ + NULL, /* Validator list */ 0, NULL, 0, NULL, 0, NULL, @@ -116,6 +150,7 @@ static Aux_item_definition simple_aux_item = { 0,0,0,0,0,0,0,0 }, /* Set flags */ 0, /* Author only */ 0, /* Supervisor only */ + 0, /* System only */ 0, /* Unique */ 0, /* Can't delete */ 0, /* Inherit limit */ @@ -125,8 +160,7 @@ static Aux_item_definition simple_aux_item = 0, TRUE, /* Letterbox */ TRUE, /* System */ - NULL, /* Validate regexp */ - NULL, /* Cached regexp */ + 0, NULL, /* Validators */ 0, NULL, /* Add triggers */ 0, NULL, /* Delete triggers */ 0, NULL, /* Undelete triggers */ @@ -224,6 +258,21 @@ aux_item_find_trigger(char *trigger_name) return NULL; } +Aux_item_validation_function +aux_item_find_validator(char *validator_name) +{ + unsigned long i = 0; + + while (aux_item_validators[i].name != NULL) + { + if (!strcmp(aux_item_validators[i].name, validator_name)) + return aux_item_validators[i].function; + i += 1; + } + return NULL; +} + + /* * find_aux_item_definition * @@ -268,7 +317,7 @@ aux_item_definition_add(Aux_item_definition *def) new_definition = smalloc(sizeof(Aux_item_definition)); if (new_definition == NULL) { - restart_kom("out of memory adding aux-item definitionn"); + restart_kom("out of memory adding aux-item definition"); } *new_definition = *def; num_aux_item_definitions += 1; @@ -285,22 +334,23 @@ aux_item_definition_add(Aux_item_definition *def) */ static void -aux_item_definition_cache_regexp(Aux_item_definition *def) +aux_item_definition_cache_regexp(Aux_item_definition *def, + unsigned long ix) { struct re_pattern_buffer *pat_buf; const char *errmsg; re_syntax_options = RE_SYNTAX_POSIX_EXTENDED; - def->cached_re_buf = smalloc(sizeof(*pat_buf)); - if (def->cached_re_buf == NULL) + def->validators[ix].v.re.cached_re_buf = smalloc(sizeof(*pat_buf)); + if (def->validators[ix].v.re.cached_re_buf == NULL) { - log("Out of memory compiling aux-item regexp %lu (%s).\n", - def->tag, - def->name); + kom_log("Out of memory compiling aux-item regexp %lu (%s).\n", + def->tag, + def->name); return; } - pat_buf = def->cached_re_buf; + pat_buf = def->validators[ix].v.re.cached_re_buf; pat_buf->translate = DEFAULT_COLLAT_TAB; pat_buf->translate = NULL; pat_buf->fastmap = 0; @@ -308,18 +358,18 @@ aux_item_definition_cache_regexp(Aux_item_definition *def) pat_buf->buffer = 0; if ((errmsg = - re_compile_pattern(def->validate_regexp, - strlen(def->validate_regexp), + re_compile_pattern(def->validators[ix].v.re.regexp, + strlen(def->validators[ix].v.re.regexp), pat_buf)) != NULL) { - log("%s in validate regexp of aux-item definition %lu (%s).\n", + kom_log("%s in validate regexp of aux-item definition %lu (%s).\n", errmsg, def->tag, def->name); - if (def->cached_re_buf) - sfree(def->cached_re_buf); - def->cached_re_buf = NULL; + if (def->validators[ix].v.re.cached_re_buf) + sfree(def->validators[ix].v.re.cached_re_buf); + def->validators[ix].v.re.cached_re_buf = NULL; return; } } @@ -344,12 +394,12 @@ initialize_aux_items(char *aux_def_file) parse_aux_item_definitions(aux_def_file); def = aux_item_definition_list; + while (def != NULL) { - if (def->validate_regexp != NULL) - { - aux_item_definition_cache_regexp(def); - } + /* FIXME: If we have validators, go through and cache their + FIXME: regexps, where appropriate */ + def = def->next; } } @@ -360,10 +410,11 @@ initialize_aux_items(char *aux_def_file) static void aux_item_call_add_triggers(Aux_item_definition *def, - short object_type, + Object_type object_type, unsigned long item_index, unsigned long integer_argument, - void * pointer_argument) + void * pointer_argument, + Aux_item * item) { unsigned long i; Aux_item_trigger_data data; @@ -373,6 +424,7 @@ aux_item_call_add_triggers(Aux_item_definition *def, data.item_index = item_index; data.object_no = integer_argument; data.object = pointer_argument; + data.item = item; for (i = 0; i < def->num_add_triggers; i++) { @@ -382,10 +434,11 @@ aux_item_call_add_triggers(Aux_item_definition *def, static void aux_item_call_delete_triggers(Aux_item_definition *def, - short object_type, - unsigned long item_index, - unsigned long integer_argument, - void * pointer_argument) + Object_type object_type, + unsigned long item_index, + unsigned long integer_argument, + void * pointer_argument, + Aux_item *item) { unsigned long i; Aux_item_trigger_data data; @@ -395,6 +448,7 @@ aux_item_call_delete_triggers(Aux_item_definition *def, data.item_index = item_index; data.object_no = integer_argument; data.object = pointer_argument; + data.item = item; for (i = 0; i < def->num_delete_triggers; i++) { @@ -404,10 +458,11 @@ aux_item_call_delete_triggers(Aux_item_definition *def, static void aux_item_call_undelete_triggers(Aux_item_definition *def, - short object_type, + Object_type object_type, unsigned long item_index, unsigned long integer_argument, - void * pointer_argument) + void * pointer_argument, + Aux_item * item) { unsigned long i; Aux_item_trigger_data data; @@ -417,6 +472,7 @@ aux_item_call_undelete_triggers(Aux_item_definition *def, data.item_index = item_index; data.object_no = integer_argument; data.object = pointer_argument; + data.item = item; for (i = 0; i < def->num_undelete_triggers; i++) { @@ -436,7 +492,8 @@ aux_item_call_undelete_triggers(Aux_item_definition *def, void prepare_aux_item_list(Aux_item_list *list, - Pers_no creator) + Pers_no creator, + time_t now) { unsigned long i; @@ -445,13 +502,14 @@ prepare_aux_item_list(Aux_item_list *list, for (i = 0; i < list->length; i++) { - prepare_aux_item(&list->items[i], creator, NULL); + prepare_aux_item(&list->items[i], creator, NULL, now); } } void prepare_aux_item(Aux_item *item, Pers_no creator, - Aux_item_definition *def) + Aux_item_definition *def, + time_t now) { if (item == NULL) return; @@ -475,8 +533,117 @@ void prepare_aux_item(Aux_item *item, item->inherit_limit = def->inherit_limit; item->creator = creator; + item->sent_at = now; + init_aux_item_link(&item->linked_item); +} + + + +static Bool aux_item_validate(Aux_item_validation_data validation_data) +{ + unsigned long i; + Aux_item_definition *def; + + def = validation_data.def; + for (i = 0; i < def->num_validators; i++) + { + switch (def->validators[i].type) + { + case AUX_VALIDATE_FUNCTION: + /* + * Call the validation function + * If it returns false, then abort validation + * If it returns true, then continue with the + * next validator + */ + + if ((*def->validators[i].v.fn.function)(&validation_data) == FALSE) + { + return FALSE; + } + break; + + case AUX_VALIDATE_REGEXP: + + /* + * Ensure that the regexp is cached + */ + + if (def->validators[i].v.re.cached_re_buf == NULL) + { + aux_item_definition_cache_regexp(def, i); + } + + /* + * If the RE is still not cached there is a problem + * in this case to not validate the item at all and + * log a problem + */ + + if (def->validators[i].v.re.cached_re_buf == NULL) + { + kom_log("Failed to cache regexp \"%s\". Rejecting all \"%s\" items", + def->validators[i].v.re.regexp, + def->name); + def->validators[i].type = AUX_VALIDATE_REJECT; + kom_errno = KOM_ILL_AUX; + return FALSE; + } + + /* + * RE is compiled and can be used + */ + + switch (re_search(def->validators[i].v.re.cached_re_buf, + validation_data.item->data.string, + s_strlen(validation_data.item->data), + 0, + s_strlen(validation_data.item->data), + NULL)) + { + case -1: + /* No match */ + kom_errno = KOM_ILL_AUX; + return FALSE; + case -2: + /* Internal error may (be temporary) */ + kom_log("Internal error in regex matching aux-item data."); + kom_errno = KOM_ILL_AUX; + return FALSE; + break; + default: + /* Matched */ + break; + } + + + break; + + case AUX_VALIDATE_REJECT: + /* + * Just reject the item. Used when we detect a problem + * with a validator + */ + + kom_errno = KOM_ILL_AUX; + return FALSE; + break; + + default: + kom_log("BUG: unknown aux_item validator type"); + break; + } + } + + /* + * If we got all the way to here we passed all the validators + */ + + return TRUE; + } + /* * aux_item_add_perm * @@ -508,7 +675,7 @@ aux_item_add_perm(Aux_item *item, Aux_item_list *add_to_list, unsigned long start_looking_at, Bool creating, - short object_type + Object_type object_type ) { short can_add_when = 0; @@ -542,6 +709,13 @@ aux_item_add_perm(Aux_item *item, } } + if (def->system_only && + owner_check) + { + kom_errno = KOM_AUX_PERM; + return FALSE; + } + if (def->author_only && owner_check && object_creator != item_creator && @@ -571,34 +745,25 @@ aux_item_add_perm(Aux_item *item, /* Check the contents */ - if (def->validate_regexp) + if (def->num_validators > 0) { - /* If regexp is not cached, cache it */ - if (def->cached_re_buf == NULL) - aux_item_definition_cache_regexp(def); - - /* If it's still not cached, then ignore it. Can't add item. */ - if (def->cached_re_buf == NULL) + Aux_item_validation_data validation_data; + + validation_data.item = item; + validation_data.def = def; + validation_data.item_creator = item_creator; + validation_data.object_creator = object_creator; + validation_data.owner_check = owner_check; + validation_data.add_to_list = add_to_list; + validation_data.start_looking_at = start_looking_at; + validation_data.creating = creating; + validation_data.object_type = object_type; + + if (aux_item_validate(validation_data) != TRUE) { kom_errno = KOM_ILL_AUX; return FALSE; } - - switch ( re_search (def->cached_re_buf, - item->data.string, s_strlen(item->data), - 0, s_strlen(item->data), - NULL) ) - { - case -1: - kom_errno = KOM_ILL_AUX; - return FALSE; - case -2: - log("Internal error in regex matching aux-item data."); - break; - default: - /* Matched */ - break; - } } return TRUE; @@ -658,7 +823,7 @@ aux_inherit_items(Aux_item_list *target, unsigned long *counter, Pers_no target_creator, Bool creating, - short object_type, + Object_type object_type, unsigned long object_no, void *object) { @@ -666,6 +831,8 @@ aux_inherit_items(Aux_item_list *target, Aux_item item; Aux_item_definition *def; + /* FIXME: Inheriting linked items is strange, but works. */ + if (!target || !parent) return; @@ -690,7 +857,8 @@ aux_inherit_items(Aux_item_list *target, continue; copy_aux_item(&item, &parent->items[i]); - prepare_aux_item(&item, parent->items[i].creator, def); + prepare_aux_item(&item, parent->items[i].creator, + def, time(NULL)); if (item.inherit_limit != 0) item.inherit_limit -= 1; @@ -705,7 +873,8 @@ aux_inherit_items(Aux_item_list *target, object_type, target->length - 1, object_no, - object); + object, + &target->items[target->length]); } } } @@ -811,6 +980,95 @@ check_delete_aux_item_list(Number_list *items_to_delete, +long +find_aux_item_index(Aux_item_list *list, unsigned long aux_no) +{ + unsigned long i; + + for (i = 0; i < list->length; i++) + { + if (list->items[i].aux_no == aux_no) + return i; + } + + return -1; +} + + +/* Find the aux item list containing the item that ITEM is linked to */ + +static Aux_item_list * +find_linked_aux_item_list(Aux_item *item) +{ + Text_stat *text_stat; + Conference *conf_stat; + + switch (item->linked_item.target_type) + { + case NO_OBJECT_TYPE: + return NULL; + + case TEXT_OBJECT_TYPE: + GET_T_STAT(text_stat, item->linked_item.target_object.text, NULL); + return &text_stat->aux_item_list; + + case CONF_OBJECT_TYPE: + GET_C_STAT(conf_stat, item->linked_item.target_object.conf, NULL); + return &text_stat->aux_item_list; + + case INFO_OBJECT_TYPE: + return &kom_info.aux_item_list; + + case PERS_OBJECT_TYPE: + default: + /* No lists in these items */ + kom_log("find_linked_aux_item_list: Bad aux_item somewhere: link to person or other kind."); + return NULL; + } +} + +/* Find the aux item that ITEM is linked to */ + +static Aux_item * +find_linked_aux_item(Aux_item *item) +{ + Aux_item_list *target_list; + + target_list = find_linked_aux_item_list(item); + if (target_list == NULL) + return NULL; + + return find_aux_item(target_list, item->linked_item.target_item); +} + +/* Mark the object linked to by an aux_item as changed */ + +static void +mark_linked_object_as_changed(Aux_item *item) +{ + Text_stat *text_stat; + Conference *conf_stat; + + switch (item->linked_item.target_type) + { + case TEXT_OBJECT_TYPE: + VOID_GET_T_STAT(text_stat, item->linked_item.target_object.text); + mark_text_as_changed(item->linked_item.target_object.text); + break; + + case CONF_OBJECT_TYPE: + VOID_GET_C_STAT(conf_stat, item->linked_item.target_object.conf); + mark_conference_as_changed(item->linked_item.target_object.conf); + break; + + case INFO_OBJECT_TYPE: + case PERS_OBJECT_TYPE: + default: + /* Need no commit for these objects */ + } +} + + /* * delete_aux_item_list * @@ -823,13 +1081,19 @@ check_delete_aux_item_list(Number_list *items_to_delete, void delete_aux_item_list(Number_list *items_to_delete, Aux_item_list *list_to_delete_from, - short object_type, + Object_type object_type, unsigned long object_no, void *object) { long i; Aux_item *item; + Aux_item *linked_item; long item_index; + long item_to_delete; + unsigned long linked_object_no; + Number_list linked_delete; + Aux_item_list *linked_item_list; + void *linked_object; for (i = 0; i < items_to_delete->length; i++) { @@ -846,7 +1110,50 @@ delete_aux_item_list(Number_list *items_to_delete, object_type, item_index, object_no, - object); + object, + item); + /* If we have linked items, undelete them too. + It is safe to do this with a recursive call + since we have marked this item as undeleted. + But just to avoid pointless recursion, only + do the recursive call if the corresponding + item is marked as deleted */ + + linked_item = find_linked_aux_item(item); + if (linked_item && !linked_item->flags.deleted) + { + /* Set up the undelete list for the target object */ + item_to_delete = item->linked_item.target_item; + linked_delete.length = 1; + linked_delete.data = &item_to_delete; + + /* Find the item list to undelete from */ + linked_item_list = find_linked_aux_item_list(item); + + /* Set up the object and object_no parameters for undelete */ + switch (item->linked_item.target_type) + { + case CONF_OBJECT_TYPE: + linked_object_no = item->linked_item.target_object.conf; + linked_object = (void*)cached_get_text_stat(linked_object_no); + break; + case TEXT_OBJECT_TYPE: + linked_object_no = item->linked_item.target_object.text; + linked_object = (void*)cached_get_conf_stat(linked_object_no); + break; + case INFO_OBJECT_TYPE: + linked_object_no = 0; + linked_object = NULL; + break; + default: + } + + delete_aux_item_list(&linked_delete, + linked_item_list, + item->linked_item.target_type, + linked_object_no, + linked_object); + } } } @@ -859,13 +1166,19 @@ delete_aux_item_list(Number_list *items_to_delete, void undelete_aux_item_list(Number_list *items_to_undelete, Aux_item_list *list_to_undelete_from, - short object_type, + Object_type object_type, unsigned long object_no, void *object) { - long i; - Aux_item *item; - long item_index; + long i; + Aux_item *item; + Aux_item *linked_item; + Aux_item_list *linked_item_list; + long item_index; + long item_to_undelete; + unsigned long linked_object_no; + Number_list linked_undelete; + void *linked_object; for (i = 0; i < items_to_undelete->length; i++) { @@ -882,10 +1195,55 @@ undelete_aux_item_list(Number_list *items_to_undelete, object_type, item_index, object_no, - object); + object, + item); + + /* If we have linked items, undelete them too. + It is safe to do this with a recursive call + since we have marked this item as undeleted. + But just to avoid pointless recursion, only + do the recursive call if the corresponding + item is marked as deleted */ + + linked_item = find_linked_aux_item(item); + if (linked_item && linked_item->flags.deleted) + { + /* Set up the undelete list for the target object */ + item_to_undelete = item->linked_item.target_item; + linked_undelete.length = 1; + linked_undelete.data = &item_to_undelete; + + /* Find the item list to undelete from */ + linked_item_list = find_linked_aux_item_list(item); + + /* Set up the object and object_no parameters for undelete */ + switch (item->linked_item.target_type) + { + case CONF_OBJECT_TYPE: + linked_object_no = item->linked_item.target_object.conf; + linked_object = (void*)cached_get_text_stat(linked_object_no); + break; + case TEXT_OBJECT_TYPE: + linked_object_no = item->linked_item.target_object.text; + linked_object = (void*)cached_get_conf_stat(linked_object_no); + break; + case INFO_OBJECT_TYPE: + linked_object_no = 0; + linked_object = NULL; + break; + default: + } + + undelete_aux_item_list(&linked_undelete, + linked_item_list, + item->linked_item.target_type, + linked_object_no, + linked_object); + } } } + /* * Commit deletions in the aux-item-list. After this has been called * undelete_aux_item_list has no effect. The memory associated with @@ -893,21 +1251,39 @@ undelete_aux_item_list(Number_list *items_to_undelete, * released from memory or reallocated. */ -void -commit_aux_item_list(Aux_item_list *list_to_commit) +static void +commit_aux_item_list_internal(Aux_item_list *list_to_commit, Bool shallow) { - long i; /* Loop index */ - long target; /* Where to move items when compacting */ + long i; /* Loop index */ + long target; /* Where to move items when compacting */ + Aux_item *linked_item; + Aux_item_list *aux_item_list; + target = 0; for (i = 0; i < list_to_commit->length; i++) { if (list_to_commit->items[i].flags.deleted) { - /* If the item we're looking at is deleted - release the memory associated with its - data and then skip it */ + /* Clear the data in the aux item */ + s_clear(&list_to_commit->items[i].data); + + /* If the item we're looking at is linked + to another item, we have to commit the list + of the object the link points to. To avoid + infinite recursion only do this if the + linked item is marked as deleted */ + + linked_item = find_linked_aux_item(&list_to_commit->items[i]); + if (linked_item && + linked_item->flags.deleted && + !shallow) + { + aux_item_list = find_linked_aux_item_list(&list_to_commit->items[i]); + commit_aux_item_list_internal(aux_item_list, TRUE); + mark_linked_object_as_changed(&list_to_commit->items[i]); + } continue; } else if (target != i) @@ -938,6 +1314,14 @@ commit_aux_item_list(Aux_item_list *list_to_commit) } +void commit_aux_item_list(Aux_item_list *list_to_commit) +{ + commit_aux_item_list_internal(list_to_commit, FALSE); +} + + + + /* * find_aux_item @@ -956,19 +1340,6 @@ find_aux_item(Aux_item_list *list, unsigned long aux_no) return &list->items[item_index]; } -long -find_aux_item_index(Aux_item_list *list, unsigned long aux_no) -{ - unsigned long i; - - for (i = 0; i < list->length; i++) - { - if (list->items[i].aux_no == aux_no) - return i; - } - - return -1; -} /* ********************************************************************** @@ -1068,7 +1439,7 @@ void text_stat_add_aux_item_list(Text_stat *text_s, text_s->highest_aux += 1; item_list->items[i].aux_no = text_s->highest_aux; item_list->items[i].creator = item_creator; - item_list->items[i].sent_at = time(NULL); + copy_aux_item( &text_s->aux_item_list.items[text_s->aux_item_list.length], &item_list->items[i]); @@ -1078,7 +1449,8 @@ void text_stat_add_aux_item_list(Text_stat *text_s, TEXT_OBJECT_TYPE, text_s->aux_item_list.length - 1, text_no, - text_s); + text_s, + &item_list->items[i]); } } @@ -1163,7 +1535,6 @@ conf_stat_add_aux_item_list(Conference *conf, conf->highest_aux += 1; item_list->items[i].aux_no = conf->highest_aux; item_list->items[i].creator = item_creator; - item_list->items[i].sent_at = time(NULL); copy_aux_item(&conf->aux_item_list.items[conf->aux_item_list.length], &item_list->items[i]); conf->aux_item_list.length += 1; @@ -1172,7 +1543,8 @@ conf_stat_add_aux_item_list(Conference *conf, CONF_OBJECT_TYPE, conf->aux_item_list.length - 1, conf_no, - conf); + conf, + &item_list->items[i]); } } @@ -1200,15 +1572,15 @@ Success system_check_add_aux_item_list(Info *info, return FAILURE; } - if (!aux_item_add_perm(item, - def, - creator, - creator, - FALSE, - &info->aux_item_list, - 0, - FALSE, - OTHER_OBJECT_TYPE) || + if (!aux_item_add_perm(item, /* item */ + def, /* definition */ + creator, /* item_creator */ + creator, /* object_creator */ + TRUE, /* owner_check */ + &info->aux_item_list, /* add_to_list */ + 0, /* start_looking_at */ + FALSE, /* creating */ + INFO_OBJECT_TYPE) || !aux_item_check_unique(item, def, list, i + 1) || !def->system) { @@ -1241,7 +1613,6 @@ system_add_aux_item_list(Info *info, info->highest_aux_no += 1; item_list->items[i].aux_no = info->highest_aux_no; item_list->items[i].creator = item_creator; - item_list->items[i].sent_at = time(NULL); copy_aux_item(&info->aux_item_list.items[info->aux_item_list.length], &item_list->items[i]); info->aux_item_list.length += 1; @@ -1251,7 +1622,8 @@ system_add_aux_item_list(Info *info, INFO_OBJECT_TYPE, info->aux_item_list.length - 1, 0, - info); + info, + &item_list->items[i]); } } @@ -1287,45 +1659,96 @@ void aux_item_trigger_mark_text(Aux_item_trigger_data *data) { Text_no text_no; Text_stat *text_stat; - Conference *conf_stat; String_size ill_char; - if (data->object_type != CONF_OBJECT_TYPE) - return; - - conf_stat = (Conference *)data->object; - text_no = s_strtol(conf_stat->aux_item_list.items[data->item_index].data, - &ill_char, - 10); - - text_stat = cached_get_text_stat(text_no); - - if (text_stat == NULL) - return; - text_stat->no_of_marks += 1; + text_no = s_strtol(data->item->data, &ill_char, 10); + VOID_GET_T_STAT(text_stat, text_no); + if (text_stat->no_of_marks < param.max_marks_text) + text_stat->no_of_marks += 1; mark_text_as_changed(text_no); } void aux_item_trigger_unmark_text(Aux_item_trigger_data *data) { - Text_no text_no; - Text_stat *text_stat; - Conference *conf_stat; - String_size ill_char; + Text_no text_no; + Text_stat *text_stat; + String_size ill_char; + + text_no = s_strtol(data->item->data, &ill_char, 10); + VOID_GET_T_STAT(text_stat, text_no); + if (text_stat->no_of_marks > 0) + text_stat->no_of_marks -= 1; + mark_text_as_changed(text_no); +} - if (data->object_type != CONF_OBJECT_TYPE) +void aux_item_trigger_mirror_faq(Aux_item_trigger_data *data) +{ + Conference *conf_stat; + Conf_no conf_no; + Text_no text_no; + Text_stat *text_stat; + Aux_item_list items; + Aux_item item_data; + char conf_no_string[40]; + String_size ill_char; + String_size end_pos; + + if (data->object_type != CONF_OBJECT_TYPE || conf_stat == NULL) return; + init_aux_item(&item_data); conf_stat = (Conference *)data->object; + conf_no = (Conf_no)data->object_no; text_no = s_strtol(conf_stat->aux_item_list.items[data->item_index].data, &ill_char, 10); + VOID_GET_T_STAT(text_stat, text_no); + sprintf(conf_no_string, "%-40lu", (unsigned long)conf_no); + + item_data.tag = 28; /* Mirror of FAQ item */ + item_data.data = s_fcrea_str(conf_no_string); + end_pos = s_strchr(item_data.data, ' ', 0); + if (end_pos != -1) + s_strdel(&item_data.data, end_pos, s_strlen(item_data.data) - 1); - text_stat = cached_get_text_stat(text_no); - if (text_stat == NULL) - return; - text_stat->no_of_marks -= 1; + /* Set up the link from the text to the conference */ + + item_data.linked_item.target_type = CONF_OBJECT_TYPE; + item_data.linked_item.target_object.conf = conf_no; + item_data.linked_item.target_item = data->item->aux_no; + + items.length = 1; + items.items = &item_data; + + prepare_aux_item_list(&items, 0, time(NULL)); + + text_stat_add_aux_item_list(text_stat, text_no, &items, 0); mark_text_as_changed(text_no); + + /* Set up the link from the conference to the text */ + + data->item->linked_item.target_type = TEXT_OBJECT_TYPE; + data->item->linked_item.target_object.text = text_no; + data->item->linked_item.target_item = text_stat->highest_aux; + mark_conference_as_changed(conf_no); +} + + +/* + * Aux item validators + */ + + +Bool aux_item_validate_existing_text(Aux_item_validation_data *v_data) +{ + Text_stat *text_stat; + Text_no text_no; + String_size ill_char; + + text_no = s_strtol(v_data->item->data, &ill_char, 10); + GET_T_STAT(text_stat, text_no, FALSE); + return person_text_read_access(text_no, text_stat, + v_data->item_creator, NULL); } diff --git a/src/server/aux-items.h b/src/server/aux-items.h index 8cd23b38d54850c82ddb1dda3339f5254fe5bb12..b8fec867136703283131f231147460d5f47a9590 100644 --- a/src/server/aux-items.h +++ b/src/server/aux-items.h @@ -1,5 +1,5 @@ /* - * $Id: aux-items.h,v 1.6 1998/12/30 17:39:35 byers Exp $ + * $Id: aux-items.h,v 1.7 1999/05/12 13:24:59 byers Exp $ * Copyright (C) 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -50,42 +50,91 @@ #define AUX_ITEM_DELETE_ACTION 2 #define AUX_ITEM_UNDELETE_ACTION 3 -/* Valid values for object_type fields */ - -#define OTHER_OBJECT_TYPE 0 -#define TEXT_OBJECT_TYPE 1 -#define CONF_OBJECT_TYPE 2 -#define INFO_OBJECT_TYPE 3 +typedef struct Aux_item_definition_s Aux_item_definition; typedef struct Aux_item_trigger_data_s { short action; - short object_type; + Object_type object_type; unsigned long item_index; unsigned long object_no; void * object; + Aux_item * item; } Aux_item_trigger_data; typedef void (*Aux_item_trigger)(Aux_item_trigger_data *); -typedef struct Aux_item_definition_s { - const char *name; - unsigned long tag; - Aux_item_flags clear_flags; - Aux_item_flags set_flags; - Bool author_only; - Bool supervisor_only; - Bool one_per_person; - Bool may_not_delete; - unsigned long inherit_limit; - Bool texts; - short text_a; /* When can we add items of this type */ - Bool confs; - short conf_a; /* When can we add items of this type */ - Bool letterboxes; - Bool system; - char *validate_regexp; - struct re_pattern_buffer *cached_re_buf; +typedef enum { + AUX_VALIDATE_FUNCTION, + AUX_VALIDATE_REGEXP, + AUX_VALIDATE_REJECT, +} Aux_item_validation_type; + +typedef struct +{ + Aux_item *item; + Aux_item_definition *def; + Pers_no item_creator; + Pers_no object_creator; + Bool owner_check; + Aux_item_list *add_to_list; + unsigned long start_looking_at; + Bool creating; + Object_type object_type; +} Aux_item_validation_data; + +typedef Bool (*Aux_item_validation_function)(Aux_item_validation_data *); + +typedef struct +{ + Aux_item_validation_type type; + union + { + struct + { + char *regexp; + struct re_pattern_buffer *cached_re_buf; + } re; + struct + { + Aux_item_validation_function function; + } fn; + } v; +} Aux_item_validator; + + + +typedef struct +{ + const char *name; + Aux_item_validation_function function; +} Aux_item_validator_mapping; + +typedef struct +{ + const char *name; + Aux_item_trigger function; +} Aux_item_trigger_mapping; + +struct Aux_item_definition_s { + const char * name; + unsigned long tag; + Aux_item_flags clear_flags; + Aux_item_flags set_flags; + Bool author_only; + Bool supervisor_only; + Bool system_only; + Bool one_per_person; + Bool may_not_delete; + unsigned long inherit_limit; + Bool texts; + short text_a; /* When can we add items of this type */ + Bool confs; + short conf_a; /* When can we add items of this type */ + Bool letterboxes; + Bool system; + unsigned long num_validators; + Aux_item_validator * validators; unsigned long num_delete_triggers; Aux_item_trigger * delete_triggers; unsigned long num_add_triggers; @@ -93,30 +142,13 @@ typedef struct Aux_item_definition_s { unsigned long num_undelete_triggers; Aux_item_trigger * undelete_triggers; struct Aux_item_definition_s *next; -} Aux_item_definition; +}; -typedef struct -{ - const char *name; - Aux_item_trigger function; -} Aux_item_trigger_mapping; +extern Aux_item_validator_mapping aux_item_validators []; extern Aux_item_trigger_mapping aux_item_triggers []; extern Aux_item_definition empty_aux_item_definition; -/* - * Predefined AUX Items - */ - -#define AUX_Content_Type 1 -#define AUX_Dont_Comment 2 -#define AUX_Private_Comment 3 -#define AUX_Quick_Reply 4 - - - - - /* Inerit items from parent to target. counter is a pointer to * highest_aux_item or equivalent. target_creator is the creator * of the target object (author for texts, person for persons and @@ -124,7 +156,7 @@ extern Aux_item_definition empty_aux_item_definition; void aux_inherit_items(Aux_item_list *target, Aux_item_list *parent, unsigned long *counter, Pers_no target_creator, - Bool creating, short object_type, + Bool creating, Object_type object_type, unsigned long object_no, void *object); @@ -145,7 +177,7 @@ Bool aux_item_add_perm(Aux_item *item, Aux_item_definition *def, Pers_no item_creator, Pers_no object_creator, Bool owner_check, Aux_item_list *add_to_list, unsigned long start_looking_at, Bool creating, - short object_type); + Object_type object_type); @@ -155,9 +187,9 @@ Bool aux_item_add_perm(Aux_item *item, Aux_item_definition *def, * You need to call this before sending the list to any of the other * functions. */ -void prepare_aux_item_list(Aux_item_list *list, Pers_no creator); +void prepare_aux_item_list(Aux_item_list *list, Pers_no creator, time_t now); void prepare_aux_item(Aux_item *item, Pers_no creator, - Aux_item_definition *def); + Aux_item_definition *def, time_t now); @@ -171,6 +203,10 @@ Aux_item_definition *find_aux_item_definition(Aux_item *item); Aux_item_trigger aux_item_find_trigger(char *trigger_name); +/* Get the function pointer for a named validation function */ + +Aux_item_validation_function aux_item_find_validator(char *validator_name); + /* Get a pointer to the item in list with aux-no aux_no. Returns * NULL if there is no such item */ @@ -195,7 +231,7 @@ void filter_aux_item_list(Aux_item_list *original, void delete_aux_item_list(Number_list *items_to_delete, Aux_item_list *list_to_delete_from, - short object_type, + Object_type object_type, unsigned long object_no, void *object); @@ -206,7 +242,7 @@ void delete_aux_item_list(Number_list *items_to_delete, void undelete_aux_item_list(Number_list *items_to_undelete, Aux_item_list *list_to_undelete_from, - short object_type, + Object_type object_type, unsigned long object_no, void *object); diff --git a/src/server/call-switch.awk b/src/server/call-switch.awk index 9fbed12fec72592ecfdd3d2f8d8f8f0055a8f06f..214ab177f9f4f32c278203155aed3e39e8b763a5 100644 --- a/src/server/call-switch.awk +++ b/src/server/call-switch.awk @@ -1,5 +1,5 @@ # -# $Id: call-switch.awk,v 0.16 1999/01/14 11:39:25 byers Exp $ +# $Id: call-switch.awk,v 0.17 1999/05/12 13:25:00 byers Exp $ # Copyright (C) 1991, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. # # This file is part of the LysKOM server. @@ -22,7 +22,7 @@ # # Please mail bug reports to bug-lyskom@lysator.liu.se. # -# $Id: call-switch.awk,v 0.16 1999/01/14 11:39:25 byers Exp $ +# $Id: call-switch.awk,v 0.17 1999/05/12 13:25:00 byers Exp $ BEGIN { printf("/* Don't edit this file - it is generated automatically"); printf(" from\n call-switch.awk and fncdef.txt */\n"); @@ -79,6 +79,8 @@ $1 != "#" && $1 != "" { printf("&client->info"); else if ( $i == "num_list" ) printf("&client->num_list" ); + else if ( $i == "pers_flags" ) + printf("client->pers_flags"); else printf("\n#error in file server/fncdef.txt\n"); } diff --git a/src/server/com-h.awk b/src/server/com-h.awk index a52f06e2a2cb156845935867d12e8017b75747e8..0d9468d69f3271301a4fb0cc0c24be429a216bbb 100644 --- a/src/server/com-h.awk +++ b/src/server/com-h.awk @@ -1,5 +1,5 @@ # -# $Id: com-h.awk,v 0.6 1999/01/14 11:39:26 byers Exp $ +# $Id: com-h.awk,v 0.7 1999/05/12 13:25:01 byers Exp $ # Copyright (C) 1991, 1996 Lysator Academic Computer Association. # # This file is part of the LysKOM server. @@ -22,7 +22,7 @@ # # Please mail bug reports to bug-lyskom@lysator.liu.se. # -# $Id: com-h.awk,v 0.6 1999/01/14 11:39:26 byers Exp $ +# $Id: com-h.awk,v 0.7 1999/05/12 13:25:01 byers Exp $ BEGIN { printf("/*\n"); printf(" * Don't edit this file! It is generated from fncdef.txt\n"); @@ -46,7 +46,7 @@ $1 == "#" || $1 == "" { cnt++ printf("\n call_fnc_%-20s = %d,", $3, $1); } -END { printf("\n illegal_fnc = %d", cnt) +END { printf("\n illegal_fnc = %d", -1) printf("\n};\n\n"); printf("typedef enum call_header Call_header;\n"); } diff --git a/src/server/conf-file.c b/src/server/conf-file.c index 74e6cc3afa146ccb01f2a6ebe779a4e164d5a7fb..a0da25156f3c909305f32c53ff0c80f456073dc9 100644 --- a/src/server/conf-file.c +++ b/src/server/conf-file.c @@ -1,5 +1,5 @@ /* - * $Id: conf-file.c,v 1.13 1999/04/20 20:45:28 ceder Exp $ + * $Id: conf-file.c,v 1.14 1999/05/12 13:25:01 byers Exp $ * Copyright (C) 1994, 1995 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -33,7 +33,7 @@ static const char * -rcsid = "$Id: conf-file.c,v 1.13 1999/04/20 20:45:28 ceder Exp $"; +rcsid = "$Id: conf-file.c,v 1.14 1999/05/12 13:25:01 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -98,15 +98,15 @@ assign_defaults(const struct parameter *par, { if (assignment_count[ix] < par[ix].min_assignments) { - log ("Parameter %s only assigned %d times (%d times needed)\n", - par[ix].name, assignment_count[ix], par[ix].min_assignments); + kom_log ("Parameter %s only assigned %d times (%d times needed)\n", + par[ix].name, assignment_count[ix], par[ix].min_assignments); (*err)++; } else if (assignment_count[ix] == 0) { if ((*par[ix].assigner)(par[ix].default_val, &par[ix]) != OK) { - log ("default assigner failed for %s\n", par[ix].name); + kom_log ("default assigner failed for %s\n", par[ix].name); (*err)++; } } @@ -143,7 +143,7 @@ configure_line(FILE *fp, case '#': /* Comment line */ return 0; case '\0': /* Too long */ - log ("line too long (max %d chars allowed): %s\n", MAXLINE-1, line); + kom_log ("line too long (max %d chars allowed): %s\n", MAXLINE-1, line); (*err)++; return 0; case '\n': /* Empty line */ @@ -153,7 +153,7 @@ configure_line(FILE *fp, val = strchr(line, ':'); if (val == NULL) { - log("missing colon: %s\n", line); + kom_log("missing colon: %s\n", line); (*err)++; return 0; } @@ -163,7 +163,7 @@ configure_line(FILE *fp, switch (*val) { case '\0': - log ("line too long (max %d chars allowed): %s\n", MAXLINE-1, line); + kom_log ("line too long (max %d chars allowed): %s\n", MAXLINE-1, line); (*err)++; return 0; } @@ -171,7 +171,7 @@ configure_line(FILE *fp, end = strchr(val, '\n'); if (end == NULL) { - log ("line too long (max %d chars allowed): %s\n", MAXLINE-1, line); + kom_log ("line too long (max %d chars allowed): %s\n", MAXLINE-1, line); (*err)++; return 0; } @@ -184,11 +184,11 @@ configure_line(FILE *fp, if (!strcmp(start, par[ix].name)) { found++; - if (assignment_count[ix] > par[ix].max_assignments + if (assignment_count[ix] >= par[ix].max_assignments && par[ix].max_assignments != -1) { (*err)++; - log ("variable already assigned %d times: %s\n", + kom_log ("variable already assigned %d times: %s\n", assignment_count[ix], line); } else @@ -196,7 +196,7 @@ configure_line(FILE *fp, assignment_count[ix]++; if ((*par[ix].assigner)(val, &par[ix]) != OK) { - log ("assigner for %s failed\n", par[ix].name); + kom_log ("assigner for %s failed\n", par[ix].name); (*err)++; } } @@ -205,7 +205,7 @@ configure_line(FILE *fp, if (found != 1) { - log ("line matches %d times: %s\n", found, line); + kom_log ("line matches %d times: %s\n", found, line); (*err)++; return 0; } @@ -289,6 +289,22 @@ assign_int(const char *val, return OK; } +Success +assign_ulong(const char *val, + const struct parameter *par) +{ + int c; + + if (val != NULL) + { + c = (unsigned char)*val; + if ((!isascii(c) || !isdigit(c)) && c != '-') + return FAILURE; + *(unsigned long*)par->value = (unsigned long)atol(val); + } + return OK; +} + Success assign_string(const char *val, const struct parameter *par) diff --git a/src/server/conf-file.h b/src/server/conf-file.h index 9f2de33607a13701841f55217f227ddeb91195bb..607fe578689b6965c7b91f73a440d21b3b2de0e8 100644 --- a/src/server/conf-file.h +++ b/src/server/conf-file.h @@ -1,5 +1,5 @@ /* - * $Id: conf-file.h,v 1.3 1998/07/08 16:16:24 ceder Exp $ + * $Id: conf-file.h,v 1.4 1999/05/12 13:25:02 byers Exp $ * Copyright (C) 1994 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -51,6 +51,7 @@ void read_config(const char *config_file, const struct parameter *par); extern Success assign_text_no (const char *val, const struct parameter *par); extern Success assign_conf_no (const char *val, const struct parameter *par); extern Success assign_int (const char *val, const struct parameter *par); +extern Success assign_ulong (const char *val, const struct parameter *par); extern Success assign_string (const char *val, const struct parameter *par); extern Success assign_bool (const char *val, const struct parameter *par); diff --git a/src/server/conference.c b/src/server/conference.c index ec5a04d2e5f66e72f40ac0798b478684749b6246..0a027cafc9e728fb4e7e9df2eabf3f17e9b9cc1c 100644 --- a/src/server/conference.c +++ b/src/server/conference.c @@ -1,5 +1,5 @@ /* - * $Id: conference.c,v 0.45 1999/04/05 16:08:33 ceder Exp $ + * $Id: conference.c,v 0.46 1999/05/12 13:25:03 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -35,7 +35,7 @@ static const char * -rcsid = "$Id: conference.c,v 0.45 1999/04/05 16:08:33 ceder Exp $"; +rcsid = "$Id: conference.c,v 0.46 1999/05/12 13:25:03 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -96,12 +96,12 @@ do_delete_conf (Conf_no conf_no, if ( do_set_presentation(conf_no, conf_c, 0) != OK ) { - log("ERROR: do_delete_conf() - couldn't unmark presentation.\n"); + kom_log("ERROR: do_delete_conf() - couldn't unmark presentation.\n"); } if ( do_set_etc_motd(conf_no, conf_c, 0) != OK ) { - log("ERROR: do_delete_conf() - couldn't unmark motd.\n"); + kom_log("ERROR: do_delete_conf() - couldn't unmark motd.\n"); } /* Delete all members */ @@ -152,8 +152,8 @@ legal_name( String name ) { if (name.len == 0 || name.len > param.conf_name_len ) { - err_stat = param.conf_name_len; - kom_errno = KOM_LONG_STR; + err_stat = name.len? param.conf_name_len : 0; + kom_errno = name.len? KOM_LONG_STR : KOM_BAD_NAME; return FALSE; } @@ -211,7 +211,7 @@ unique_name( const String name, Conf_no conf_no ) if ( parse_info.no_of_matches == -1 ) /* Error. */ { - log("unique_name(): parse returned error.\n"); + kom_log("unique_name(): parse returned error.\n"); sfree(parse_info.indexes); return FALSE; } @@ -276,20 +276,28 @@ do_create_conf(String name, { Conf_no conf_no; Conference * conf_c; + time_t now; /* Prepare, then check the aux items */ /* Allocate memory for conf_c */ conf_no = cached_create_conf( name ); + if (conf_no == 0) + { + /* kom_errno and err_stat set in cached_create_conf */ + kom_log("ERROR: Couldn't create conference. Too many conferences."); + return 0; + } if ( (conf_c = cached_get_conf_stat( conf_no ) ) == NULL) { restart_kom("create_conf() - can't get conf_stat"); } + now = time(NULL); conf_c->creator = creator; - conf_c->creation_time = time(NULL); + conf_c->creation_time = now; conf_c->presentation= 0; /* No presentation yet */ conf_c->supervisor = supervisor; conf_c->permitted_submitters = 0; @@ -302,7 +310,7 @@ do_create_conf(String name, conf_c->highest_aux = 0; conf_c->expire = 0; - prepare_aux_item_list(aux, creator); + prepare_aux_item_list(aux, creator, now); if (conf_stat_check_add_aux_item_list(conf_c, conf_no, aux, @@ -569,7 +577,7 @@ delete_conf (Conf_no conf_no ) if ( do_delete_pers (conf_no) != OK ) { - log("ERROR: delete_conf(): can't delete person.\n"); + kom_log("ERROR: delete_conf(): can't delete person.\n"); } } @@ -699,7 +707,7 @@ do_lookup (const String name, practice as long as Conf_no is a short. */ if (retsize == 0) { - log("WNG: do_lookup: far too many matches\n"); + kom_log("WNG: do_lookup: far too many matches\n"); --retsize; } } @@ -776,7 +784,7 @@ get_conf_stat_old (Conf_no conf_no, if ( acc == error ) return FAILURE; - if ( acc == none ) + if ( acc <= none ) { err_stat = conf_no; kom_errno = KOM_UNDEF_CONF; @@ -837,7 +845,7 @@ get_conf_stat_older (Conf_no conf_no, if ( acc == error ) return FAILURE; - if ( acc == none ) + if ( acc <= none ) { err_stat = conf_no; kom_errno = KOM_UNDEF_CONF; @@ -1235,7 +1243,7 @@ do_set_presentation(Conf_no conf_no, GET_T_STAT(new_pres, text_no, FAILURE); if ( new_pres->no_of_marks >= param.max_marks_text ) { - log("%s(%d, ptr, %lu): New presentation has %d marks.\n", + kom_log("%s(%d, ptr, %lu): New presentation has %d marks.\n", "LIMIT: do_set_presentation", conf_no, (unsigned long)text_no, new_pres->no_of_marks); err_stat = text_no; @@ -1256,7 +1264,7 @@ do_set_presentation(Conf_no conf_no, } else { - log("ERROR: do_set_presentation(): Old presentation not marked\n"); + kom_log("ERROR: do_set_presentation(): Old presentation not marked\n"); } } @@ -1294,7 +1302,7 @@ do_set_etc_motd(Conf_no conf_no, GET_T_STAT(new_motd, text_no, FAILURE); if ( new_motd->no_of_marks >= param.max_marks_text ) { - log("LIMIT: do_set_motd(%d, ptr, %lu): New motd has %d marks.\n", + kom_log("LIMIT: do_set_motd(%d, ptr, %lu): New motd has %d marks.\n", conf_no, (unsigned long)text_no, new_motd->no_of_marks); err_stat = text_no; kom_errno = KOM_MARK_LIMIT; @@ -1314,7 +1322,7 @@ do_set_etc_motd(Conf_no conf_no, } else { - log("ERROR: do_set_motd(): Old motd not marked\n"); + kom_log("ERROR: do_set_motd(): Old motd not marked\n"); } } @@ -1345,7 +1353,7 @@ modify_conf_info(Conf_no conf_no, /* Check if we may delete and add the items */ - prepare_aux_item_list(aux, ACTPERS); + prepare_aux_item_list(aux, ACTPERS, time(NULL)); if (check_delete_aux_item_list(items_to_delete,&conf->aux_item_list)!=OK) return FAILURE; diff --git a/src/server/connections.c b/src/server/connections.c index e9281efccaeeeec130ec13f91e1f0dc6113b6470..297880e8310bbe8d0d4f3a99045a71cf1f00ba01 100644 --- a/src/server/connections.c +++ b/src/server/connections.c @@ -1,5 +1,5 @@ /* - * $Id: connections.c,v 0.57 1999/04/28 22:07:22 ceder Exp $ + * $Id: connections.c,v 0.58 1999/05/12 13:25:04 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -36,7 +36,7 @@ #endif static const char * -rcsid = "$Id: connections.c,v 0.57 1999/04/28 22:07:22 ceder Exp $"; +rcsid = "$Id: connections.c,v 0.58 1999/05/12 13:25:04 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -132,7 +132,7 @@ logout_client(Connection *cp) if ( active_connection != NULL ) { - log("BUGCHK: logout_client(%ld): connection %ld is active.\n", + kom_log("BUGCHK: logout_client(%ld): connection %ld is active.\n", cp->session_no, active_connection->session_no); } @@ -142,7 +142,7 @@ logout_client(Connection *cp) break; case CONN_MAGIC_FREE: - log("LOGOUT_CLIENT: Trying to free freed Connection - ignored!\n"); + kom_log("LOGOUT_CLIENT: Trying to free freed Connection - ignored!\n"); return; default: @@ -176,7 +176,7 @@ logout_client(Connection *cp) ret = isc_destroy(kom_server_mcb, cp->isc_session); if (ret < 0) - log("logout_client(): isc_destroyed returned %d\n", ret); + kom_log("logout_client(): isc_destroyed returned %d\n", ret); cp->isc_session = NULL; kill_client(cp); /* Free the Connection */ @@ -223,7 +223,7 @@ call_function (Connection * client, if ( active_connection != NULL ) { - log("call_function(%ld): active_connection = %ld", + kom_log("call_function(%ld): active_connection = %ld", client->session_no, active_connection->session_no); } @@ -464,7 +464,7 @@ dump_statistics(void) if ((fp = fopen(param.statistic_name, "a")) == NULL) { - log("%s: dump_statistics(): can't open file %s\n", + kom_log("%s: dump_statistics(): can't open file %s\n", __FILE__, param.statistic_name); return; @@ -510,7 +510,7 @@ add_to_kill_list(Connection *conn) for (i = 0; i < kill_list_size; i++) if (kill_list[i] == conn->session_no) { - log("add_to_kill_list(%ld): already present as %d of %d.\n", + kom_log("add_to_kill_list(%ld): already present as %d of %d.\n", conn->session_no, i, kill_list_size); return; } @@ -552,7 +552,7 @@ check_kill_flg(void) conn = get_conn_by_number (kill_list[kill_list_size]); if (conn == NULL) { - log("check_kill_flg(): Connection %ld doesn't exist.\n", + kom_log("check_kill_flg(): Connection %ld doesn't exist.\n", kill_list[kill_list_size]); } else @@ -577,7 +577,7 @@ login_request(IscEvent *event) char *hostname = NULL; /* Supress logins if /etc/nologin exists */ - if (fexists("/etc/nologin")) + if (fexists(param.nologin_file)) { isc_puts("%% No logins allowed.\n", event->session); isc_flush(event->session); @@ -589,13 +589,13 @@ login_request(IscEvent *event) if (hostname == NULL) hostname = isc_getipnum(event->session->info.tcp.raddr, NULL, 0); if (hostname == NULL) - log("WNG: login_request(): unknown hostid.\n"); + kom_log("WNG: login_request(): unknown hostid.\n"); /* Get the real user name, as returned by the Ident protocol (rfc 931). */ realuser = get_real_username(event->session, hostname); if (realuser == NULL && param.authentication_level == 2) { - log ("Connection from %s rejected - no IDENT available.\n", + kom_log("Connection from %s rejected - no IDENT available.\n", hostname); isc_puts("%% No IDENT server reachable at your site.\n", @@ -699,7 +699,7 @@ toploop(void) case ISC_EVENT_ERROR: if (errno != EINTR) { - log("toploop: ISC_EVENT_ERROR (error = '%s'):\n '%s'\n", + kom_log("toploop: ISC_EVENT_ERROR (error = '%s'):\n '%s'\n", strerror(errno), event->msg ? event->msg->buffer : "(unknown)"); } @@ -750,7 +750,7 @@ toploop(void) default: pending_input = TRUE; - log("ERROR: toploop(): Unknown ISC_EVENT\n"); + kom_log("ERROR: toploop(): Unknown ISC_EVENT\n"); break; } diff --git a/src/server/connections.h b/src/server/connections.h index b1425e66bc78c629a7b536660cf872d17a893362..6b806f0b21f2f72870fc232a5e3d5022635a450d 100644 --- a/src/server/connections.h +++ b/src/server/connections.h @@ -1,5 +1,5 @@ /* - * $Id: connections.h,v 0.40 1999/04/28 22:07:32 ceder Exp $ + * $Id: connections.h,v 0.41 1999/05/12 13:25:05 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 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: connections.h,v 0.40 1999/04/28 22:07:32 ceder Exp $ + * $Id: connections.h,v 0.41 1999/05/12 13:25:05 byers Exp $ * * connections.h -- The top level of the communication packet. * @@ -101,6 +101,7 @@ typedef struct connection { Membership_type membership_type; struct tm time; Info info; + Personal_flags pers_flags; /* Protocol independent things. */ diff --git a/src/server/dbck-cache.c b/src/server/dbck-cache.c index 0ab18965cacb5b423957d8bb0d6c02a5b2e7dee1..26a0ddb91cbc12c3894f5b41d6459a310972ceb7 100644 --- a/src/server/dbck-cache.c +++ b/src/server/dbck-cache.c @@ -1,5 +1,5 @@ /* - * $Id: dbck-cache.c,v 0.37 1999/04/17 00:09:00 ceder Exp $ + * $Id: dbck-cache.c,v 0.38 1999/05/12 13:25:06 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -39,7 +39,7 @@ static const char * -rcsid = "$Id: dbck-cache.c,v 0.37 1999/04/17 00:09:00 ceder Exp $"; +rcsid = "$Id: dbck-cache.c,v 0.38 1999/05/12 13:25:06 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -73,7 +73,6 @@ USE(rcsid); #include "kom-types.h" #include "kom-errno.h" #include "cache.h" -#include "tmp-limits.h" #include "debug.h" #include "server/smalloc.h" #include "log.h" @@ -91,14 +90,13 @@ USE(rcsid); * if they fail. */ -Person * pers_arr[ MAX_CONF ]; -Conference * conf_arr[ MAX_CONF ]; -Conf_type conf_type_arr[ MAX_CONF ]; -String name_list [ MAX_CONF ]; /* "cache" list */ +Person ** pers_arr; +Conference ** conf_arr; +String * name_list; /* "cache" list */ /* Global var auto init to NULL */ int next_free_num = 1; -Text_stat * text_arr[ MAX_TEXT ]; +Text_stat ** text_arr; static Text_no next_text_num = 1; /* Defined in standalone.c */ @@ -237,7 +235,7 @@ cached_create_conf (String name) TRACESTR(name); TRACE1(" )\n"); - if ( next_free_num >= MAX_CONF ) + if ( next_free_num >= param.max_conf ) { err_stat = next_free_num; kom_errno = KOM_INDEX_OUT_OF_RANGE; @@ -348,7 +346,7 @@ cached_get_text( Text_no text ) if ( fread(the_string.string, sizeof(char), the_string.len, text_file) != (size_t)the_string.len ) { - log("%s read enough characters of text %lu\n", + kom_log("%s read enough characters of text %lu\n", "WARNING: cached_get_text: couldn't", (unsigned long)text); } @@ -385,9 +383,9 @@ cached_create_text( String message) TRACE2("cached_create_text (len=%d)\n", message.len); - if ( tno >= MAX_TEXT ) + if ( tno >= param.max_text ) { - next_text_num = MAX_TEXT; + next_text_num = param.max_text; kom_errno = KOM_INDEX_OUT_OF_RANGE; err_stat = next_text_num; @@ -405,7 +403,7 @@ cached_create_text( String message) if ( fwrite(message.string, sizeof(char), message.len, text_file) != message.len ) { - log("WARNING: cached_create_text: Couldn't write the text %d\n", + kom_log("WARNING: cached_create_text: Couldn't write the text %d\n", tno); } @@ -423,7 +421,7 @@ cached_flush_text(Text_no text_no, { if ( text_no >= next_text_num ) { - log("cached_flush_text(%lu, string): only text %lu exists.", + kom_log("cached_flush_text(%lu, string): only text %lu exists.", (u_long) text_no, (u_long) next_text_num); return; } @@ -434,7 +432,7 @@ cached_flush_text(Text_no text_no, if ( fwrite(message.string, sizeof(char), message.len, new_text_file) != (size_t)message.len ) { - log("WARNING: cached_flush_text: Couldn't write the text %ld\n", + kom_log("WARNING: cached_flush_text: Couldn't write the text %ld\n", (unsigned long)text_no); } @@ -585,19 +583,19 @@ cache_sync_all(void) if (rename(param.backupfile_name, param.backupfile_name_2) != 0) { - log("pre_sync: can't do extra backup.\n"); + kom_log("pre_sync: can't do extra backup.\n"); } } if ( rename(param.datafile_name, param.backupfile_name) != 0 ) - log("WARNING: cache_sync_all: can't backup.\n"); + kom_log("WARNING: cache_sync_all: can't backup.\n"); } else - log("cache_sync_all: datafile not clean. No backup taken.\n"); + kom_log("cache_sync_all: datafile not clean. No backup taken.\n"); if ( (fp=fopen(param.datafile_name, "w") ) == NULL ) { - log("WARNING: cache_sync_all: can't open file to save in.\n"); + kom_log("WARNING: cache_sync_all: can't open file to save in.\n"); return; } @@ -765,7 +763,7 @@ cache_sync_all(void) fclose(fp); #ifdef TIME_SYNC - log("Sync ready.\n" + kom_log("Sync ready.\n" "User: %4ld sec (%4ld conf, %4ld pers, %4ld stat, %4ld text)\n" "Sys: %4ld sec (%4ld conf, %4ld pers, %4ld stat, %4ld text)\n" "Real: %4ld sec (%4ld conf, %4ld pers, %4ld stat, %4ld text)\n" @@ -800,7 +798,7 @@ cache_open_new_text_file(void) { if ( ( new_text_file = fopen(param.textfile_name, "w")) == NULL ) { - log("Can't open file to save new texts. Goodbye.\n"); + kom_log("Can't open file to save new texts. Goodbye.\n"); exit(1); } } @@ -825,11 +823,16 @@ init_cache(void) read_text_num = 0; read_conf_num = 0; - for (i = 0; i < MAX_CONF; i++) + pers_arr = smalloc(sizeof(*pers_arr) * param.max_conf); + conf_arr = smalloc(sizeof(*conf_arr) * param.max_conf); + text_arr = smalloc(sizeof(*text_arr) * param.max_text); + name_list = smalloc(sizeof(*name_list) * param.max_conf); + + for (i = 0; i < param.max_conf; i++) conf_arr[i] = NULL; - for (i = 0; i < MAX_CONF; i++) + for (i = 0; i < param.max_conf; i++) pers_arr[i] = NULL; - for (i = 0; i < MAX_TEXT; i++) + for (i = 0; i < param.max_text; i++) text_arr[i] = NULL; @@ -847,24 +850,24 @@ init_cache(void) data_file_version = get_version(param.datafile_name); if ( (fp = fopen(param.datafile_name, "rb")) == NULL ) { - log("WARNING: init_cache: can't open datafile.\n"); + kom_log("WARNING: init_cache: can't open datafile.\n"); return FAILURE; } - log("MSG: init_cache: using datafile.\n"); + kom_log("MSG: init_cache: using datafile.\n"); } else if ( is_clean(param.backupfile_name) ) { data_file_version = get_version(param.backupfile_name); if ( (fp = fopen(param.backupfile_name, "rb")) == NULL ) { - log("WARNING: init_cache: can't open backupfile.\n"); + kom_log("WARNING: init_cache: can't open backupfile.\n"); return FAILURE; } - log("MSG: init_cache: using backup file.\n"); + kom_log("MSG: init_cache: using backup file.\n"); } else { - log("WARNING: init_cache: can't find old data base.\n"); + kom_log("WARNING: init_cache: can't find old data base.\n"); return FAILURE; } @@ -888,8 +891,8 @@ init_cache(void) read_conf_num = 1; if (vflag) { - log("Data file version is '%ld'\n", data_file_version); - log("Reading %d conferences, starting at pos %ld.\n", + kom_log("Data file version is '%ld'\n", data_file_version); + kom_log("Reading %d conferences, starting at pos %ld.\n", next_free_num-1, (unsigned long)ftell(fp)); } break; @@ -897,7 +900,7 @@ init_cache(void) case 2: fseek(fp, 12, SEEK_SET); if (vflag) - log("Data file version is '%ld'\n", data_file_version); + kom_log("Data file version is '%ld'\n", data_file_version); break; default: restart_kom("Unknown input file format: %ld\n", data_file_version); @@ -1080,7 +1083,7 @@ init_cache(void) /* Simply ignore everything else. The cause of this error might be that the file has been truncated (maybe due to an overfull disk). */ - log("init_cache(): fparse_text_stat failed " + kom_log("init_cache(): fparse_text_stat failed " "for text %ld.\n%s", num, "Everything remaining is lost.\n"); next_text_num = i; @@ -1211,7 +1214,7 @@ init_cache(void) if (data_file_version == 0) { if ( vflag ) - log("Reading %d persons, starting at pos %lu.\n", + kom_log("Reading %d persons, starting at pos %lu.\n", next_free_num-1, (unsigned long)ftell(fp)); for ( i = 1; i < next_free_num; i++ ) /* PERSONS */ { @@ -1235,7 +1238,7 @@ init_cache(void) read_text_num = 1; if ( vflag ) - log("Reading %ld texts, starting at pos %lu.\n", + kom_log("Reading %ld texts, starting at pos %lu.\n", next_text_num-1, (unsigned long)ftell(fp)); for ( i = 1; i < next_text_num; i++ ) /* TEXT_STATS */ @@ -1255,7 +1258,7 @@ init_cache(void) error might be that the file has been truncated (maybe due to an overfull disk). */ - log("init_cache(): fparse_text_stat failed for text %ld.\n" + kom_log("init_cache(): fparse_text_stat failed for text %ld.\n" "All remaining texts are lost.\n", i); next_text_num = i; truncated_texts = TRUE; @@ -1265,7 +1268,7 @@ init_cache(void) } } /* if (datafile_version == 0) */ - log("Read %d confs/persons and %ld texts, eof at %lu\n", + kom_log("Read %d confs/persons and %ld texts, eof at %lu\n", next_free_num-1, next_text_num-1, (unsigned long)ftell(fp)); if (read_text_num == 0 || read_conf_num == 0) diff --git a/src/server/dbck.c b/src/server/dbck.c index cb75f80aa8352df410826182c2448f0488b36e73..be529203320dff22394b87e4893ba1d08db3f42d 100644 --- a/src/server/dbck.c +++ b/src/server/dbck.c @@ -1,5 +1,5 @@ /* - * $Id: dbck.c,v 0.46 1999/04/17 21:53:30 ceder Exp $ + * $Id: dbck.c,v 0.47 1999/05/12 13:25:08 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -35,7 +35,7 @@ static const char * -rcsid = "$Id: dbck.c,v 0.46 1999/04/17 21:53:30 ceder Exp $"; +rcsid = "$Id: dbck.c,v 0.47 1999/05/12 13:25:08 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -63,7 +63,6 @@ USE(rcsid); #include "misc-types.h" #include "s-string.h" #include "kom-types.h" -#include "tmp-limits.h" #include "lyskomd.h" #include "log.h" #include "server/smalloc.h" @@ -157,7 +156,7 @@ typedef struct { static const Person_scratchpad EMPTY_PERSON_SCRATCHPAD = { 0 }; -static Person_scratchpad *person_scratchpad[MAX_CONF]; +static Person_scratchpad **person_scratchpad = NULL; int buglevel = 0; BUGDECL; @@ -196,7 +195,7 @@ execute_deletions(Local_to_global *l2g, #if defined(HAVE_VFPRINTF) && defined(HAVE_STDARG_H) extern void -log (const char * format, ...) +kom_log (const char * format, ...) { va_list AP; @@ -208,7 +207,7 @@ log (const char * format, ...) } #else extern void -log (format, a, b, c, d, e, f, g) +kom_log (format, a, b, c, d, e, f, g) const char * format; int a, b, c, d, e, f, g; { @@ -474,14 +473,14 @@ check_misc_infos(Text_no tno, c = cached_get_conf_stat (group.recipient); if ( c == NULL && group.recipient == 0 ) { - log ("Conference 0 is recipient to text %lu.\n", + kom_log ("Conference 0 is recipient to text %lu.\n", (unsigned long)tno); if (rflag || confirm("Repair by deleting misc_item? ")) { delete_misc(tstat, previous); mark_text_as_changed(tno); modifications++; - log("Repaired: Conference 0 is no longer a recipient.\n"); + kom_log("Repaired: Conference 0 is no longer a recipient.\n"); misc = previous; } else @@ -499,7 +498,7 @@ check_misc_infos(Text_no tno, if (group.local_no < conf_min) { - log("Text %lu: Recipient %lu<%lu> loc_no is less than %lu\n", + kom_log("Text %lu: Recipient %lu<%lu> loc_no is less than %lu\n", (unsigned long)tno, (unsigned long)group.recipient, (unsigned long)group.local_no, (unsigned long)conf_min); @@ -507,7 +506,7 @@ check_misc_infos(Text_no tno, } else if (group.local_no >= conf_max) { - log("Text %lu: Recipient %lu<%lu> loc_no >= %lu\n", + kom_log("Text %lu: Recipient %lu<%lu> loc_no >= %lu\n", (unsigned long)tno, (unsigned long)group.recipient, (unsigned long)group.local_no, (unsigned long)conf_max); @@ -515,7 +514,7 @@ check_misc_infos(Text_no tno, } else if (l2g_lookup(&c->texts, group.local_no) != tno) { - log("Text %lu: Recipient %lu<%lu>: %s to %lu.\n", + kom_log("Text %lu: Recipient %lu<%lu>: %s to %lu.\n", (unsigned long)tno, (unsigned long)group.recipient, (unsigned long)group.local_no, "that local number is mapped", @@ -529,14 +528,14 @@ check_misc_infos(Text_no tno, c = cached_get_conf_stat (group.cc_recipient); if ( c == NULL && group.cc_recipient == 0 ) { - log ("Conference 0 is cc_recipient to text %lu.\n", + kom_log ("Conference 0 is cc_recipient to text %lu.\n", (unsigned long)tno); if (rflag || confirm("Repair by deleting misc_item? ")) { delete_misc(tstat, previous); mark_text_as_changed(tno); modifications++; - log("Repaired: Conf 0 is no longer a cc_recipient.\n"); + kom_log("Repaired: Conf 0 is no longer a cc_recipient.\n"); misc = previous; } else @@ -554,7 +553,7 @@ check_misc_infos(Text_no tno, if (group.local_no < conf_min) { - log("Text %lu: CC_Recipient %lu<%lu> is less than %lu\n", + kom_log("Text %lu: CC_Recipient %lu<%lu> is less than %lu\n", (unsigned long)tno, (unsigned long)group.cc_recipient, (unsigned long)group.local_no, (unsigned long)conf_min); @@ -562,7 +561,7 @@ check_misc_infos(Text_no tno, } else if (group.local_no >= conf_max) { - log("Text %lu: CC_Recipient %lu<%lu> loc_no >= %lu\n", + kom_log("Text %lu: CC_Recipient %lu<%lu> loc_no >= %lu\n", (unsigned long)tno, (unsigned long)group.cc_recipient, (unsigned long)group.local_no, (unsigned long)conf_max); @@ -570,7 +569,7 @@ check_misc_infos(Text_no tno, } else if (l2g_lookup(&c->texts, group.local_no) != tno) { - log("Text %lu: CC_Recipient %lu<%lu>: %s to %lu.\n", + kom_log("Text %lu: CC_Recipient %lu<%lu>: %s to %lu.\n", (unsigned long)tno, (unsigned long)group.cc_recipient, (unsigned long)group.local_no, "that local number is mapped", @@ -584,14 +583,14 @@ check_misc_infos(Text_no tno, c = cached_get_conf_stat (group.bcc_recipient); if ( c == NULL && group.bcc_recipient == 0 ) { - log ("Conference 0 is bcc_recipient to text %lu.\n", + kom_log ("Conference 0 is bcc_recipient to text %lu.\n", (unsigned long)tno); if (rflag || confirm("Repair by deleting misc_item? ")) { delete_misc(tstat, previous); mark_text_as_changed(tno); modifications++; - log("Repaired: Conf 0 is no longer a bcc_recipient.\n"); + kom_log("Repaired: Conf 0 is no longer a bcc_recipient.\n"); misc = previous; } else @@ -609,7 +608,7 @@ check_misc_infos(Text_no tno, if (group.local_no < conf_min) { - log("Text %lu: BCC_Recipient %lu<%lu> is less than %lu\n", + kom_log("Text %lu: BCC_Recipient %lu<%lu> is less than %lu\n", (unsigned long)tno, (unsigned long)group.bcc_recipient, (unsigned long)group.local_no, (unsigned long)conf_min); @@ -617,7 +616,7 @@ check_misc_infos(Text_no tno, } else if (group.local_no >= conf_max) { - log("Text %lu: BCC_Recipient %lu<%lu> loc_no >= %lu\n", + kom_log("Text %lu: BCC_Recipient %lu<%lu> loc_no >= %lu\n", (unsigned long)tno, (unsigned long)group.bcc_recipient, (unsigned long)group.local_no, (unsigned long)conf_max); @@ -625,7 +624,7 @@ check_misc_infos(Text_no tno, } else if (l2g_lookup(&c->texts, group.local_no) != tno) { - log("Text %lu: BCC_Recipient %lu<%lu>: %s to %lu.\n", + kom_log("Text %lu: BCC_Recipient %lu<%lu>: %s to %lu.\n", (unsigned long)tno, (unsigned long)group.bcc_recipient, (unsigned long)group.local_no, "that local number is mapped", @@ -641,7 +640,7 @@ check_misc_infos(Text_no tno, if ( t == NULL ) { - log("Text %lu is a comment to %lu, which doesn't exist.\n", + kom_log("Text %lu is a comment to %lu, which doesn't exist.\n", (unsigned long)tno, (unsigned long)group.comment_to); if (rflag || confirm("Repair by deleting misc_item? ")) @@ -649,7 +648,7 @@ check_misc_infos(Text_no tno, delete_misc(tstat, previous); mark_text_as_changed(tno); modifications++; - log("Repaired: Comment-link deleted.\n"); + kom_log("Repaired: Comment-link deleted.\n"); misc = previous; } else @@ -659,7 +658,7 @@ check_misc_infos(Text_no tno, } else if (!is_comment_to(tno, t)) { - log("Text %lu is a comment to %lu, but not the reverse.\n", + kom_log("Text %lu is a comment to %lu, but not the reverse.\n", (unsigned long)tno, (unsigned long)group.comment_to); errors++; } @@ -671,7 +670,7 @@ check_misc_infos(Text_no tno, if ( t == NULL ) { - log("Text %lu is commented in %lu, which doesn't exist.\n", + kom_log("Text %lu is commented in %lu, which doesn't exist.\n", (unsigned long)tno, (unsigned long)group.commented_in); if (rflag || confirm("Repair by deleting misc_item? ")) @@ -679,7 +678,7 @@ check_misc_infos(Text_no tno, delete_misc(tstat, previous); mark_text_as_changed(tno); modifications++; - log("Repaired: Comment-link deleted.\n"); + kom_log("Repaired: Comment-link deleted.\n"); misc = previous; } else @@ -687,7 +686,7 @@ check_misc_infos(Text_no tno, } else if (!is_commented_in(tno, t)) { - log("Text %lu is commented in %lu, but not the reverse.\n", + kom_log("Text %lu is commented in %lu, but not the reverse.\n", (unsigned long)tno, (unsigned long)group.commented_in); errors++; } @@ -699,7 +698,7 @@ check_misc_infos(Text_no tno, if ( t == NULL ) { - log("Text %lu is a footnote to %lu, which doesn't exist.\n", + kom_log("Text %lu is a footnote to %lu, which doesn't exist.\n", (unsigned long)tno, (unsigned long)group.footnote_to); if (rflag || confirm("Repair by deleting misc_item? ")) @@ -707,7 +706,7 @@ check_misc_infos(Text_no tno, delete_misc(tstat, previous); mark_text_as_changed(tno); modifications++; - log("Repaired: Footnote-link deleted.\n"); + kom_log("Repaired: Footnote-link deleted.\n"); misc = previous; } else @@ -715,7 +714,7 @@ check_misc_infos(Text_no tno, } else if (!is_footnote_to(tno, t)) { - log("Text %lu is a footnote to %lu, but not the reverse.\n", + kom_log("Text %lu is a footnote to %lu, but not the reverse.\n", (unsigned long)tno, (unsigned long)group.footnote_to); errors++; } @@ -727,7 +726,7 @@ check_misc_infos(Text_no tno, if ( t == NULL ) { - log("Text %lu is footnoted in %lu, which doesn't exist.\n", + kom_log("Text %lu is footnoted in %lu, which doesn't exist.\n", (unsigned long)tno, (unsigned long)group.footnoted_in); if (rflag || confirm("Repair by deleting misc_item? ")) @@ -735,7 +734,7 @@ check_misc_infos(Text_no tno, delete_misc(tstat, previous); mark_text_as_changed(tno); modifications++; - log("Repaired: Footnote-link deleted.\n"); + kom_log("Repaired: Footnote-link deleted.\n"); misc = previous; } else @@ -743,7 +742,7 @@ check_misc_infos(Text_no tno, } else if (!is_footnoted_in(tno, t)) { - log("Text %lu is footnoted in %lu, but not the reverse.\n", + kom_log("Text %lu is footnoted in %lu, but not the reverse.\n", (unsigned long)tno, (unsigned long)group.footnoted_in); errors++; } @@ -751,7 +750,7 @@ check_misc_infos(Text_no tno, break; default: - log("check_misc_infos(): parse_next_misc returned type %lu\n", + kom_log("check_misc_infos(): parse_next_misc returned type %lu\n", (unsigned long)group.type); break; } @@ -759,7 +758,7 @@ check_misc_infos(Text_no tno, if ( group.type == m_error ) { - log("Text %lu has a bad misc_info_list.\n", (unsigned long)tno); + kom_log("Text %lu has a bad misc_info_list.\n", (unsigned long)tno); errors++; } @@ -787,13 +786,13 @@ check_texts(void) ctp = cached_get_text_stat( ct ); if ( ctp == NULL ) { - log("Text %lu nonexistent.\n", ct); + kom_log("Text %lu nonexistent.\n", ct); errors++; } else { if (dump_text_numbers) - log("Checking text_no %ld\n", (unsigned long)ct); + kom_log("Checking text_no %ld\n", (unsigned long)ct); bytes += ctp->no_of_chars; if ( (unsigned long)ctp->no_of_chars > max_bytes ) @@ -810,14 +809,14 @@ check_texts(void) if (vflag) { if ( number_of_texts == 0 ) - log("WARNING: No texts found.\n"); + kom_log("WARNING: No texts found.\n"); else { - log("Total of %lu texts (total %lu bytes, avg. %lu bytes/text).\n", + kom_log("Total of %lu texts (total %lu bytes, avg. %lu bytes/text).\n", (unsigned long)number_of_texts, (unsigned long)bytes, (unsigned long)(bytes/number_of_texts)); - log("Longest text is %lu (%lu bytes).\n", + kom_log("Longest text is %lu (%lu bytes).\n", (unsigned long)max_text, (unsigned long)max_bytes); } } @@ -843,7 +842,7 @@ check_created_texts(Pers_no pno, t = cached_get_text_stat(iter.tno); if ( t != NULL && t->author != pno) { - log("Person %lu is author of text %lu whose author is %lu.\n", + kom_log("Person %lu is author of text %lu whose author is %lu.\n", (unsigned long)pno, (unsigned long)iter.tno, (unsigned long)t->author); errors++; @@ -851,7 +850,7 @@ check_created_texts(Pers_no pno, if ( t == NULL ) { - log("Person %lu is author of text %lu, which doesn't exist.\n", + kom_log("Person %lu is author of text %lu, which doesn't exist.\n", (unsigned long)pno, (unsigned long)iter.tno); if ( rflag || confirm("Repair by setting to text_no to 0 in local map")) @@ -859,7 +858,7 @@ check_created_texts(Pers_no pno, delete_list_append(&del_list, iter.lno); mark_person_as_changed(pno); modifications++; - log("Repaired: created_texts corrected.\n"); + kom_log("Repaired: created_texts corrected.\n"); } else errors++; @@ -884,7 +883,7 @@ check_membership(Pers_no pno, conf = cached_get_conf_stat(mship->conf_no); if ( conf == NULL ) { - log("Person %lu is a member in the non-existing conference %lu.\n", + kom_log("Person %lu is a member in the non-existing conference %lu.\n", (unsigned long)pno, (unsigned long)mship->conf_no); errors++; } @@ -893,7 +892,7 @@ check_membership(Pers_no pno, /* Check read texts */ if (mship->last_text_read >= l2g_first_appendable_key(&conf->texts)) { - log("Person %lu %s %lu in conf %lu, which only has %lu texts.\n", + kom_log("Person %lu %s %lu in conf %lu, which only has %lu texts.\n", (unsigned long)pno, "has read text", (unsigned long)mship->last_text_read, @@ -906,7 +905,7 @@ check_membership(Pers_no pno, { if ( mship->read_texts[i] <= last ) { - log("Person %lu's membership in %lu %s %lu<%lu> <= %lu.\n", + kom_log("Person %lu's membership in %lu %s %lu<%lu> <= %lu.\n", (unsigned long)pno, (unsigned long)mship->conf_no, "is corrupt: read text number", (unsigned long)mship->read_texts[i], (unsigned long)i, @@ -920,7 +919,7 @@ check_membership(Pers_no pno, /* Check that he is a member */ if ( (mem = locate_member(pno, conf)) == NULL ) { - log("Person %lu is a member in %lu in which he isn't a member.\n", + kom_log("Person %lu is a member in %lu in which he isn't a member.\n", (unsigned long)pno, (unsigned long)mship->conf_no); errors++; } @@ -942,7 +941,7 @@ check_membership(Pers_no pno, mem->added_at != mship->added_at || mem->added_by != mship->added_by) { - log("Person %lu membership in %lu does not match member record.\n", + kom_log("Person %lu membership in %lu does not match member record.\n", (unsigned long)pno, (unsigned long)mship->conf_no ); @@ -1030,17 +1029,17 @@ check_persons(void) if ( pstat == NULL ) { - log("Person %lu nonexistent.\n", (unsigned long)cp); + kom_log("Person %lu nonexistent.\n", (unsigned long)cp); errors++; } else if (cstat == NULL) { - log("Person %lu has no conference.\n", (unsigned long)cp); + kom_log("Person %lu has no conference.\n", (unsigned long)cp); errors++; } else if (!cstat->type.letter_box) { - log("Person %lu's conference is not a letter_box.\n", + kom_log("Person %lu's conference is not a letter_box.\n", (unsigned long)cp); errors++; } @@ -1053,7 +1052,7 @@ check_persons(void) if (unset_change_name_is_error == 1 && pstat->privileges.change_name == 0) { - log("Person %lu has no change_name capability.\n", + kom_log("Person %lu has no change_name capability.\n", (unsigned long)cp); if (rflag || confirm("Grant him the capability")) @@ -1102,7 +1101,7 @@ check_persons(void) } if (vflag) - log("Total of %lu persons.\n", (unsigned long)number_of_persons); + kom_log("Total of %lu persons.\n", (unsigned long)number_of_persons); return errors; } @@ -1174,7 +1173,7 @@ check_texts_in_conf(Conf_no cc, t = cached_get_text_stat(iter.tno); if (t == NULL) { - log("Text %lu<%lu> in conference %lu is non-existent.\n", + kom_log("Text %lu<%lu> in conference %lu is non-existent.\n", (unsigned long)iter.tno, (unsigned long)iter.lno, (unsigned long)cc); @@ -1184,7 +1183,7 @@ check_texts_in_conf(Conf_no cc, delete_list_append(&del_list, iter.lno); mark_conference_as_changed(cc); modifications++; - log("Repaired: %lu is no longer a recipient.\n", + kom_log("Repaired: %lu is no longer a recipient.\n", (unsigned long)cc); } else @@ -1194,7 +1193,7 @@ check_texts_in_conf(Conf_no cc, { if (!is_recipient(cc, t)) { - log("Text %lu<%lu> in conference %lu %s.\n", + kom_log("Text %lu<%lu> in conference %lu %s.\n", (unsigned long)iter.tno, (unsigned long)iter.lno, (unsigned long)cc, @@ -1205,7 +1204,7 @@ check_texts_in_conf(Conf_no cc, delete_list_append(&del_list, iter.lno); mark_conference_as_changed(cc); modifications++; - log("Repaired: %lu is no longer a recipient.\n", + kom_log("Repaired: %lu is no longer a recipient.\n", (unsigned long)cc); } else @@ -1247,7 +1246,7 @@ check_member(Conf_no cc, pp = cached_get_person_stat(memb->member); if ( pp == NULL ) { - log("Person %lu, supposedly a member in conf %lu, is nonexistent.\n", + kom_log("Person %lu, supposedly a member in conf %lu, is nonexistent.\n", (unsigned long)memb->member, (unsigned long)cc); errors++; } @@ -1255,7 +1254,7 @@ check_member(Conf_no cc, { if ( locate_membership(cc, pp) == NULL ) { - log("Person %lu is not a member in conf %lu.\n", + kom_log("Person %lu is not a member in conf %lu.\n", (unsigned long)memb->member, (unsigned long)cc); errors++; @@ -1295,7 +1294,7 @@ check_confs(void) if ( cstat == NULL ) { - log("Conference %lu nonexistent.\n", (unsigned long)cc); + kom_log("Conference %lu nonexistent.\n", (unsigned long)cc); errors++; } else @@ -1305,7 +1304,7 @@ check_confs(void) pstat = cached_get_person_stat(cc); if (pstat == NULL) { - log("Mailbox %lu has no person.\n", (unsigned long)cc); + kom_log("Mailbox %lu has no person.\n", (unsigned long)cc); errors++; } } @@ -1322,7 +1321,7 @@ check_confs(void) } if ( vflag ) - log("Total of %lu conferences.\n", (unsigned long)number_of_confs); + kom_log("Total of %lu conferences.\n", (unsigned long)number_of_confs); return errors; } @@ -1332,6 +1331,11 @@ init_person_scratch(void) { Pers_no pno = 0; + if (person_scratchpad == NULL) + { + person_scratchpad = smalloc(sizeof(*person_scratchpad) * param.max_conf); + } + while( (pno = traverse_person(pno)) != 0 ) { person_scratchpad[pno] = alloc_person_scratchpad(); @@ -1350,7 +1354,7 @@ post_check_persons(void) { if ((pstat = cached_get_person_stat(pers_no)) == NULL) { - log("%s(): can't cached_get_person_stat(%d).\n", + kom_log("%s(): can't cached_get_person_stat(%d).\n", "INTERNAL DBCK ERROR: post_check_persons", pers_no); } } @@ -1377,10 +1381,10 @@ init_data_base(void) { if ( vflag ) { - log("Database = %s\n", param.datafile_name); - log("Backup = %s\n", param.backupfile_name); - log("Text = %s\n", param.textfile_name); - log("Textback = %s\n", param.textbackupfile_name); + kom_log("Database = %s\n", param.datafile_name); + kom_log("Backup = %s\n", param.backupfile_name); + kom_log("Text = %s\n", param.textfile_name); + kom_log("Textback = %s\n", param.textbackupfile_name); } if ( init_cache() == FAILURE ) @@ -1393,9 +1397,9 @@ garb_text_file(void) Text_no tno = 0; String text; - log("Renaming %s to %s\n", param.textfile_name, param.textbackupfile_name); + kom_log("Renaming %s to %s\n", param.textfile_name, param.textbackupfile_name); rename(param.textfile_name, param.textbackupfile_name); - log("Writing texts to (new) %s\n", param.textfile_name); + kom_log("Writing texts to (new) %s\n", param.textfile_name); fflush(stdout); fflush(stderr); cache_open_new_text_file(); @@ -1406,11 +1410,11 @@ garb_text_file(void) cached_flush_text(tno, text); free_tmp(); } - log("Writing datafile with new indexes.\n"); + kom_log("Writing datafile with new indexes.\n"); fflush(stdout); fflush(stderr); cache_sync_all(); - log("Ready."); + kom_log("Ready."); } @@ -1436,17 +1440,17 @@ print_statistics(void) ts = cached_get_text_stat(t); if (ts == NULL) { - log("print_statistics(): Can't get text_stat.\n"); + kom_log("print_statistics(): Can't get text_stat.\n"); return; } hist[ts->no_of_chars]++; } - log("Length Frequency\n"); + kom_log("Length Frequency\n"); for(i=0; i 0 ) - log("%d error%s found.\n", errors, errors == 1 ? "" : "s"); + kom_log("%d error%s found.\n", errors, errors == 1 ? "" : "s"); if ( modifications > 0 || force_output) { - log("%d modification%s made. Syncing...\n", + kom_log("%d modification%s made. Syncing...\n", modifications, modifications == 1 ? "" : "s"); fflush(stdout); fflush(stderr); cache_sync_all(); - log("ready.\n"); + kom_log("ready.\n"); } if ( sflag ) @@ -1673,26 +1677,26 @@ main (int argc, { if ( modifications == 0 && errors == 0 ) { - log("No errors found. Compressing textfile.\n"); + kom_log("No errors found. Compressing textfile.\n"); fflush(stdout); fflush(stderr); garb_text_file(); - log("ready.\n"); + kom_log("ready.\n"); } else { - log("Found %d errors; performed %d modifications.\n", + kom_log("Found %d errors; performed %d modifications.\n", errors, modifications); fflush(stdout); fflush(stderr); if (confirm ("garb texts anyhow?")) { garb_text_file(); - log("ready.\n"); + kom_log("ready.\n"); } else { - log("Compression not done since errors was found.\n"); + kom_log("Compression not done since errors was found.\n"); } } } diff --git a/src/server/fncdef.txt b/src/server/fncdef.txt index abdab0c1306dca5f27c38781a5218ae5b8af13e2..471b4acc5b6290997cca788f3324ff1da3b286d1 100644 --- a/src/server/fncdef.txt +++ b/src/server/fncdef.txt @@ -1,5 +1,5 @@ # -# $Id: fncdef.txt,v 0.38 1999/01/18 11:55:28 byers Exp $ +# $Id: fncdef.txt,v 0.39 1999/05/12 13:25:09 byers Exp $ # Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997 # Lysator Academic Computer Association. # @@ -23,7 +23,7 @@ # # Please mail bug reports to bug-lyskom@lysator.liu.se. # -# $Id: fncdef.txt,v 0.38 1999/01/18 11:55:28 byers Exp $ +# $Id: fncdef.txt,v 0.39 1999/05/12 13:25:09 byers Exp $ # # This file is used to describe the functions in services.c. All # functions that are reachable from the clients are listed here, together @@ -156,7 +156,7 @@ 86 number create_text c_string (param.text_len) num c_misc_info_p (param.max_crea_misc) aux_item_list (param.max_add_aux) 87 number create_anonymous_text c_string (param.text_len) num c_misc_info_p (param.max_crea_misc) aux_item_list (param.max_add_aux) 88 number create_conf c_string (param.conf_name_len) conf_type aux_item_list (param.max_add_aux) -89 number create_person c_string (param.conf_name_len) c_string (param.pwd_len) aux_item_list (param.max_add_aux) +89 number create_person c_string (param.conf_name_len) c_string (param.pwd_len) pers_flags aux_item_list (param.max_add_aux) 90 success get_text_stat num : text_stat 91 success get_conf_stat num : conference 92 success modify_text_info num num_list (param.max_delete_aux) aux_item_list (param.max_add_aux) @@ -173,6 +173,7 @@ 103 success local_to_global num num num : text_mapping 104 success map_created_texts num num num : text_mapping 105 success set_keep_commented num num +106 success set_pers_flags num pers_flags #ifdef DEBUG_CALLS 1000 success get_memory_info : memory_info diff --git a/src/server/internal-connections.c b/src/server/internal-connections.c index d195928c9d288f00f19abaf6eb3475ae11f79a51..16f610421e59272465670943651a112fce37684f 100644 --- a/src/server/internal-connections.c +++ b/src/server/internal-connections.c @@ -1,5 +1,5 @@ /* - * $Id: internal-connections.c,v 0.34 1999/04/28 22:07:52 ceder Exp $ + * $Id: internal-connections.c,v 0.35 1999/05/12 13:25:10 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -35,7 +35,7 @@ static const char * -rcsid = "$Id: internal-connections.c,v 0.34 1999/04/28 22:07:52 ceder Exp $"; +rcsid = "$Id: internal-connections.c,v 0.35 1999/05/12 13:25:10 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -151,6 +151,7 @@ init_connection(Connection *conn) init_priv_bits(&conn->priv_bits); init_conf_type(&conn->conf_type); init_struct_tm(&conn->time); + init_personal_flags(&conn->pers_flags); } static Connection * @@ -263,18 +264,18 @@ kill_client(Connection *cp) if ( cp->isc_session != NULL ) { - log("kill_client(): client %ld has isc_session != NULL.\n", - cp->session_no); + kom_log("kill_client(): client %ld has isc_session != NULL.\n", + cp->session_no); } if ( !s_empty(cp->c_string0) || !s_empty(cp->c_string1) || !s_empty(cp->string0) ) { - log("kill_client(): unexpected string remains.\n"); + kom_log("kill_client(): unexpected string remains.\n"); } if ( cp->c_misc_info_p != NULL || cp->c_local_text_no_p != NULL ) - log("kill_client(): unexpected remaining data.\n"); + kom_log("kill_client(): unexpected remaining data.\n"); sfree(cp); --no_of_allocated_connections; diff --git a/src/server/kom-memory.h b/src/server/kom-memory.h index 9938e72c7d46c9611d335111a9d0852274470703..e2c02c0cb5ea7ed2a367f50396f0021b040d3e89 100644 --- a/src/server/kom-memory.h +++ b/src/server/kom-memory.h @@ -1,5 +1,5 @@ /* - * $Id: kom-memory.h,v 1.9 1998/10/17 16:41:33 ceder Exp $ + * $Id: kom-memory.h,v 1.10 1999/05/12 13:25:11 byers Exp $ * Copyright (C) 1991, 1993, 1994, 1996 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: kom-memory.h,v 1.9 1998/10/17 16:41:33 ceder Exp $ + * $Id: kom-memory.h,v 1.10 1999/05/12 13:25:11 byers Exp $ * * The time has come to get some order into this mess. * @@ -115,6 +115,8 @@ extern void init_who_info_old (Who_info_old *w); extern void free_aux_item_list (Aux_item_list *list); extern void init_aux_item_list (Aux_item_list *list); +extern void init_aux_item_link(Aux_item_link *dest); +extern void init_aux_item(Aux_item *dest); extern void copy_aux_item (Aux_item *dest, const Aux_item *src); /* diff --git a/src/server/local-to-global.c b/src/server/local-to-global.c index 99b4c4af23b2eb268c83e7be96987792b5a67040..b994666468006778383d5f2ae478ca3d27c6b459 100644 --- a/src/server/local-to-global.c +++ b/src/server/local-to-global.c @@ -627,7 +627,7 @@ l2g_append(Local_to_global *l2g, if (lno < l2g->first_unused) { - log("l2g_append: won't add %lu<%lu> when first_unused=%lu\n", + kom_log("l2g_append: won't add %lu<%lu> when first_unused=%lu\n", (unsigned long)tno, (unsigned long)lno, (unsigned long)l2g->first_unused); return; @@ -880,8 +880,8 @@ l2g_read(FILE *fp, Local_to_global *l2g) fskipwhite(fp); if ( (c = getc(fp)) == EOF || c != '[') { - log("l2g_read() failed to find ``['' marker at pos %lu.\n", - (unsigned long) ftell(fp)); + kom_log("l2g_read() failed to find ``['' marker at pos %lu.\n", + (unsigned long) ftell(fp)); return FAILURE; } @@ -892,7 +892,7 @@ l2g_read(FILE *fp, Local_to_global *l2g) { if ((c = getc(fp)) == EOF) { - log("l2g_read(): unexpected EOF at pos %lu.\n", + kom_log("l2g_read(): unexpected EOF at pos %lu.\n", (unsigned long) ftell(fp)); return FAILURE; } @@ -903,7 +903,7 @@ l2g_read(FILE *fp, Local_to_global *l2g) lno = fparse_long(fp); if (lno == 0) { - log("l2g_read(): got local number 0 at pos %lu.\n", + kom_log("l2g_read(): got local number 0 at pos %lu.\n", (unsigned long) ftell(fp)); return FAILURE; } @@ -911,7 +911,7 @@ l2g_read(FILE *fp, Local_to_global *l2g) case ',': if (lno == 0) { - log("l2g_read(): missing local number at pos %lu.\n", + kom_log("l2g_read(): missing local number at pos %lu.\n", (unsigned long)ftell(fp)); return FAILURE; } @@ -920,7 +920,7 @@ l2g_read(FILE *fp, Local_to_global *l2g) case ':': if (lno == 0) { - log("l2g_read(): missing local number at pos %lu.\n", + kom_log("l2g_read(): missing local number at pos %lu.\n", (unsigned long)ftell(fp)); return FAILURE; } @@ -932,7 +932,7 @@ l2g_read(FILE *fp, Local_to_global *l2g) l2g->first_unused = first_unused; return OK; default: - log("l2g_read(): unexpected character ``%c'' at pos %lu.\n", + kom_log("l2g_read(): unexpected character ``%c'' at pos %lu.\n", c, (unsigned long) ftell(fp)); return FAILURE; } @@ -1026,7 +1026,7 @@ l2gi_searchsome(L2g_iterator *l2gi, if (begin < 1) { - log("l2gi_searchsome(%lu, %lu) called: min is 1\n", + kom_log("l2gi_searchsome(%lu, %lu) called: min is 1\n", (unsigned long)begin, (unsigned long)end); begin = 1; } diff --git a/src/server/log.c b/src/server/log.c index 6556d9bc18625e4d9f88a79bb8a7417d6d69c4fc..5a5ca3eb533353539ca5252c2b95d71ca3f4b6f9 100644 --- a/src/server/log.c +++ b/src/server/log.c @@ -1,5 +1,5 @@ /* - * $Id: log.c,v 0.18 1998/12/26 22:40:41 byers Exp $ + * $Id: log.c,v 0.19 1999/05/12 13:25:13 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1995 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -35,7 +35,7 @@ #endif static const char * -rcsid = "$Id: log.c,v 0.18 1998/12/26 22:40:41 byers Exp $"; +rcsid = "$Id: log.c,v 0.19 1999/05/12 13:25:13 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -57,18 +57,18 @@ USE(rcsid); #if defined(HAVE_VFPRINTF) && defined(HAVE_STDARG_H) extern void -log (const char * format, ...) +kom_log (const char * format, ...) { va_list AP; va_start(AP, format); - logv(format, AP); + kom_logv(format, AP); va_end(AP); } extern void -logv (const char *format, va_list AP) +kom_logv (const char *format, va_list AP) { time_t clk; struct tm *t; @@ -85,7 +85,7 @@ logv (const char *format, va_list AP) } #else /* !HAVE_VFPRINTF */ extern void -log (const char * format, +kom_log (const char * format, int a, int b, int c, int d, int e, int f, int g) { time_t clk; @@ -131,26 +131,30 @@ restart_kom(format, #if defined(HAVE_VFPRINTF) && defined(HAVE_STDARG_H) va_start(AP, format); - logv(format, AP); + kom_logv(format, AP); va_end(AP); #else - log(format, a, b, c, d, e, f, g); + kom_log(format, a, b, c, d, e, f, g); #endif - log("Previous message is fatal. Will dump core now.\n"); + kom_log("Previous message is fatal. Will dump core now.\n"); #ifdef HAVE_GETCWD /* getcwd is POSIX, so try that first. */ if (getcwd(pathname, 1026) == NULL) - log("getcwd failed: errno %d\n", errno); + kom_log("getcwd failed: errno %d\n", errno); else - log("Search for the core in %s\n", pathname); + kom_log("Search for the core in %s\n", pathname); #else if ( getwd(pathname) == NULL ) - log("getwd failed: %s\n", pathname); + kom_log("getwd failed: %s\n", pathname); else - log("Search for the core in %s\n", pathname); + kom_log("Search for the core in %s\n", pathname); #endif +#ifdef AVOID_ABORTS + exit(255); +#else abort(); +#endif } diff --git a/src/server/log.h b/src/server/log.h index ccbf592ba259a183b159b100cf2f0cdcb7eb392e..b550ee82c32cd14636e7a82339563a71e725f2ba 100644 --- a/src/server/log.h +++ b/src/server/log.h @@ -1,5 +1,5 @@ /* - * $Id: log.h,v 0.12 1996/09/01 19:32:54 inge Exp $ + * $Id: log.h,v 0.13 1999/05/12 13:25:14 byers Exp $ * Copyright (C) 1991, 1993, 1994, 1995, 1996 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: log.h,v 0.12 1996/09/01 19:32:54 inge Exp $ + * $Id: log.h,v 0.13 1999/05/12 13:25:14 byers Exp $ * * log.h * @@ -43,14 +43,14 @@ #if defined(HAVE_VFPRINTF) && defined(HAVE_STDARG_H) extern void -log (const char * format, ...) +kom_log (const char * format, ...) # if HAVE_ATTRIBUTE_FORMAT_PRINTF __attribute__ ((format (printf, 1, 2))) # endif ; extern void -logv (const char * format, va_list AP) +kom_logv (const char * format, va_list AP) # if HAVE_ATTRIBUTE_FORMAT_PRINTF __attribute__ ((format (printf, 1, 0))) # endif @@ -58,7 +58,7 @@ logv (const char * format, va_list AP) #else /* !HAVE_VFPRINTF || !HAVE_STDARG_H*/ extern void -log (); +kom_log (); #endif /* !HAVE_VFPRINTF || !HAVE_STDARG_H*/ diff --git a/src/server/manipulate.h b/src/server/manipulate.h index 70f3d36b46bb18f494b1a14c20fc975f115ab86e..a7091203c4a5c935a34f18f79aa8de20030437de 100644 --- a/src/server/manipulate.h +++ b/src/server/manipulate.h @@ -1,5 +1,5 @@ /* - * $Id: manipulate.h,v 0.20 1999/01/18 11:55:29 byers Exp $ + * $Id: manipulate.h,v 0.21 1999/05/12 13:25:14 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1996 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.20 1999/01/18 11:55:29 byers Exp $ + * $Id: manipulate.h,v 0.21 1999/05/12 13:25:14 byers Exp $ * * manipulate.h * @@ -419,6 +419,12 @@ extern Bool text_read_access(Text_no text_no, Text_stat * text_stat); +extern Bool +person_text_read_access(Text_no text_no, + Text_stat * text_stat, + Pers_no pers_no, + Person * pers_stat); + diff --git a/src/server/membership.c b/src/server/membership.c index 69d996b6088dd471be89116bf0ce6e90032d93ae..78b553eafcbec19cba01f7d6cb0ec16533da55da 100644 --- a/src/server/membership.c +++ b/src/server/membership.c @@ -1,5 +1,5 @@ /* - * $Id: membership.c,v 0.41 1999/01/18 11:55:29 byers Exp $ + * $Id: membership.c,v 0.42 1999/05/12 13:25:15 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 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.41 1999/01/18 11:55:29 byers Exp $"; +rcsid = "$Id: membership.c,v 0.42 1999/05/12 13:25:15 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -341,7 +341,7 @@ add_rec_time(Conference * conf_c, if( found == FALSE ) { - log("ERROR: add_rec_time(): found==FALSE\n"); + kom_log("ERROR: add_rec_time(): found==FALSE\n"); } mark_text_as_changed( text_no); @@ -436,7 +436,7 @@ adjust_read( Membership * m, { if ( prev >= m->read_texts[ i ] ) { - log("Bug in adjust_read. Conference %lu, Priority %lu\n" + kom_log("Bug in adjust_read. Conference %lu, Priority %lu\n" "\tprev = %lu, i = %lu, m->read_texts[i] = %lu\n", (unsigned long)m->conf_no, (unsigned long)m->priority, (unsigned long)prev, (unsigned long)i, @@ -783,11 +783,8 @@ fast_access_perm(Conf_no victim, /* Only read in conference struct when really necessary. */ conf_type = cached_get_conf_type (victim); - if ( conf_type.secret ) + if ( conf_type.secret || conf_type.rd_prot ) return access_perm(victim, NULL, viewer, viewer_p); - - if ( conf_type.rd_prot ) - return read_protected; return limited; } @@ -975,8 +972,6 @@ add_member_common(Conf_no conf_no, to know this. Pretend that the addition worked, and hope that the user does not double-check */ - log ("\nTHIS IS STRANGE\n"); - return OK; } @@ -1000,7 +995,7 @@ add_member_common(Conf_no conf_no, { if (pers_no != ACTPERS) { - log("Person %lu added to conference %lu by %lu.\n", + kom_log("Person %lu added to conference %lu by %lu.\n", (unsigned long)pers_no, (unsigned long)conf_no, (unsigned long)ACTPERS); @@ -1056,7 +1051,7 @@ check_membership(Pers_no pno, if (mship->last_text_read >= l2g_first_appendable_key(&conf->texts)) { if ( log_no++ < 80 ) - log("%s%d) Person %lu has read text %lu in conf %lu%s%lu texts.\n", + kom_log("%s%d) Person %lu has read text %lu in conf %lu%s%lu texts.\n", "membership.c: check_membership(): (", log_no, (unsigned long)pno, @@ -1142,7 +1137,7 @@ mark_as_read (Conf_no conference, #ifdef DEBUG_MARK_AS_READ if ( m->read_texts == NULL && m->no_of_read != 0 ) { - log("mark_as_read(): m->read_texts == NULL && m->no_of_read == %lu (corrected).", + kom_log("mark_as_read(): m->read_texts == NULL && m->no_of_read == %lu (corrected).", (unsigned long)m->no_of_read); m->no_of_read = 0; } @@ -1220,10 +1215,10 @@ mark_as_read (Conf_no conference, /* Check that the membership is correct. Otherwise log all info. */ if ( check_membership(ACTPERS, conf_c, m) > 0 && log_no++ < 40 ) { - log("mark_as_read(): (Msg no %d) Person %lu %s:\n", + kom_log("mark_as_read(): (Msg no %d) Person %lu %s:\n", log_no, (unsigned long)ACTPERS, "has a corrupt membership"); - log("Dump of data follows: %s\n", + kom_log("Dump of data follows: %s\n", " "); foutput_membership(stderr, &original); putc('\n', stderr); @@ -1659,6 +1654,9 @@ extern Success set_membership_type(Pers_no pers_no, FIXME: membership record. */ + kom_log("Membership and member record mismatch for pers %lu in conf %lu", + (unsigned long)pers_no, (unsigned long)conf_no); + kom_log("You should run dbck"); err_stat = conf_no; kom_errno = KOM_NOT_MEMBER; return FAILURE; diff --git a/src/server/memory.c b/src/server/memory.c index 6d03ca1dcf718239ac1fe0cd9888c60f0b771953..b76e7585a5ce503c667e5b8358329902663a7b1f 100644 --- a/src/server/memory.c +++ b/src/server/memory.c @@ -1,5 +1,5 @@ /* - * $Id: memory.c,v 0.31 1999/04/05 16:15:34 ceder Exp $ + * $Id: memory.c,v 0.32 1999/05/12 13:25:16 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -33,7 +33,7 @@ #endif static const char * -rcsid = "$Id: memory.c,v 0.31 1999/04/05 16:15:34 ceder Exp $"; +rcsid = "$Id: memory.c,v 0.32 1999/05/12 13:25:16 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -200,7 +200,7 @@ clear_mark_list(Mark_list *mark_list) { if ( mark_list == NULL ) { - log("clear_mark_list(): mark_list == NULL.\n"); + kom_log("clear_mark_list(): mark_list == NULL.\n"); return; } @@ -263,7 +263,7 @@ clear_membership(Membership *mship) { if ( mship == NULL ) { - log("clear_membership(): mship == NULL.\n"); + kom_log("clear_membership(): mship == NULL.\n"); return; } @@ -313,7 +313,7 @@ clear_membership_list(Membership_list *mlist) if ( mlist == NULL ) { - log("clear_membership_list(): membership_list == NULL.\n"); + kom_log("clear_membership_list(): membership_list == NULL.\n"); return; } @@ -699,6 +699,35 @@ init_aux_item_list(Aux_item_list *list) list->items = NULL; } +void +init_aux_item_link(Aux_item_link *dest) +{ + dest->target_type = NO_OBJECT_TYPE; + dest->target_item = 0; + dest->target_object.conf = 0; + dest->target_object.text = 0; +} + +void +init_aux_item(Aux_item *dest) +{ + dest->aux_no = 0; + dest->creator = 0; + dest->sent_at = 0; + dest->flags.deleted = 0; + dest->flags.inherit = 0; + dest->flags.secret = 0; + dest->flags.hide_creator = 0; + dest->flags.dont_garb = 0; + dest->flags.reserved3 = 0; + dest->flags.reserved4 = 0; + dest->flags.reserved5 = 0; + dest->inherit_limit = 0; + dest->tag = 0; + dest->data = EMPTY_STRING; + init_aux_item_link(&dest->linked_item); +} + void copy_aux_item(Aux_item *dest, const Aux_item *src) { @@ -710,6 +739,7 @@ copy_aux_item(Aux_item *dest, const Aux_item *src) dest->tag = src->tag; dest->data = EMPTY_STRING; s_strcpy(&dest->data, src->data); + dest->linked_item = src->linked_item; } diff --git a/src/server/mux-parse.c b/src/server/mux-parse.c new file mode 100644 index 0000000000000000000000000000000000000000..4fb7ca43e18c11d4133452f217b10d6e127cfc78 --- /dev/null +++ b/src/server/mux-parse.c @@ -0,0 +1,298 @@ +/* + * $Id: mux-parse.c,v 0.23 1999/05/12 13:25:17 byers Exp $ + * Copyright (C) 1991, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. + * + * This file is part of the LysKOM server. + * + * LysKOM is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1, or (at your option) + * any later version. + * + * LysKOM is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * along with LysKOM; see the file COPYING. If not, write to + * Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN, + * or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * Please mail bug reports to bug-lyskom@lysator.liu.se. + */ +/* + ** mux-parse.c Handle the MUX protocol + * This is a hack. Clean this mess up with lacgen. + */ + + + +#ifdef HAVE_CONFIG_H +# include +#endif + +static const char * +rcsid = "$Id: mux-parse.c,v 0.23 1999/05/12 13:25:17 byers Exp $"; +#include "rcs.h" +USE(rcsid); + +#include +#include +#include +#include +#ifdef HAVE_STDARG_H +# include +#endif +#include + +#include "s-string.h" +#include "kom-types.h" +#include "com.h" +#include "async.h" +#include "connections.h" +#include "isc-interface.h" +#include "kom-config.h" +#include "log.h" +#include "minmax.h" +#include "mux.h" +#include "mux-parse.h" + +jmp_buf mux_parse_env; + +static String +mux_get_token(Mux *mux) +{ + String result; + String_size old_first; + + old_first = mux->parse.first_to_parse; + + result = s_strtok(mux->parse.unparsed, &mux->parse.first_to_parse, + s_fcrea_str(WHITESPACE)); + + /* Check that there was at least one trailing blank. */ + + if ( mux->parse.first_to_parse >= s_strlen(mux->parse.unparsed) ) + { + mux->parse.first_to_parse = old_first; + longjmp(mux_parse_env, MUX_MSG_INCOMPLETE); + } + + return result; +} + +static long +mux_parse_long(Mux *mux) +{ + String token; + String_size end; + long res; + + token = mux_get_token(mux); + res = s_strtol(token, &end, PROTOCOL_NUMBER_BASE); + if (end != s_strlen(token)) + longjmp(mux_parse_env, MUX_PROTOCOL_ERR); + + return res; +} + + +/* + * Parse a string. At most 'maxlen' characters are allowed. If the + * mux sends a longer string only the first 'maxlen+1' characters + * are read. Any remaining characters are discarded. + * + * longjmp if not enough characters are available or if there + * is an error. Result is used to save state in that case. + * +++ Result should not be used to save state. + */ +static void +mux_parse_string(Mux *mux, + String *result, + int maxlen) +{ + String_size hptr; /* Pointer to 'H' */ + String_size mux_len; /* The len the mux is sending. */ + String_size truncated_len; /* How much the server will receive. */ + String_size to_skip; + static u_long err_cnt = 0; + + switch ( mux->parse.string_parse_pos ) + { + case 0: + if ( ( result->len != 0 || result->string != NULL) && err_cnt++ < 20 ) + { + kom_log ("%s == %lu, result->string == %lu. %s.\n", + "mux_parse_string(): result->len", + (u_long)result->len, (u_long)result->string, + "This memory will not be free()'d"); + *result = EMPTY_STRING; + if ( err_cnt == 20 ) + kom_log("Won't log the above warning no more."); + } + + /* Get number and discard trailing 'H' */ + mux_len = s_strtol(s_fsubstr(mux->parse.unparsed, + mux->parse.first_to_parse, + END_OF_STRING), + &hptr, PROTOCOL_NUMBER_BASE); + + if ( hptr == -1 + || mux->parse.first_to_parse + hptr + >= s_strlen(mux->parse.unparsed) ) + { + longjmp(mux_parse_env, MUX_MSG_INCOMPLETE); + } + + if (mux_len < 0) + { + kom_log("Insane string length from mux. Logging out mux.\n"); + longjmp(mux_parse_env, MUX_LOGOUT); + } + + /* Check that + a) there is a trailing H + b) there was at least one digit before the H */ + + /* +++ Use s-string.c to extract the char. */ + /* +++ Fix prot_a_parse_string also. */ + if ( mux->parse.unparsed.string[ mux->parse.first_to_parse + + hptr ] != 'H' + || hptr <= 0 ) + { + longjmp(mux_parse_env, MUX_PROTOCOL_ERR); + } + + mux->parse.first_to_parse += 1 + hptr; + mux->parse.string_parse_pos = 1; + result->len = mux_len; /* +++ Transfer mux_len. */ + /* Fall through */ + case 1: + mux_len = result->len; + /* Check that the entire string is transmitted. */ + /* (Don't care about the trailing part that will be skipped if the + * string is longer than maxlen) */ + truncated_len = min(maxlen + 1, mux_len); + + if ( mux->parse.first_to_parse + truncated_len + > s_strlen(mux->parse.unparsed) ) + { + longjmp(mux_parse_env, MUX_MSG_INCOMPLETE); + } + + *result = EMPTY_STRING; + + s_mem_crea_str(result, + mux->parse.unparsed.string + mux->parse.first_to_parse, + truncated_len); + + mux->parse.first_to_parse += truncated_len; + mux->parse.string_parse_pos = 2; + result->len = mux_len; /* Can't transfer the local mux_len across + * call boundary. +++ There should be room + * for mux_len in the per-connection + * protocol data. + */ + /* Fall through */ + case 2: + /* Was the string too long? If so, skip the truncated data. */ + + mux_len = result->len; /* +++ shouldn't modify ->len */ + truncated_len = min(maxlen+1, mux_len); + + if ( mux_len > truncated_len ) + { + to_skip = min(mux_len - truncated_len, + mux->parse.unparsed.len - mux->parse.first_to_parse); + /* From now on, mux_len is length of result + numer of + chars to skip. Clean up this! +++ + */ + mux_len -= to_skip; + mux->parse.first_to_parse += to_skip; + } + + result->len = mux_len; + + if ( mux_len > truncated_len ) + { + /* +++ mux_len is transferred in result->len. */ + longjmp(mux_parse_env, MUX_MSG_INCOMPLETE); + } + + /* Fall through */ + default: + mux->parse.string_parse_pos = 0; + } +} + + + + + +static Bool +mux_is_legal_fnc(int fnc) +{ + switch(fnc) + { + case 0: + case 1: + case 2: + case 3: + return TRUE; + + default: + return FALSE; + } +} + +static void +mux_parse_client_message(Mux *mux) +{ + switch(mux->parse.parse_pos_2) + { + case 0: + mux->parse.num = mux_parse_long(mux); + mux->parse.parse_pos_2 = 1; + /* Fall through */ + case 1: + mux_parse_string(mux, &mux->parse.string, 10000); + /* Fall through */ + default: + mux->parse.parse_pos_2 = 0; + } +} + +void +mux_parse_packet(Mux *mux) +{ + switch(mux->parse.parse_pos) + { + case 0: /* Get fnc_no */ + mux->parse.function = mux_parse_long(mux); + if ( !mux_is_legal_fnc(mux->parse.function) ) + longjmp(mux_parse_env, MUX_PROTOCOL_ERR); + mux->parse.parse_pos = 1; + /* Fall through */ + case 1: + /* Call the function that parses the arguments for this call. */ + switch(mux->parse.function) + { + case 0: + break; + + case 2: + mux->parse.num = mux_parse_long(mux); + break; + + case 1: + case 3: + mux_parse_client_message(mux); + break; + } + /* Fall through */ + default: + mux->parse.parse_pos = 0; + } +} diff --git a/src/server/param.h b/src/server/param.h index 72d4ef94ff296519b42312fdc4b21f2bdf99fccf..bfe2b862d51726a93f25f23e80a9aa885a6eea0b 100644 --- a/src/server/param.h +++ b/src/server/param.h @@ -1,5 +1,5 @@ /* - * $Id: param.h,v 1.24 1999/04/28 22:11:19 ceder Exp $ + * $Id: param.h,v 1.25 1999/05/12 13:25:18 byers Exp $ * Copyright (C) 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -56,6 +56,7 @@ struct kom_par { char *aux_def_file; char *status_file; /* Only used in komrunning and updateLysKOM */ char *core_dir; + char *nologin_file; char *lyskomd_path; char *savecore_path; int timeout; @@ -65,6 +66,7 @@ struct kom_par { Bool permissive_sync; int sync_interval; int sync_retry_interval; + int client_data_len; int conf_name_len; int pwd_len; int what_do_len; @@ -109,6 +111,8 @@ struct kom_par { Bool secret_memberships; Bool allow_reinvite; Bool regex_use_collate_table; + unsigned long max_conf; + unsigned long max_text; }; extern struct kom_par param; diff --git a/src/server/person.c b/src/server/person.c index 34241f4ca8396fec61ecb25e8fa9d83707aecba1..0b7747919b3cdd97171842313c50746ba4a7e8a8 100644 --- a/src/server/person.c +++ b/src/server/person.c @@ -1,5 +1,6 @@ + /* - * $Id: person.c,v 0.48 1999/04/05 00:42:27 ceder Exp $ + * $Id: person.c,v 0.49 1999/05/12 13:25:19 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -35,7 +36,7 @@ #endif static const char * -rcsid = "$Id: person.c,v 0.48 1999/04/05 00:42:27 ceder Exp $"; +rcsid = "$Id: person.c,v 0.49 1999/05/12 13:25:19 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -80,6 +81,7 @@ USE(rcsid); #include "param.h" #include "aux-items.h" #include "local-to-global.h" +#include "kom-memory.h" BUGDECL; @@ -258,7 +260,7 @@ do_unmark_text(Pers_no pers_no, { if ( text_s->no_of_marks == 0 ) { - log("WNG: do_unmark_text(): Text %lu has no_of_marks==0,\ + kom_log("WNG: do_unmark_text(): Text %lu has no_of_marks==0,\ but person %d had marked the text.", (unsigned long)text_no, pers_no); } @@ -303,7 +305,7 @@ do_set_user_area(Pers_no pers_no, GET_T_STAT(new_user_area, user_area, FAILURE); if ( new_user_area->no_of_marks >= param.max_marks_text ) { - log("%s(%d, %lu): New user_area's mark count (%d) > %d.\n", + kom_log("%s(%d, %lu): New user_area's mark count (%d) > %d.\n", "LIMIT: set_user_area", pers_no, (unsigned long)user_area, new_user_area->no_of_marks, param.max_marks_text); @@ -328,7 +330,7 @@ do_set_user_area(Pers_no pers_no, } else { - log("ERROR: set_user_area(%d, %lu): Old user_area %lu unmarked\n", + kom_log("ERROR: set_user_area(%d, %lu): Old user_area %lu unmarked\n", pers_no, (unsigned long)user_area, (unsigned long)pers_p->user_area); } @@ -376,7 +378,7 @@ do_delete_pers (Pers_no pers_no) pers_no, pers_p, pers_p->conferences.confs + i) != OK) { - log("ERROR: do_delete_pers(): can't sub_member\n"); + kom_log("ERROR: do_delete_pers(): can't sub_member\n"); } } @@ -385,14 +387,14 @@ do_delete_pers (Pers_no pers_no) if ( do_unmark_text(pers_no, pers_p, pers_p->marks.marks[0].text_no, NULL) != OK ) { - log("WNG: do_delete_pers(): can't unmark text %lu (i == %d)\n", + kom_log("WNG: do_delete_pers(): can't unmark text %lu (i == %d)\n", (unsigned long)pers_p->marks.marks[0].text_no, i); } } if ( do_set_user_area(pers_no, pers_p, 0) != OK ) { - log("WNG: do_delete_pers(): can't unmark user_area\n"); + kom_log("WNG: do_delete_pers(): can't unmark user_area\n"); } s_clear( &pers_p->username ); @@ -480,7 +482,7 @@ mark_text(Text_no text_no, /* Will fail if the user is not */ if ( !text_read_access(text_no, text_s) ) { err_stat = text_no; - kom_errno = KOM_PERM; + kom_errno = KOM_NO_SUCH_TEXT; return FAILURE; } @@ -529,12 +531,14 @@ static Pers_no create_person_generic ( const String name, const String passwd, Aux_item_list *conf_aux, + Personal_flags flags, Bool do_auto_login ) { Pers_no new_user; Conference * mailbox; Person * pers_p; Membership_type mship_type; + time_t now; if (ACTPERS == 0) @@ -575,7 +579,7 @@ create_person_generic ( const String name, if ( !unique_name( name, 0 ) ) { err_stat = 0; - kom_errno = KOM_CONF_EXISTS; + kom_errno = KOM_PERS_EXISTS; return 0; } @@ -587,15 +591,22 @@ create_person_generic ( const String name, } new_user = cached_create_conf( name ); + if (new_user == 0) + { + /* kom_errno and err_stat set in cached_create_conf */ + kom_log("ERROR: Couldn't create person. Too many conferences."); + return 0; + } if ( (mailbox = cached_get_conf_stat( new_user ) ) == NULL) { restart_kom("create_person() - can't get conf_stat"); } - + now = time(NULL); + mailbox->creator = ACTPERS ? ACTPERS : new_user; - mailbox->creation_time = time(NULL); + mailbox->creation_time = now; mailbox->presentation = 0; /* No presentation yet */ mailbox->supervisor = ACTPERS ? ACTPERS : new_user; mailbox->permitted_submitters = 0; @@ -637,6 +648,7 @@ create_person_generic ( const String name, restart_kom("create_person(): can't set passwd\n"); pers_p->privileges.change_name = param.default_change_name; + pers_p->flags = flags; mark_person_as_changed( new_user ); @@ -652,7 +664,7 @@ create_person_generic ( const String name, do_add_member( new_user, mailbox, new_user, pers_p, UCHAR_MAX, 0, &mship_type, FALSE ); - prepare_aux_item_list(conf_aux, new_user); + prepare_aux_item_list(conf_aux, new_user, now); if (conf_stat_check_add_aux_item_list(mailbox, new_user, @@ -691,17 +703,21 @@ extern Pers_no create_person_old(const String name, const String passwd) { - return create_person_generic(name, passwd, NULL, TRUE); + Personal_flags flags; + + init_personal_flags(&flags); + return create_person_generic(name, passwd, NULL, flags, TRUE); } extern Pers_no create_person(const String name, const String passwd, + Personal_flags flags, Aux_item_list *conf_aux) { Pers_no pers; - pers = create_person_generic(name, passwd, conf_aux, FALSE); + pers = create_person_generic(name, passwd, conf_aux, flags, FALSE); if (pers != 0) { /* FIXME: Send asynch message */ @@ -733,7 +749,7 @@ get_person_stat (Pers_no person, if ( acc == error ) return FAILURE; - if ( acc == none ) + if ( acc <= none ) { err_stat = person; kom_errno = KOM_UNDEF_PERS; @@ -771,7 +787,7 @@ get_person_stat_old (Pers_no person, if ( acc == error ) return FAILURE; - if ( acc == none ) + if ( acc <= none ) { err_stat = person; kom_errno = KOM_UNDEF_PERS; @@ -813,7 +829,7 @@ get_created_texts(Pers_no pers_no, if (acc == error) return FAILURE; - if (acc == none) + if (acc <= none) { err_stat = pers_no; kom_errno = KOM_UNDEF_PERS; @@ -864,15 +880,15 @@ map_created_texts(Pers_no pers_no, return FAILURE; } - CHK_LOGIN(FAILURE); GET_P_STAT(pers_p, pers_no, FAILURE); + CHK_LOGIN(FAILURE); acc = access_perm(pers_no, NULL, ACTPERS, ACT_P); if (acc == error) return FAILURE; - if (acc == none) + if (acc <= none) { err_stat = pers_no; kom_errno = KOM_UNDEF_PERS; @@ -1076,11 +1092,19 @@ set_user_area(Pers_no pers_no, Text_no user_area) { Person *pers_p; + Access acc; CHK_LOGIN(FAILURE); - GET_P_STAT(pers_p, pers_no, FAILURE); - if ( access_perm(pers_no, NULL, ACTPERS, ACT_P) != unlimited ) + GET_P_STAT(pers_p, pers_no, FAILURE); + acc = access_perm(pers_no, NULL, ACTPERS, ACT_P); + if (acc <= none) + { + err_stat = pers_no; + kom_errno = KOM_UNDEF_PERS; + return FAILURE; + } + if (acc != unlimited) { err_stat = pers_no; kom_errno = KOM_PERM; @@ -1089,3 +1113,39 @@ set_user_area(Pers_no pers_no, return do_set_user_area (pers_no, pers_p, user_area); } + + +/* + * Set the personal flags + */ + +extern Success +set_pers_flags(Pers_no pers_no, + Personal_flags flags) +{ + Person *pers_p; + Access acc; + + CHK_LOGIN(FAILURE); + + GET_P_STAT(pers_p, pers_no, FAILURE); + + acc = access_perm(pers_no, NULL, ACTPERS, ACT_P); + if (acc <= none) + { + err_stat = pers_no; + kom_errno = KOM_UNDEF_PERS; + return FAILURE; + } + if (acc != unlimited) + { + err_stat = pers_no; + kom_errno = KOM_PERM; + return FAILURE; + } + + pers_p->flags = flags; + mark_person_as_changed(pers_no); + + return OK; +} diff --git a/src/server/prot-a-output.c b/src/server/prot-a-output.c index 4201d39989ae3bcf6ba1b8068e6e69f663d4bafb..878dd5ca446c55cc0b3dabaceccffb42ed27dbd7 100644 --- a/src/server/prot-a-output.c +++ b/src/server/prot-a-output.c @@ -1,5 +1,5 @@ /* - * $Id: prot-a-output.c,v 0.42 1999/04/28 22:11:44 ceder Exp $ + * $Id: prot-a-output.c,v 0.43 1999/05/12 13:25:20 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -35,7 +35,7 @@ #endif static const char * -rcsid = "$Id: prot-a-output.c,v 0.42 1999/04/28 22:11:44 ceder Exp $"; +rcsid = "$Id: prot-a-output.c,v 0.43 1999/05/12 13:25:20 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -944,6 +944,18 @@ prot_a_output_text_mapping(Connection *fp, Local_text_no nonzeroes = 0; L2g_iterator iter; + /* Initialize iter to something. Otherwise some tools will flag + a read uninitialized memory in the for initializer. */ + + iter.l2g = NULL; + iter.binfo = NULL; + iter.arrindex = 0; + iter.beginval = 0; + iter.endval = 0; + iter.search_ended = 0; + iter.lno = 0; + iter.tno = 0; + /* Count the number of internal zeroes to determine if we should use a dense or sparse representation. */ diff --git a/src/server/prot-a-parse-arg-c.awk b/src/server/prot-a-parse-arg-c.awk index f580f8b13255954c36cbdb0eff07039703e4d10e..062dd52c832ba019bf37a45339f6c6dd27e3b97e 100644 --- a/src/server/prot-a-parse-arg-c.awk +++ b/src/server/prot-a-parse-arg-c.awk @@ -1,5 +1,5 @@ # -# $Id: prot-a-parse-arg-c.awk,v 0.21 1999/04/03 22:24:17 ceder Exp $ +# $Id: prot-a-parse-arg-c.awk,v 0.22 1999/05/12 13:25:21 byers Exp $ # Copyright (C) 1991, 1992, 1993, 1994, 1996 Lysator Academic Computer Association. # # This file is part of the LysKOM server. @@ -22,7 +22,7 @@ # # Please mail bug reports to bug-lyskom@lysator.liu.se. # -# $Id: prot-a-parse-arg-c.awk,v 0.21 1999/04/03 22:24:17 ceder Exp $ +# $Id: prot-a-parse-arg-c.awk,v 0.22 1999/05/12 13:25:21 byers Exp $ BEGIN { printf("/* Don't edit this file - it is generated automatically"); printf(" from\n prot-a-parse-arg-c.awk and fncdef.txt */\n\n"); @@ -149,6 +149,8 @@ $1 != "#" && $1 != "" { else if ( $i == "num_list" ) printf("\tprot_a_parse_num_list(client, &client->num_list, %s);\n", $(++i)); + else if ( $i == "pers_flags" ) + printf("\tprot_a_parse_pers_flags(client, &client->pers_flags);\n"); else printf("#error in prot-a-parse-arg-c.awk: not ready yet.\n"); diff --git a/src/server/prot-a-parse.c b/src/server/prot-a-parse.c index 6316a5632bdfd0eac82aa2d835b9f6f9b77a4886..0e8b3e265530a8ba87b821c2bac3491ec8fa4bb6 100644 --- a/src/server/prot-a-parse.c +++ b/src/server/prot-a-parse.c @@ -1,5 +1,5 @@ /* - * $Id: prot-a-parse.c,v 0.36 1999/04/28 22:12:08 ceder Exp $ + * $Id: prot-a-parse.c,v 0.37 1999/05/12 13:25:22 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -34,7 +34,7 @@ #endif static const char * -rcsid = "$Id: prot-a-parse.c,v 0.36 1999/04/28 22:12:08 ceder Exp $"; +rcsid = "$Id: prot-a-parse.c,v 0.37 1999/05/12 13:25:22 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -65,6 +65,7 @@ USE(rcsid); #include "log.h" #include "minmax.h" #include "param.h" +#include "kom-memory.h" BUGDECL; @@ -133,12 +134,12 @@ prot_a_parse_num_list(Connection *client, /* This could just as well have been an assertion. */ if ((res->length != 0 || res->data != NULL) && err_cnt++ < 20) { - log("WNG: prot_a_parse_num_list(): len = %lu data = %lu\n", + kom_log("WNG: prot_a_parse_num_list(): len = %lu data = %lu\n", (unsigned long)res->length, (unsigned long)res->data); res->length = 0; res->data = NULL; if (err_cnt == 20) - log("The above warning is now turned off."); + kom_log("The above warning is now turned off."); } res->length = prot_a_parse_long(client); @@ -212,6 +213,33 @@ prot_a_parse_priv_bits(Connection *client, res->flg16 = token.string[ 15 ] != '0'; } +void +prot_a_parse_pers_flags(Connection *client, + Personal_flags *res) +{ + String token; + String_size len; + + token = prot_a_get_token(client); + len = s_strlen(token); + if (len <= 0) + longjmp(parse_env, ISC_PROTOCOL_ERR); + + init_personal_flags(res); + switch (len = s_strlen(token)) + { + default: + case 8: res->flg8 = token.string[ 7 ] != '0'; + case 7: res->flg7 = token.string[ 6 ] != '0'; + case 6: res->flg6 = token.string[ 5 ] != '0'; + case 5: res->flg5 = token.string[ 4 ] != '0'; + case 4: res->flg4 = token.string[ 3 ] != '0'; + case 3: res->flg3 = token.string[ 2 ] != '0'; + case 2: res->flg2 = token.string[ 1 ] != '0'; + case 1: res->unread_is_secret = token.string[ 0 ] != '0'; + } +} + void prot_a_parse_membership_type(Connection *client, Membership_type *res) @@ -285,13 +313,13 @@ prot_a_parse_string(Connection *client, case 0: if ( (result->len != 0 || result->string != NULL) && err_cnt++ < 20 ) { - log ("%s == %lu, result->string == %lu. %s\n", + kom_log ("%s == %lu, result->string == %lu. %s\n", "prot_a_parse_string(): result->len", (unsigned long)result->len, (unsigned long)result->string, "This memory will not be free()'d."); *result = EMPTY_STRING; if ( err_cnt == 20 ) - log("Won't log the above warning no more."); + kom_log("Won't log the above warning no more."); } /* Get number and discard trailing 'H' */ @@ -406,6 +434,7 @@ prot_a_parse_aux_item(Connection *client, switch ( client->struct_parse_pos ) { case 0: + init_aux_item(result); result->tag = prot_a_parse_long(client); client->struct_parse_pos = 1; case 1: @@ -428,13 +457,34 @@ prot_a_parse_aux_item_list(Connection *client, Aux_item_list *result, unsigned long maxlen) { + static unsigned long err_cnt = 0; int i; + long len; switch (client->array_parse_pos) { case 0: - result->length = prot_a_parse_long(client); + if ((result->length != 0 || result->items != NULL) && err_cnt++ < 20) + { + kom_log("WNG: prot_a_parse_aux_item_list(): len = %lu data = %lu\n", + (unsigned long)result->length, (unsigned long)result->items); + result->length = 0; + result->items = NULL; + if (err_cnt == 20) + kom_log("The above warning is now turned off."); + } + + len = prot_a_parse_long(client); + if (len < 0) + { + isc_puts("%%Insane array size.\n", client->isc_session); + isc_flush(client->isc_session); + longjmp(parse_env, ISC_LOGOUT); + } + result->length = len; client->array_parse_pos = 1; + /* Fall through */ + case 1: if ( parse_nonwhite_char(client) != '{' ) longjmp(parse_env, ISC_PROTOCOL_ERR); diff --git a/src/server/prot-a-parse.h b/src/server/prot-a-parse.h index 773f4b2fbdc839a7d63bd369db32a074c9110921..a32e3cc07e8f71e7a587ade73525a496af274ce3 100644 --- a/src/server/prot-a-parse.h +++ b/src/server/prot-a-parse.h @@ -1,5 +1,5 @@ /* - * $Id: prot-a-parse.h,v 0.15 1998/06/14 14:51:09 byers Exp $ + * $Id: prot-a-parse.h,v 0.16 1999/05/12 13:25:23 byers Exp $ * Copyright (C) 1991, 1992, 1994, 1995, 1996 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: prot-a-parse.h,v 0.15 1998/06/14 14:51:09 byers Exp $ + * $Id: prot-a-parse.h,v 0.16 1999/05/12 13:25:23 byers Exp $ * */ extern long @@ -38,6 +38,10 @@ extern void prot_a_parse_priv_bits(Connection *client, Priv_bits *result); +extern void +prot_a_parse_pers_flags(Connection *client, + Personal_flags *res); + extern void prot_a_parse_membership_type(Connection *client, Membership_type *res); diff --git a/src/server/ram-output.c b/src/server/ram-output.c index 79bbcc5008ffc10dacc4a722c17686777889bebc..023250cdfcd6ec2c5cc2a2d85819adbbfadae8f3 100644 --- a/src/server/ram-output.c +++ b/src/server/ram-output.c @@ -1,5 +1,5 @@ /* - * $Id: ram-output.c,v 0.29 1999/04/05 16:19:26 ceder Exp $ + * $Id: ram-output.c,v 0.30 1999/05/12 13:25:24 byers Exp $ * Copyright (C) 1991, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -39,7 +39,7 @@ #endif static const char * -rcsid = "$Id: ram-output.c,v 0.29 1999/04/05 16:19:26 ceder Exp $"; +rcsid = "$Id: ram-output.c,v 0.30 1999/05/12 13:25:24 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -171,6 +171,7 @@ foutput_person_2(FILE *fp, foutput_priv_bits (fp, person->privileges); foutput_personal_flags (fp, person->flags); + putc(' ', fp); l2g_write (fp, &person->created_texts); foutput_mark_list (fp, person->marks); foutput_membership_list (fp, person->conferences); @@ -217,6 +218,7 @@ foutput_conference_2(FILE *fp, { foutput_string(fp, conf_c->name); foutput_member_list(fp, conf_c->members); + putc(' ', fp); l2g_write(fp, &conf_c->texts); foutput_conf_type(fp, conf_c->type); @@ -394,6 +396,24 @@ foutput_aux_flags(FILE *fp, putc(f.reserved5 + '0', fp); } +static void +foutput_aux_item_link(FILE *fp, + Aux_item_link *link) +{ + foutput_ulong((unsigned long) link->target_type, fp); + foutput_ulong((unsigned long) link->target_item, fp); + switch (link->target_type) + { + case CONF_OBJECT_TYPE: + foutput_ulong((unsigned long) link->target_object.conf, fp); + break; + case TEXT_OBJECT_TYPE: + foutput_ulong((unsigned long) link->target_object.text, fp); + break; + default: + } +} + static void foutput_aux_item(FILE *fp, Aux_item *a_item) @@ -405,6 +425,7 @@ foutput_aux_item(FILE *fp, foutput_aux_flags(fp, a_item->flags); foutput_ulong((unsigned long) a_item->inherit_limit, fp); foutput_string(fp, a_item->data); + foutput_aux_item_link(fp, &a_item->linked_item); } static void @@ -451,8 +472,8 @@ foutput_membership_0(FILE *fp, if ( mship->read_texts == NULL && mship->no_of_read != 0 ) { - log("%s(): no_of_read forced to 0 in a membership in %lu.\n", - "foutput_membership", (unsigned long)mship->conf_no); + kom_log("%s(): no_of_read forced to 0 in a membership in %lu.\n", + "foutput_membership", (unsigned long)mship->conf_no); mship->no_of_read = 0; } @@ -484,8 +505,8 @@ foutput_membership_2(FILE *fp, if ( mship->read_texts == NULL && mship->no_of_read != 0 ) { - log("%s(): no_of_read forced to 0 in a membership in %lu.\n", - "foutput_membership", (unsigned long)mship->conf_no); + kom_log("%s(): no_of_read forced to 0 in a membership in %lu.\n", + "foutput_membership", (unsigned long)mship->conf_no); mship->no_of_read = 0; } diff --git a/src/server/ram-parse.c b/src/server/ram-parse.c index 023f3abbbaa46ff59d5bac2cef999de4f7dc8b68..40b5926034a39de2162c3f1e0bba6481861c7f98 100644 --- a/src/server/ram-parse.c +++ b/src/server/ram-parse.c @@ -1,5 +1,5 @@ /* - * $Id: ram-parse.c,v 0.32 1999/03/31 08:04:19 ceder Exp $ + * $Id: ram-parse.c,v 0.33 1999/05/12 13:25:25 byers Exp $ * Copyright (C) 1991, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -35,7 +35,7 @@ #endif static const char * -rcsid = "$Id: ram-parse.c,v 0.32 1999/03/31 08:04:19 ceder Exp $"; +rcsid = "$Id: ram-parse.c,v 0.33 1999/05/12 13:25:25 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -118,7 +118,7 @@ fparse_long(FILE *fp) if ( foo == 0 ) { - log("fparse_long() failed at pos %lu.\n", (unsigned long)ftell(fp)); + kom_log("fparse_long() failed at pos %lu.\n", (unsigned long)ftell(fp)); ++fparse_long_errors; } @@ -163,7 +163,7 @@ fparse_info(FILE *fp, Info *info) { if ( fparse_long_errors != 0 ) { - log("fparse_info(): fparse_long_errors == %d on entry. Reset.\n", + kom_log("fparse_info(): fparse_long_errors == %d on entry. Reset.\n", fparse_long_errors); fparse_long_errors = 0; } @@ -192,14 +192,14 @@ fparse_conference_2(FILE *fp, { if ( fparse_long_errors != 0 ) { - log("fparse_conference(): fparse_long_errors == %d on entry. Reset.\n", + kom_log("fparse_conference(): fparse_long_errors == %d on entry. Reset.\n", fparse_long_errors); fparse_long_errors = 0; } if ( fparse_string(fp, &result->name) != OK ) { - log("fparse_conference(): Can't parse name.\n"); + kom_log("fparse_conference(): Can't parse name.\n"); return FAILURE; } @@ -207,7 +207,7 @@ fparse_conference_2(FILE *fp, || l2g_read(fp, &result->texts) != OK || fparse_conf_type(fp, &result->type) != OK ) { - log("fparse_conference: file is corrupt.\n"); + kom_log("fparse_conference: file is corrupt.\n"); return FAILURE; } @@ -223,7 +223,7 @@ fparse_conference_2(FILE *fp, if ( fparse_long_errors != 0 ) { - log("fparse_conference(): %d %s before 'nice'. Reset.\n", + kom_log("fparse_conference(): %d %s before 'nice'. Reset.\n", fparse_long_errors, "fparse_long_errors"); fparse_long_errors = 0; return FAILURE; @@ -234,7 +234,7 @@ fparse_conference_2(FILE *fp, #ifdef DISKERR if ( fparse_long_errors != 0 ) { - log("fparse_conference(): Error parsing 'nice' at pos %d. " + kom_log("fparse_conference(): Error parsing 'nice' at pos %d. " "nice set to 77 and error ignored.\n", ftell(fp)); fparse_long_errors = 0; result->nice = 77; @@ -250,12 +250,12 @@ fparse_conference_2(FILE *fp, if ( name == NULL ) { - log("fparse_conference(): nice in (null) was %d, set to %d.\n", + kom_log("fparse_conference(): nice in (null) was %d, set to %d.\n", result->nice, new_nice); } else { - log("fparse_conference(): nice in %s was %d, set to %d.\n", + kom_log("fparse_conference(): nice in %s was %d, set to %d.\n", name, result->nice, new_nice); string_free(name); } @@ -281,14 +281,14 @@ fparse_conference_0(FILE *fp, { if ( fparse_long_errors != 0 ) { - log("fparse_conference(): fparse_long_errors == %d on entry. Reset.\n", + kom_log("fparse_conference(): fparse_long_errors == %d on entry. Reset.\n", fparse_long_errors); fparse_long_errors = 0; } if ( fparse_string(fp, &result->name) != OK ) { - log("fparse_conference(): Can't parse name.\n"); + kom_log("fparse_conference(): Can't parse name.\n"); return FAILURE; } @@ -296,7 +296,7 @@ fparse_conference_0(FILE *fp, || fparse_text_list(fp, &result->texts) != OK || fparse_conf_type(fp, &result->type) != OK ) { - log("fparse_conference: file is corrupt.\n"); + kom_log("fparse_conference: file is corrupt.\n"); return FAILURE; } @@ -312,7 +312,7 @@ fparse_conference_0(FILE *fp, if ( fparse_long_errors != 0 ) { - log("fparse_conference(): %d %s before 'nice'. Reset.\n", + kom_log("fparse_conference(): %d %s before 'nice'. Reset.\n", fparse_long_errors, "fparse_long_errors"); fparse_long_errors = 0; return FAILURE; @@ -323,7 +323,7 @@ fparse_conference_0(FILE *fp, #ifdef DISKERR if ( fparse_long_errors != 0 ) { - log("fparse_conference(): Error parsing 'nice' at pos %d. " + kom_log("fparse_conference(): Error parsing 'nice' at pos %d. " "nice set to 77 and error ignored.\n", ftell(fp)); fparse_long_errors = 0; result->nice = 77; @@ -339,12 +339,12 @@ fparse_conference_0(FILE *fp, if ( name == NULL ) { - log("fparse_conference(): nice in (null) was %d, set to %d.\n", + kom_log("fparse_conference(): nice in (null) was %d, set to %d.\n", result->nice, new_nice); } else { - log("fparse_conference(): nice in %s was %d, set to %d.\n", + kom_log("fparse_conference(): nice in %s was %d, set to %d.\n", name, result->nice, new_nice); string_free(name); } @@ -390,14 +390,14 @@ fparse_person_0(FILE *fp, if ( fparse_long_errors != 0 ) { - log("fparse_person(): fparse_long_errors == %d on entry. Reset.\n", + kom_log("fparse_person(): fparse_long_errors == %d on entry. Reset.\n", fparse_long_errors); fparse_long_errors = 0; } if ( fparse_string(fp, &pwd) != OK ) { - log("fparse_person(): Failed to parse password.\n"); + kom_log("fparse_person(): Failed to parse password.\n"); return FAILURE; } @@ -411,7 +411,7 @@ fparse_person_0(FILE *fp, || fparse_mark_list(fp, &person->marks) != OK || fparse_membership_list(fp, &person->conferences) != OK ) { - log("fparse_person(): parse error.\n"); + kom_log("fparse_person(): parse error.\n"); return FAILURE; } @@ -428,7 +428,7 @@ fparse_person_0(FILE *fp, if ( fparse_long_errors != 0 ) { - log("fparse_person(): %d %s before 'created_confs'. Reset.\n", + kom_log("fparse_person(): %d %s before 'created_confs'. Reset.\n", fparse_long_errors, "fparse_long_errors"); fparse_long_errors = 0; return FAILURE; @@ -439,7 +439,7 @@ fparse_person_0(FILE *fp, #ifdef DISKERR if ( fparse_long_errors != 0 ) { - log("fparse_person(): Error parsing 'created_confs' at pos %d. " + kom_log("fparse_person(): Error parsing 'created_confs' at pos %d. " "created_confs set to 0 and error ignored.\n", ftell(fp)); fparse_long_errors = 0; person->created_confs = 0; @@ -458,14 +458,14 @@ fparse_person_2(FILE *fp, if ( fparse_long_errors != 0 ) { - log("fparse_person(): fparse_long_errors == %d on entry. Reset.\n", + kom_log("fparse_person(): fparse_long_errors == %d on entry. Reset.\n", fparse_long_errors); fparse_long_errors = 0; } if ( fparse_string(fp, &pwd) != OK ) { - log("fparse_person(): Failed to parse password.\n"); + kom_log("fparse_person(): Failed to parse password.\n"); return FAILURE; } @@ -479,7 +479,7 @@ fparse_person_2(FILE *fp, || fparse_mark_list(fp, &person->marks) != OK || fparse_membership_list(fp, &person->conferences) != OK ) { - log("fparse_person(): parse error.\n"); + kom_log("fparse_person(): parse error.\n"); return FAILURE; } @@ -496,7 +496,7 @@ fparse_person_2(FILE *fp, if ( fparse_long_errors != 0 ) { - log("fparse_person(): %d %s before 'created_confs'. Reset.\n", + kom_log("fparse_person(): %d %s before 'created_confs'. Reset.\n", fparse_long_errors, "fparse_long_errors"); fparse_long_errors = 0; return FAILURE; @@ -507,7 +507,7 @@ fparse_person_2(FILE *fp, #ifdef DISKERR if ( fparse_long_errors != 0 ) { - log("fparse_person(): Error parsing 'created_confs' at pos %d. " + kom_log("fparse_person(): Error parsing 'created_confs' at pos %d. " "created_confs set to 0 and error ignored.\n", ftell(fp)); fparse_long_errors = 0; person->created_confs = 0; @@ -594,7 +594,7 @@ fparse_membership_2(FILE *fp, { err_stat = 1; kom_errno = KOM_LDB_ERR; - log("fparse_membership(): expected '}' at pos %lu.\n", + kom_log("fparse_membership(): expected '}' at pos %lu.\n", (unsigned long)ftell(fp)); return FAILURE; } @@ -606,12 +606,12 @@ fparse_membership_2(FILE *fp, sfree(mship->read_texts); mship->read_texts = NULL; } - log("fparse_membership(): %s with %lu elements (corrected)\n", + kom_log("fparse_membership(): %s with %lu elements (corrected)\n", "empty read_texts", (unsigned long)mship->no_of_read); mship->no_of_read = 0; break; default: - log("fparse_membership(): expected '*' or '{' at pos %lu.\n", + kom_log("fparse_membership(): expected '*' or '{' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 2; kom_errno = KOM_LDB_ERR; @@ -623,7 +623,7 @@ fparse_membership_2(FILE *fp, fskipwhite(fp); if ( getc(fp) != '*' ) { - log("fparse_membership(): expected '*' at pos %lu.\n", + kom_log("fparse_membership(): expected '*' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 3; kom_errno = KOM_LDB_ERR; @@ -682,7 +682,7 @@ fparse_membership_0(FILE *fp, { err_stat = 1; kom_errno = KOM_LDB_ERR; - log("fparse_membership(): expected '}' at pos %lu.\n", + kom_log("fparse_membership(): expected '}' at pos %lu.\n", (unsigned long)ftell(fp)); return FAILURE; } @@ -694,12 +694,12 @@ fparse_membership_0(FILE *fp, sfree(mship->read_texts); mship->read_texts = NULL; } - log("fparse_membership(): %s with %lu elements (corrected)\n", + kom_log("fparse_membership(): %s with %lu elements (corrected)\n", "empty read_texts", (unsigned long)mship->no_of_read); mship->no_of_read = 0; break; default: - log("fparse_membership(): expected '*' or '{' at pos %lu.\n", + kom_log("fparse_membership(): expected '*' or '{' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 2; kom_errno = KOM_LDB_ERR; @@ -711,7 +711,7 @@ fparse_membership_0(FILE *fp, fskipwhite(fp); if ( getc(fp) != '*' ) { - log("fparse_membership(): expected '*' at pos %lu.\n", + kom_log("fparse_membership(): expected '*' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 3; kom_errno = KOM_LDB_ERR; @@ -792,7 +792,7 @@ fparse_membership_list_0(FILE *fp, fskipwhite(fp); if ( getc(fp) != '}' ) { - log("fparse_membership_list(): expected '}' at pos %lu.\n", + kom_log("fparse_membership_list(): expected '}' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 4; kom_errno = KOM_LDB_ERR; @@ -806,14 +806,14 @@ fparse_membership_list_0(FILE *fp, sfree(result->confs); result->confs = NULL; } - log("%s empty list with %lu elements (corrected).\n", + kom_log("%s empty list with %lu elements (corrected).\n", "fparse_membership_list():", (unsigned long)result->no_of_confs); result->no_of_confs = 0; break; default: - log("fparse_membership_list(): expected '*' or '{' at pos %lu.\n", + kom_log("fparse_membership_list(): expected '*' or '{' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 5; kom_errno = KOM_LDB_ERR; @@ -825,7 +825,7 @@ fparse_membership_list_0(FILE *fp, fskipwhite(fp); if ( getc(fp) != '*' ) { - log("fparse_membership_list(): expected '*' at pos %lu.\n", + kom_log("fparse_membership_list(): expected '*' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 6; kom_errno = KOM_LDB_ERR; @@ -882,7 +882,7 @@ fparse_membership_list_2(FILE *fp, fskipwhite(fp); if ( getc(fp) != '}' ) { - log("fparse_membership_list(): expected '}' at pos %lu.\n", + kom_log("fparse_membership_list(): expected '}' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 4; kom_errno = KOM_LDB_ERR; @@ -896,14 +896,14 @@ fparse_membership_list_2(FILE *fp, sfree(result->confs); result->confs = NULL; } - log("%s empty list with %lu elements (corrected).\n", + kom_log("%s empty list with %lu elements (corrected).\n", "fparse_membership_list():", (unsigned long)result->no_of_confs); result->no_of_confs = 0; break; default: - log("fparse_membership_list(): expected '*' or '{' at pos %lu.\n", + kom_log("fparse_membership_list(): expected '*' or '{' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 5; kom_errno = KOM_LDB_ERR; @@ -915,7 +915,7 @@ fparse_membership_list_2(FILE *fp, fskipwhite(fp); if ( getc(fp) != '*' ) { - log("fparse_membership_list(): expected '*' at pos %lu.\n", + kom_log("fparse_membership_list(): expected '*' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 6; kom_errno = KOM_LDB_ERR; @@ -982,7 +982,7 @@ fparse_conf_list(FILE *fp, fskipwhite(fp); if ( getc(fp) != '}' ) { - log("fparse_conf_list(): expected '}' at pos %lu.\n", + kom_log("fparse_conf_list(): expected '}' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 7; kom_errno = KOM_LDB_ERR; @@ -998,7 +998,7 @@ fparse_conf_list(FILE *fp, } break; default: - log("fparse_conf_list(): expected '*' or '{' at pos %lu.\n", + kom_log("fparse_conf_list(): expected '*' or '{' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 8; kom_errno = KOM_LDB_ERR; @@ -1010,7 +1010,7 @@ fparse_conf_list(FILE *fp, fskipwhite(fp); if ( getc(fp) != '*' ) { - log("fparse_conf_list(): expected '*' at pos %lu.\n", + kom_log("fparse_conf_list(): expected '*' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 9; kom_errno = KOM_LDB_ERR; @@ -1049,7 +1049,7 @@ fparse_conf_list(FILE *fp, fskipwhite(fp); if ( getc(fp) != '}' ) { - log("fparse_conf_list(): expected '}' at pos %lu.\n", + kom_log("fparse_conf_list(): expected '}' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 10; kom_errno = KOM_LDB_ERR; @@ -1065,7 +1065,7 @@ fparse_conf_list(FILE *fp, } break; default: - log("fparse_conf_list(): expected '*' or '+' at pos %lu.\n", + kom_log("fparse_conf_list(): expected '*' or '+' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 11; kom_errno = KOM_LDB_ERR; @@ -1077,7 +1077,7 @@ fparse_conf_list(FILE *fp, fskipwhite(fp); if ( getc(fp) != '*' ) { - log("fparse_conf_list(): expected '*' at pos %lu.\n", + kom_log("fparse_conf_list(): expected '*' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 12; kom_errno = KOM_LDB_ERR; @@ -1128,7 +1128,7 @@ fparse_mark_list(FILE *fp, fskipwhite(fp); if ( getc(fp) != '}' ) { - log("fparse_mark_list(): expected '}' at pos %lu.\n", + kom_log("fparse_mark_list(): expected '}' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 13; kom_errno = KOM_LDB_ERR; @@ -1146,7 +1146,7 @@ fparse_mark_list(FILE *fp, break; default: - log("fparse_mark_list(): expected '*' or '{' at pos %lu.\n", + kom_log("fparse_mark_list(): expected '*' or '{' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 14; kom_errno = KOM_LDB_ERR; @@ -1158,7 +1158,7 @@ fparse_mark_list(FILE *fp, fskipwhite(fp); if ( getc(fp) != '*' ) { - log("fparse_mark_list(): expected '*' at pos %lu.\n", + kom_log("fparse_mark_list(): expected '*' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 15; kom_errno = KOM_LDB_ERR; @@ -1182,7 +1182,7 @@ fparse_text_stat_2(FILE *fp, if ( fparse_long_errors != 0 ) { - log("fparse_text_stat(): fparse_long_errors == %d on entry. Reset.\n", + kom_log("fparse_text_stat(): fparse_long_errors == %d on entry. Reset.\n", fparse_long_errors); fparse_long_errors = 0; } @@ -1198,7 +1198,7 @@ fparse_text_stat_2(FILE *fp, if ( fparse_long_errors != 0 ) { - log("%s(): %d fparse_long_errors before 'misc_items'. Reset.\n", + kom_log("%s(): %d fparse_long_errors before 'misc_items'. Reset.\n", "fparse_text_stat", fparse_long_errors); fparse_long_errors = 0; @@ -1233,14 +1233,14 @@ fparse_text_stat_2(FILE *fp, if ( c == '@' || c == '+' ) { ungetc(c, fp); - log("fparse_text_stat(): got '%c' when expecting '}'.\n." + kom_log("fparse_text_stat(): got '%c' when expecting '}'.\n." "Character ungetc'd and interpreted as a '}'." " (pos %d).\n", c, ftell(fp)); } else #endif { - log("fparse_text_stat(): expected '}' at pos %lu.\n", + kom_log("fparse_text_stat(): expected '}' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 16; kom_errno = KOM_LDB_ERR; @@ -1253,8 +1253,8 @@ fparse_text_stat_2(FILE *fp, case '@': case '+': ungetc(c, fp); - log("fparse_text_stat(): got '%c'; expected '{' or '*'\n.", c); - log("Character ungetc'd and interpreted as a '*'. (pos %lu).\n", + kom_log("fparse_text_stat(): got '%c'; expected '{' or '*'\n.", c); + kom_log("Character ungetc'd and interpreted as a '*'. (pos %lu).\n", (unsigned long)ftell(fp)); /* Fall through */ case '*': @@ -1266,7 +1266,7 @@ fparse_text_stat_2(FILE *fp, break; default: - log("fparse_text_stat(): expected '*' or '}' at pos %lu.\n", + kom_log("fparse_text_stat(): expected '*' or '}' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 17; kom_errno = KOM_LDB_ERR; @@ -1282,14 +1282,14 @@ fparse_text_stat_2(FILE *fp, if ( c == '@' || c == '+' ) { ungetc(c, fp); - log("fparse_text_stat(): got '%c' when expecting '*'.\n." + kom_log("fparse_text_stat(): got '%c' when expecting '*'.\n." "Character ungetc'd and interpreted as a '*'." " (pos %d).\n", c, ftell(fp)); } else #endif { - log("fparse_text_stat(): expected '*' at pos %lu.\n", + kom_log("fparse_text_stat(): expected '*' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 18; kom_errno = KOM_LDB_ERR; @@ -1322,7 +1322,7 @@ fparse_text_stat_0(FILE *fp, if ( fparse_long_errors != 0 ) { - log("fparse_text_stat(): fparse_long_errors == %d on entry. Reset.\n", + kom_log("fparse_text_stat(): fparse_long_errors == %d on entry. Reset.\n", fparse_long_errors); fparse_long_errors = 0; } @@ -1338,7 +1338,7 @@ fparse_text_stat_0(FILE *fp, if ( fparse_long_errors != 0 ) { - log("%s(): %d fparse_long_errors before 'misc_items'. Reset.\n", + kom_log("%s(): %d fparse_long_errors before 'misc_items'. Reset.\n", "fparse_text_stat", fparse_long_errors); fparse_long_errors = 0; @@ -1373,14 +1373,14 @@ fparse_text_stat_0(FILE *fp, if ( c == '@' || c == '+' ) { ungetc(c, fp); - log("fparse_text_stat(): got '%c' when expecting '}'.\n." + kom_log("fparse_text_stat(): got '%c' when expecting '}'.\n." "Character ungetc'd and interpreted as a '}'." " (pos %d).\n", c, ftell(fp)); } else #endif { - log("fparse_text_stat(): expected '}' at pos %lu.\n", + kom_log("fparse_text_stat(): expected '}' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 19; kom_errno = KOM_LDB_ERR; @@ -1393,8 +1393,8 @@ fparse_text_stat_0(FILE *fp, case '@': case '+': ungetc(c, fp); - log("fparse_text_stat(): got '%c'; expected '{' or '*'\n.", c); - log("Character ungetc'd and interpreted as a '*'. (pos %lu).\n", + kom_log("fparse_text_stat(): got '%c'; expected '{' or '*'\n.", c); + kom_log("Character ungetc'd and interpreted as a '*'. (pos %lu).\n", (unsigned long)ftell(fp)); /* Fall through */ case '*': @@ -1406,7 +1406,7 @@ fparse_text_stat_0(FILE *fp, break; default: - log("fparse_text_stat(): expected '*' or '}' at pos %lu.\n", + kom_log("fparse_text_stat(): expected '*' or '}' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 20; kom_errno = KOM_LDB_ERR; @@ -1422,14 +1422,14 @@ fparse_text_stat_0(FILE *fp, if ( c == '@' || c == '+' ) { ungetc(c, fp); - log("fparse_text_stat(): got '%c' when expecting '*'.\n." + kom_log("fparse_text_stat(): got '%c' when expecting '*'.\n." "Character ungetc'd and interpreted as a '*'." " (pos %d).\n", c, ftell(fp)); } else #endif { - log("fparse_text_stat(): expected '*' at pos %lu.\n", + kom_log("fparse_text_stat(): expected '*' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 21; kom_errno = KOM_LDB_ERR; @@ -1497,7 +1497,7 @@ fparse_text_list(FILE *fp, fskipwhite(fp); if ( getc(fp) != '}' ) { - log("fparse_text_list(): expected '}' at pos %lu.\n", + kom_log("fparse_text_list(): expected '}' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 22; kom_errno = KOM_LDB_ERR; @@ -1507,7 +1507,7 @@ fparse_text_list(FILE *fp, break; default: - log("fparse_text_list(): expected '{' at pos %lu.\n", + kom_log("fparse_text_list(): expected '{' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 23; kom_errno = KOM_LDB_ERR; @@ -1519,7 +1519,7 @@ fparse_text_list(FILE *fp, fskipwhite(fp); if ( getc(fp) != '*' ) { - log("fparse_text_list(): expected '*' at pos %lu.\n", + kom_log("fparse_text_list(): expected '*' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 24; kom_errno = KOM_LDB_ERR; @@ -1540,7 +1540,7 @@ fparse_string(FILE *fp, if ( getc(fp) != 'H' ) { - log("fparse_string(): expected 'H' at pos %lu.\n", + kom_log("fparse_string(): expected 'H' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 25; kom_errno = KOM_LDB_ERR; @@ -1559,7 +1559,7 @@ fparse_string(FILE *fp, if ( fread(result->string, sizeof(char), result->len, fp) != (size_t)result->len ) { - log("fparse_string(): unexpected eof at pos %lu.\n", + kom_log("fparse_string(): unexpected eof at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 26; kom_errno = KOM_LDB_ERR; @@ -1603,7 +1603,7 @@ fparse_member_list(FILE *fp, fskipwhite(fp); if ( getc(fp) != '}' ) { - log("fparse_member_list(): expected '}' at pos %lu.\n", + kom_log("fparse_member_list(): expected '}' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 27; kom_errno = KOM_LDB_ERR; @@ -1621,7 +1621,7 @@ fparse_member_list(FILE *fp, break; default: - log("fparse_member_list(): expected '*' or '{' at pos %lu.\n", + kom_log("fparse_member_list(): expected '*' or '{' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 28; kom_errno = KOM_LDB_ERR; @@ -1633,7 +1633,7 @@ fparse_member_list(FILE *fp, fskipwhite(fp); if ( getc(fp) != '*' ) { - log("fparse_member_list(): expected '*' at pos %lu.\n", + kom_log("fparse_member_list(): expected '*' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 29; kom_errno = KOM_LDB_ERR; @@ -1781,7 +1781,7 @@ fparse_who_info(FILE *fp, result->working_conference = fparse_long(fp); if ( fparse_string(fp, &result->what_am_i_doing) != OK ) { - log("fparse_who_info(): parse error.\n"); + kom_log("fparse_who_info(): parse error.\n"); err_stat = 30; kom_errno = KOM_LDB_ERR; return FAILURE; @@ -1829,7 +1829,7 @@ fparse_who_info_list(FILE *fp, fskipwhite(fp); if ( getc(fp) != '}' ) { - log("fparse_who_info_list(): expected '}' at pos %lu.\n", + kom_log("fparse_who_info_list(): expected '}' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 31; kom_errno = KOM_LDB_ERR; @@ -1847,7 +1847,7 @@ fparse_who_info_list(FILE *fp, break; default: - log("fparse_who_info_list(): expected '*' or '{' at pos %lu.\n", + kom_log("fparse_who_info_list(): expected '*' or '{' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 32; kom_errno = KOM_LDB_ERR; @@ -1859,7 +1859,7 @@ fparse_who_info_list(FILE *fp, fskipwhite(fp); if ( getc(fp) != '*' ) { - log("fparse_who_info_list(): expected '*' at pos %lu.\n", + kom_log("fparse_who_info_list(): expected '*' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 33; kom_errno = KOM_LDB_ERR; @@ -1893,6 +1893,25 @@ fparse_aux_item_flags(FILE *fp, return OK; } +extern Success +fparse_aux_item_link(FILE *fp, + Aux_item_link *link) +{ + link->target_type = (Object_type)fparse_long(fp); + link->target_item = fparse_long(fp); + switch (link->target_type) + { + case CONF_OBJECT_TYPE: + link->target_object.conf = (Conf_no)fparse_long(fp); + break; + case TEXT_OBJECT_TYPE: + link->target_object.text = (Text_no)fparse_long(fp); + break; + default: + } + + return OK; +} extern Success fparse_aux_item(FILE *fp, @@ -1907,7 +1926,13 @@ fparse_aux_item(FILE *fp, item->data = EMPTY_STRING; if (fparse_string(fp, &item->data) != OK) { - log("fparse_aux_item(): Can't parse name.\n"); + kom_log("fparse_aux_item(): Can't parse name.\n"); + return FAILURE; + } + + if (fparse_aux_item_link(fp, &(item->linked_item)) != OK) + { + kom_log("fparse_aux_item(): Can't parse link.\n"); return FAILURE; } @@ -1925,7 +1950,7 @@ fparse_aux_item_list(FILE *fp, if ( fparse_long_errors != 0 ) { - log("%s(): %d fparse_long_errors before 'aux_items'. Reset.\n", + kom_log("%s(): %d fparse_long_errors before 'aux_items'. Reset.\n", "fparse_text_stat", fparse_long_errors); fparse_long_errors = 0; @@ -1956,7 +1981,7 @@ fparse_aux_item_list(FILE *fp, fskipwhite(fp); if ( (c = getc(fp)) != '}' ) { - log("fparse_aux_item_list(): expected '}' at pos %lu.\n", + kom_log("fparse_aux_item_list(): expected '}' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 34; kom_errno = KOM_LDB_ERR; @@ -1975,7 +2000,7 @@ fparse_aux_item_list(FILE *fp, break; default: - log("fparse_aux_item_list(): expected '*' or '}' at pos %lu.\n", + kom_log("fparse_aux_item_list(): expected '*' or '}' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 35; kom_errno = KOM_LDB_ERR; @@ -1987,7 +2012,7 @@ fparse_aux_item_list(FILE *fp, fskipwhite(fp); if ( (c = getc(fp)) != '*' ) { - log("fparse_aux_item_list(): expected '*' at pos %lu.\n", + kom_log("fparse_aux_item_list(): expected '*' at pos %lu.\n", (unsigned long)ftell(fp)); err_stat = 36; kom_errno = KOM_LDB_ERR; @@ -2056,7 +2081,7 @@ fparse_misc_info(FILE *fp, break; default: - log("fparse_misc_info(): illegal info_type %d at pos %lu.\n", + kom_log("fparse_misc_info(): illegal info_type %d at pos %lu.\n", result->type, (unsigned long)ftell(fp)); err_stat = 37; kom_errno = KOM_LDB_ERR; diff --git a/src/server/ram-parse.h b/src/server/ram-parse.h index 6bd72b654f82a898bdff7c266fde407502d65c22..7f614b75cfd06f690b75ff4363a057cba1e0ec05 100644 --- a/src/server/ram-parse.h +++ b/src/server/ram-parse.h @@ -1,5 +1,5 @@ /* - * $Id: ram-parse.h,v 0.10 1998/07/26 16:41:35 ceder Exp $ + * $Id: ram-parse.h,v 0.11 1999/05/12 13:25:26 byers Exp $ * Copyright (C) 1991, 1993, 1994, 1995 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: ram-parse.h,v 0.10 1998/07/26 16:41:35 ceder Exp $ + * $Id: ram-parse.h,v 0.11 1999/05/12 13:25:26 byers Exp $ * * ram-parse.h -- parse objects from disk file. */ @@ -122,6 +122,9 @@ fparse_aux_item_flags(FILE *fp, Aux_item_flags *f); extern Success +fparse_aux_item_link(FILE *fp, + Aux_item_link *link); +extern Success fparse_aux_item(FILE *fp, Aux_item *result); diff --git a/src/server/ramkomd.c b/src/server/ramkomd.c index 6294666d04d078910f91832ff1d95892f4d7c492..16ace45518d63689b15c9f72bec0094c0701ac4f 100644 --- a/src/server/ramkomd.c +++ b/src/server/ramkomd.c @@ -1,5 +1,5 @@ /* - * $Id: ramkomd.c,v 0.81 1999/04/28 22:13:29 ceder Exp $ + * $Id: ramkomd.c,v 0.82 1999/05/12 13:25:27 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -44,7 +44,7 @@ #endif static const char * -rcsid = "$Id: ramkomd.c,v 0.81 1999/04/28 22:13:29 ceder Exp $"; +rcsid = "$Id: ramkomd.c,v 0.82 1999/05/12 13:25:27 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -163,7 +163,7 @@ server_init(const char *host, const char * client_port) if (isc_adr == NULL) restart_kom("server_init(): can't isc_getladdress (listen_client)\n"); - log("Listening for clients on %d.\n", isc_getportnum(isc_adr)); + kom_log("Listening for clients on %d.\n", isc_getportnum(isc_adr)); isc_freeaddress (isc_adr); @@ -185,9 +185,9 @@ server_init(const char *host, const char * client_port) static void init_data_base(void) { - log("Database = %s\n", param.datafile_name); - log("Backup = %s\n", param.backupfile_name); - log("2nd Backup = %s\n", param.backupfile_name_2); + kom_log("Database = %s\n", param.datafile_name); + kom_log("Backup = %s\n", param.backupfile_name); + kom_log("2nd Backup = %s\n", param.backupfile_name_2); if ( init_cache() == FAILURE ) restart_kom ("Cannot find database.\n"); @@ -199,16 +199,16 @@ sighandler_hup (int UNUSED(sig)) #ifndef HAVE_STRUCT_SIGACTION signal(SIGHUP, sighandler_hup); #endif - log ("Signal HUP received. Shutting down server.\n"); + kom_log ("Signal HUP received. Shutting down server.\n"); go_and_die = 1; } static void sighandler_quit (int UNUSED(sig)) { - log ("Signal QUIT received - syncing...\n"); + kom_log ("Signal QUIT received - syncing...\n"); cache_sync_all(); - log ("Dumping core now.\n"); + kom_log ("Dumping core now.\n"); abort(); } @@ -230,16 +230,16 @@ sighandler_usr2 (int UNUSED(sig)) signal(SIGUSR2, sighandler_usr2); #endif - log ("Signal USR2 received - will dump core now. (Check that child dies.)\n"); + kom_log ("Signal USR2 received - will dump core now. (Check that child dies.)\n"); if ((child = fork()) == 0) { abort(); - log ("Abort() failed!!!"); + kom_log ("Abort() failed!!!"); exit(1); } else if (child < 0) { - log ("Couldn't fork.\n"); + kom_log ("Couldn't fork.\n"); } else { @@ -327,8 +327,8 @@ go_daemon(void) who knows? */ restart_kom("open of log file failed: %d\n", errno); } - log("*** Version %s (process %lu) coming up.\n", - kom_version_info.server_version, (unsigned long)getpid()); + kom_log("*** Version %s (process %lu) coming up.\n", + kom_version_info.server_version, (unsigned long)getpid()); } static void @@ -408,11 +408,11 @@ initialize(const char *config_file) /* Check that getrlimit and sysconf/getdtablesize/the compiled default makes sense. */ if (rlim.rlim_cur > MAX_NO_OF_CONNECTIONS + PROTECTED_FDS) - log("WARNING: getrlimit indicates that %ld files can be open, " + kom_log("WARNING: getrlimit indicates that %ld files can be open, " "but MAX_NO_OF_CONNECTIONS is only %ld\n", (long)rlim.rlim_cur, (long)MAX_NO_OF_CONNECTIONS); else if (rlim.rlim_cur < MAX_NO_OF_CONNECTIONS + PROTECTED_FDS) - log("warning: getrlimit indicates that only %ld files can be open, " + kom_log("warning: getrlimit indicates that only %ld files can be open, " "but MAX_NO_OF_CONNECTIONS is %ld (this should be harmless)\n", (long)rlim.rlim_cur, (long)MAX_NO_OF_CONNECTIONS); #endif @@ -437,11 +437,11 @@ main (int argc, struct sigaction act; #endif - log("*** Version %s (process %lu) started.\n", + kom_log("*** Version %s (process %lu) started.\n", kom_version_info.server_version, (unsigned long)getpid()); #ifdef DEBUG_CALLS - log("WARNING: This server was compiled with --with-debug-calls.\n"); - log("It isn't safe to use in a production environment.\n"); + kom_log("WARNING: This server was compiled with --with-debug-calls.\n"); + kom_log("It isn't safe to use in a production environment.\n"); #endif #ifdef ENCRYPT_PASSWORDS @@ -513,9 +513,12 @@ main (int argc, cache_sync_all(); free_kom_info(); + + /* Finish */ + dump_exit_statistics(); - log("%s terminated normally.\n", argv[0]); + kom_log("%s terminated normally.\n", argv[0]); /* Don't actually die until something is entered on stdin in debug mode. This is mainly here for the benefit of the test suite, @@ -523,10 +526,10 @@ main (int argc, do pre-mortem debugging of the process at this point. */ if (buglevel > 0) { - log("Press enter to terminate lyskomd\n"); + kom_log("Press enter to terminate lyskomd\n"); getchar(); } - + exit(0); } diff --git a/src/server/regex-match.c b/src/server/regex-match.c index 9a8f68d27a5a334482ffe6e4f027392c83f853bf..2bbb300f7d943e17f661aee5865f24edcd274ab3 100644 --- a/src/server/regex-match.c +++ b/src/server/regex-match.c @@ -1,5 +1,5 @@ /* - * $Id: regex-match.c,v 1.19 1998/12/26 22:41:00 byers Exp $ + * $Id: regex-match.c,v 1.20 1999/05/12 13:25:28 byers Exp $ * Copyright (C) 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -33,7 +33,7 @@ #endif static const char * -rcsid = "$Id: regex-match.c,v 1.19 1998/12/26 22:41:00 byers Exp $"; +rcsid = "$Id: regex-match.c,v 1.20 1999/05/12 13:25:28 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -124,7 +124,7 @@ lookup_regexp (const String regexp, case -1: break; case -2: - log("Internal error in regex."); + kom_log("Internal error in regex."); break; default: /* It matched. (Ignore where it matched). */ diff --git a/src/server/rfc931.c b/src/server/rfc931.c index a57b029373d54b5278a04f3567dedb4f97481eaa..683f983531f3ef657cd6b6d45b0a3719245006b1 100644 --- a/src/server/rfc931.c +++ b/src/server/rfc931.c @@ -1,5 +1,5 @@ /* - * $Id: rfc931.c,v 1.17 1998/12/26 22:41:01 byers Exp $ + * $Id: rfc931.c,v 1.18 1999/05/12 13:25:29 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -85,12 +85,12 @@ get_real_username(IscSession *USE_IF_LIBAUTHUSER(scb), time(&before); result = auth_tcpuser3(inlocal, inremote, local, remote, 20); if (result == NULL && errno == ETIMEDOUT) - log ("Identd request to %s timed out.\n", hostname); + kom_log ("Identd request to %s timed out.\n", hostname); else { time(&after); if (after-before > 15) - log ("Identd at %s said %s after %d seconds.\n", + kom_log ("Identd at %s said %s after %d seconds.\n", hostname, result == NULL ? "(error)" : result, (int)after-before); diff --git a/src/server/send-async.c b/src/server/send-async.c index 587fb59a6d158ec406d48ffb9d33ed54c5a9c299..65ca6c5944ed447108315204cf1531596eb0206c 100644 --- a/src/server/send-async.c +++ b/src/server/send-async.c @@ -1,5 +1,5 @@ /* - * $Id: send-async.c,v 0.25 1999/01/18 11:55:32 byers Exp $ + * $Id: send-async.c,v 0.26 1999/05/12 13:25:30 byers Exp $ * Copyright (C) 1991, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -34,7 +34,7 @@ #endif static const char * -rcsid = "$Id: send-async.c,v 0.25 1999/01/18 11:55:32 byers Exp $"; +rcsid = "$Id: send-async.c,v 0.26 1999/05/12 13:25:30 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -155,7 +155,7 @@ async_logout(Pers_no pers_no, if ( cptr == NULL ) { - log("async_logout(): cptr == NULL\n"); + kom_log("async_logout(): cptr == NULL\n"); return; } @@ -193,7 +193,7 @@ async_new_name(Conf_no conf_no, if ( cptr == NULL ) { - log("async_new_name(): cptr == NULL\n"); + kom_log("async_new_name(): cptr == NULL\n"); return; } @@ -245,7 +245,7 @@ async_sync_db(void) if ( cptr == NULL ) { - log("async_sync_db(): cptr == NULL\n"); + kom_log("async_sync_db(): cptr == NULL\n"); return; } @@ -302,7 +302,7 @@ async_login(Pers_no pers_no, if ( cptr == NULL ) { - log("async_login(): cptr == NULL\n"); + kom_log("async_login(): cptr == NULL\n"); return; } @@ -345,7 +345,7 @@ async_rejected_connection(void) if ( cptr == NULL ) { - log("async_rejected_connections(): cptr == NULL\n"); + kom_log("async_rejected_connections(): cptr == NULL\n"); return; } @@ -409,7 +409,7 @@ async_send_group_message(Pers_no recipient, if ( cptr == NULL ) { - log("async_send_message(): cptr == NULL\n"); + kom_log("async_send_message(): cptr == NULL\n"); err_stat = 0; kom_errno = KOM_INTERNAL_ERROR; return FAILURE; diff --git a/src/server/server-config.c b/src/server/server-config.c index 547090e370479de14da54669edfab59bcb7d85b0..57771b6d6caf8bf6c32d6f4a6c2f9712ed2749f7 100644 --- a/src/server/server-config.c +++ b/src/server/server-config.c @@ -1,5 +1,5 @@ /* - * $Id: server-config.c,v 0.58 1999/04/28 22:13:41 ceder Exp $ + * $Id: server-config.c,v 0.59 1999/05/12 13:25:31 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -37,7 +37,7 @@ #endif static const char * -rcsid = "$Id: server-config.c,v 0.58 1999/04/28 22:13:41 ceder Exp $"; +rcsid = "$Id: server-config.c,v 0.59 1999/05/12 13:25:31 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -102,10 +102,8 @@ static const struct parameter parameters[] = { assign_text_no, 0, 1, "0", &kom_info.motd_of_lyskom}, {"Garb", assign_bool, 0, 1, "on", ¶m.garb_enable}, -#ifndef NDEBUG {"Never save", assign_bool, 0, 1, "no", ¶m.never_save}, -#endif #ifdef LOGACCESSES {"Log accesses", assign_string, 0, 1, NULL, ¶m.logaccess_file}, @@ -148,6 +146,8 @@ static const struct parameter parameters[] = { {"Core directory", assign_string, 0, 1, "cores", ¶m.core_dir}, + {"Nologin file", + assign_string, 0, 1, "/etc/nologin", ¶m.nologin_file}, /* Performance tuning parameters (milliseconds) */ @@ -182,6 +182,8 @@ static const struct parameter parameters[] = { {"Max conference name length", assign_int, 0, 1, "60", ¶m.conf_name_len}, + {"Max client data length", + assign_int, 0, 1, "60", ¶m.client_data_len}, {"Max password length", assign_int, 0, 1, "128", ¶m.pwd_len}, {"Max what am I doing length", @@ -268,6 +270,14 @@ static const struct parameter parameters[] = { {"Jubel", jubel, 0, -1, NULL, NULL}, + {"Ident-authentication", + ident_param, 0, 1, "try", ¶m.authentication_level}, + {"Regexps use collate table", + assign_bool, 0, 1, "on", ¶m.regex_use_collate_table}, + {"Max conferences", + assign_ulong, 1, 1, "4765", ¶m.max_conf}, + {"Max texts", + assign_ulong, 1, 1, "2000000", ¶m.max_text}, /* Configuration for support programs. */ @@ -320,7 +330,7 @@ static Success log_param(const char *val, const struct parameter *UNUSED(par)) { if (val != NULL) - log ("config: %s\n", val); + kom_log ("config: %s\n", val); return OK; } @@ -343,7 +353,7 @@ jubel(const char *val, const struct parameter *par) register_jubel (a, 0, b); break; default: - log ("%s expecting 2 or 3 integers as args\n", par->name); + kom_log ("%s expecting 2 or 3 integers as args\n", par->name); return FAILURE; } return OK; @@ -371,7 +381,7 @@ ident_param(const char *val, const struct parameter *par) } else { - log ("%s expects \"never\", \"try\" or \"required\" as argument\n", + kom_log ("%s expects \"never\", \"try\" or \"required\" as argument\n", par->name); return FAILURE; } @@ -402,6 +412,8 @@ param_name(void *value) return parameters[ix].name; restart_kom("Internal error: non-existing config param in param_name.\n"); + /* notreached */ + return NULL; } static Bool @@ -410,7 +422,7 @@ check_abs_path(char **path) if (**path == '/') return FALSE; - log("Parameter '%s' must be an absolute path when 'Prefix' is empty.\n", + kom_log("Parameter '%s' must be an absolute path when 'Prefix' is empty.\n", param_name(path)); return TRUE; } @@ -442,7 +454,7 @@ read_configuration(const char *conf_file) { if (param.dbase_dir[0] != '/') { - log("The 'Prefix' parameter must be an absolute path.\n"); + kom_log("The 'Prefix' parameter must be an absolute path.\n"); err = TRUE; } diff --git a/src/server/session.c b/src/server/session.c index 1a69b45928c19f0ff7d56945c3354c52eb31a560..375db9472140f832920d57e68e618b4f5edad904 100644 --- a/src/server/session.c +++ b/src/server/session.c @@ -1,5 +1,5 @@ /* - * $Id: session.c,v 0.44 1999/01/18 11:55:33 byers Exp $ + * $Id: session.c,v 0.45 1999/05/12 13:25:33 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -34,7 +34,7 @@ #endif static const char * -rcsid = "$Id: session.c,v 0.44 1999/01/18 11:55:33 byers Exp $"; +rcsid = "$Id: session.c,v 0.45 1999/05/12 13:25:33 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -105,7 +105,7 @@ leave_conf(void) } else { - log("ERROR: leave_conf(): Can't find membership of cwc.\n"); + kom_log("ERROR: leave_conf(): Can't find membership of cwc.\n"); } cached_unlock_conf( active_connection->cwc ); @@ -187,7 +187,7 @@ login_old (Pers_no pers_no, if (param.log_login == TRUE) { char *id = s_crea_c_str (pers_p->username); - log ("Login %d %s\n", ACTPERS, id); + kom_log ("Login %d %s\n", ACTPERS, id); string_free (id); } @@ -282,7 +282,7 @@ login (Pers_no pers_no, if (param.log_login == TRUE && same_person == FALSE) { char *id = s_crea_c_str (pers_p->username); - log ("Login %d %s\n", ACTPERS, id); + kom_log ("Login %d %s\n", ACTPERS, id); string_free (id); } @@ -485,7 +485,7 @@ who_is_on( Who_info_list *result ) } if ( i != no_of_clients ) - log("who_is_on: i == %d, no_of_clients == %d\n", + kom_log("who_is_on: i == %d, no_of_clients == %d\n", i, no_of_clients); return OK; @@ -540,7 +540,7 @@ who_is_on_ident( Who_info_ident_list *result ) } if ( i != no_of_clients ) - log("who_is_on_ident: i == %d, no_of_clients == %d\n", + kom_log("who_is_on_ident: i == %d, no_of_clients == %d\n", i, no_of_clients); return OK; @@ -628,7 +628,7 @@ who_is_on_dynamic(int want_visible, } if ( i != no_of_clients ) - log("who_is_on_dynamic: i == %ld, no_of_clients == %ld\n", + kom_log("who_is_on_dynamic: i == %ld, no_of_clients == %ld\n", i, no_of_clients); return OK; @@ -819,7 +819,7 @@ who_is_on_old( Who_info_list_old *result ) } if ( i != no_of_clients ) - log("who_is_on_old: i == %d, no_of_clients == %d\n", + kom_log("who_is_on_old: i == %d, no_of_clients == %d\n", i, no_of_clients); return OK; @@ -853,10 +853,10 @@ extern Success set_client_version (const String client_name, const String client_version) { - if (s_strlen(client_name) > param.conf_name_len - || s_strlen(client_version) > param.conf_name_len) + if (s_strlen(client_name) > param.client_data_len + || s_strlen(client_version) > param.client_data_len) { - err_stat = param.conf_name_len; + err_stat = param.client_data_len; kom_errno = KOM_LONG_STR; return FAILURE; } diff --git a/src/server/simple-cache.c b/src/server/simple-cache.c index cabc605133f2cb5b413ebdda5cf54e0ae352e8c5..360c1833e0cc4752c6e417b81085990bd7b3ab33 100644 --- a/src/server/simple-cache.c +++ b/src/server/simple-cache.c @@ -1,5 +1,5 @@ /* - * $Id: simple-cache.c,v 0.73 1999/04/03 22:16:37 ceder Exp $ + * $Id: simple-cache.c,v 0.74 1999/05/12 13:25:35 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -40,7 +40,7 @@ #endif static const char * -rcsid = "$Id: simple-cache.c,v 0.73 1999/04/03 22:16:37 ceder Exp $"; +rcsid = "$Id: simple-cache.c,v 0.74 1999/05/12 13:25:35 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -71,7 +71,6 @@ USE(rcsid); #include "misc-types.h" #include "s-string.h" #include "kom-types.h" -#include "tmp-limits.h" #include "cache-node.h" #include "cache.h" #include "parser.h" @@ -106,7 +105,7 @@ USE(rcsid); * if they fail. */ -static Small_conf * small_conf_arr[ MAX_CONF ]; +static Small_conf ** small_conf_arr; static Cache_node_mcb * pers_mcb; static Cache_node_mcb * conf_mcb; static Conf_no next_free_num = 1; @@ -635,7 +634,7 @@ cached_create_conf (String name) TRACESTR(name); TRACE1(" )\n"); - if ( next_free_num >= MAX_CONF ) + if ( next_free_num >= param.max_conf ) { err_stat = next_free_num; kom_errno = KOM_INDEX_OUT_OF_RANGE; @@ -699,10 +698,12 @@ cached_delete_conf( Conf_no conf ) } if ( node->lock_cnt > 0 ) - log("WNG: cached_delete_conf(%d): lock_cnt === %d\n", + kom_log("WNG: cached_delete_conf(%d): lock_cnt === %d\n", conf, node->lock_cnt); - s_clear( &small_conf_arr[conf]->name ); + free_small_conf(small_conf_arr[conf]); + small_conf_arr[conf] = NULL; + free_conference(node->ptr); node->ptr = NULL; node->s.exists = 0; @@ -727,7 +728,7 @@ cached_delete_person(Pers_no pers) if ( pers >= next_free_num ) { - log("cached_delete_person(%lu): next_free_num == %lu\n", + kom_log("cached_delete_person(%lu): next_free_num == %lu\n", (unsigned long)pers, (unsigned long)next_free_num); err_stat = pers; kom_errno = KOM_UNDEF_PERS; @@ -738,14 +739,14 @@ cached_delete_person(Pers_no pers) if ( pers >= next_free_num || node == NULL || node->s.exists == 0 ) { - log("cached_delete_person(): attempt to delete void person.\n"); + kom_log("cached_delete_person(): attempt to delete void person.\n"); err_stat = pers; kom_errno = KOM_UNDEF_PERS; return FAILURE; } if ( node->lock_cnt > 0 ) - log("cached_delete_pers(%lu): lock_cnt === %lu\n", + kom_log("cached_delete_pers(%lu): lock_cnt === %lu\n", (unsigned long)pers, (unsigned long)node->lock_cnt); LOGACC(lt_delete_pers, pers); @@ -773,14 +774,14 @@ cached_delete_text(Text_no text) if ( text >= next_text_num || node == NULL || node->s.exists == 0 ) { - log("cached_delete_text(): attempt to delete void text %lu.\n", text); + kom_log("cached_delete_text(): attempt to delete void text %lu.\n", text); err_stat = text; kom_errno = KOM_NO_SUCH_TEXT; return FAILURE; } if ( node->lock_cnt > 0 ) - log("cached_delete_text(%lu): lock_cnt === %d\n", + kom_log("cached_delete_text(%lu): lock_cnt === %d\n", text, node->lock_cnt); @@ -858,17 +859,7 @@ cached_conf_exists(Conf_no conf_no) if (conf_no == 0 || conf_no >= next_free_num ) return FALSE; - /* FIXME: it is probably faster to use - return small_conf_arr[conf_no] != NULL ? TRUE : FALSE - but that requires changes to cached_delete_conf. - */ - - node = get_conf_node (conf_no); - - if (node != NULL && node->s.exists != 0) - return TRUE; - else - return FALSE; + return small_conf_arr[conf_no] != NULL ? TRUE : FALSE; } @@ -899,7 +890,7 @@ cached_get_text( Text_no text ) if ( fread(the_string.string, sizeof(char), the_string.len, text_file) != (size_t)the_string.len ) { - log("WARNING: cached_get_text: premature end on text %lu\n", + kom_log("WARNING: cached_get_text: premature end on text %lu\n", text); return EMPTY_STRING; } @@ -979,18 +970,18 @@ cached_create_text(const String message) TRACE2("cached_create_text (len=%lu)\n", message.len); - if ( tno >= MAX_TEXT ) + if ( tno >= param.max_text ) { err_stat = tno; kom_errno = KOM_INDEX_OUT_OF_RANGE; - next_text_num = MAX_TEXT; + next_text_num = param.max_text; return 0; } if (fseek(text_file, 0, SEEK_END) != 0) { - log("ERROR: cannot seek to end of text_file: %s\n", strerror(errno)); + kom_log("ERROR: cannot seek to end of text_file: %s\n", strerror(errno)); clearerr(text_file); return 0; } @@ -1001,7 +992,7 @@ cached_create_text(const String message) != (size_t)message.len) { if (errno != ENOSPC) - log("WARNING: cached_create_text: Couldn't write text %lu: %s\n", + kom_log("WARNING: cached_create_text: Couldn't write text %lu: %s\n", tno, strerror(errno)); err_stat = 0; kom_errno = KOM_TEMPFAIL; @@ -1012,7 +1003,7 @@ cached_create_text(const String message) if (fflush(text_file) != 0) { if (errno != ENOSPC) - log("WARNING: cached_create_text: Couldn't fflush text %lu: %s\n", + kom_log("WARNING: cached_create_text: Couldn't fflush text %lu: %s\n", tno, strerror(errno)); err_stat = 0; kom_errno = KOM_TEMPFAIL; @@ -1023,7 +1014,7 @@ cached_create_text(const String message) if (fsync(fileno(text_file)) != 0) { if (errno != ENOSPC) - log("WARNING: cached_create_text: Couldn't fsync text %lu: %s\n", + kom_log("WARNING: cached_create_text: Couldn't fsync text %lu: %s\n", tno, strerror(errno)); err_stat = 0; kom_errno = KOM_TEMPFAIL; @@ -1206,7 +1197,7 @@ cached_unlock_person(Pers_no pers_no) if ( node->lock_cnt <= 0 ) { - log("cached_unlock_person(%d): lock_cnt == %d.\n", + kom_log("cached_unlock_person(%d): lock_cnt == %d.\n", pers_no, node->lock_cnt); node->lock_cnt = 0; @@ -1266,7 +1257,7 @@ cached_unlock_conf(Conf_no conf_no) if ( node->lock_cnt <= 0 ) { - log("cached_unlock_conf(%d): lock_cnt == %d.\n", + kom_log("cached_unlock_conf(%d): lock_cnt == %d.\n", conf_no, node->lock_cnt); node->lock_cnt = 0; @@ -1560,7 +1551,7 @@ pre_sync(void) if (rename(param.backupfile_name, param.backupfile_name_2) != 0) { - log("pre_sync: can't do extra backup.\n"); + kom_log("pre_sync: can't do extra backup.\n"); } } @@ -1568,11 +1559,11 @@ pre_sync(void) restart_kom("pre_sync: can't backup.\n"); } else - log("pre_sync: datafile not clean. No backup taken.\n"); + kom_log("pre_sync: datafile not clean. No backup taken.\n"); if ( file_b != NULL ) { - log("pre_sync: Save in progress aborted.\n"); + kom_log("pre_sync: Save in progress aborted.\n"); fclose(file_b); #ifdef FASTSAVE file_b = NULL; @@ -1581,7 +1572,7 @@ pre_sync(void) if ( (file_b = fopen(param.datafile_name, "wb") ) == NULL ) { - log("WARNING: pre_sync: can't open file to save in.\n"); + kom_log("WARNING: pre_sync: can't open file to save in.\n"); sync_state = sync_wait; return; @@ -1592,7 +1583,7 @@ pre_sync(void) { fclose(file_b); file_b = NULL; - log("WARNING: pre_sync: can't open file to save in for reading.\n"); + kom_log("WARNING: pre_sync: can't open file to save in for reading.\n"); sync_state = sync_wait; return; @@ -1696,7 +1687,7 @@ copy_file(FILE *from, if ( fseek(to, 0, SEEK_END) == -1 ) { sync_state = sync_error; - log("sync: copy_file(): second fseek failed.\n"); + kom_log("sync: copy_file(): second fseek failed.\n"); sfree(buf); return; } @@ -1704,7 +1695,7 @@ copy_file(FILE *from, if ( fwrite(buf, 1, len, to) != (size_t)len ) { sync_state = sync_error; - log("sync: copy_file(): fwrite failed.\n"); + kom_log("sync: copy_file(): fwrite failed.\n"); sfree(buf); return; } @@ -1846,14 +1837,14 @@ post_sync(void) async_sync_db(); if ( file_a == NULL ) - log("WARNING: post_sync(): file_a == NULL. This is only normal %s", + kom_log("WARNING: post_sync(): file_a == NULL. This is only normal %s", "if this is the first sync ever on this data file.\n"); else fclose(file_a); if ( ( file_a = fopen(param.datafile_name, "rb") ) == NULL ) { - log("post_sync: can't open the file I just saved.\n"); + kom_log("post_sync: can't open the file I just saved.\n"); sync_state = sync_wait; return; } @@ -1975,7 +1966,7 @@ save_one_text(void) { if ( ferror(file_b) != 0 ) { - log ("save_one_text(): ferror() detected.\n"); + kom_log ("save_one_text(): ferror() detected.\n"); sync_state = sync_error; return; } @@ -1987,7 +1978,7 @@ save_one_text(void) if (offset == -1) { - log ("save_one_text(): ftell returned -1.\n"); + kom_log ("save_one_text(): ftell returned -1.\n"); sync_state = sync_error; return; } @@ -1995,7 +1986,7 @@ save_one_text(void) rewind(file_b); if ( ferror(file_b) != 0 ) { - log ("save_one_text(): rewind failed.\n"); + kom_log ("save_one_text(): rewind failed.\n"); sync_state = sync_error; return; } @@ -2004,21 +1995,21 @@ save_one_text(void) if ( ferror(file_b) != 0 ) { - log ("save_one_text(): fprintf(CLEAN) failed.\n"); + kom_log ("save_one_text(): fprintf(CLEAN) failed.\n"); sync_state = sync_error; return; } if (fflush(file_b) != 0) { - log ("save_one_text(): fflush failed.\n"); + kom_log ("save_one_text(): fflush failed.\n"); sync_state = sync_error; return; } if ( ferror(file_b) != 0 ) { - log ("save_one_text(): ferror after fflush failed.\n"); + kom_log ("save_one_text(): ferror after fflush failed.\n"); sync_state = sync_error; return; } @@ -2027,7 +2018,7 @@ save_one_text(void) { file_b = NULL; - log("Sync: fclose() failed in save_one_text. Retrying.\n"); + kom_log("Sync: fclose() failed in save_one_text. Retrying.\n"); remove(param.datafile_name); sync_state = sync_wait; return; @@ -2039,7 +2030,7 @@ save_one_text(void) { file_b_r = NULL; - log("Sync: fclose() of reader failed in save_one_text. Retrying.\n"); + kom_log("Sync: fclose() of reader failed in save_one_text. Retrying.\n"); remove(param.datafile_name); sync_state = sync_wait; return; @@ -2050,7 +2041,7 @@ save_one_text(void) file_b = fopen(param.datafile_name, "rb"); if (file_b == NULL) { - log("save_one_text(): failed to reopen file.\n"); + kom_log("save_one_text(): failed to reopen file.\n"); remove (param.datafile_name); sync_state = sync_wait; return; @@ -2058,7 +2049,7 @@ save_one_text(void) if (fseek(file_b, 0, SEEK_END) != 0) { - log("save_one_text(): fseek failed.\n"); + kom_log("save_one_text(): fseek failed.\n"); sync_state = sync_error; return; } @@ -2066,7 +2057,7 @@ save_one_text(void) offset2 = ftell (file_b); if ( offset2 != offset ) { - log ("save_one_text(): ftell confused (%ld and %ld).\n", + kom_log ("save_one_text(): ftell confused (%ld and %ld).\n", offset, offset2); sync_state = sync_error; return; @@ -2124,6 +2115,11 @@ sync_part(void) return TRUE; case sync_idle: + if (param.never_save) + { + return TRUE; + } + if (ldifftime(time(NULL), last_sync_start) < 60 * param.sync_interval) { #ifdef LOGACCESSES @@ -2153,7 +2149,7 @@ sync_part(void) break; case sync_error: - log("sync: Error saving new file. Retrying.\n"); + kom_log("sync: Error saving new file. Retrying.\n"); fclose(file_b); file_b = NULL; #ifdef FASTSAVE @@ -2211,9 +2207,10 @@ init_cache(void) Bool read_conf_no = FALSE; int c = 0; - pers_mcb = create_cache_node_mcb(100, MAX_CONF); - conf_mcb = create_cache_node_mcb(100, MAX_CONF); - text_mcb = create_cache_node_mcb(100, MAX_TEXT); + small_conf_arr = smalloc(sizeof(*small_conf_arr) * param.max_conf); + pers_mcb = create_cache_node_mcb(100, param.max_conf); + conf_mcb = create_cache_node_mcb(100, param.max_conf); + text_mcb = create_cache_node_mcb(100, param.max_text); init_conference(&tmp_conf); init_person(&tmp_pers); @@ -2224,22 +2221,25 @@ init_cache(void) { logfile = fopen(param.logaccess_file, "a"); if (logfile) - log("Logging db accesses to %s.\n", param.logaccess_file); + kom_log("Logging db accesses to %s.\n", param.logaccess_file); else - log("Failed to open db log file %s. Not logging.\n", + kom_log("Failed to open db log file %s. Not logging.\n", param.logaccess_file); } #endif LOGACC(lt_restart, time(NULL)); - for (i = 1; i < MAX_CONF; i++) + for (i = 0; i < param.max_conf; i++) + small_conf_arr[i] = NULL; + + for (i = 1; i < param.max_conf; i++) zero_init_cache_node(pers_mcb, i); - for (i = 1; i < MAX_CONF; i++) + for (i = 1; i < param.max_conf; i++) zero_init_cache_node(conf_mcb, i); - for (i = 1; i < MAX_TEXT; i++) + for (i = 1; i < param.max_text; i++) zero_init_cache_node(text_mcb, i); @@ -2257,24 +2257,24 @@ init_cache(void) { if ((file_a = fopen(param.datafile_name, "rb")) == NULL) { - log("WARNING: init_cache: can't open datafile.\n"); + kom_log("WARNING: init_cache: can't open datafile.\n"); kom_errno = KOM_INTERNAL_ERROR; err_stat = 0; return FAILURE; } - log("MSG: init_cache: using datafile.\n"); + kom_log("MSG: init_cache: using datafile.\n"); datafile_version = get_version(param.datafile_name); } else if (is_clean(param.backupfile_name)) { if ((file_a = fopen(param.backupfile_name, "rb")) == NULL) { - log("WARNING: init_cache: can't open backupfile.\n"); + kom_log("WARNING: init_cache: can't open backupfile.\n"); kom_errno = KOM_INTERNAL_ERROR; err_stat = 0; return FAILURE; } - log("MSG: init_cache: using backup file.\n"); + kom_log("MSG: init_cache: using backup file.\n"); datafile_version = get_version(param.backupfile_name); } else @@ -2282,7 +2282,7 @@ init_cache(void) /* Don't attempt to use backupfile_name_2 automatically. If that file is ever needed something is really broken; manual intervention is needed to assess the damage. */ - log("WARNING: init_cache: can't find old data base.\n"); + kom_log("WARNING: init_cache: can't find old data base.\n"); kom_errno = KOM_INTERNAL_ERROR; err_stat = 0; return FAILURE; @@ -2482,7 +2482,7 @@ init_cache(void) build_matching_info(); - log("Read %d confs/persons and %ld texts\n", + kom_log("Read %d confs/persons and %ld texts\n", next_free_num, next_text_num); return OK; diff --git a/src/server/standalone.c b/src/server/standalone.c index 0dcb195fa77b4c3d84ca304bae2f0cbf64eeabf1..ab0d401c2fd1a9c64328ec7751d54eae088d9a14 100644 --- a/src/server/standalone.c +++ b/src/server/standalone.c @@ -1,5 +1,5 @@ /* - * $Id: standalone.c,v 1.1 1999/04/17 00:14:08 ceder Exp $ + * $Id: standalone.c,v 1.2 1999/05/12 13:25:36 byers Exp $ * Copyright (C) 1999 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -49,5 +49,7 @@ Info kom_info = 2, /* pers_pres_conf */ 3, /* motd_conf */ 4, /* kom_news_conf */ - 0 /* motd_of_lyskom */ + 0, /* motd_of_lyskom */ + 0, /* highest_aux_no */ + { 0, NULL } /* aux_item_list */ }; diff --git a/src/server/testsuite/config/prot-a.exp b/src/server/testsuite/config/prot-a.exp index 903e04f9c51e9451e51241a0a183839cfc8314df..5bb2fcaa9858c671c494f84276762ce148ead236 100644 --- a/src/server/testsuite/config/prot-a.exp +++ b/src/server/testsuite/config/prot-a.exp @@ -38,13 +38,13 @@ proc kom_accept_async { str {result ""} {testname ""}} { simple_expect $result $testname } -proc kom_create_person { name password aux {result ""} {testname ""}} { +proc kom_create_person { name password flags aux {result ""} {testname ""}} { global ref_no global any_num global pers_no kom_next_call - send "$ref_no 89 [holl "$name"] [holl "$password"] $aux\n" + send "$ref_no 89 [holl "$name"] [holl "$password"] $flags $aux\n" set result [cres $result "=$ref_no ($any_num)" ] extracting_expect $result pers_no 1 @@ -60,6 +60,15 @@ proc kom_logout {{result ""} {testname ""}} { simple_expect $result $testname } +proc kom_login_old {person password {result ""} {testname ""}} { + global ref_no + + kom_next_call + send "$ref_no 0 $person [holl "$password"]\n" + set result [cres $result "=$ref_no"] + simple_expect $result $testname +} + proc kom_login {person password invisible {result ""} {testname ""}} { global ref_no @@ -100,6 +109,25 @@ proc kom_set_supervisor { conf admin {result ""} {testname ""} } { simple_expect $result $testname } +proc kom_set_permitted_submitters { conf permitted {result ""} {testname ""}} { + global ref_no + + kom_next_call + send "$ref_no 19 $conf $permitted\n" + set result [cres $result "=$ref_no"] + simple_expect $result $testname +} + +proc kom_set_super_conf { conf super {result ""} {testname ""}} { + global ref_no + + kom_next_call + send "$ref_no 20 $conf $super\n" + set result [cres $result "=$ref_no"] + simple_expect $result $testname +} + + proc kom_add_member { conf pers prio where type {result ""} {testname ""}} { global ref_no @@ -109,6 +137,53 @@ proc kom_add_member { conf pers prio where type {result ""} {testname ""}} { simple_expect $result $testname } +proc kom_mark_text { text mark { result "" } { testname "" }} { + global ref_no + + kom_next_call + send "$ref_no 72 $text $mark\n" + set result [cres $result "=$ref_no"] + simple_expect $result $testname +} + +proc kom_sub_recipient { text recpt { result "" } { testname "" }} { + global ref_no + + kom_next_call + send "$ref_no 31 $text $recpt\n" + set result [cres $result "=$ref_no"] + simple_expect $result $testname +} + +proc kom_set_conf_type { conf type { result "" } { testname "" }} { + global ref_no + + kom_next_call + send "$ref_no 21 $conf $type\n" + set result [cres $result "=$ref_no"] + simple_expect $result $testname +} + +proc kom_change_conference { conf { result "" } { testname "" }} { + global ref_no + + kom_next_call + send "$ref_no 2 $conf\n" + set result [cres $result "=$ref_no"] + simple_expect $result $testname +} + +proc kom_set_priv_bits { pers bits { result "" } { testname "" }} { + global ref_no + + kom_next_call + send "$ref_no 7 $pers $bits\n" + set result [cres $result "=$ref_no"] + simple_expect $result $testname +} + + + proc kom_ping_server { } { global ref_no global any_time diff --git a/src/server/testsuite/config/unix.exp b/src/server/testsuite/config/unix.exp index e566384f9e76e7ee7f2fa48ce197c900d1cf4ef5..75d81d76e72ae5875c0c7483d1c0e8d918703cfc 100644 --- a/src/server/testsuite/config/unix.exp +++ b/src/server/testsuite/config/unix.exp @@ -6,7 +6,7 @@ set attach 0 set efence 0 # Set the timeout value to something small for quicker testing -# set timeout 1 +set timeout 5 # Some useful constants. set nl "\r?\n" @@ -108,6 +108,13 @@ proc simple_expect {regex {testname ""} {is_meta ""}} { global nl global line_leader global meta_line_leader + global verbose + + if { $verbose } { + puts -nonewline "." + flush stdout + } + if {$is_meta == "meta"} { set ll $meta_line_leader @@ -133,9 +140,15 @@ proc extracting_expect {regex var grp} { global nl global line_leader global $var + global verbose set test "looking for $regex" + if { $verbose } { + puts -nonewline "." + flush stdout + } + expect { -re "^$line_leader$regex$nl" { set $var $expect_out($grp,string) @@ -153,8 +166,16 @@ proc unanchored_expect {regex testname} { global test global any global nl + global verbose set test $testname + + if { $verbose } { + puts -nonewline "." + flush stdout + } + + expect { -re "$regex" {pass "$test"} timeout {fail "$test (timeout)"} @@ -171,7 +192,10 @@ proc unanchored_expect {regex testname} { unset test } -proc lyskomd_start {{aux_item_conf_file ""} {extra_config ""}} { +proc lyskomd_start {{aux_item_conf_file "" } + {extra_config ""} + {base_config ""} + {args ""}} { global spawn_id global server_id global test @@ -205,11 +229,26 @@ proc lyskomd_start {{aux_item_conf_file ""} {extra_config ""}} { set cf [open "config/lyskomd-config" "w"] puts $cf "Client port: $clientport" puts $cf "Prefix: [pwd]" - puts $cf "Aux-item definition file: $aux_item_conf_file" + if { $base_config == "" } { + if { [regexp -nocase "Max conferences" $extra_config] == 0 } { + puts $cf "Max conferences: 2000" + } + if { [regexp -nocase "Max texts" $extra_config] == 0 } { + puts $cf "Max texts: 2000" + } + puts $cf "Aux-item definition file: [pwd]/$aux_item_conf_file" + } else { + puts $cf $base_config + } puts $cf $extra_config close $cf - set pid [spawn ../lyskomd -d config/lyskomd-config] + if { $args == "" } { + set pid [spawn ../lyskomd -d $srcdir/config/lyskomd-config] + } else { + set pid [spawn ../lyskomd $args] + } + set lyskomd_pid $pid set server_id $spawn_id @@ -246,6 +285,89 @@ proc lyskomd_start {{aux_item_conf_file ""} {extra_config ""}} { } } +proc lyskomd_fail_start {{aux_item_conf_file "" } + {extra_config ""} + {base_config ""} + {args ""}} { + global spawn_id + global server_id + global test + global nl + global attach + global timeout + global expect_active + global expect_always + global srcdir + global clientport + global aux_item_default_conf_file + global lyskomd_pid + + if { $aux_item_conf_file == "" } { + set aux_item_conf_file $aux_item_default_conf_file + } + + # Check that we are in in the correct directory before removing + # directories... + set f [open "../lyskomd" "r"] + close $f + system "rm -rf db etc" + system "mkdir db etc" + system "cp $srcdir/../../../db-crypt/db/lyskomd-data db/" + system "cp $srcdir/../../../db-crypt/db/lyskomd-texts db/" + + set cf [open "$srcdir/config/lyskomd-config" "w"] + set cwd [pwd] + cd $srcdir + set wd [pwd] + cd $cwd + puts $cf "Client port: $clientport" + if { $base_config == "" } { + puts $cf "Max conferences: 2000" + puts $cf "Max texts: 2000" + puts $cf "Prefix: $wd" + puts $cf "Aux-item definition file: $wd/$aux_item_conf_file" + } else { + puts $cf $base_config + } + puts $cf $extra_config + close $cf + + if { $args == "" } { + set pid [spawn ../lyskomd -d $srcdir/config/lyskomd-config] + } else { + set pid [spawn ../lyskomd -d $args] + } + + set lyskomd_pid $pid + + set server_id $spawn_id + set expect_active($server_id) \ + " -i $server_id eof { fail \"\$test (eof on lyskomd); wait\" }" + set expect_always($server_id) \ + " -i $server_id buffer_full { fail \"\$test (buffer_full on lyskomd)\" }" + + talk_to lyskomd + set test "server start failed" + set t $timeout + set timeout [expr {2 * $timeout}] + + expect { + -re "Search for the core" { pass "$test" } + timeout {fail "$test (timeout)" } + buffer_full {fail "$test (buffer_full)" } + eof {fail "$test (eof)"; wait} + } + + set timeout $t + + set test "server died" + expect { + -re "..*" { exp_continue } + timeout { fail "$test (timeout)" } + eof { pass "$test"; wait } + } +} + proc lyskomd_death {} { global spawn_id global server_id @@ -288,6 +410,48 @@ proc client_start {nr} { simple_expect "Connected" "client connected" meta } +proc client_start_fail {nr {response ""}} { + global client_id + global clientport + global spawn_id + global test + global nl + global expect_always + global expect_active + global srcdir + global deep_any + + spawn python $srcdir/tcpconnect.py localhost $clientport MRK:client$nr + set client_id($nr) $spawn_id + set expect_active($client_id($nr)) " -i $client_id($nr) -re \"($deep_any*)$nl\" { fail \"\$test (unexpected line \$expect_out(1,string))\"; exp_continue } " + set expect_always($client_id($nr)) \ + " -i $client_id($nr) eof { fail \"\$test (eof on client$nr); wait\" } -i $client_id($nr) buffer_full { fail \"\$test (buffer_full on client$nr)\" } " + + talk_to client $nr + + simple_expect "Connecting to localhost $clientport" \ + "client connects" meta + simple_expect "Connected" "client connected" meta + + if { $response != "" } { + simple_expect "$response" + } + + simple_expect "EOF on socket" "client $nr got EOF from server" meta + send "die\n" + set test "client $nr closes pty" + expect { + eof { pass "$test"; wait } + } + unset test + + unset expect_active($client_id($nr)) + unset expect_always($client_id($nr)) + unset spawn_id + + fix_expect_after +} + proc kill_client {nr} { global client_id global expect_always @@ -295,14 +459,19 @@ proc kill_client {nr} { close -i $client_id($nr) wait -i $client_id($nr) - set expect_active($client_id($nr)) "" - set expect_always($client_id($nr)) "" + unset expect_active($client_id($nr)) + unset expect_always($client_id($nr)) + fix_expect_after } proc suspend_client {} { send "\#suspend socket\n" } +proc hose_client {} { + send "\#hose socket\n" +} + proc resume_client {} { send "\#resume socket\n" } diff --git a/src/server/testsuite/lyskomd.0/00.exp b/src/server/testsuite/lyskomd.0/00.exp index 32c4e5a553371e25c4f4150dd2e2b0f24c9636e1..945a50b206c83a69a129209a4d80bf83fbbf6101 100644 --- a/src/server/testsuite/lyskomd.0/00.exp +++ b/src/server/testsuite/lyskomd.0/00.exp @@ -159,7 +159,7 @@ simple_expect "=1035 10 { 5 6 7 8 9 11 12 13 14 15 }" "setting async" send "1036 76 [holl "Eskil Block, FOA"] 0 1\n" simple_expect "=1036 0 \\*" "No Eskil Block yet" -send "1037 89 [holl "Eskil Block, FOA"] [holl "liksE"] 2 { 9 00000000 1 [holl "simulated compface data"] 12 00000000 1 [holl "simulated pgp public key"] }\n" +send "1037 89 [holl "Eskil Block, FOA"] [holl "liksE"] 00000000 2 { 9 00000000 1 [holl "simulated compface data"] 12 00000000 1 [holl "simulated pgp public key"] }\n" simple_expect "=1037 6" "created Eskil, got 6" send "1037 62 6 [holl "liksE"] 0\n" simple_expect ":2 9 6 2" "Eskil logged in (async c1)" diff --git a/src/server/testsuite/lyskomd.0/01.exp b/src/server/testsuite/lyskomd.0/01.exp index 22ce8d36768d6a00a7268f622dc8bacdce68ee69..fd645ecfd759038edaeec0e0824dea7e768e1d48 100644 --- a/src/server/testsuite/lyskomd.0/01.exp +++ b/src/server/testsuite/lyskomd.0/01.exp @@ -321,7 +321,7 @@ simple_expect "%1102 6 0" "create-conf" send "1103 88 [holl "new conf"] 00000000 0 { }\n" simple_expect "%1103 6 0" "create-conf" # 89:create-person -send "1104 89 [holl "new 89 person"] [holl "89pwd"] 0 { }\n" +send "1104 89 [holl "new 89 person"] [holl "89pwd"] 00000000 0 { }\n" simple_expect "=1104 7" "create-person" send "1104 62 7 [holl "89pwd"] 0\n" simple_expect "=1104" @@ -351,7 +351,7 @@ send "1113 95 0 { } 0 { }\n" simple_expect "%1113 6 0" "modify-system-info" # 96:query-predefined-aux-items send "1114 96\n" -simple_expect "=1114 25 { 27 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 }" "query-predefined-aux-items" +simple_expect "=1114 26 { 28 27 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 }" "query-predefined-aux-items" # 97:set-expire send "1115 97 1 76\n" simple_expect "%1115 6 0" "set-expire" @@ -379,11 +379,13 @@ simple_expect "%1122 6 0" "map-created-texts" # 105:set-keep-commented send "1123 105 1 99\n" simple_expect "%1123 6 0" "set-keep-commented" +# 106:set-pers-flags +send "1124 106 5 10101010\n" +simple_expect "%1124 6 0" "set-pers-flags" - -# 106:does not exist (change this when you add a call) -send "2000 106\n" +# 107:does not exist (change this when you add a call) +send "2000 107\n" simple_expect "%2000 2 0" # finally, check that 55=disconnect actually works without logging in. send "2001 55 1\n" diff --git a/src/server/testsuite/lyskomd.0/02.exp b/src/server/testsuite/lyskomd.0/02.exp index b263f315be0f118098d492933212a7c0a1dbb8f5..cc7d3687335dd5b7c9f98a64068a46613bd7fb89 100644 --- a/src/server/testsuite/lyskomd.0/02.exp +++ b/src/server/testsuite/lyskomd.0/02.exp @@ -176,7 +176,7 @@ send "1060 56\n" simple_expect "=1060 2" send "1061 83 1 1 0\n" simple_expect "=1061 2 { 2 0 0 $any_num 10000000 0H 1 5 0 $any_num 00000000 0H }" -send "1062 89 [holl "John Doe"] [holl "letmein"] 0 { }\n" +send "1062 89 [holl "John Doe"] [holl "letmein"] 00000000 0 { }\n" simple_expect "=1062 7" send "1062 62 7 [holl "letmein"] 0\n" simple_expect ":2 9 7 2" diff --git a/src/server/testsuite/lyskomd.0/03.exp b/src/server/testsuite/lyskomd.0/03.exp index 3df6588748e8208e6627b08d76ec0ab7271f1411..106766eed91d62fae5debf5624258093fa814b1e 100644 --- a/src/server/testsuite/lyskomd.0/03.exp +++ b/src/server/testsuite/lyskomd.0/03.exp @@ -114,7 +114,7 @@ simple_expect "=1009" # exactly these aux-items. It shouldn't be hard to fix the test suite # when more items are added. send "1010 96\n" -simple_expect "=1010 25 { 27 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 }" +simple_expect "=1010 26 { 28 27 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 }" send "1011 82\n" simple_expect "=1011" @@ -178,7 +178,7 @@ simple_expect "=1027" send "1028 81\n" simple_expect "=1028 11 { 0 5 6 7 8 9 11 12 13 14 15 }" -send "1029 89 [holl "Kelly Talisman"] [holl "the stars"] 7 { 3 00000000 0 [holl "C6 My Creator"] 3 00000000 0 [holl "C7 Slightly offensive name, huh"] 8 00000000 0 [holl "E-mail:kelly@hotbox.com"] 9 00000000 0 [holl "compface must die"] 10 00000000 0\n" +send "1029 89 [holl "Kelly Talisman"] [holl "the stars"] 00000000 7 { 3 00000000 0 [holl "C6 My Creator"] 3 00000000 0 [holl "C7 Slightly offensive name, huh"] 8 00000000 0 [holl "E-mail:kelly@hotbox.com"] 9 00000000 0 [holl "compface must die"] 10 00000000 0\n" send "[holl "Air"] 12 00000000 0 [holl "PGP public key"] 13 00000000 0 [holl "kelly@hotbox.com"] }\n" simple_expect "=1029 8" send "1029 62 8 [holl "the stars"] 0\n" @@ -1177,13 +1177,13 @@ send "1325 88 [holl "aux non anon"] 01000000 1 { 14 00000000 1 [holl "10"] }\n" simple_expect "=1325 11" # test call 89 (create-person) -send "1326 89 [holl "aux person"] [holl "secret"] 1 { 12 00000000 1 [holl "public"] }\n" +send "1326 89 [holl "aux person"] [holl "secret"] 00000000 1 { 12 00000000 1 [holl "public"] }\n" simple_expect "=1326 12" # test call 90 (get-text-stat) send "1327 90 10\n" -# Text 10 should have two marks since it is the FAQ of conferences 10 and 11. -simple_expect "=1327 $time_10 0 0 17 2 2 { 0 7 6 8 } 1 { 1 1 0 $time_10 00000111 1 [holl "text/plain"] }" +# Text 10 should have two extra aux-items since it is the FAQ of conferences 10 and 11. +simple_expect "=1327 $time_10 0 0 17 0 2 { 0 7 6 8 } 3 { 1 1 0 $time_10 00000111 1 [holl "text/plain"] 2 28 0 $any_time 00001000 0 2H10 3 28 0 $any_time 00001000 0 2H11 }" # setup_xfail "*" # if {$n_marks == 2} { @@ -1243,28 +1243,23 @@ talk_to client 2 send "1341 95 0 { } 2 { 9 00000000 1 [holl "compface must die"] 13 00000000 1 [holl "maint@kom"] }\n" simple_expect "=1341" # Attempt to set a nonexisting text as faq for the server. -# FIXME: this should fail, since there is no way we can ensure that -# the text is marked when text 999 is finally created. If this item -# is later removed an inconsistency may appear. send "1342 95 0 { } 1 { 14 00000000 1 [holl "999"] }\n" -simple_expect "=1342" -setup_xfail "*" -fail "was able to set nonexisting text as faq" +simple_expect "%1342 48 0" send "1343 94\n" -simple_expect "=1343 $server_compat_version 1 2 3 4 0 3 { 1 9 5 $any_time 00000000 1 [holl "compface must die"] 2 13 5 $any_time 00000000 1 [holl "maint@kom"] 3 14 5 $any_time 00000000 1 [holl "999"] }" +simple_expect "=1343 $server_compat_version 1 2 3 4 0 2 { 1 9 5 $any_time 00000000 1 [holl "compface must die"] 2 13 5 $any_time 00000000 1 [holl "maint@kom"] }" send "1344 95 1 { 2 } 0 { }\n" simple_expect "=1344" send "1345 94\n" -simple_expect "=1345 $server_compat_version 1 2 3 4 0 2 { 1 9 5 $any_time 00000000 1 [holl "compface must die"] 3 14 5 $any_time 00000000 1 [holl "999"] }" +simple_expect "=1345 $server_compat_version 1 2 3 4 0 1 { 1 9 5 $any_time 00000000 1 [holl "compface must die"] }" # test call 96 (query-predefined-aux-items) talk_to client 1 send "1346 96\n" -simple_expect "=1346 25 { 27 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 }" +simple_expect "=1346 26 { 28 27 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 }" # test call 97 (set-expire) send "1347 97 10 7123123\n" @@ -1350,10 +1345,13 @@ simple_expect "=1352" send "1353 91 10\n" simple_expect "=1353 [holl "aux in general"] 01001000 $time_c_10 $time_c_10 8 0 8 0 8 0 77 99 1 1 0 7123123 1 { 1 14 8 $time_c_10 00000000 1 [holl "10"] }" +# test call 106 (set-pers-flags) -# There is no call 106--yet. -send "1353 106\n" -simple_expect "%1353 2 0" +send "1354 106 8 01011010\n" +simple_expect "=1354" + +send "1399 49 8\n" +simple_expect "=1399 [holl "ic@gratia.unknown.@localhost"] 0000010000000000 01011010 $any_time 0 $any_num 3 0 80 0 0 1 2 1 5 0 2" # There is no call 107--yet. send "1354 107\n" diff --git a/src/server/testsuite/lyskomd.0/04.exp b/src/server/testsuite/lyskomd.0/04.exp index 85f600ff46f1e1b5f103686d4c89ad9e38f26fc4..a0218168a8480c46c52422b9fa7238cd9202e3e9 100644 --- a/src/server/testsuite/lyskomd.0/04.exp +++ b/src/server/testsuite/lyskomd.0/04.exp @@ -14,12 +14,12 @@ kom_connect "DejaGnu test suite" "" "AIX: Client connected" kom_accept_async "0 { }" "" "AIX: Accept-async" -set pers_6 [ kom_create_person "User 1" "pw1" "0 { }" "" "AIX: Create P6" ] +set pers_6 [ kom_create_person "User 1" "pw1" "00000000" "0 { }" "" "AIX: Create P6" ] kom_login 6 "pw1" 0 -set pers_7 [ kom_create_person "User 2" "pw2" "0 { }" "" "AIX: Create P7" ] +set pers_7 [ kom_create_person "User 2" "pw2" "00000000" "0 { }" "" "AIX: Create P7" ] kom_logout "" "AIX: Logout P7" -set pers_8 [ kom_create_person "User 3" "pw3" "0 { }" "" "AIX: Create P8" ] +set pers_8 [ kom_create_person "User 3" "pw3" "00000000" "0 { }" "" "AIX: Create P8" ] kom_login 8 "pw3" 0 kom_login 7 "pw2" 0 "" "AIX: Login P7" @@ -909,7 +909,7 @@ simple_expect "=4401 $conf_stat" # Check that item restricted to create letterbox can be added on create # Try to add one after create -kom_create_person "User 13" "pw13" "1 { 3002 00000000 0 [holl "CP1"] }" +kom_create_person "User 13" "pw13" "00000000" "1 { 3002 00000000 0 [holl "CP1"] }" send "4402 91 13\n" extracting_expect "=4402 (.*)" conf_stat 1 diff --git a/src/server/testsuite/lyskomd.0/05.exp b/src/server/testsuite/lyskomd.0/05.exp index d3d305f6c59fae525b621b2b1e303d7f1a798e31..93e0fe49cf4c7ad8d1e3be07258accfd5553ea89 100644 --- a/src/server/testsuite/lyskomd.0/05.exp +++ b/src/server/testsuite/lyskomd.0/05.exp @@ -34,11 +34,11 @@ proc startup_05 {} { kom_accept_async "0 { }" "" "MSHIP: accept-async" - kom_create_person "P6" "pw1" "0 { }" + kom_create_person "P6" "pw1" "00000000" "0 { }" kom_login 6 "pw1" 0 - kom_create_person "P7" "pw2" "0 { }" + kom_create_person "P7" "pw2" "00000000" "0 { }" kom_logout - kom_create_person "P8" "pw3" "0 { }" + kom_create_person "P8" "pw3" "00000000" "0 { }" kom_logout kom_login 7 "pw2" 0 @@ -50,10 +50,10 @@ proc startup_05 {} { kom_logout kom_login 8 "pw3" 0 - kom_create_person "P13" "pw4" "0 { }" + kom_create_person "P13" "pw4" "00000000" "0 { }" kom_logout - kom_create_person "P14" "pw5" "0 { }" + kom_create_person "P14" "pw5" "00000000" "0 { }" kom_logout kom_login 5 "gazonk" 0 @@ -169,7 +169,7 @@ kom_logout kom_login 13 "pw4" 0 send "1040 101 9 0 10000\n" -simple_expect "=1040 2 { 7 7 $any_time 00000000 0 0 0 0 1 1 0 70 4 0 0 00100000 }" +simple_expect "=1040 2 { 7 7 $any_time 00000000 0 0 0 0 \[12\] 1 0 70 4 0 \[01\] 00100000 }" send "1041 99 8 0 10000 0\n" simple_expect "=1041 1 { 0 $any_time 8 255 0 0 \\* 0 $any_time 00000000 }" @@ -182,7 +182,7 @@ kom_logout kom_login 5 "gazonk" 0 send "1050 101 9 0 10000\n" -simple_expect "=1050 2 { 7 7 $any_time 00000000 0 0 0 0 1 1 0 70 4 0 0 00100000 }" +simple_expect "=1050 2 { 7 7 $any_time 00000000 0 0 0 0 \[12\] 1 0 70 4 0 \[01\] 00100000 }" send "1051 99 8 0 10000 0\n" simple_expect "=1051 1 { 0 $any_time 8 255 0 0 \\* 0 $any_time 00000000 }" @@ -336,7 +336,10 @@ shutdown_05 lyskomd_start "" \ "Add members by invitation: on Allow reinvitations: off -Allow secret memberships: off" +Allow secret memberships: off +Garb interval: 9999999 +Sync interval: 9999999 +" startup_05 @@ -428,7 +431,10 @@ simple_expect "=2014 1 { 14 8 $any_time 00000000 }" shutdown_05 -lyskomd_start "" "Add members by invitation: on" +lyskomd_start "" "Add members by invitation: on +Garb interval: 9999999 +Sync interval: 9999999 +" startup_05 # ---------------------------------------------------------------------- diff --git a/src/server/testsuite/lyskomd.0/06.exp b/src/server/testsuite/lyskomd.0/06.exp index ffdc9146027885f6ec722f8a4ae5501f627e3d50..a5c0c456dfd99a96036c1792c601c2bd7205743c 100644 --- a/src/server/testsuite/lyskomd.0/06.exp +++ b/src/server/testsuite/lyskomd.0/06.exp @@ -47,11 +47,11 @@ proc startup_06 {} { # Set up some users - kom_create_person "P6" "pw1" "0 { }" + kom_create_person "P6" "pw1" "00000000" "0 { }" kom_login 6 "pw1" 0 - kom_create_person "P7" "pw2" "0 { }" + kom_create_person "P7" "pw2" "00000000" "0 { }" kom_logout - kom_create_person "P8" "pw3" "0 { }" + kom_create_person "P8" "pw3" "00000000" "0 { }" # Set up conferences @@ -66,10 +66,10 @@ proc startup_06 {} { kom_logout kom_login 8 "pw3" 0 - kom_create_person "P13" "pw4" "0 { }" + kom_create_person "P13" "pw4" "00000000" "0 { }" kom_logout - kom_create_person "P14" "pw5" "0 { }" + kom_create_person "P14" "pw5" "00000000" "0 { }" kom_logout kom_login 5 "gazonk" 0 diff --git a/src/server/testsuite/lyskomd.0/admin-cov.exp b/src/server/testsuite/lyskomd.0/admin-cov.exp index 88a3418c77986d6dbc57801cf7ebedc62193745e..e85f70cda0c6a3712669a7f35aa1656fd7a9560c 100644 --- a/src/server/testsuite/lyskomd.0/admin-cov.exp +++ b/src/server/testsuite/lyskomd.0/admin-cov.exp @@ -22,6 +22,18 @@ simple_expect "LysKOM" kom_accept_async "1 { 12 }" +# Set up + +kom_login 5 "gazonk" 0 +kom_create_conference "C6" "10100000" "0 { }" +kom_create_person "P7" "PW7" "00000000" "0 { }" +kom_create_person "P8" "PW8" "00000000" "0 { }" +kom_create_conference "C9" "00000000" "0 { }" + +kom_add_member 9 8 100 0 "01000000" + + + # Attempt to do set-info of non-existent text kom_login 5 "gazonk" 0 @@ -77,10 +89,32 @@ kom_enable 0 send "2000 53 0 [holl "1234567890X"]\n" simple_expect "%2000 5 10" -# Send a message to a non-existent conference +# Send a message to a non-existent conference (9999) + +send "2001 53 9999 [holl "FUBAR"]\n" +simple_expect "%2001 9 9999" + +# Attempt to sent a message to a secret conference + +kom_login 7 "PW7" 0 +send "2002 53 6 [holl "FUBAR"]\n" +simple_expect "%2002 9 6" + +# Send message to conference with passive members + +client_start 1 +talk_to client 1 +kom_connect "DejaGnu Test Suite" +kom_accept_async "0 { }" +kom_login 8 "PW8" 0 + +talk_to client 0 +send "2003 53 9 [holl "SILENT"]\n" +simple_expect "%2003 53 0" + +talk_to client 1 +kom_ping_server -send "2001 53 6 [holl "FUBAR"]\n" -simple_expect "%2001 9 6" # Attempt to shut down LysKOM without privs @@ -96,5 +130,7 @@ kom_login 5 "gazonk" 0 kom_enable 255 send "9999 44 0\n" simple_expect "=9999" + +client_death 1 client_death 0 lyskomd_death diff --git a/src/server/testsuite/lyskomd.0/aux-items-cov.exp b/src/server/testsuite/lyskomd.0/aux-items-cov.exp index 8372679eb990e1d77e1c52f1fce4a27dec313dcb..80310cacad685790fab6732348ed519d38a9375a 100644 --- a/src/server/testsuite/lyskomd.0/aux-items-cov.exp +++ b/src/server/testsuite/lyskomd.0/aux-items-cov.exp @@ -79,7 +79,7 @@ send "2000 86 [holl "Text"] 1 { 0 1 } 1 { 1001 01000000 0 [holl "FUBAR"] }\n" simple_expect "=2000 2" kom_logout -kom_create_person "P1" "joshua5" "0 { }" +kom_create_person "P1" "joshua5" "00000000" "0 { }" kom_login 6 "joshua5" 0 send "2001 86 [holl "Comment"] 2 { 0 1 2 2 } 0 { }\n" @@ -107,6 +107,30 @@ simple_expect "=4000" send "4001 95 0 { } 1 { 1004 00000000 0 [holl "999"] }\n" simple_expect "=4001" +# Attempt to create item with a broken validation regexp, twice + +send "5000 95 0 { } 1 { 1000 00000000 0 [holl "ABC"] }\n" +simple_expect "%5000 48 0" + +send "5001 95 0 { } 1 { 1000 00000000 0 [holl "ABC"] }\n" +simple_expect "%5001 48 0" + +# Attempt to create an item that is system-only + +send "5002 95 0 { } 1 { 1005 00000000 0 [holl "FUBAR"] }\n" +simple_expect "%5002 49 0" + +# Delete aux-item zero is ignored +# (this is undocumented behavior and may change) + +send "5003 93 1 1 { 0 } 0 { }\n" +simple_expect "=5003" + +# FIXME: Call to undelete_aux_item_list with item zero +# FIXME: Delete an item that has the delete flag set +# FIXME: Call to aux_item_trigger_mark_text on item added to text? +# FIXME: Call to aux_item_trigger_unmark_text on item added to text? + # Finish @@ -117,3 +141,8 @@ send "9999 44 0\n" simple_expect "=9999" client_death 0 lyskomd_death + +# Try some broken config files + +lyskomd_fail_start "lyskomd.0/broken-aux-items.conf" + diff --git a/src/server/testsuite/lyskomd.0/aux-items.cov b/src/server/testsuite/lyskomd.0/aux-items.cov index 8f3ee976e2bf65fb33f2fb4e8083762fc94c77dd..8a0bd29d9d200eb0f83926f21fc56de0b60c36e7 100644 --- a/src/server/testsuite/lyskomd.0/aux-items.cov +++ b/src/server/testsuite/lyskomd.0/aux-items.cov @@ -26,3 +26,8 @@ { add-trigger = unmark-text(); } + +1005 : system-only (any) +{ + system-only = true; +} diff --git a/src/server/testsuite/lyskomd.0/broken-aux-items.conf b/src/server/testsuite/lyskomd.0/broken-aux-items.conf new file mode 100644 index 0000000000000000000000000000000000000000..68dfa98f1f26c2c2a46f76480b7b326eb8f6f0b4 --- /dev/null +++ b/src/server/testsuite/lyskomd.0/broken-aux-items.conf @@ -0,0 +1,10 @@ +1002 : invalid-trigger (any) +{ + add-trigger = fubar(); +} + +1003 : invalid-validator (any) +{ + validate = fubar(); +} + diff --git a/src/server/testsuite/lyskomd.0/cache-node-cov.exp b/src/server/testsuite/lyskomd.0/cache-node-cov.exp new file mode 100644 index 0000000000000000000000000000000000000000..3e9d5e6c75f7a125f23927d502d69cb01e8afcd2 --- /dev/null +++ b/src/server/testsuite/lyskomd.0/cache-node-cov.exp @@ -0,0 +1,11 @@ +# Supplemental tests for cache-node.c +# get_cache_node +# Try to get a text beyond the text table size +# Try to get a conf beyond the conf table size +# destruct_cache_node +# Try to go beyond the table size -- can't be done in LysKOM +# +# Remaining stuff is defensive programming + +# Can't do any of this from outside the server + diff --git a/src/server/testsuite/lyskomd.0/conf-file-cov.exp b/src/server/testsuite/lyskomd.0/conf-file-cov.exp new file mode 100644 index 0000000000000000000000000000000000000000..ac232b2044a7df9076445c68e1cfc7afd304b3be --- /dev/null +++ b/src/server/testsuite/lyskomd.0/conf-file-cov.exp @@ -0,0 +1,50 @@ +# Supplemental test cases to work through conf-file.c + +# Make the default assigner for a parameter fail +# If this happens, it is a bug in the server. The server +# will never be released with a problem like this +# Start server so it can't find config file + + + + +set conf_file "\ +\# This is a comment + + Lots of spaces before key +Key too long XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +Colon right at max XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: Foo +Key and colon ok: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + +Line no colon val +\# Don't assign Max conferences: 100 +Max: 102 +Idle timeout: 100000 +Idle timeout: 100001 +Send async: Juggle! +Max texts: ¤ +Presentation of conferences: ¤ +Message of the day: ¤ +Garb interval: ¤ +" + + +# Read a file with a comment +# Read a file that has one line that whose key is longer than max line +# Read a file that has one line that whose key + value is too long +# Read a file that has one line with colon just before max line +# Read a file with a line without a colon +# Assign a parameter too few times. +# Assign a variable too many times +# Read a file that has a line that matches more than one param +# Try to assign a bool with value "Juggle!" +# Try to assign an int with a non-ascii and non-digit character +# Ditto for conf_no +# Ditto for text_no +# Ditto for ulong + +read_versions + +lyskomd_fail_start "" "" $conf_file +lyskomd_fail_start "" "" "" "nosuchfile" + diff --git a/src/server/testsuite/lyskomd.0/conference-cov.exp b/src/server/testsuite/lyskomd.0/conference-cov.exp new file mode 100644 index 0000000000000000000000000000000000000000..7b717f5ca0817bb8c06974d69c17eaf7490d7458 --- /dev/null +++ b/src/server/testsuite/lyskomd.0/conference-cov.exp @@ -0,0 +1,425 @@ +# Supplemental test cases to give conference.c a workout + +# No-can-dos +# General stuff +# Can't really reach any restart_kom lines +# do_delete_conf +# Can't get to the kom_logs after do_set_presentation and do_set_etc_motd +# since none of them can return FAILURE if called with 0 as argument. +# unique_name +# Can't simulate -1 exit from parse() +# delete_conf +# Can't get to the kom_log since do_delete_pers always succeeds +# lookup_name, lookup_z_name +# Can't get to first return FAILURE since cached_lookup_name only fails +# if parse failse, which it won't +# lookup_z_name +# Can't get to internal error +# do_lookup +# Can't get to the first return FAILURE +# Can't get to far too many matches without creating 2^32 confs +# get_conf_stat_old +# Can't get to first return FAILURE + +# Privilege bits +# 0001000000000000 create pers +# 0000100000000000 create conf +# 0000010000000000 change name + + +read_versions +source "config/prot-a.exp" + +lyskomd_start "" "\ +Max marks per text: 1 +Max conference name length: 60 +Anyone can create new conferences: false +Default change name capability: false +Max conferences: 20 +" + +client_start 0 +talk_to client 0 +kom_connect "DejaGnu Test Suite" +kom_accept_async "0 { }" + +kom_create_person "P6" "PW6" "00000000" "0 { }" +kom_create_person "P7" "PW7" "00000000" "0 { }" +kom_create_person "P8" "PW8" "00000000" "0 { }" +kom_create_person "P9" "PW9" "00000000" "0 { }" + +kom_login 5 "gazonk" 0 +kom_enable 255 +kom_set_priv_bits 6 "0001110000000000" +kom_set_priv_bits 7 "0001110000000000" + +kom_login 6 "PW6" 0 +kom_create_conference "C10" "00000000" "0 { }" +kom_create_conference "C11" "00000000" "0 { }" +kom_create_conference "Conference With a Name 12" "00000000" "0 { }" +kom_create_conference "Conference With a Name 13" "00000000" "0 { }" +kom_create_conference "C14" "10100000" "0 { }" + + +# Delete a conference with three members + +kom_login 7 "PW7" 0 +kom_create_conference "C15" "00000000" "0 { }" +kom_add_member 15 5 100 0 "00000000" +kom_add_member 15 6 100 0 "00000000" +kom_add_member 15 7 100 0 "00000000" + +send "1000 11 15\n" +simple_expect "=1000" + +# Attempt to delete a secret conf we don't know about + +send "1001 11 14\n" +simple_expect "%1001 9 14" + +# Attempt to delete someone else's conference + +send "1002 11 10\n" +simple_expect "%1002 12 10" + +# Delete the letterbox of a person who is logged in + +client_start 1 +talk_to client 1 +kom_connect "DejaGnu Test Suite" +kom_accept_async "0 { }" + +kom_login 9 "PW9" 0 + +talk_to client 0 +kom_login 5 "gazonk" 0 +kom_enable 255 +send "1003 11 9\n" +simple_expect "=1003" + +talk_to client 1 +send "1004 2 10\n" +simple_expect "%1004 6 0" + +send "1005 55 0\n" +simple_expect "=1005" +client_death 1 + +talk_to client 0 + +# Attempt to create a conf without privs to do so + +kom_login 8 "PW8" 0 +send "1100 88 [holl "No Can Do"] 00000000 0 { }\n" +simple_expect "%1100 12 0" + + +# Attempt to create a conf with long name + +kom_login 6 "PW6" 0 +send "1101 88 [holl "\ +Some folks say there ain't no bears in Arkansas \ +Some folks never seen a bear at all \ +Some folks say bears go around eating rabbits raw \ +Some folks got a bear across the hall \ +"] 00000000 0 { }\n" +simple_expect "%1101 5 60" + +# Attempt to create a conf with nonprintable character + +send "1102 88 [holl "Nonprintable \001"] 00000000 0 { }\n" +simple_expect "%1102 18 0" + +# Attempt to create a conf with empty name + +send "1103 88 [holl ""] 00000000 0 { }\n" +simple_expect "%1103 18 0" + +# Attempt to create a conf with duplicate name + +send "1104 88 [holl "C10"] 00000000 0 { }\n" +simple_expect "%1104 20 0" + +# Create a conf with name matching two others but fewer words + +send "1105 88 [holl "Conference With a Name"] 00000000 0 { }\n" +simple_expect "=1105 16" +send "1106 11 16\n" +simple_expect "=1106" + +# Create a conf with name matching two others but not exact match + +send "1107 88 [holl "Conf W a Name 1"] 00000000 0 { }\n" +simple_expect "=1107 17" +send "1108 11 17\n" +simple_expect "=1108" + +# Attempt to create a conf with invalid aux-item list + +send "1109 88 [holl "CXX"] 00000000 1 { 0 00000000 0 [holl "A1"] }\n" +simple_expect "%1109 48 0" + +# Attempt to create a conf with letterbox bit set + +send "1110 88 [holl "CXX"] 00010000 0 { }\n" +simple_expect "%1110 12 0" + +# Attempt to create a conf with secret but not rd_prot set + +send "1111 88 [holl "CXX"] 00100000 0 { }\n" +simple_expect "%1111 22 0" + + +# Attempt to change name of secret conf we don't know about + +kom_login 7 "PW7" 0 +send "1200 3 14 [holl "Lungs"]\n" +simple_expect "%1200 9 14" + +# Attempt to change name of conf without enough privs + +send "1201 3 10 [holl "Step Inside This House"]\n" +simple_expect "%1201 12 10" + +# Attempt to change name to empty + +send "1202 3 7 [holl ""]\n" +simple_expect "%1202 18 0" + +# Attempt to change name to one with nonprinting character + +send "1203 3 7 [holl "Memphis Midnight \001"]\n" +simple_expect "%1203 18 0" + + +# Call lookup-name with args that show a secret conf + +kom_login 7 "PW7" 0 + +send "1300 12 [holl "C"]\n" +simple_expect "=1300 4 { 10 11 12 13 } { 0000 0000 0000 0000 }" + +# Call lookup-z-name with args that show a secret conf + +send "1301 76 [holl "C"] 0 1\n" +simple_expect "=1301 4 { [holl "C10"] 0000 10 [holl "C11"] 0000 11 [holl "Conference With a Name 12"] 0000 12 [holl "Conference With a Name 13"] 0000 13 }" + + +# Do a get-conf-stat that fails somehow + +kom_login 7 "PW7" 0 + +send "1400 91 9999\n" +simple_expect "%1400 9 9999" + +# Do a get-conf-stat for a secret conf + +send "1401 91 14\n" +simple_expect "%1401 9 14" + +# Do a get-uconf-stat for a secret conf + +send "1402 78 14\n" +simple_expect "%1402 9 14" + +# Do a get-conf-stat-older on a secret conf + +send "1403 13 14 1\n" +simple_expect "%1403 9 14" + + +# Do set-presentation on a secret conf we don't know about +# Do set-presentation on conf without enough privs + +kom_login 7 "PW7" 0 + +send "1500 86 [holl "T1"] 1 { 0 10 } 0 { }\n" +simple_expect "=1500 1" + +send "1501 16 10 1\n" +simple_expect "%1501 12 10" + +send "1502 16 14 1\n" +simple_expect "%1502 9 14" + +# Do set-etc-motd on secret and conf wo privs + +send "1503 17 10 1\n" +simple_expect "%1503 12 10" + +send "1504 17 14 1\n" +simple_expect "%1504 9 14" + +# Do set-supervisor on secret and conf wo privs + +send "1505 18 10 7\n" +simple_expect "%1505 12 10" + +send "1506 18 14 7\n" +simple_expect "%1506 9 14" + +# Do set-permitted-submitters on secret and conf wo privs + +send "1507 19 10 7\n" +simple_expect "%1507 12 10" + +send "1508 19 14 7\n" +simple_expect "%1508 9 14" + +# Do set-super-conf on secret and conf wo privs + +send "1509 20 10 7\n" +simple_expect "%1509 12 10" + +send "1510 20 14 7\n" +simple_expect "%1510 9 14" + +# Do set-garb-nice on secret and conf wo privs + +send "1511 22 10 1\n" +simple_expect "%1511 12 10" + +send "1512 22 14 1\n" +simple_expect "%1512 9 14" + +# Do set-expire on secret and conf wo privs + +send "1513 97 10 1\n" +simple_expect "%1513 12 10" + +send "1514 97 14 1\n" +simple_expect "%1514 9 14" + +# Do set-keep-commented on secret and conf wo privs + +send "1515 105 10 1\n" +simple_expect "%1515 12 10" + +send "1516 105 14 1\n" +simple_expect "%1516 9 14" + + +# Do set-conf-type on secret conf and conf wo privs + +send "1517 21 10 00000000\n" +simple_expect "%1517 12 10" + +send "1518 21 14 00000000\n" +simple_expect "%1518 9 14" + +# Do set-conf-type with secret but not rd_prot + +kom_login 6 "PW6" 0 + +send "1600 21 10 00100000\n" +simple_expect "%1600 22 0" + +# Attempt to set letterbox bit + +send "1601 21 10 00010000\n" +simple_expect "%1601 23 10" + +# Attemp to clear the letterbox bit + +send "1602 21 6 00000000\n" +simple_expect "%1602 23 6" + + +# Attempt to set presentation to a text with max marks + +kom_login 6 "PW6" 0 +send "1700 86 [holl "T2"] 1 { 0 10 } 0 { }\n" +simple_expect "=1700 2" + +send "1701 86 [holl "T3"] 1 { 0 10 } 0 { }\n" +simple_expect "=1701 3" + +send "1702 72 2 0\n" +simple_expect "=1702" + +# Do it + +send "1703 16 10 2\n" +simple_expect "%1703 36 2" + +# Succeed + +send "1704 73 2\n" +simple_expect "=1704" + +send "1705 16 10 2\n" +simple_expect "=1705" + +# Change to a new text + +send "1706 16 10 3\n" +simple_expect "=1706" + +# Change to a new presentation when current presentation has zero marks + +send "1707 1001 3 0\n" +simple_expect "=1707" + +send "1708 16 10 0\n" +simple_expect "=1708" + + +# Do set-etc-motd with text that has max marks +# Do set-etc-motd with when there already is a motd +# Do set-etc-motd when current motd has zero marks + +kom_login 6 "PW6" 0 +send "1800 86 [holl "T4"] 1 { 0 10 } 0 { }\n" +simple_expect "=1800 4" + +send "1801 86 [holl "T5"] 1 { 0 10 } 0 { }\n" +simple_expect "=1801 5" + +send "1802 72 4 0\n" +simple_expect "=1802" + +# Do it + +send "1803 17 10 4\n" +simple_expect "%1803 36 4" + +# Succeed + +send "1804 73 4\n" +simple_expect "=1804" + +send "1805 17 10 4\n" +simple_expect "=1805" + +# Change to a new text + +send "1806 17 10 5\n" +simple_expect "=1806" + +# Do set-etc-motd when there already is a motd + +send "1807 1001 5 0\n" +simple_expect "=1807" + +send "1808 17 10 0\n" +simple_expect "=1808" + +# Try to create too many conferences + +kom_create_conference "C19" "00000000" "0 { }" + +send "9000 88 [holl "C20"] 00000000 0 { }\n" +simple_expect "%9000 19 20" + + +# Finish + +talk_to client 0 +kom_login 5 "gazonk" 0 +kom_enable 255 + +send "9999 44 0\n" +simple_expect "=9999" + +client_death 0 +lyskomd_death diff --git a/src/server/testsuite/lyskomd.0/connections-cov.exp b/src/server/testsuite/lyskomd.0/connections-cov.exp new file mode 100644 index 0000000000000000000000000000000000000000..9370abe9e6bf720879869c3543efc99b20ad7780 --- /dev/null +++ b/src/server/testsuite/lyskomd.0/connections-cov.exp @@ -0,0 +1,195 @@ +# Supplemental test cases for connections.c +# +# Note: With the MUX support compiled-in, the coverage of this file +# is really low, around 65-66% or so. There is also quite a lot +# of panic code which is never reached. + +# Hard to do +# Connect from a client with not reverse name mapping +# Connect from a client where we can't get the IP number either +# Add more than one client at a time to the kill list + +# Stuff to ignore +# Mux-related garbage + + +read_versions +source "config/prot-a.exp" + +lyskomd_start "" "\ +Open files: 17 +Log statistics: /tmp/swedish/chef/bork/bork/bork/nosuchfile +Nologin file: nologin +" + + +# Attempt to connect with invalid protocol + +client_start 0 +talk_to client 0 +send "B[holl "DejaGnu Test Suite]\n"]" +simple_expect "%%LysKOM unsupported protocol." +client_death 0 + + +# Disconnect a client that has not declared a protocol yes + +client_start 1 +talk_to client 1 + +client_start 0 +talk_to client 0 +kom_connect "DejaGnu Test Suite" +kom_accept_async "0 { }" +kom_create_person "P6" "PW6" "00000000" "0 { }" +kom_login 5 "gazonk" 0 +kom_enable 255 + +send "1000 55 2\n" +simple_expect "=1000" +kom_login 6 "PW6" 0 + +client_death 1 + + +# Kill off three clients with EPIPE + +client_start 1 +talk_to client 1 +kom_connect "DejaGnu Test Suite" +kom_accept_async "1 { 12 }" + +client_start 2 +talk_to client 2 +kom_connect "DejaGnu Test Suite" +kom_accept_async "1 { 12 }" + +client_start 3 +talk_to client 3 +kom_connect "DejaGnu Test Suite" +kom_accept_async "1 { 12 }" + +talk_to client 1 +suspend_client +talk_to client 2 +suspend_client +talk_to client 3 +suspend_client + +talk_to client 0 +send "1001 53 0 [holl "\ +And cattle is their game +And Archer is the name +They give to the acres that they own +If the Brazons don't run dry +And the newborn calves don't die +Another year from Mary will have flown +Another year from Mary will have flown"]\n" +simple_expect "=1001" + +kill_client 1 +kill_client 2 +kill_client 3 + +talk_to client 0 +send "1002 53 0 [holl "\ +Mary Martin was a schoolgirl +Just seventeen or so +When she married Billy Archer +About fourteen years ago +Not even out of high school +Folks said it wouldn't last +But when you grow up in the country +You grow up mighty fast"]\n" +simple_expect "=1002" + + +# Generate a protocol error + +talk_to client 0 +send "We crossed the wild Pecos\n" +simple_expect "%% LysKOM protocol error." + + +# Cause dump_statistics to fail because of bad file name + +dump_statistics + + +# Attempt to create too many connections + +client_start 1 +talk_to client 1 +kom_connect "DejaGnu Test Suite" +kom_accept_async "0 { }" + +client_start 2 +talk_to client 2 +kom_connect "DejaGnu Test Suite" +kom_accept_async "0 { }" + +client_start 3 +talk_to client 3 +kom_connect "DejaGnu Test Suite" +kom_accept_async "0 { }" + +client_start 4 +talk_to client 4 +send "A[holl "DejaGnu Test Suite"]\n" +simple_expect "%% No connections left." + +talk_to client 1 +send "1000 55 0\n" +simple_expect "=1000" +client_death 1 + +talk_to client 2 +send "1000 55 0\n" +simple_expect "=1000" +client_death 2 + +talk_to client 3 +send "1000 55 0\n" +simple_expect "=1000" +client_death 3 + +kill_client 4 + + + +# Check that nologin file actually works + +set fp [open "$srcdir/nologin" "w+"] +close $fp +client_start_fail 1 "%% No logins allowed." +system "rm -f $srcdir/nologin" + +# Finish with lots of clients connected + +client_start 1 +talk_to client 1 +kom_connect "DejaGnu Test Suite" +kom_accept_async "0 { }" + +client_start 2 +talk_to client 2 +kom_connect "DejaGnu Test Suite" +kom_accept_async "0 { }" + +client_start 3 +talk_to client 3 +kom_connect "DejaGnu Test Suite" +kom_accept_async "0 { }" + +talk_to client 0 +kom_login 5 "gazonk" 0 +kom_enable 255 + +send "9999 44 0\n" +simple_expect "=9999" + +client_death 0 +client_death 1 +client_death 2 +client_death 3 +lyskomd_death diff --git a/src/server/testsuite/lyskomd.0/disk-end-of-atomic-cov.exp b/src/server/testsuite/lyskomd.0/disk-end-of-atomic-cov.exp new file mode 100644 index 0000000000000000000000000000000000000000..dd46b33a83429a32ffba1ce8b80161e5690ab383 --- /dev/null +++ b/src/server/testsuite/lyskomd.0/disk-end-of-atomic-cov.exp @@ -0,0 +1,6 @@ +# Supplemental test cases for end-of-atomic + +# Hard to do cause of timing issues +# Start a sync and then issue an atomic call while the server +# is writing data to one of the data files (so sync_part returns FALSE) + diff --git a/src/server/testsuite/lyskomd.0/internal-connections-cov.exp b/src/server/testsuite/lyskomd.0/internal-connections-cov.exp new file mode 100644 index 0000000000000000000000000000000000000000..419cc8b1af6eef50c1ca1d9af1d9f1f065232102 --- /dev/null +++ b/src/server/testsuite/lyskomd.0/internal-connections-cov.exp @@ -0,0 +1,4 @@ +# Supplemental test cases for internal-connections.c + +# No test cases here yet. As of 1999-91-24 the other test cases +# cover all of internal-connections diff --git a/src/server/testsuite/lyskomd.0/isc-parse-cov.exp b/src/server/testsuite/lyskomd.0/isc-parse-cov.exp new file mode 100644 index 0000000000000000000000000000000000000000..f5f8608b016085acf25231e5160b92aa61087ce9 --- /dev/null +++ b/src/server/testsuite/lyskomd.0/isc-parse-cov.exp @@ -0,0 +1,3 @@ +# Supplemental test cases for isc-parse + +# The regular test suide gets 100% coverage diff --git a/src/server/testsuite/lyskomd.0/leaks00.exp b/src/server/testsuite/lyskomd.0/leaks00.exp deleted file mode 100644 index f90f8fec1d1f91e0380a86f062362cfb227bd3fe..0000000000000000000000000000000000000000 --- a/src/server/testsuite/lyskomd.0/leaks00.exp +++ /dev/null @@ -1,30 +0,0 @@ -# Check for memory leaks - -read_versions -source "$srcdir/config/leaks.exp" - -# ---------------------------------------------------------------------- -# Test for leaks in text creation - -startup_leaks -send "1000 86 [holl "Memory leaks suck"] 1 { 0 5 } 1 { 1000 00000000 0 [holl "Aux-items rock!"] }\n" -simple_expect "=1000 1" -shutdown_leaks -read_usage_base - - -startup_leaks -kom_accept_async "2 { 0 15 }" -for { set i 0 } { $i < 200 } { incr i 1 } { - send "[expr 1000 + $i] 86 [holl "Memory leaks suck"] 1 { 0 5 } 1 { 1000 00000000 0 [holl "Aux-items rock!"] }\n" - simple_expect ":16 0\[^\n\]*" - simple_expect ":18 15\[^\n\]*" - simple_expect "=[expr 1000 + $i] [expr 1 + $i]" -} -shutdown_leaks -check_usage "Text creation" "leaks00" - -# Inherit a bunch of aux-items a bunch of levels -# Validate a bunch of aux-items with a regexp - -# Create a bunch of confs diff --git a/src/server/testsuite/lyskomd.0/log-cov.exp b/src/server/testsuite/lyskomd.0/log-cov.exp new file mode 100644 index 0000000000000000000000000000000000000000..25a0a4d39435277691c807578a84d8b9ed0717ed --- /dev/null +++ b/src/server/testsuite/lyskomd.0/log-cov.exp @@ -0,0 +1,3 @@ +# Supplemental test cases for log + +# Regular test suite does the job well enough diff --git a/src/server/testsuite/lyskomd.0/membership-cov.exp b/src/server/testsuite/lyskomd.0/membership-cov.exp new file mode 100644 index 0000000000000000000000000000000000000000..fbf536ad8d16627d3fca9147762cadc6376eccbd --- /dev/null +++ b/src/server/testsuite/lyskomd.0/membership-cov.exp @@ -0,0 +1,354 @@ +# Supplemental tests for membership.c + +# Second iteration (possibly) +# Call to do_sub_member with conf_c, pers_p set to NULL +# Generate a call to access_perm, fast_access_perm with viewer_p set to NULL +# --- I don't think there are any such calls in the server +# Generate a call to locate_member that fails to locate a member +# --- Can't be done unless the membership and member lists are out of sync + +# Stuff to ignore +# Everything in check_membership +# Error statements in DEBUG_MARK_AS_READ +# Membership and member record mismatches + + +source "config/prot-a.exp" +read_versions +lyskomd_start "" "\ +Add members by invitation: false" + + +client_start 0 +talk_to client 0 + +kom_connect "DejaGnu Test Suite" +kom_accept_async "0 { }" + +kom_create_person "P6" "PW6" "00000000" "0 { }" +kom_create_person "P7" "PW7" "00000000" "0 { }" +kom_create_person "P8" "PW8" "00000000" "0 { }" +kom_create_person "P9" "PW9" "00000000" "0 { }" + +kom_login 7 "PW7" 0 +kom_set_conf_type 7 "10110000" + +kom_login 6 "PW6" 0 + +kom_create_conference "C10" "00000000" "0 { }" +kom_create_conference "C11" "00000000" "0 { }" +kom_create_conference "C12" "00000000" "0 { }" +kom_create_conference "C13" "00000000" "0 { }" +kom_create_conference "C14" "10000000" "0 { }" +kom_create_conference "C15" "10100000" "0 { }" +kom_create_conference "C16" "00000000" "0 { }" +kom_add_member 16 6 200 9999 "00000000" + +kom_logout +kom_create_person "P17" "PW17" "00000000" "0 { }" +kom_create_person "P18" "PW18" "00000000" "0 { }" +kom_create_person "P19" "PW19" "00000000" "0 { }" + +kom_login 6 "PW6" 0 +kom_add_member 10 17 200 9999 "00000000" + + +kom_login 9 "PW9" 0 +send "1000 106 9 1\n" +simple_expect "=1000" + +send "1001 100 10 9 100 9999 00000000\n" +simple_expect "=1001" + +send "1002 100 11 9 100 9999 00000000\n" +simple_expect "=1002" + +send "1003 100 12 9 100 9999 00000000\n" +simple_expect "=1003" + +send "1004 86 [holl "T1"] 4 { 0 1 0 10 0 11 0 12 } 0 { }\n" +simple_expect "=1004 1" + +send "1005 86 [holl "T2"] 4 { 0 1 0 10 0 11 0 12 } 0 { }\n" +simple_expect "=1005 2" + +send "1006 86 [holl "T3"] 4 { 0 1 0 10 0 11 0 12 } 0 { }\n" +simple_expect "=1006 3" + +send "1007 27 10 2 { 1 3 }\n" +simple_expect "=1007" + +send "1008 27 11 2 { 1 3 }\n" +simple_expect "=1008" + +send "1009 27 12 2 { 1 3 }\n" +simple_expect "=1009" + +kom_login 6 "PW6" 0 +kom_add_member 10 18 200 9999 "00000000" +kom_add_member 10 19 200 9999 "00000000" + +# Get membership from a person with unread-is-secret set + +kom_login 8 "PW8" 0 + +send "1100 99 9 0 9999 1\n" +simple_expect "=1100 4 { 0 $any_time 9 255 0 0 \\* 0 $any_time 00000000 1 $any_time 10 100 0 0 \\* 9 $any_time 00000000 2 $any_time 11 100 0 0 \\* 9 $any_time 00000000 3 $any_time 12 100 0 0 \\* 9 $any_time 00000000 }" + +# Call add_membership with WHERE set way too high + +kom_login 9 "PW9" 0 + +send "1200 100 13 9 100 9999 00000000\n" +simple_expect "=1200" + + +# Move an existing membership from N to N-2, N-2 to N + +send "1201 100 13 9 100 1 00000000\n" +simple_expect "=1201" + +send "1202 100 13 9 100 4 00000000\n" +simple_expect "=1202" + +send "1203 15 10 9\n" +simple_expect "=1203" + + +# Add a member with priority 0 and fake_passive ON +# This *really* should have been tested in 05.exp! + +send "1300 14 10 9 0 9999\n" +simple_expect "=1300" + +# Restore the flags + +kom_login 9 "PW9" 0 +send "1301 102 9 10 00000000\n" +simple_expect "=1301" + + +# Remove a member from conf X when member is logged on with CWC X + +client_start 1 +talk_to client 1 +kom_connect "DejaGnu Test Suite" +kom_accept_async "1 { 8 }" + +kom_login 6 "PW6" 0 +kom_add_member 10 6 100 9999 00000000 +kom_change_conference 10 + +talk_to client 0 +kom_login 6 "PW6" 0 +send "1401 15 10 6\n" +simple_expect "=1401" + +talk_to client 1 +simple_expect ":1 8 10" +send "1400 55 0\n" +simple_expect "=1400" +client_death 1 + +talk_to client 0 + + +# Remove a membership in the middle of the membership list + +kom_login 9 "PW9" 0 +send "1500 15 11 9\n" +simple_expect "=1500" + + +# Remove a member without being supervisor of conf or person + +kom_login 6 "PW6" 0 +send "1600 100 15 9 100 9999 00000000\n" +simple_expect "=1600" + +send "1601 100 11 9 100 9999 00100000\n" +simple_expect "=1601" + +# Remove with read access to conf and membership + +kom_login 8 "PW8" 0 +send "1602 15 12 9\n" +simple_expect "%1602 12 12" + +# Remove secret conf + +send "1603 15 15 9\n" +simple_expect "%1603 9 15" + +# Remove secret membership + +send "1604 15 11 9\n" +simple_expect "%1604 13 11" + + + +# Add a member to a rd_prot conference without access to conf + +kom_login 8 "Pw8" 0 +send "1700 100 14 8 100 9999 00000000\n" +simple_expect "%1700 11 14" + +# Add a member to a secret conf we don't know about + +send "1701 100 15 8 100 9999 00000000\n" +simple_expect "%1701 9 15" + +# Try to add a member who is already a secret member + +kom_login 9 "PW9" 0 +send "1702 99 9 0 100 0\n" +extracting_expect "=1702 (.*)" tmp 1 +regsub -all "\\*" "$tmp" "\\*" mship + +kom_login 8 "PW8" 0 +send "1703 100 11 9 100 9999 00000000\n" +simple_expect "=1703" + +kom_login 9 "PW9" 0 +send "1704 99 9 0 100 0\n" +simple_expect "=1704 $mship" + +# Try to change someone else's priorities + +kom_login 8 "PW8" 0 +send "1705 100 12 9 200 9999 00000000\n" +simple_expect "%1705 12 9" + + +# Attempt to mark a text as read in a conf the person is not a member of + +kom_login 9 "PW9" 0 + +send "1800 27 1 3 { 1 2 3 }\n" +simple_expect "%1800 13 1" + +# Attempt to mark local text zero as read + +send "1801 27 10 1 { 0 }\n" +simple_expect "%1801 17 0" + +# As person 6 mark text with rcpt,cc,bcc 6 as read + +send "1802 86 [holl "T4"] 2 { 0 6 0 9 } 0 { }\n" +simple_expect "=1802 4" + +send "1803 86 [holl "T5"] 2 { 1 6 0 9 } 0 { }\n" +simple_expect "=1803 5" + +send "1804 86 [holl "T6"] 2 { 15 6 0 9 } 0 { }\n" +simple_expect "=1804 6" + +kom_login 6 "PW6" 0 + +send "1805 27 6 3 { 1 2 3 }\n" +simple_expect "=1805" + + +# Create a conf with 5 text, with conf as CWC +# Create a bunch of texts, read a nonconsecutive range +# Delete all texts in that range and one more +# Read the first existing text + +kom_login 6 "PW6" 0 + +send "1900 86 [holl "T7"] 1 { 0 16 } 0 { }\n" +simple_expect "=1900 7" + +send "1901 86 [holl "T8"] 1 { 0 16 } 0 { }\n" +simple_expect "=1901 8" + +send "1902 86 [holl "T9"] 1 { 0 16 } 0 { }\n" +simple_expect "=1902 9" + +send "1903 86 [holl "T10"] 1 { 0 16 } 0 { }\n" +simple_expect "=1903 10" + +send "1904 86 [holl "T11"] 1 { 0 16 } 0 { }\n" +simple_expect "=1904 11" + +send "1905 2 16\n" +simple_expect "=1905" + +send "1906 27 16 1 { 1 }\n" +simple_expect "=1906" + +send "1907 27 16 1 { 3 }\n" +simple_expect "=1907" + +send "1908 29 7\n" +simple_expect "=1908" + +send "1909 29 8\n" +simple_expect "=1909" + +send "1910 29 9\n" +simple_expect "=1910" + +send "1911 29 10\n" +simple_expect "=1911" + +send "1912 27 16 1 { 5 }\n" +simple_expect "=1912" + + +# Try to get the membership of a secret person + +kom_login 6 "PW6" 0 + +send "2000 99 7 0 9999 0\n" +simple_expect "%2000 10 7" + +# Try to get membership with first WAY too high + +send "2001 99 6 999 9999 0\n" +simple_expect "%2001 19 999" + + +# Try to get the members of a secret conference + +kom_login 8 "PW8" 0 + +send "2100 101 15 0 9999\n" +simple_expect "%2100 9 15" + + +# Call set-unread on a conf we are not a member of +# Call set-last-read on a conf we are not a member of + +kom_login 8 "PW8" 0 + +send "2200 40 10 0\n" +simple_expect "%2200 13 10" + +send "2201 77 10 1\n" +simple_expect "%2201 13 10" + + +# Call set-membership-type for a secret conf we are not member of +# Call set-membership-type for an open conf we are not member of + +send "2300 102 8 15 00000000\n" +simple_expect "%2300 9 15" + +send "2301 102 8 10 00000000\n" +simple_expect "%2301 13 10" + + + +# ====================================================================== +# Shut it all down + + +kom_login 5 "gazonk" 0 +kom_enable 255 + +send "9999 44 0\n" +simple_expect "=9999" + +client_death 0 +lyskomd_death diff --git a/src/server/testsuite/lyskomd.0/memory-cov.exp b/src/server/testsuite/lyskomd.0/memory-cov.exp new file mode 100644 index 0000000000000000000000000000000000000000..f6cb52d5985d629649e873984342631dac512991 --- /dev/null +++ b/src/server/testsuite/lyskomd.0/memory-cov.exp @@ -0,0 +1,16 @@ +# Supplemental test cases to exercise memory.c + +# Call copy_aux_item_list with a non-empty aux_item_list +# -- Probably has to be called from the garb + +# Stuff we can't call +# -- Call to clear_mark_list with mark_list set to NULL +# -- Call to clear_member_list with member_list set to NULL +# -- Call to clear_membership with membership set to NULL +# -- Call to clear_membership_list with membership set to NULL +# -- Call to clear_text_stat when misc-info-list contains junk + +# Stuff that gets called when we get coverage elsewhere +# -- copy_text_stat + +# Nothing more to do then... diff --git a/src/server/testsuite/lyskomd.0/person-cov.exp b/src/server/testsuite/lyskomd.0/person-cov.exp new file mode 100644 index 0000000000000000000000000000000000000000..9c624e27cf371ccaca2833bd0419be97b94c0327 --- /dev/null +++ b/src/server/testsuite/lyskomd.0/person-cov.exp @@ -0,0 +1,490 @@ +# Supplemental test cases for person.c + +# X Attempt to mark a text in a secret conference +# X Attempt to mark a text in an rd_prot conference +# X Attempt to mark a text when it has reached the mark limit +# X Attempt to unmark a text that has zero marks + +# X Attempt to set the user area to a text that has reached mark limit +# X Set a user area when there already is a user area +# X Set a user area when the current user area has zero marks +# X Set a user area when the current user area is deleted +# X Attempt to set-user-area for a secret person +# X Attempt to ser-user-area for a person we don't have rights to + +# X Delete a person that has marked texts +# X Delete a person that has a marked text that has zero marks +# X Delete a person whose user area is deleted + +# X Try to log in with incorrect password + +# X Try to create a person before login with param.create_person_before_login set +# X Try to create a person without the privs to do so +# X Try to create a person with zero-length name +# X Try to create a person with a non-printable character in the name +# X Try to create a person with the name of a person already there +# X Try to create a person with a password containing a NUL +# X Create a person with an invalid aux-item-list +# X Create persons so we hit the max number of confs + +# X get-pers-stat for person with secret letterbox +# X get-pers-stat-old for person with secret letterbox + +# X get-created-texts for a person with secret letterbox + +# X Request 256 texts from map-created-texts + +# X Call map-created-texts for a secret person + +# X Attempt to change someone else's password +# X Attempt to change password to one containing a NUL + +# X Attempt to query-read-texts for a secret person +# X Attempt to query-read-texts for a secret conference +# X Attempt to query-read-texts for an open conf we are not member of +# X Attempt to query-read-texts for someone else's secret membership +# X Attempt to query-read-texts for a person with unread_is_secret set + +# X Call set-pers-flags for self +# X Call set-pers-flags for supervised person +# X Call set-pers-flags as administrator +# X Call set-pers-flags for a secret person we may not know about +# X Call set-pers-flags for person 0 +# X Call set-pers-flags for someone else + + +# Hard to do +# All the restart_kom calls... +# Fail to create the password string in legal_passwd +# Call to do_mark_text with pers_p equal NULL +# Call to do_mark_text with text_s equal to NULL +# Call to do_unmark_text with pers_p equal NULL +# Call to do_set_user_area with pers_p equal NULL +# In do_delete_person fail to remove the person as a member in a conf +# -- Happens if the member/membership correspondence is FUBAR +# Fail to create the password string in chk_passwd +# Failure in cached_create_person (bloddy thing can't fail!) +# Failure in cached_get_person_stat +# Failure in do_set_passwd +# Failure in access_perm + +read_versions +source "config/prot-a.exp" + +lyskomd_start "" "" "\ +Aux-item definition file: lyskomd.0/aux-items.conf +Max conferences: 18 +Max texts: 2000 +Max marks per text: 1 +Max conference name length: 60 +Anyone can create new persons: false +Allow creation of persons before login: false +" + +client_start 0 +talk_to client 0 +kom_connect "DejaGnu Test Suite" +kom_accept_async "0 { }" + +kom_login 5 "gazonk" 0 +kom_enable 255 +kom_create_person "P6" "PW6" "00000000" "0 { }" +kom_create_person "P7" "PW7" "00000000" "0 { }" +kom_create_person "P8" "PW8" "00000000" "0 { }" +kom_create_person "P9" "PW9" "00000000" "0 { }" + +kom_set_conf_type 7 "10110000" +kom_set_priv_bits 6 "0001110000000000" + + +kom_login 6 "PW6" 0 +kom_create_conference "C10" "00000000" "0 { }" +kom_create_conference "C11" "00000000" "0 { }" +kom_create_conference "C12" "00000000" "0 { }" +kom_create_conference "C13" "10000000" "0 { }" +kom_create_conference "C14" "10100000" "0 { }" + +kom_add_member 11 6 100 9999 00100000 +kom_add_member 14 6 100 9999 00100000 +kom_add_member 14 7 100 9999 00000000 +kom_add_member 10 7 100 9999 00000000 +kom_add_member 10 9 100 9999 00000000 + + +# Tests for text marking + +kom_login 6 "PW6" 0 + +send "1000 86 [holl "T1"] 1 { 0 14 } 0 { }\n" +simple_expect "=1000 1" +send "1001 86 [holl "T2"] 1 { 0 13 } 0 { }\n" +simple_expect "=1001 2" +send "1002 86 [holl "T3"] 1 { 0 10 } 0 { }\n" +simple_expect "=1002 3" + + +# Attempt to mark a text in a secret conference we don't know about + +kom_login 8 "PW8" 0 + +send "1003 72 1 0\n" +simple_expect "%1003 14 1" + +# Attempt to mark a text in an rd_prot conference we're not members of + +send "1004 72 2 0\n" +simple_expect "%1004 14 2" + +# Attempt to mark beyond mark-limit + +send "1005 72 3 0\n" +simple_expect "=1005" + +kom_login 9 "PW9" 0 +send "1006 72 3 0\n" +simple_expect "%1006 36 3" + +# Attempt to unmark a text that has zero mark count but is marked + +kom_login 8 "PW8" 0 + +send "1007 1001 3 0\n" +simple_expect "=1007" + +send "1008 73 3\n" +simple_expect "=1008" + + + +# Tests for set-user-area + +# Attempt to set the user area to a text that has reached mark limit +# Set a user area when there already is a user area +# Set a user area when the current user area has zero marks +# Set a user area when the current user area is deleted +# Attempt to set-user-area for a secret person +# Attempt to ser-user-area for a person we don't have rights to + +kom_login 6 "PW6" 0 + +send "2000 86 [holl "T4"] 1 { 0 10 } 0 { }\n" +simple_expect "=2000 4" + +send "2001 86 [holl "T5"] 1 { 0 10 } 0 { }\n" +simple_expect "=2001 5" + +send "2002 86 [holl "T6"] 1 { 0 10 } 0 { }\n" +simple_expect "=2002 6" + + +# Attempt to set a user area that has reached mark-limit + +kom_login 8 "PW8" 0 + +send "2003 72 4 1\n" +simple_expect "=2003" + +send "2004 57 8 4\n" +simple_expect "%2004 36 4" + + +# Set a user area when there already is a user area + +send "2005 57 8 5\n" +simple_expect "=2005" + +send "2006 57 8 6\n" +simple_expect "=2006" + + +# Set a user area when the current one has zero marks + +send "2007 1001 6 0\n" +simple_expect "=2007" + +send "2008 57 8 5\n" +simple_expect "=2008" + + +# Set a user area when the current one has been deleted + +kom_login 6 "PW6" 0 +send "2009 29 5\n" +simple_expect "=2009" +kom_login 8 "PW8" 0 + +send "2010 57 8 6\n" +simple_expect "=2010" + + +# Attempt to set the user area for a secret person + +send "2011 57 7 6\n" +simple_expect "%2011 10 7" + + +# Attempt to set the user area for another person we don't have rights to + +send "2012 57 9 6\n" +simple_expect "%2012 12 9" + + + +# Tests for deleting a person + +kom_login 6 "PW6" 0 +kom_create_person "P15" "PW15" "00000000" "0 { }" + +kom_login 15 "PW15" 0 +send "3000 86 [holl "T7"] 1 { 0 10 } 0 { }\n" +simple_expect "=3000 7" +send "3001 86 [holl "T8"] 1 { 0 10 } 0 { }\n" +simple_expect "=3001 8" +send "3002 86 [holl "T9"] 1 { 0 10 } 0 { }\n" +simple_expect "=3002 9" + +send "3003 72 7 1\n" +simple_expect "=3003" +send "3004 72 8 1\n" +simple_expect "=3004" + +send "3006 1001 8 0\n" +simple_expect "=3006" + +send "3007 57 15 9\n" +simple_expect "=3007" + +send "3008 29 9\n" +simple_expect "=3008" + +# The setup at this point is +# Person 15 has user area 9, which is deleted +# Person 15 has marked text 8 and 9 +# Text 9 has had its mark count set to zero + +# Delete a user who has marked texts, whose user area is +# deleted and who has a text marked that has zero marks + +send "3009 11 15\n" +simple_expect "=3009" + + +# Login stuff. Try to log in with the bad password + +send "4000 62 6 [holl "BADPWD"] 0\n" +simple_expect "%4000 4 6" + + +# Create person stuff + +# Try to create a person without logging in when that's not allowed + +kom_logout +send "5000 89 [holl "PXX"] [holl "PXX"] 00000000 0 { }\n" +simple_expect "%5000 6 0" + +# Try to create a person without the privs to do so + +kom_login 8 "PW8" 0 +send "5001 89 [holl "PXX"] [holl "PXX"] 00000000 0 { }\n" +simple_expect "%5001 12 0" + +# Try to create a person with an empty name + +kom_login 6 "PW6" 0 +send "5002 89 [holl ""] [holl "PXX"] 00000000 0 { }\n" +simple_expect "%5002 18 0" + +# Try to create a person with a non-printable character in the name + +send "5003 89 [holl "X\001Y"] [holl "PXX"] 00000000 0 { }\n" +simple_expect "%5003 18 0" + +# Try to create a person with a duplicate name + +send "5004 89 [holl "P6"] [holl "PWX"] 00000000 0 { }\n" +simple_expect "%5004 21 0" + +# Try to create a person with a password with a NUL +# Stupid TCL sort of FORGETS about the string after the NUL +# +# send "5005 89 [holl "PXX"] [holl "P\000X"] 00000000 0 { }\n" +# simple_expect "%5005 18 0" + +# Attempt to create a person with an invalid aux-item list + +kom_login 6 "PW6" 0 +send "5006 89 [holl "PXX"] [holl "PYY"] 00000000 1 { 0 00000000 0 [holl "A"] }\n" +simple_expect "%5006 48 0" + +# Create persons til we hit the max number of confs + +kom_login 6 "PW6" 0 +send "5006 89 [holl "P16"] [holl "PW16"] 00000000 0 { }\n" +simple_expect "=5006 17" + +send "5007 89 [holl "P17"] [holl "PW17"] 00000000 0 { }\n" +simple_expect "%5007 19 18" + + +# Tests for get-pers-stat + +send "6000 49 7\n" +simple_expect "%6000 10 7" + +send "6001 6 7 1\n" +simple_expect "%6001 10 7" + + +# Tests for get-created-texts + +send "7000 47 7 0 9999\n" +simple_expect "%7000 10 7" + + +# Test for map-created-texts + +# Try to get too many entries + +send "7001 104 6 1 256\n" +simple_expect "%7001 46 255" + +# Try to get created texts for a secret person + +send "7002 104 7 1 10\n" +simple_expect "%7002 10 7" + +# Attempt to change someone else's password + +kom_login 8 "PW8" 0 +send "8000 8 9 [holl "PW9"] [holl "9PW"]\n" +simple_expect "%8000 12 9" + +# Attempt to change password to one with a NUL +# Stupid TCL truncates the password at the NUL +# +# send "8001 8 [holl "PW8"] [holl "A\000B"]\n" +# simple_expect "%8001 4 8" + + +# Tests for query-read-texts + +kom_login 8 "PW8" 0 + +# Attempt to query-read-texts for a secret person + +send "9000 98 7 10\n" +simple_expect "%9000 10 7" + +# Attempt to query-read-texts for a secret conference on an open person + +send "9001 98 6 14\n" +simple_expect "%9001 9 14" + +# Attempt to query-read-texts for a conference we're not a member of + +send "9002 98 8 10\n" +simple_expect "%9002 13 10" + +# Attempt to query-read-texts for someone else's secret membership + +send "9003 98 6 11\n" +simple_expect "%9003 13 11" + +# Attempt to query-read-texts for a person with unread_is_secret set + +kom_login 5 "gazonk" 0 +kom_enable 255 + +kom_add_member 10 9 100 9999 00000000 +send "9004 106 9 10000000\n" +simple_expect "=9004" +send "9005 86 [holl "T10"] 1 { 0 10 } 0 { }\n" +simple_expect "=9005 10" +kom_login 9 "PW9" 0 +send "9006 27 10 2 { 1 2 }\n" +simple_expect "=9006" + +kom_login 6 "PW6" 0 +send "9007 98 9 10\n" +simple_expect "=9007 1 $any_time 10 100 0 0 \\* 6 $any_time 00000000" + + +# Tests on set-pers-flags + +kom_login 9 "PW9" 0 + +send "10000 49 9\n" +extracting_expect "=10000 \[0-9\]+H.* \[01\]+ 10000000 (.*)" pers 1 + +# Call on self + +send "10001 106 9 10011001\n" +simple_expect "=10001" + +send "10001 49 9\n" +simple_expect "=10001 \[0-9\]+H.* \[01\]+ 10011001 $pers" + +# Call on supervised person + +kom_login 5 "gazonk" 0 +kom_enable 0 + +send "10002 106 9 01100110\n" +simple_expect "=10002" + +send "10002 49 9\n" +simple_expect "=10002 \[0-9\]+H.* \[01\]+ 01100110 $pers" + + +# Call as administrator + +kom_login 5 "gazonk" 0 +kom_enable 255 + +send "10003 106 9 11000011\n" +simple_expect "=10003" + +send "10003 49 9\n" +simple_expect "=10003 \[0-9\]+H.* \[01\]+ 11000011 $pers" + + +# Call on secret person we don't know about + +kom_login 8 "PW8" 0 +send "10004 106 7 01010101\n" +simple_expect "%10004 10 7" + +kom_login 5 "gazonk" 0 +kom_enable 0 +send "10005 49 7\n" +simple_expect "=10005 \[0-9\]+H.* \[01\]+ 00000000 .*" + +# Call on person 0 + +send "10006 106 0 01110111\n" +simple_expect "%10006 8 0" + +# Call on non-supervised person + +kom_login 8 "PW8" 0 +send "10007 106 9 10101010\n" +simple_expect "%10007 12 9" + +send "10008 49 9\n" +simple_expect "=10008 \[0-9\]+H.* \[01\]+ 11000011 $pers" + + + +# ============================================================ +# Shut it down + +talk_to client 0 +kom_login 5 "gazonk" 0 +kom_enable 255 + +send "99999 44 0\n" +simple_expect "=99999" + +client_death 0 +lyskomd_death diff --git a/src/server/testsuite/lyskomd.0/prot-a-parse-cov.exp b/src/server/testsuite/lyskomd.0/prot-a-parse-cov.exp new file mode 100644 index 0000000000000000000000000000000000000000..0986ee96d314f7ffa91f92c2a41964ef502230fb --- /dev/null +++ b/src/server/testsuite/lyskomd.0/prot-a-parse-cov.exp @@ -0,0 +1,220 @@ +# Supplemental test cases for prot-a-parse.c + + +# Not done yet +# Try to send a long string that is split into packages +# Try to send a string that will get truncated and that gets sent +# in several packages +# These trigger the branches that longjump to ISC_MSG_INCOMPLETE +# I think. But I'm not sure. + +source "config/prot-a.exp" +read_versions + +proc protocol_error {} { + simple_expect "%% LysKOM protocol error." +} + +lyskomd_start "" "\ +Max password length: 8 +Max aux_items deleted per call: 1 +Max aux_items added per call: 1 +Max text length: 100 +" + +# Send an insane token length + +client_start 0 +talk_to client 0 +kom_connect "DejaGnu Test Sweet" +kom_accept_async "0 { }" +hose_client +simple_expect "%%Insane token length." +client_death 0 + + +# Send some numbers followed by alphanumerics + +client_start 0 +talk_to client 0 +kom_connect "DejaGnu Test Bitter" +kom_accept_async "0 { }" +send "1POPGOESTHEWEASEL 9999\n" +protocol_error + + +# Send a negative array size + +send "1000 80 -1 { 1 }\n" +simple_expect "%%Insane array size." +client_death 0 + + +# Forget the opening curly of an array + +client_start 0 +talk_to client 0 +kom_connect "DejaGnu Test Bitter" +kom_accept_async "0 { }" + +send "1001 80 1 1 }\n" +protocol_error + +# Forget the closing curly (or get the length wrong) + +send "1002 80 1 { 1 10 }\n" +protocol_error + +# For completeness, specify the array as longer than it is + +send "1003 80 9 { 1 10 }\n" +protocol_error + + +# Send priv bits that are too short and too long + +send "1004 7 5 000000000000000\n" +protocol_error + +send "1005 7 5 00000000000000000\n" +protocol_error + +# Send membership type that is not eight bits long + +send "1006 102 5 5 0000000\n" +protocol_error + +send "1007 102 5 5 000000000\n" +protocol_error + +# Send conf type that is not four or eight bits long + +send "1008 21 5 000\n" +protocol_error + +send "1009 21 5 00000\n" +protocol_error + +send "1010 21 5 0000000\n" +protocol_error + +send "1011 21 5 000000000\n" +protocol_error + + +# Send a negative string length + +send "1012 62 5 -6Hgazonk 0\n" +simple_expect "%%Insane string length." +client_death 0 + +client_start 0 +talk_to client 0 +kom_connect "DejaGnu Test Bitter" +kom_accept_async "0 { }" + +# Try to send a string without an H, with a Q + +send "1013 62 5 Hgazonk 0\n" +protocol_error + +send "1014 62 5 6Qgazonk 0\n" +protocol_error + +# Send a long string + +send "1015 86 [holl "This +is +a +test +of +something +I +think"] 0 { } 0 { }\n" +simple_expect "%1015 6 0" + +send "1015 86 [holl "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +XXXXXXXXXXXXXXXXXXXX +XXXXXXXXXXXXXXXXXXXX +XXXXXXXXXXXXXXXXXXXX +XXXXXXXXXXXXXXXXXXXX +XXXXXXXXXXXXXXXXXXXX"] 0 { } 0 { }\n" +simple_expect "%1015 6 0" + + + +# Sent a short or long aux-item-flags + +send "1015 86 [holl "Text"] 0 { } 1 { 1 0000000 0 [holl "A"] }\n" +protocol_error + +send "1016 86 [holl "Text"] 0 { } 1 { 1 000000000 0 [holl "A"] }\n" +protocol_error + + +# Forget opening brace in aux-item-list, closing brace, too long array +# negative length + +send "1016 86 [holl "Text"] 0 { } 1 1 00000000 0 [holl "A"] }\n" +protocol_error + +send "1017 86 [holl "Text"] 0 { } 1 { 1 00000000 0 [holl "A"] 1 00000000 0 [holl "A"] }\n" +protocol_error + +send "1018 86 [holl "Text"] 0 { } 2 { 1 00000000 0 [holl "A"] }\n" +protocol_error + +send "1019 86 [holl "Text"] 0 { } -1 { 1 00000000 0 [holl "A"] }\n" +simple_expect "%%Insane array size." +client_death 0 +client_start 0 +kom_connect [holl "DejaGnu Test Suite"] +kom_accept_async "0 { }" + +# Try to send a long aux-item list + +send "1020 92 1 10 { 1 2 3 4 5 6 7 8 9 10 } 0 { }\n" +simple_expect "%1020 6 0" +setup_xfail "*" +fail "Exceed max num_list length" + +send "1021 92 1 0 { } 2 { 1 00000000 0 [holl "A"] 2 00000000 0 [holl "B"] }\n" +protocol_error + + +# Send a misc-info list that contains an invalid item and a footn_to +# (Yes, footn_to is untested in 00-06.exp!) + +send "1021 86 [holl "TX"] 2 { 4 10 999 999 } 0 { }\n" +protocol_error + + +# Tests for prot_a_hunt_nl + +send "1100 9999 A\n" +protocol_error + +send "1101 9999 [holl "Data"] [holl "End +of +Data"]\n" +simple_expect "%1101 2 0" + +send "1102 9999 1 { 12 } \r\t 1234\n" +simple_expect "%1102 2 0" + + +send "1103 9999 ERROR\n" +protocol_error + +# Finish + +talk_to client 0 +kom_login 5 "gazonk" 0 +kom_enable 255 + +send "9999 44 0\n" +simple_expect "=9999" + +client_death 0 +lyskomd_death diff --git a/src/server/testsuite/lyskomd.0/prot-a-send-async-cov.exp b/src/server/testsuite/lyskomd.0/prot-a-send-async-cov.exp new file mode 100644 index 0000000000000000000000000000000000000000..f801134df683e0ee75f62a77dfd891a836ec3aff --- /dev/null +++ b/src/server/testsuite/lyskomd.0/prot-a-send-async-cov.exp @@ -0,0 +1,37 @@ +# Supplemental test cases for prot-a-send-async + +read_versions +source "config/prot-a.exp" + +lyskomd_start "" " +Open files: 15" + +client_start 0 +talk_to client 0 +kom_connect [holl "DejaGnu Test Suite"] +kom_accept_async "1 { 11 }" + +client_start 1 +talk_to client 1 +kom_connect [holl "DejaGnu Test Suite"] +kom_accept_async "0 { }" + +client_start 2 +talk_to client 2 +send "A[holl "DejaGnu Test Suite"]\n" +simple_expect "%% No connections left." +kill_client 2 + +talk_to client 0 +simple_expect ":0 11" + +kom_login 5 "gazonk" 0 +kom_enable 255 + +send "1000 44 0\n" +simple_expect "=1000" + +client_death 1 +client_death 0 + +lyskomd_death diff --git a/src/server/testsuite/lyskomd.0/send-async-cov.exp b/src/server/testsuite/lyskomd.0/send-async-cov.exp new file mode 100644 index 0000000000000000000000000000000000000000..650409812a4b7e701da4bf71e6549f854d7742ed --- /dev/null +++ b/src/server/testsuite/lyskomd.0/send-async-cov.exp @@ -0,0 +1,151 @@ +# Supplemental test cases for send-async.c + +# Note: We can't get good coverage of this file since there +# is lots of code that checks for protocol A. This code +# is never run. + + +source "config/prot-a.exp" + +read_versions +lyskomd_start "" " +Send async: on +Open files: 15" + +client_start 0 +talk_to client 0 +kom_connect "DejaGnu Test Suite" + +client_start 1 +talk_to client 1 +kom_connect "DejaGnu Test Suite" +kom_accept_async "0 { }" +kom_create_person "P6" "PW6" 00000000 "0 { }" +kom_login 6 "PW6" 1 + + +talk_to client 0 +kom_accept_async "14 { 0 5 6 7 8 9 11 12 13 14 15 16 17 18 }" + +# Test async 9 + +send "1000 62 5 [holl "gazonk"] 0\n" +simple_expect ":2 9 5 1" +simple_expect "=1000" + +# Test async 0 and 15 + +send "1001 86 [holl "T1"] 1 { 0 5 } 0 { }\n" +simple_expect ":16 0 1 $any_time 5 0 2 0 2 { 0 5 6 1 }" +simple_expect ":18 15 1 $any_time 5 0 2 0 2 { 0 5 6 1 } 0 \\*" +simple_expect "=1001 1" + +send "1001 86 [holl "T2"] 1 { 0 5 } 0 { }\n" +simple_expect ":16 0 2 $any_time 5 0 2 0 2 { 0 5 6 2 }" +simple_expect ":18 15 2 $any_time 5 0 2 0 2 { 0 5 6 2 } 0 \\*" +simple_expect "=1001 2" + +# Test async 5 + +send "1002 3 5 [holl "Nameless Thing"]\n" +simple_expect ":3 5 5 26HAdministratör \\(för\\) LysKOM [holl "Nameless Thing"]" +simple_expect "=1002" + +# Test async 6 + +send "1003 4 [holl "Testing"]\n" +simple_expect ":5 6 5 0 1 [holl "Testing"] ${any_num}H.*" +simple_expect "=1003" + +# Test async 7 +kom_enable 255 +send "1004 43\n" +simple_expect ":0 7" +simple_expect ":0 7" +simple_expect "=1004" + + +# Test async 8 + +kom_add_member 1 6 100 0 00000000 +talk_to client 1 +kom_accept_async "1 { 8 }" +talk_to client 0 +kom_enable 255 +send "1100 15 1 6\n" +simple_expect "=1100" +talk_to client 1 +simple_expect ":1 8 1" +talk_to client 0 +kom_enable 0 + + +# Test async 12 + +send "1200 53 0 [holl "Message"]\n" +simple_expect ":3 12 0 5 [holl "Message"]" +simple_expect "=1200" + + +# Test async 13 + +send "1201 1\n" +simple_expect ":2 13 5 1" +simple_expect "=1201" + +send "1202 62 5 [holl "gazonk"] 0\n" +simple_expect ":2 9 5 1" +simple_expect "=1202" + + +# Test async 14 + +send "1300 29 1\n" +simple_expect ":18 14 1 $any_time 5 0 2 0 2 { 0 5 6 1 } 0 \\*" +simple_expect "=1300" + + +# Test async 16 + +send "1400 30 2 4 0\n" +simple_expect ":3 16 2 4 0" +simple_expect "=1400" + + +# Test async 17 + +send "1500 31 2 4\n" +simple_expect ":3 17 2 4 0" +simple_expect "=1500" + + +# Test async 18 + +send "1600 100 4 5 100 0 00000000\n" +simple_expect ":2 18 5 4" +simple_expect "=1600" + + +kom_accept_async "0 { }" +kom_login 5 "gazonk" 0 +kom_enable 255 +kom_accept_async "1 { 11 }" + +# Test async 11 + +client_start 2 +talk_to client 2 +send "A[holl "Reject Me"]\n" +simple_expect "%% No connections left." +kill_client 2 + +talk_to client 0 +simple_expect ":0 11" + + +send "9999 44 0\n" +simple_expect "=9999" + +client_death 1 +client_death 0 +lyskomd_death diff --git a/src/server/testsuite/lyskomd.0/session-cov.exp b/src/server/testsuite/lyskomd.0/session-cov.exp new file mode 100644 index 0000000000000000000000000000000000000000..f902be0567389b12532f53da119ba34e0bcfb99c --- /dev/null +++ b/src/server/testsuite/lyskomd.0/session-cov.exp @@ -0,0 +1,80 @@ +# Additional test cases for session.c + +source "config/prot-a.exp" +read_versions + +lyskomd_start "" "\ +Max client data length: 10 +Log login: true +Max what am I doing length: 10 +" + +client_start 0 +talk_to client 0 +kom_connect "DejaGnu Test Suite" +kom_accept_async "0 { }" +kom_create_person "P6" "PW6" "00000000" "0 { }" +kom_create_person "P7" "PW7" "00000000" "0 { }" + + +client_start 1 +talk_to client 1 +kom_connect "DejaGnu Test Suite" +kom_accept_async "0 { }" +kom_login 7 "PW7" 0 + + +talk_to client 0 + +kom_login_old 6 "PW6" +send "1000 4 [holl "Halley came to Jackson in 1912"]\n" +simple_expect "%1000 5 10" + +send "1001 54 9999\n" +simple_expect "%1001 42 9999" + +send "1002 84 9999\n" +simple_expect "%1002 42 9999" + +send "1003 64 9999\n" +simple_expect "%1003 42 9999" + +send "1004 55 9999\n" +simple_expect "%1004 42 9999" + +send "1005 55 2\n" +simple_expect "%1005 12 2" + +send "1006 69 [holl "She ain't go no hair"] [holl "0.0"]\n" +simple_expect "%1006 5 10" + +send "1007 69 [holl "Iko Iko"] [holl "\ +The Tennessee stud was long and lean +the color of the sun and his eyes were green. +He had the nerve and he had the blood +There never was a horse like the Tennessee stud.\ +"]\n" +simple_expect "%1007 5 10" + + +send "1008 70 9999\n" +simple_expect "%1008 42 9999" + +send "1009 71 9999\n" +simple_expect "%1009 42 9999" + + +talk_to client 1 +send "9998 55 0\n" +simple_expect "=9998" + +talk_to client 0 +kom_login 5 "gazonk" 0 +kom_enable 255 + +send "9999 44 0\n" +simple_expect "=9999" + +client_death 0 +client_death 1 +lyskomd_death diff --git a/src/server/testsuite/lyskomd.0/text-cov.exp b/src/server/testsuite/lyskomd.0/text-cov.exp new file mode 100644 index 0000000000000000000000000000000000000000..881fe1f4ba86c06406d7c395d237db05ce89cc0b --- /dev/null +++ b/src/server/testsuite/lyskomd.0/text-cov.exp @@ -0,0 +1,1058 @@ +# More coverage of text.c + +# SECOND ITERATION +# Calls to sender, is_sender and is_comm_sender +# Check the jubel crap +# Module test greater +# Make do_add_comment fail +# Make do_add_footnote fail +# Do get-last-text with... +# No text 0. No text 1. No text 3. Text 4 newer. Text 5 newer. + + +# MISSING +# Call add_recipient when the misc-info list has an invalid item +# Call to is_member_in_recpt when the misc-info list has an invalid item +# Call to do_delete_misc with invalid misc item in list +# Call to do_sub_recpt with invalud misc item in list +# Call to skip_recpt with invalid misc item in list +# Call to check_double_subm with invalid misc item in list +# Call to filter_secret_info with invalid misc item in list +# Call to check_double_subm with invalid misc item in list +# Call to create_text_add_miscs with invalid misc item in list +# Attempt to delete a text with misc-item list that starts with loc_no +# ----Add debug call to add arbitrary (invalid) misc item anywhere +# Call to do_delete_misc with loc that is out of range +# ----Add debug call to delete specific misc item +# Call to do_sub_recpt without text_s +# ----Can't be done in the server right now +# Call to do_sub_comment with text_s set to NULL +# ----Can't be done in the server right now +# Call to do_sub_comment with parent_s set to NULL +# ----Can't be done in the server right now +# Call to do_sub_comment when there is no comment +# ----Can't be done in the server right now +# Call to do_sub_comment when there is a comm-to but no comm-in link +# ----Can't be done in the server right now +# Same stuff to do_sub_footnote +# Call to locate_mark with nonexistant person +# ----Can't be done in current server +# Call to filter_secret_info with viewer_p set to NULL +# ----Can't be done in current server +# Call to text_read_access with text_stat NULL +# ----Can't be done in current server +# Attempt to delete a recipient where do_sub_recpt fails +# Fail to get the text stat of a newly created text + + +read_versions +source "config/prot-a.exp" + +lyskomd_start "" "\ +Max footnotes per text: 3 +Max comments per text: 3 +Max recipients per text: 8 +Max super_conf loop: 3 +Max text length: 40 +Jubel: 9 1 +Jubel: 9 2 0" + +client_start 0 +talk_to client 0 + +kom_connect "DejaGnu Test Suite" +kom_accept_async "0 { }" + +kom_create_person "P6" "PW6" "00000000" "0 { }" +kom_create_person "P7" "PW7" "00000000" "0 { }" +kom_create_person "P8" "PW8" "00000000" "0 { }" +kom_create_person "P9" "PW9" "00000000" "0 { }" + +kom_login 6 "PW6" 0 +kom_create_conference "C10" "00001000" "0 { }" +kom_create_conference "C11" "00001000" "0 { }" +kom_create_conference "C12" "00001000" "0 { }" +kom_create_conference "C13" "00001000" "0 { }" +kom_create_conference "C14" "00001000" "0 { }" + +kom_create_conference "C15" "00000000" "0 { }" +kom_create_conference "C16 (rd-prot)" "10000000" "0 { }" +kom_create_conference "C17 (secret)" "10100000" "0 { }" + +kom_create_conference "C18 (no-anon)" "00000000" "0 { }" +kom_create_conference "C19" "00000000" "0 { }" + +kom_set_permitted_submitters 18 5 +kom_set_permitted_submitters 19 5 +kom_set_super_conf 18 19 +kom_set_super_conf 19 0 + +kom_create_conference "C20" "00000000" "0 { }" +kom_create_conference "C21" "00000000" "0 { }" +kom_create_conference "C22" "00000000" "0 { }" +kom_create_conference "C23" "00000000" "0 { }" +kom_create_conference "C24" "00000000" "0 { }" +kom_create_conference "C25" "00000000" "0 { }" +kom_create_conference "C26" "00000000" "0 { }" + +kom_set_permitted_submitters 20 5 +kom_set_permitted_submitters 21 5 +kom_set_permitted_submitters 22 5 +kom_set_permitted_submitters 23 5 +kom_set_permitted_submitters 24 5 +kom_set_permitted_submitters 25 5 + +kom_set_super_conf 20 21 +kom_set_super_conf 21 22 +kom_set_super_conf 22 23 +kom_set_super_conf 23 24 +kom_set_super_conf 24 25 +kom_set_super_conf 25 26 +kom_set_super_conf 26 0 + +kom_create_conference "C27 (secret)" "10100000" "0 { }" + + + +# Check that jubel is denied two ways from tuesday + +kom_login 9 "PW9" 0 +send "1000 86 [holl "T1 (oops)"] 1 { 0 10 } 0 { }\n" +simple_expect "%1000 45 0" + +# Check that max footnotes is enforced in create text + +kom_login 6 "PW6" 0 + +send "1000 86 [holl "T1"] 1 { 0 10 } 1 { 10000 01000000 2 [holl "A1"] }\n" +simple_expect "=1000 1" + +send "1001 86 [holl "F11"] 2 { 0 10 4 1 } 0 { }\n" +simple_expect "=1001 2" + +send "1002 86 [holl "F12"] 2 { 0 10 4 1 } 0 { }\n" +simple_expect "=1002 3" + +send "1003 86 [holl "F13"] 2 { 0 10 4 1 } 0 { }\n" +simple_expect "=1003 4" + +send "1004 86 [holl "F14"] 2 { 0 10 4 1 } 0 { }\n" +simple_expect "%1004 35 1" + + +# Check that max comments is enforced in create text + +send "1100 86 [holl "T5"] 1 { 0 10 } 0 { }\n" +simple_expect "=1100 5" + +send "1101 86 [holl "C51"] 2 { 0 10 2 1 } 0 { }\n" +simple_expect "=1101 6" + +send "1102 86 [holl "C52"] 2 { 0 10 2 1 } 0 { }\n" +simple_expect "=1102 7" + +send "1103 86 [holl "C53"] 2 { 0 10 2 1 } 0 { }\n" +simple_expect "=1103 8" + +send "1104 86 [holl "C54"] 2 { 0 10 2 1 } 0 { }\n" +simple_expect "%1104 34 1" + + + +send "1200 86 [holl "T9"] 1 { 15 10 } 0 { }\n" +simple_expect "=1200 9" + +# Call add-recipient when we have a BCC recipient + +send "1201 30 9 11 0\n" +simple_expect "=1201" + +# Change a BCC recipient into a CC recipient + +send "1202 30 9 10 1\n" +simple_expect "=1202" + +# Call add-recipient when we have a cc recpt different from the new recpt + +send "1203 30 9 12 0\n" +simple_expect "=1203" + + +# Remove a recipient when we have a cc recipient +# Remove a recipient when we have a bcc recipient +# Remove a BCC recipient + +send "1204 30 9 10 15\n" +simple_expect "=1204" + +send "1205 31 9 11\n" +simple_expect "=1205" + +send "1206 31 9 10\n" +simple_expect "=1206" + +send "1207 31 9 12\n" +simple_expect "=1207" + +# Attempt to remove a recipient that's not there + +send "1208 31 9 13\n" +simple_expect "%1208 30 13" + + + +# Call create-text when we have no access to one of the recipients + +kom_login 7 "PW7" 0 + +send "1300 86 [holl "T10 (oops)"] 1 { 0 17 } 0 { }\n" +simple_expect "%1300 9 17" + +send "1301 86 [holl "T10 (oops)"] 1 { 1 17 } 0 { }\n" +simple_expect "%1301 9 17" + +send "1302 86 [holl "T10 (oops)"] 1 { 15 17 } 0 { }\n" +simple_expect "%1302 9 17" + + +# Call create-text when we have no write access to one of the recipients +# and no write access to the superconf + +send "1400 86 [holl "T10 (oops)"] 1 { 0 18 } 0 { }\n" +simple_expect "%1400 11 19" + +send "1401 86 [holl "T10 (oops)"] 1 { 1 18 } 0 { }\n" +simple_expect "%1401 11 19" + +send "1402 86 [holl "T10 (oops)"] 1 { 15 18 } 0 { }\n" +simple_expect "%1402 11 19" + + +# Call create-text when we have no write access to the conf +# and no write access to super confs and we exceed super-conf-loop + +send "1500 86 [holl "T10 (oops)"] 1 { 0 20 } 0 { }\n" +simple_expect "%1500 11 23" + + +# Creaate a multi-line text + +send "1500 86 [holl "T10\nBody"] 1 { 0 10 } 0 { }\n" +simple_expect "=1500 10" + + +# Attempt to create a footnote to a text wr did not author + +send "1501 86 [holl "T11 (oops)"] 2 { 0 10 4 1 } 0 { }\n" +simple_expect "%1501 37 1" + +# Attempt to get a text we have marked (2nd mark of 3) and has no recipients + +kom_login 6 "PW6" 0 + +send "1600 86 [holl "T11\nBODY 1\nBODY 2"] 1 { 0 10 } 0 { }\n" +simple_expect "=1600 11" + +kom_login 8 "PW8" 0 +kom_mark_text 11 1 + +kom_login 7 "PW7" 0 +kom_mark_text 11 111 + +kom_login 6 "PW6" 0 +kom_mark_text 11 1 +kom_sub_recipient 11 10 + +kom_login 7 "PW7" 0 + +send "1601 90 11\n" +simple_expect "=1601 $any_time 6 2 17 3 0 \\* 0 \\*" + + +# Check jubel blocking again + +kom_login 9 "PW9" 0 + +send "1699 86 [holl "T12 (oops)"] 1 { 0 10 } 0 { }\n" +simple_expect "%1699 45 0" + +# Get a text with a recipient that we may not know about + +kom_login 6 "PW6" 0 + +send "1700 86 [holl "T12"] 2 { 0 17 0 10 } 0 { }\n" +simple_expect "=1700 12" + +send "1701 86 [holl "T13"] 2 { 1 17 0 10 } 0 { }\n" +simple_expect "=1701 13" + +send "1702 86 [holl "T14"] 2 { 15 17 0 10 } 0 { }\n" +simple_expect "=1702 14" + +kom_login 7 "PW7" 0 + +send "1800 90 12\n" +simple_expect "=1800 $any_time 6 0 3 0 2 { 0 10 6 $any_num } 0 \\*" + +send "1801 90 13\n" +simple_expect "=1801 $any_time 6 0 3 0 2 { 0 10 6 $any_num } 0 \\*" + +send "1802 90 14\n" +simple_expect "=1802 $any_time 6 0 3 0 2 { 0 10 6 $any_num } 0 \\*" + + +# Get an invalid range of a text + +send "1803 25 14 100 101\n" +simple_expect "%1803 19 $any_num" + + + +# Get a text that has a BCC recpt we added after the fact + +kom_login 6 "PW6" 0 +send "1900 86 [holl "T15"] 1 { 0 10 } 0 { }\n" +simple_expect "=1900 15" + +kom_login 7 "PW7" 0 +send "1901 30 15 11 15\n" +simple_expect "=1901" + +send "1902 90 15\n" +simple_expect "=1902 $any_time 6 0 3 0 6 { 0 10 6 $any_num 15 11 6 $any_num 8 7 9 $any_time } 0 \\*" + + +# Get a text that we did not write and has CWC as recpt, cc and bcc + +kom_login 6 "PW6" 0 + +send "2000 86 [holl "T16"] 3 { 0 10 1 11 15 12 } 0 { }\n" +simple_expect "=2000 16" + +kom_login 7 "PW7" 0 + +send "2001 90 16\n" +simple_expect "=2001 $any_time 6 0 3 0 6 { 0 10 6 $any_num 1 11 6 $any_num 15 12 6 $any_num } 0 \\*" + +kom_add_member 10 7 0 255 00000000 +kom_change_conference 10 +send "2002 90 16\n" +simple_expect "=2002 $any_time 6 0 3 0 6 { 0 10 6 $any_num 1 11 6 $any_num 15 12 6 $any_num } 0 \\*" + +kom_add_member 11 7 0 255 00000000 +kom_change_conference 11 +send "2003 90 16\n" +simple_expect "=2003 $any_time 6 0 3 0 6 { 0 10 6 $any_num 1 11 6 $any_num 15 12 6 $any_num } 0 \\*" + +kom_add_member 12 7 0 255 00000000 +kom_change_conference 12 +send "2004 90 16\n" +simple_expect "=2004 $any_time 6 0 3 0 6 { 0 10 6 $any_num 1 11 6 $any_num 15 12 6 $any_num } 0 \\*" + + + +# Get a text with secret recpt and public recpt, cc-recpt and bcc-recpt + +kom_login 6 "PW6" 0 +send "2100 86 [holl "T17"] 2 { 0 17 0 10 } 0 { }\n" +simple_expect "=2100 17" + +send "2101 86 [holl "T18"] 2 { 0 17 1 10 } 0 { }\n" +simple_expect "=2101 18" + +send "2102 86 [holl "T19"] 2 { 0 17 15 10 } 0 { }\n" +simple_expect "=2102 19" + +kom_login 7 "PW7" 0 + +send "2103 90 17\n" +simple_expect "=2103 $any_time 6 0 3 0 2 { 0 10 6 $any_num } 0 \\*" + +send "2104 90 18\n" +simple_expect "=2104 $any_time 6 0 3 0 2 { 1 10 6 $any_num } 0 \\*" + +send "2105 90 19\n" +simple_expect "=2105 $any_time 6 0 3 0 2 { 15 10 6 $any_num } 0 \\*" + + +# Get a text that has an open conf we are not member of as cc, bcc + +kom_login 6 "PW6" 0 +send "2200 86 [holl "T20"] 1 { 1 15 } 0 { }\n" +simple_expect "=2200 20" + +send "2201 86 [holl "T21"] 1 { 15 15 } 0 { }\n" +simple_expect "=2201 21" + + +kom_login 7 "PW7" 0 +send "2202 90 20\n" +simple_expect "=2202 $any_time 6 0 3 0 2 { 1 15 6 $any_num } 0 \\*" + +send "2203 90 21\n" +simple_expect "=2203 $any_time 6 0 3 0 2 { 15 15 6 $any_num } 0 \\*" + + +# Get a text BCCd to a conference we are supervisor of but not member of + +send "2204 86 [holl "T22"] 1 { 15 16 } 0 { }\n" +simple_expect "=2204 22" + +kom_login 6 "PW6" 0 + +send "2205 90 22\n" +simple_expect "=2205 $any_time 7 0 3 0 2 { 15 16 6 $any_num } 0 \\*" + + +# Attempt to delete a text that does not exist + +send "2300 29 9999\n" +simple_expect "%2300 14 9999" + +# Attempt to delete a text we are not author of + +send "2301 29 22\n" +simple_expect "%2301 37 22" + +# Delete a text that has a BCC recpt + +send "2302 29 21\n" +simple_expect "=2302" + +# Delete a text that is a comment to something + +kom_login 6 "PW6" 0 +send "2400 86 [holl "T23"] 1 { 0 10 } 0 { }\n" +simple_expect "=2400 23" + +send "2401 86 [holl "T24"] 2 { 0 10 2 23 } 0 { }\n" +simple_expect "=2401 24" + +send "2402 29 24\n" +simple_expect "=2402" + +# Delete a text that has a comment + +send "2403 86 [holl "T25"] 2 { 0 10 2 23 } 0 { }\n" +simple_expect "=2403 25" + +send "2404 29 23\n" +simple_expect "=2404" + + +# Delete a text that is a footnote to something + +kom_login 6 "PW6" 0 +send "2405 86 [holl "T26"] 1 { 0 10 } 0 { }\n" +simple_expect "=2405 26" + +send "2406 86 [holl "T27"] 2 { 0 10 4 26 } 0 { }\n" +simple_expect "=2406 27" + +send "2407 29 27\n" +simple_expect "=2407" + +# Delete a text that has a footnote + +send "2408 86 [holl "T28"] 2 { 0 10 4 26 } 0 { }\n" +simple_expect "=2408 28" + +send "2404 29 26\n" +simple_expect "=2404" + + +# Attempt to create a text with recpt equal other recpt, cc, bcc + +send "2500 86 [holl "T29 (oops)"] 2 { 0 10 0 10 } 0 { }\n" +simple_expect "%2500 25 \[01\]" + +send "2501 86 [holl "T29 (oops)"] 2 { 0 10 1 10 } 0 { }\n" +simple_expect "%2501 25 \[01\]" + +send "2502 86 [holl "T29 (oops)"] 2 { 0 10 15 10 } 0 { }\n" +simple_expect "%2502 25 \[01\]" + + +# Create text with recpt, cc, bcc + +send "2503 86 [holl "T29"] 3 { 0 10 1 11 15 12 } 0 { }\n" +simple_expect "=2503 29" + +# Attempt to create text with two identical comm-to + +send "2504 86 [holl "T30 (oops)"] 3 { 0 10 2 29 2 29 } 0 { }\n" +simple_expect "%2504 25 \[12\]" + +# Attempt to create text with comm-to equal footn-to + +send "2505 86 [holl "T30 (oops)"] 3 { 0 10 2 29 4 29 } 0 { }\n" +simple_expect "%2505 25 \[12\]" + +# Create text with two different comm-to, two footn-to + +send "2506 86 [holl "T30"] 5 { 0 10 2 11 2 12 4 13 4 14 } 0 { }\n" +simple_expect "=2506 30" + +# Attempt to create a comment to a text that we may not read + +send "2507 86 [holl "T31"] 1 { 0 17 } 0 { }\n" +simple_expect "=2507 31" + +kom_login 7 "PW7" 0 +send "2508 86 [holl "T32 (oops)"] 2 { 0 10 2 31 } 0 { }\n" +simple_expect "%2508 14 31" + +# Attempt to create a footnote to a text that we may not read + +send "2509 86 [holl "T32 (oops)"] 2 { 0 10 4 31 } 0 { }\n" +simple_expect "%2509 14 31" + + +# Attempt to add an anon text as recpt, cc, bcc to conf with forbid-anon + +kom_login 6 "PW6" 0 +send "2600 87 [holl "T32"] 1 { 0 10 } 0 { }\n" +simple_expect "=2600 32" + +send "2601 30 32 15 0\n" +simple_expect "%2601 47 0" + +send "2602 30 32 15 1\n" +simple_expect "%2602 47 0" + +send "2603 30 32 15 15\n" +simple_expect "%2603 47 0" + + +# Attempt to crete a text with a comm-in item + +send "2604 86 [holl "T33 (oops)"] 2 { 0 10 3 32 } 0 { }\n" +simple_expect "%% LysKOM protocol error." +setup_xfail "*" +fail "got protocol error instead of illegal-misc" + + +# Attempt to recpt, cc, bcc a conference that does not exist + +send "2605 30 32 9999 0\n" +simple_expect "%2605 9 9999" + +send "2606 30 32 9999 1\n" +simple_expect "%2606 9 9999" + +send "2607 30 32 9999 15\n" +simple_expect "%2607 9 9999" + + +# Attempt to add a recipient to a text we may not see + +kom_login 6 "PW6" 0 +send "2700 86 [holl "T33"] 1 { 0 17 } 0 { }\n" +simple_expect "=2700 33" + +kom_login 7 "PW7" 0 +send "2701 30 33 10 0\n" +simple_expect "%2701 14 33" + +# Attempt to add a recipient that is already a recipient + +kom_login 6 "PW6" 0 + +send "2702 86 [holl "T34"] 1 { 0 10 } 0 { }\n" +simple_expect "=2702 34" + +send "2703 30 34 10 0\n" +simple_expect "%2703 27 10" + +# Attempt to add an existing recipient with invalid type + +send "2704 30 34 10 99\n" +simple_expect "%2704 26 99" + +# Attempt to convert a recipient when not supervisor of recipient + +kom_login 7 "PW7" 0 +send "2705 30 34 10 1\n" +simple_expect "%2705 12 10" + +# Attempt to add too many recipients to a text + +send "2800 86 [holl "T35"] 1 { 0 10 } 0 { }\n" +simple_expect "=2800 35" + +send "2801 30 35 11 0\n" +simple_expect "=2801" + +send "2802 30 35 12 0\n" +simple_expect "=2802" + +send "2803 30 35 13 0\n" +simple_expect "=2803" + +send "2804 30 35 14 0\n" +simple_expect "=2804" + +send "2805 30 35 15 0\n" +simple_expect "=2805" + +send "2806 30 35 5 0\n" +simple_expect "=2806" + +send "2807 30 35 6 0\n" +simple_expect "=2807" + +send "2808 30 35 7 0\n" +simple_expect "%2808 33 35" + + +# Attempt to create anon text in non-anon conf + +kom_login 6 "PW6" 0 + +send "2900 87 [holl "T36 (oops)"] 1 { 0 15 } 0 { }\n" +simple_expect "%2900 47 15" + +send "2901 87 [holl "T36 (oops)"] 1 { 1 15 } 0 { }\n" +simple_expect "%2901 47 15" + +send "2902 87 [holl "T36 (oops)"] 1 { 15 15 } 0 { }\n" +simple_expect "%2902 47 15" + + +send "2903 86 [holl "T36"] 1 { 0 10 } 0 { }\n" +simple_expect "=2903 36" + + +# Attempt to add conf w no write access as recpt + +kom_login 7 "PW7" 0 + +send "3000 86 [holl "T37"] 1 { 0 10 } 0 { }\n" +simple_expect "=3000 37" + +send "3001 30 37 19 0\n" +simple_expect "%3001 11 19" + +send "3002 30 37 19 1\n" +simple_expect "%3002 11 19" + +send "3003 30 37 19 15\n" +simple_expect "%3003 11 19" + +# Attempt to add recpt w no write access to conf but to super conf + +send "3004 30 37 24 0\n" +simple_expect "%3004 11 24" + + +# Attempt to footnote a nonexistant text + +send "3100 86 [holl "T38 (oops)"] 2 { 0 10 4 9999 } 0 { }\n" +simple_expect "%3100 14 9999" + +send "3101 86 [holl "Well I'm on the downeaster Alexa, and I'm cruising through Block Island Sound. I have charted a course to the Vineyard, but tonight I am Nantucket Bound."] 1 { 0 10 } 0 { }\n" +simple_expect "%3101 5 40" + + +# Attempt to remove a recpt from text we have no access to + +kom_login 6 "PW6" 0 + +send "3200 86 [holl "T38"] 2 { 0 16 0 17 } 0 { }\n" +simple_expect "=3200 38" + +kom_login 7 "PW7" 0 +send "3201 31 38 16\n" +simple_expect "%3201 14 38" + +# Attempt to remove a recipient we may not know about from a text we +# may know about + +kom_login 6 "PW6" 0 +send "3202 30 38 10 0\n" +simple_expect "=3202" + +kom_login 7 "PW7" 0 + +send "3203 31 38 17\n" +simple_expect "%3203 9 17" + +send "3204 31 38 16\n" +simple_expect "%3204 12 38" + +# Attempt to delete a secret conf thats not a recipient + +send "3205 31 38 27\n" +simple_expect "%3205 9 27" + +# Attempt to remove a recipient that's not + +kom_login 6 "PW6" 0 + +send "3206 31 38 24\n" +simple_expect "%3206 30 24" + +# Attempt to remove a recipient that doesn't even exist + +send "3207 31 38 9999\n" +simple_expect "%3207 9 9999" + + +# Attempt to make a text a comment of itself + +send "3300 86 [holl "T39"] 1 { 0 10 } 0 { }\n" +simple_expect "=3300 39" + +send "3301 32 39 39\n" +simple_expect "%3301 19 39" + + +# Attempt to add a text we may not see as a comment to one we may see +# Attempt to add a text as a comment to something we cannot see +# Same with footnotes + +kom_login 6 "PW6" 0 + +send "3400 86 [holl "T40"] 1 { 0 16 } 0 { }\n" +simple_expect "=3400 40" + +kom_login 7 "PW7" 0 + +send "3401 86 [holl "T41"] 1 { 0 10 } 0 { }\n" +simple_expect "=3401 41" + +send "3402 32 41 40\n" +simple_expect "%3402 14 40" + +send "3403 32 40 41\n" +simple_expect "%3403 14 40" + +send "3404 37 41 40\n" +simple_expect "%3404 14 40" + +send "3405 37 40 41\n" +simple_expect "%3405 14 40" + + +send "3406 86 [holl "T42"] 1 { 0 10 } 0 { }\n" +simple_expect "=3406 42" + + +# Attempt to add a text as a footnote to itself + +send "3411 37 42 42\n" +simple_expect "%3411 19 42" + + +# Attempt to add a text as a comment twice over +# Same for footnote + +send "3407 32 42 41\n" +simple_expect "=3407" + +send "3408 32 42 41\n" +simple_expect "%3408 28 42" + +send "3409 37 41 42\n" +simple_expect "=3409" + +send "3410 37 41 42\n" +simple_expect "%3410 29 41" + +# Attempt to add a text as a footnote when authors differ + +kom_login 6 "PW6" 0 +send "3500 86 [holl "T43"] 1 { 0 10 } 0 { }\n" +simple_expect "=3500 43" + +kom_login 7 "PW7" 0 +send "3501 86 [holl "T44"] 1 { 0 10 } 0 { }\n" +simple_expect "=3501 44" + +send "3502 37 44 43\n" +simple_expect "%3502 37 43" + + +# Attempt to add comment as person other than authors + +kom_login 6 "PW6" 0 +send "3503 86 [holl "T45"] 1 { 0 10 } 0 { }\n" +simple_expect "=3503 45" + +kom_login 7 "PW7" 0 +send "3504 86 [holl "T46"] 1 { 0 10 } 0 { }\n" +simple_expect "=3504 46" + +kom_login 8 "PW8" 0 +send "3505 32 46 45\n" +simple_expect "=3505" + + + +# Attempt to remove a comment that's not really a comment + +kom_login 7 "PW7" 0 + +send "3600 33 45 44\n" +simple_expect "%3600 31 45" + +# Attempt to remove a footnote that's not really a footnote + +send "3601 38 45 44\n" +simple_expect "%3601 32 45" + + +# Sub a footnote when adder, but not author of either text + +kom_login 8 "PW8" 0 + +send "3602 33 46 45\n" +simple_expect "=3602" + +# Attempt to sub a comment when not author of either + +send "3603 33 42 41\n" +simple_expect "%3603 12 42" + + +# Attempt to sub a footnote when not author of either + +send "3604 38 41 42\n" +simple_expect "%3604 12 41" + + +# Do a get-map on conf we may not know about + +kom_login 7 "PW7" 0 + +send "3700 34 17 1 1\n" +simple_expect "%3700 9 17" + +# Do a get-map on conf that is rd_prot + +send "3701 34 16 1 1\n" +simple_expect "%3701 11 16" + + +# Do a local-to-global on secret and rd_prot conf + +send "3702 103 17 1 1\n" +simple_expect "%3702 9 17" + +send "3703 103 16 1 1\n" +simple_expect "%3703 11 16" + + +# Add a comment to a text that already has a comment + +kom_login 6 "PW6" 0 + +send "3800 86 [holl "T47"] 1 { 0 10 } 0 { }\n" +simple_expect "=3800 47" + +send "3801 86 [holl "T48"] 2 { 0 10 2 47 } 0 { }\n" +simple_expect "=3801 48" + +send "3802 86 [holl "T49"] 1 { 0 10 } 0 { }\n" +simple_expect "=3802 49" + +send "3803 32 49 47\n" +simple_expect "=3803" + + +# Add a footnote to a text that already has a footnote + +kom_login 6 "PW6" 0 + +send "3804 86 [holl "T50"] 1 { 0 10 } 0 { }\n" +simple_expect "=3804 50" + +send "3805 86 [holl "T51"] 2 { 0 10 4 50 } 0 { }\n" +simple_expect "=3805 51" + +send "3806 86 [holl "T52"] 1 { 0 10 } 0 { }\n" +simple_expect "=3806 52" + +send "3807 37 52 50\n" +simple_expect "=3807" + + +# Remove a cc recipient from a text that has an earlier cc recpt + +send "3900 86 [holl "T53"] 3 { 1 10 1 11 1 12 } 0 { }\n" +simple_expect "=3900 53" + +send "3901 31 53 11\n" +simple_expect "=3901" + + +# Call sub-recipient to remove single recpt as wrong person + +kom_login 6 "PW6" 0 + +send "4000 86 [holl "T54"] 1 { 0 10 } 0 { }\n" +simple_expect "=4000 54" + +kom_login 7 "PW7" 0 +send "4001 31 54 10\n" +simple_expect "%4001 12 54" + + +# Call sub-recipient with misc-info list +# --- recpt 7 +# --- recpt 8 +# --- recpt 13 sent-by 8 +# --- cc-recpt 14 sent-by 8 +# --- bcc-recpt 15 sent-by 8 +# --- recpt 10 sent-by 7 +# --- cc-recpt 11 sent-by 7 +# --- bcc-recpt 12 send-by 7 +# Then remove 12, 11 and 10. + +kom_login 6 "PW6" 0 + +send "4100 86 [holl "T55"] 2 { 0 7 0 8 } 0 { }\n" +simple_expect "=4100 55" + +kom_login 8 "PW8" 0 + +send "4101 30 55 13 0\n" +simple_expect "=4101" + +send "4102 30 55 14 1\n" +simple_expect "=4102" + +send "4103 30 55 15 15\n" +simple_expect "=4103" + +kom_login 7 "PW7" 0 + +send "4104 30 55 10 0\n" +simple_expect "=4104" + +send "4105 30 55 11 1\n" +simple_expect "=4105" + +send "4106 30 55 12 15\n" +simple_expect "=4106" + +send "4107 31 55 12\n" +simple_expect "=4107" + +send "4108 31 55 11\n" +simple_expect "=4108" + +send "4109 31 55 10\n" +simple_expect "=4109" + + +# Get a text with a bcc to a conf we are not member of that we sent + +kom_login 6 "PW6" 0 + +send "4200 86 [holl "T56"] 1 { 0 10 } 0 { }\n" +simple_expect "=4200 56" + +kom_login 7 "PW7" 0 + +send "4201 30 56 5 15\n" +simple_expect "=4201" + +send "4202 90 56\n" +simple_expect "=4202 $any_time 6 0 3 0 6 { 0 10 6 $any_num 15 5 6 $any_num 8 7 9 $any_time } 0 \\*" + + +# Check various permutations of double submission + +kom_login 6 "PW6" 0 + +send "4300 86 [holl "T57 (oops)"] 2 { 0 10 1 10 } 0 { }\n" +simple_expect "%4300 25 \[12\]" + +send "4301 86 [holl "T57 (oops)"] 2 { 1 10 0 10 } 0 { }\n" +simple_expect "%4301 25 \[12\]" + +send "4302 86 [holl "T57 (oops)"] 2 { 0 10 15 10 } 0 { }\n" +simple_expect "%4302 25 \[12\]" + +send "4303 86 [holl "T57 (oops)"] 2 { 15 10 0 10 } 0 { }\n" +simple_expect "%4303 25 \[12\]" + +send "4304 86 [holl "T57 (oops)"] 2 { 15 10 1 10 } 0 { }\n" +simple_expect "%4304 25 \[12\]" + +send "4305 86 [holl "T57 (oops)"] 2 { 1 10 15 10 } 0 { }\n" +simple_expect "%4305 25 \[12\]" + + +# Check various permutations of double comments + +send "4400 86 [holl "T57"] 1 { 0 10 } 0 { }\n" +simple_expect "=4400 57" + +send "4401 86 [holl "T58 (oops)"] 3 { 0 10 2 57 4 57 } 0 { }\n" +simple_expect "%4401 25 \[12\]" + +send "4402 86 [holl "T58 (oops)"] 3 { 0 10 4 57 2 57 } 0 { }\n" +simple_expect "%4402 25 \[12\]" + + +# Add a footnote written by someone else to our text + +kom_login 6 "PW6" 0 + +send "4500 86 [holl "T58"] 1 { 0 10 } 0 { }\n" +simple_expect "=4500 58" + +kom_login 7 "PW7" 0 + +send "4501 86 [holl "T59"] 1 { 0 10 } 0 { }\n" +simple_expect "=4501 59" + +kom_login 6 "PW6" 0 + +send "4502 37 59 58\n" +simple_expect "%4502 37 59" + + +# Add comments until we hit the limit + +kom_login 6 "PW6" 0 + +send "4600 86 [holl "T60"] 1 { 0 10 } 0 { }\n" +simple_expect "=4600 60" + +send "4601 86 [holl "T61"] 1 { 0 10 } 0 { }\n" +simple_expect "=4601 61" + +send "4602 86 [holl "T62"] 1 { 0 10 } 0 { }\n" +simple_expect "=4602 62" + +send "4603 86 [holl "T63"] 1 { 0 10 } 0 { }\n" +simple_expect "=4603 63" + +send "4604 86 [holl "T64"] 1 { 0 10 } 0 { }\n" +simple_expect "=4604 64" + +send "4605 32 61 60\n" +simple_expect "=4605" + +send "4606 32 62 60\n" +simple_expect "=4606" + +send "4607 32 63 60\n" +simple_expect "=4607" + +send "4608 32 64 60\n" +simple_expect "%4608 34 60" + + + +kom_login 5 "gazonk" 0 +kom_enable 255 + +send "9999 44 0\n" +simple_expect "=9999" + +client_death 0 +lyskomd_death diff --git a/src/server/testsuite/tcpconnect.py b/src/server/testsuite/tcpconnect.py index 05399cad515179abab61d19adf2028897ae3b9ec..c89294c09458461f6ece4ec6eaca61deca4aa72a 100644 --- a/src/server/testsuite/tcpconnect.py +++ b/src/server/testsuite/tcpconnect.py @@ -52,5 +52,7 @@ while 1: fdset = [sys.stdin] elif d == "#resume socket\n": fdset = [s, sys.stdin] + elif d == "#hose socket\n": + s.send(string.zfill(0, 2000)) else: s.send(d) diff --git a/src/server/text-garb.c b/src/server/text-garb.c index 7b0611404dde0f35b398e657e2248ca01797bde6..377c42e36e3b4e0cac555dee61740368beb3af25 100644 --- a/src/server/text-garb.c +++ b/src/server/text-garb.c @@ -1,5 +1,5 @@ /* - * $Id: text-garb.c,v 0.25 1999/01/13 12:08:41 byers Exp $ + * $Id: text-garb.c,v 0.26 1999/05/12 13:25:37 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1995 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -34,7 +34,7 @@ #endif static const char * -rcsid = "$Id: text-garb.c,v 0.25 1999/01/13 12:08:41 byers Exp $"; +rcsid = "$Id: text-garb.c,v 0.26 1999/05/12 13:25:37 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -124,7 +124,7 @@ garb_text(void) return TRUE; } - log("MSG: garb started.\n"); + kom_log("MSG: garb started.\n"); time( &last_start ); } @@ -133,7 +133,7 @@ garb_text(void) if ( last_checked == 0 ) { - log("MSG: garb ready. %lu texts deleted.\n", (u_long)deleted_texts); + kom_log("MSG: garb ready. %lu texts deleted.\n", (u_long)deleted_texts); deleted_texts = 0; tell_cache_garb_text(0); return FALSE; @@ -141,7 +141,7 @@ garb_text(void) if ( (text_s = cached_get_text_stat( last_checked )) == NULL ) { - log("ERROR: garb_text(): Can't get text-stat.\n"); + kom_log("ERROR: garb_text(): Can't get text-stat.\n"); tell_cache_garb_text(0); return FALSE; } diff --git a/src/server/text.c b/src/server/text.c index d309b2864ac1989708b6ab6fc41458c20121a3be..afc5ac4ebea5a1ede465224d2f833e7a69a55ecb 100644 --- a/src/server/text.c +++ b/src/server/text.c @@ -1,5 +1,5 @@ /* - * $Id: text.c,v 0.62 1999/04/05 00:42:52 ceder Exp $ + * $Id: text.c,v 0.63 1999/05/12 13:25:38 byers Exp $ * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -34,7 +34,7 @@ #endif static const char * -rcsid = "$Id: text.c,v 0.62 1999/04/05 00:42:52 ceder Exp $"; +rcsid = "$Id: text.c,v 0.63 1999/05/12 13:25:38 byers Exp $"; #include "rcs.h" USE(rcsid); @@ -314,7 +314,11 @@ submit_to(Conf_no conf_no, /* The conference the user is trying to */ acc = access_perm (conf_no, conf_c, ACTPERS, ACT_P); if ( acc <= none ) + { + err_stat = conf_no; + kom_errno = KOM_UNDEF_CONF; return 0; + } if (conf_c->permitted_submitters == 0 || acc == unlimited @@ -324,12 +328,19 @@ submit_to(Conf_no conf_no, /* The conference the user is trying to */ } - if ((conf_no = conf_c->super_conf) == 0) + if (conf_c->super_conf == 0) + { + err_stat = conf_no; + kom_errno = KOM_ACCESS; return 0; + } + conf_no = conf_c->super_conf; GET_C_STAT(conf_c, conf_no, 0); } + err_stat = conf_no; + kom_errno = KOM_ACCESS; return 0; } @@ -504,7 +515,7 @@ is_member_in_recpt(Person *person, #ifndef COMPILE_CHECKS default: - log("%s: is_member_in_recpt(): bad misc_item.\n", __FILE__); + kom_log("%s: is_member_in_recpt(): bad misc_item.\n", __FILE__); break; #endif } @@ -719,7 +730,7 @@ do_sub_recpt (Text_no text_no, #ifndef COMPILE_CHECKS default: - log("%s: do_sub_recpt(): bad misc_item.\n", __FILE__); + kom_log("%s: do_sub_recpt(): bad misc_item.\n", __FILE__); break; #endif } @@ -892,7 +903,7 @@ sender(Text_stat * t_stat, #ifndef COMPILE_CHECKS default: - log("ERROR: sender(): Illegal misc_item found.\n"); + kom_log("ERROR: sender(): Illegal misc_item found.\n"); return 0; #endif } @@ -1051,7 +1062,6 @@ check_comm(Text_stat * t_stat) { if ( count_comment( t_stat ) >= param.max_comm ) { - err_stat = 0; kom_errno = KOM_COMM_LIMIT; return FAILURE; } @@ -1150,7 +1160,7 @@ recp_sent_by(Misc_info *misc, Misc_info *end, /* Found the sent-by. Check it out. */ return (is_supervisor(misc->datum.sender, NULL, viewer, viewer_p)); - break; + case loc_no: case rec_time: case sent_at: @@ -1165,10 +1175,10 @@ recp_sent_by(Misc_info *misc, Misc_info *end, case footn_in: /* Found the next "major" item without finding a sent-by. */ return FALSE; - break; + #ifndef COMPILE_CHECKS default: - restart_kom("skip_recp() - illegal misc\n"); + restart_kom("recp_sent_by() - illegal misc\n"); #endif } misc += 1; @@ -1396,92 +1406,131 @@ send_async_deleted_text (Text_no text_no, Text_stat *text_s) * Check if ACTPERS is allowed to read this text. * Returns TRUE if he is allowed to read it. */ + Bool text_read_access(Text_no text_no, Text_stat * text_stat) { - int i; - Misc_info *misc; - Conference *recipient; + return person_text_read_access(text_no, + text_stat, + ACTPERS, + ACT_P); +} + +/* + * 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 + */ + +Bool +person_text_read_access(Text_no text_no, + Text_stat * text_stat, + Pers_no pers_no, + Person * pers_stat) +{ + int i = 0; + Misc_info *misc = NULL; + Conference *recipient = NULL; + Conf_no cwc = 0; + + /* Everyone may read the MOTD of KOM */ - /* - * Nope, people who aren't logged in, should NOT be - * allowed to read any texts but motd_of_lyskom! - */ if ( text_no == kom_info.motd_of_lyskom ) return TRUE; - CHK_LOGIN(FALSE); - + /* Users who are not logged in may not read anything else */ + + if (!pers_no) + { + err_stat = 0; + kom_errno = KOM_LOGIN; + return FALSE; + } + if ( text_stat == NULL ) GET_T_STAT(text_stat, text_no, FALSE); - if ( ENA(wheel, 10)) - return TRUE; - if ( ACTPERS ) - { - if ( text_stat->author == ACTPERS ) - return TRUE; - - /* Check if ACTPERS or current working conference is a recipient */ - - for (i = text_stat->no_of_misc, misc = text_stat->misc_items; - i; i--, misc++) - { - if ( misc->type == recpt - && (misc->datum.recipient == active_connection->cwc - || misc->datum.recipient == ACTPERS )) - { - return TRUE; - } + /* Some bits let you read everything */ - if ( misc->type == cc_recpt - && (misc->datum.cc_recipient == active_connection->cwc - || misc->datum.cc_recipient == ACTPERS )) - { - return TRUE; - } + if ( pers_no == ACTPERS && ENA(wheel, 10)) + return TRUE; - if ( misc->type == bcc_recpt - && (misc->datum.bcc_recipient == active_connection->cwc - || misc->datum.bcc_recipient == ACTPERS )) - { - return TRUE; - } - - } + /* Additional checks on CWC if pers_no is ACTPERS */ - /* Check if ACTPERS is member in any of the recipients */ - - for (i = text_stat->no_of_misc, misc = text_stat->misc_items; - i; i--, misc++) - { - if ( misc->type == recpt - && locate_membership( misc->datum.recipient, ACT_P) != NULL) - { - return TRUE; - } + if (pers_no == ACTPERS) + { + cwc = active_connection->cwc; + } - if ( misc->type == cc_recpt - && locate_membership( misc->datum.cc_recipient, ACT_P) != NULL) - { - return TRUE; - } - if ( misc->type == bcc_recpt - && locate_membership( misc->datum.bcc_recipient, ACT_P) - != NULL) - { - return TRUE; - } -} + if ( text_stat->author == pers_no ) + return TRUE; + + /* Check if pers_no or current working conference is a recipient */ + + for (i = text_stat->no_of_misc, misc = text_stat->misc_items; + i; i--, misc++) + { + if ( misc->type == recpt + && (misc->datum.recipient == cwc + || misc->datum.recipient == pers_no )) + { + return TRUE; + } + + if ( misc->type == cc_recpt + && (misc->datum.cc_recipient == cwc + || misc->datum.cc_recipient == pers_no )) + { + return TRUE; + } + + if ( misc->type == bcc_recpt + && (misc->datum.bcc_recipient == cwc + || misc->datum.bcc_recipient == pers_no )) + { + return TRUE; + } + + } + - if ( locate_mark(ACTPERS, ACT_P, text_no) != NULL ) - { - 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); + + for (i = text_stat->no_of_misc, misc = text_stat->misc_items; + i; i--, misc++) + { + if ( misc->type == recpt + && locate_membership( misc->datum.recipient, pers_stat) != NULL) + { + return TRUE; + } + + if ( misc->type == cc_recpt + && locate_membership( misc->datum.cc_recipient, pers_stat) != NULL) + { + return TRUE; + } + + if ( misc->type == bcc_recpt + && locate_membership( misc->datum.bcc_recipient, pers_stat) + != NULL) + { + return TRUE; + } } + + if ( locate_mark(pers_no, pers_stat, 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 */ @@ -1495,9 +1544,9 @@ text_read_access(Text_no text_no, cached_get_conf_stat( misc->datum.recipient )) != NULL ) { if ( !recipient->type.rd_prot || - ENA(wheel, 8) || + (pers_no == ACTPERS && ENA(wheel, 8)) || is_supervisor(misc->datum.recipient, recipient, - ACTPERS, ACT_P) == TRUE) + pers_no, pers_stat) == TRUE) { return TRUE; } @@ -1508,9 +1557,9 @@ text_read_access(Text_no text_no, cached_get_conf_stat( misc->datum.cc_recipient )) != NULL ) { if ( !recipient->type.rd_prot || - ENA(wheel, 8) || + (pers_no == ACTPERS && ENA(wheel, 8)) || is_supervisor(misc->datum.cc_recipient, recipient, - ACTPERS, ACT_P) == TRUE) + pers_no, pers_stat) == TRUE) { return TRUE; } @@ -1520,9 +1569,10 @@ text_read_access(Text_no text_no, && (recipient = cached_get_conf_stat( misc->datum.bcc_recipient )) != NULL ) { - if ( ENA(wheel, 8) || + if ( !recipient->type.rd_prot || + (pers_no == ACTPERS && ENA(wheel, 8)) || is_supervisor(misc->datum.bcc_recipient, recipient, - ACTPERS, ACT_P) == TRUE ) + pers_no, pers_stat) == TRUE ) { return TRUE; } @@ -1800,7 +1850,7 @@ check_double_subm (Misc_info * misc, #ifndef COMPILE_CHECKS default: - log("%s: check_double_subm(): bad misc_item.\n", __FILE__); + kom_log("%s: check_double_subm(): bad misc_item.\n", __FILE__); break; #endif } @@ -1844,7 +1894,7 @@ check_double_comm (Misc_info *misc, #ifndef COMPILE_CHECKS default: - log("%s: check_double_subm(): bad misc_item.\n", __FILE__); + kom_log("%s: check_double_subm(): bad misc_item.\n", __FILE__); break; #endif } @@ -1882,12 +1932,23 @@ create_text_check_misc (u_short * no_of_misc, GET_T_STAT( parent, misc[ i ].datum.footnote_to, FAILURE); + if (!text_read_access(misc[i].datum.footnote_to, parent)) + { + err_stat = misc[i].datum.footnote_to; + kom_errno = KOM_NO_SUCH_TEXT; + return FAILURE; + } + if ( check_footn(parent) == FAILURE ) + { + err_stat = misc[i].datum.footnote_to; return FAILURE; + } if ( check_double_comm(misc, i, misc[ i ].datum.footnote_to) != OK ) { + err_stat = i; kom_errno = KOM_ILL_MISC; return FAILURE; } @@ -1899,22 +1960,27 @@ create_text_check_misc (u_short * no_of_misc, GET_T_STAT( parent, misc[ i ].datum.comment_to, FAILURE); + if (!text_read_access(misc[i].datum.comment_to, parent)) + { + err_stat = misc[i].datum.comment_to; + kom_errno = KOM_NO_SUCH_TEXT; + return FAILURE; + } + if ( check_comm(parent) == FAILURE ) + { + err_stat = misc[i].datum.comment_to; return FAILURE; + } if ( check_double_comm(misc, i, misc[ i ].datum.comment_to) != OK ) { + err_stat = i; kom_errno = KOM_ILL_MISC; return FAILURE; } - if (!text_read_access(misc[i].datum.comment_to, parent)) - { - kom_errno = KOM_NO_SUCH_TEXT; - return FAILURE; - } - break; case recpt: @@ -1926,9 +1992,10 @@ create_text_check_misc (u_short * no_of_misc, /* Update in case of super_conf */ - if ((misc[ i ].datum.recipient = addressee) == 0) + misc[ i ].datum.recipient = addressee; + if (addressee == 0) { - kom_errno = KOM_ACCESS; + /* Error data set in submit_to */ return FAILURE; } @@ -1936,6 +2003,7 @@ create_text_check_misc (u_short * no_of_misc, if ( check_double_subm(misc, i, addressee) != OK ) { + err_stat = i; kom_errno = KOM_ILL_MISC; return FAILURE; } @@ -1944,6 +2012,7 @@ create_text_check_misc (u_short * no_of_misc, if (anonymous && check_anonymous_subm(addressee) != OK) { + err_stat = addressee; kom_errno = KOM_ANON_REJECTED; return FAILURE; } @@ -1960,9 +2029,10 @@ create_text_check_misc (u_short * no_of_misc, /* Update in case of super_conf */ - if ((misc[ i ].datum.cc_recipient = addressee) == 0) + misc[ i ].datum.cc_recipient = addressee; + if (addressee == 0) { - kom_errno = KOM_ACCESS; + /* Error data set in submit_to */ return FAILURE; } @@ -1970,6 +2040,7 @@ create_text_check_misc (u_short * no_of_misc, if (check_double_subm(misc, i, addressee) != OK) { + err_stat = i; kom_errno = KOM_ILL_MISC; return FAILURE; } @@ -1978,6 +2049,7 @@ create_text_check_misc (u_short * no_of_misc, if (anonymous && check_anonymous_subm(addressee) != OK) { + err_stat = addressee; kom_errno = KOM_ANON_REJECTED; return FAILURE; } @@ -1994,9 +2066,10 @@ create_text_check_misc (u_short * no_of_misc, /* Update in case of super_conf */ - if ((misc[ i ].datum.bcc_recipient = addressee) == 0) + misc[ i ].datum.bcc_recipient = addressee; + if (addressee == 0) { - kom_errno = KOM_ACCESS; + /* Error data set in submit_to */ return FAILURE; } @@ -2004,6 +2077,7 @@ create_text_check_misc (u_short * no_of_misc, if (check_double_subm(misc, i, addressee) != OK) { + err_stat = i; kom_errno = KOM_ILL_MISC; return FAILURE; } @@ -2012,6 +2086,7 @@ create_text_check_misc (u_short * no_of_misc, if (anonymous && check_anonymous_subm(addressee) != OK) { + err_stat = addressee; kom_errno = KOM_ANON_REJECTED; return FAILURE; } @@ -2103,9 +2178,11 @@ create_text_add_aux(Text_stat *t_stat, static Success create_text_add_miscs(Text_no new_text, int no_of_misc, - Misc_info * misc) + Misc_info * misc, + time_t now) { int i; + Conference *conf_c; for ( i = 0; i < no_of_misc; i++) { @@ -2129,21 +2206,24 @@ create_text_add_miscs(Text_no new_text, case recpt: if ( do_add_recpt(new_text, NULL, misc[ i ].datum.recipient) != OK) return FAILURE; - + GET_C_STAT(conf_c, misc[i].datum.recipient, FAILURE); + conf_c->last_written = now; break; case cc_recpt: if ( do_add_cc_recpt(new_text, NULL, misc[ i ].datum.cc_recipient) !=OK ) return FAILURE; - + GET_C_STAT(conf_c, misc[i].datum.cc_recipient, FAILURE); + conf_c->last_written = now; break; case bcc_recpt: if ( do_add_bcc_recpt(new_text, NULL, misc[ i ].datum.bcc_recipient) !=OK ) return FAILURE; - + GET_C_STAT(conf_c, misc[i].datum.bcc_recipient, FAILURE); + conf_c->last_written = now; break; case loc_no: /* Ignore loc_no. */ @@ -2305,7 +2385,7 @@ ok_to_create_next_text(void) { if (ACTPERS == j->bad_guy) { - log("Stopped person %d from creating jubel %lu.\n", + kom_log("Stopped person %d from creating jubel %lu.\n", ACTPERS, next_tno); return FALSE; } @@ -2315,7 +2395,7 @@ ok_to_create_next_text(void) } if (is_jubel) - log("Granted jubel %lu to person %d.\n", next_tno, ACTPERS); + kom_log("Granted jubel %lu to person %d.\n", next_tno, ACTPERS); return TRUE; } @@ -2437,6 +2517,7 @@ do_create_text(const String message, { Text_no text; Text_stat * t_stat; + time_t now; CHK_LOGIN(0); @@ -2458,9 +2539,13 @@ do_create_text(const String message, return 0; } + /* Get creation time */ + + now = time(NULL); + /* Check all misc-items and aux-items */ - prepare_aux_item_list(aux, anonymous?0:ACTPERS); + prepare_aux_item_list(aux, anonymous?0:ACTPERS, now); if ( create_text_check_misc(&no_of_misc, misc, anonymous) != OK || text_stat_check_add_aux_item_list(NULL, aux, ACTPERS, TRUE) != OK @@ -2480,13 +2565,13 @@ do_create_text(const String message, *ret_stat = t_stat; t_stat->author = anonymous?0:ACTPERS; - t_stat->creation_time = time(NULL); + t_stat->creation_time = now; t_stat->no_of_lines = count_lines( message ); t_stat->no_of_chars = s_strlen( message ); - if ( create_text_add_miscs(text, no_of_misc, misc) != OK ) + if ( create_text_add_miscs(text, no_of_misc, misc, now) != OK ) { - log("ERROR: create_text(): can't add miscs.\n"); + kom_log("ERROR: create_text(): can't add miscs.\n"); return 0; } @@ -2495,7 +2580,7 @@ do_create_text(const String message, aux, anonymous?0:ACTPERS ) != OK ) { - log("ERROR: create_text(): can't att aux.\n"); + kom_log("ERROR: create_text(): can't add aux.\n"); return 0; } @@ -2723,9 +2808,10 @@ add_recipient( Text_no text_no, Conf_no conf_no, Info_type type ) /* recpt or cc_recpt */ { - Text_stat * t_stat; - Conference * conf_c; - int rcpt_index; + Text_stat *t_stat; + Conference *conf_c; + int rcpt_index; + Conf_no submit_conf; CHK_LOGIN(FAILURE); GET_T_STAT(t_stat, text_no, FAILURE); @@ -2801,12 +2887,21 @@ add_recipient( Text_no text_no, FIXME: Should extract the "is allowed to write to this FIXME: conference test from submit_to() */ - if (submit_to(conf_no, conf_c) != conf_no) + submit_conf = submit_to(conf_no, conf_c); + + if (submit_conf == 0) { - err_stat = conf_no; - kom_errno = KOM_PERM; + /* Error data set in submit_to */ return FAILURE; } + else if (submit_conf != conf_no) + { + /* Error data not set in submit_to */ + err_stat = conf_no; + kom_errno = KOM_ACCESS; + return FAILURE; + } + if (!conf_c->type.allow_anon && t_stat->author == 0) { @@ -2887,14 +2982,21 @@ sub_recipient( Text_no text_no, return FAILURE; } + if (fast_access_perm(conf_no, ACTPERS, ACT_P) <= none) + { + err_stat = conf_no; + kom_errno = KOM_UNDEF_CONF; + return FAILURE; + } + + GET_C_STAT(conf_c, conf_no, FAILURE); + if (find_recipient(conf_no, text_s) == -1) { err_stat = conf_no; kom_errno = KOM_NOT_RECIPIENT; return FAILURE; } - - GET_C_STAT(conf_c, conf_no, FAILURE); if ( !is_supervisor (text_s->author, NULL, ACTPERS, ACT_P) && @@ -3061,7 +3163,7 @@ add_footnote( Text_no footnote, if ( text_s->author != parent_s->author ) { - err_stat = footnote_to; + err_stat = footnote; kom_errno = KOM_NOT_AUTHOR; return FAILURE; } @@ -3259,7 +3361,7 @@ modify_text_info(Text_no text, /* Check if we may delete and add the items */ - prepare_aux_item_list(aux, ACTPERS); + prepare_aux_item_list(aux, ACTPERS, time(NULL)); if (check_delete_aux_item_list(items_to_delete,&text_s->aux_item_list)!=OK) return FAILURE;