Commit 147c0add authored by Per Cederqvist's avatar Per Cederqvist

Renamed the error code illegal-aux-item to illegal-aux-item-tag.

Added error code 62=aux-exists, 63=aux-bad-object,
64=illegal-aux-data, 65=aux-create-only, 66=aux-modify-only,
67=aux-server-only, 68=aux-data-exists and 69=aux-no-such-text.
Return proper error codes.  (Bug 192).
* doc/Protocol-A.texi (Predefined Aux-Item Types): Renamed the
error code illegal-aux-item to illegal-aux-item-tag.
(create-text): Updated the error code section to mention the
aux-related error codes illegal-aux-item-tag, aux-item-permission,
aux-exists, aux-bad-object, illegal-aux-data, aux-modify-only,
aux-server-only, aux-data-exists and aux-no-such-text instead of
only illegal-aux-item and aux-item-permission.  Refer to the
"Error Codes" node instead of duplicating the reasons here.
(create-anonymous-text): Ditto.
(create-conf): Ditto.
(create-person): Ditto.
(modify-text-info): Ditto, but with aux-create-only instead of
aux-modify-only.
(modify-conf-info): Ditto.
(modify-system-info): Ditto.
(Error Codes): Renamed error code 48 from illegal-aux-item to
illegal-aux-item-tag, and redefine it to not include errors in the
data.  Added error code 62=aux-exists, 63=aux-bad-object,
64=illegal-aux-data, 65=aux-create-only, 66=aux-modify-only,
67=aux-server-only, 68=aux-data-exists and 69=aux-no-such-text.
* doc/Makefile.am (check-doc): Replaced the error code
illegal-aux-item with illegal-aux-item-tag and
illegal-aux-item-data.
* src/include/kom-errno.h (enum kom_err): Renamed KOM_ILL_AUX to
KOM_ILL_AUX_TAG.  Added KOM_AUX_EXISTS, KOM_AUX_BAD_OBJECT,
KOM_ILL_AUX_DATA, KOM_AUX_CREATE_ONLY, KOM_AUX_MODIFY_ONLY,
KOM_AUX_SERVER_ONLY, KOM_AUX_DATA_EXISTS and KOM_AUX_NO_SUCH_TEXT.
* src/server/aux-items.c (aux_item_validate): Doc added.  Added
missing punctuation in comments.  Set kom_errno to
KOM_ILL_AUX_DATA instead of KOM_ILL_AUX when a regexp cannot be
compiled or doesn't match an entry, or when a validator fails.
(aux_item_add_perm): Document that kom_errno is set on failure.
Do not modify kom_errno on success.  Track name change of
KOM_ILL_AUX_TAG.  Set KOM_AUX_MODIFY_ONLY, KOM_AUX_CREATE_ONLY,
KOM_AUX_SERVER_ONLY when appropriate (used to be KOM_AUX_PERM).
Don't override the error code set by aux_item_check_unique() or
aux_item_validate() when any of those check fails.
(aux_item_check_unique): Set kom_errno to KOM_AUX_EXISTS or
KOM_AUX_DATA_EXISTS on failure (used to sometimes be
KOM_ILL_AUX).
(text_stat_check_add_aux_item_list): Track name change of
KOM_ILL_AUX_TAG.  Set kom_errno to KOM_AUX_BAD_OBJECT if the
aux-item is not allowed on the active object (used to be
KOM_AUX_PERM).
(conf_stat_check_add_aux_item_list): Ditto.
(system_check_add_aux_item_list): Ditto.
(aux_item_validate_existing_text): Set kom_errno to
KOM_AUX_NO_SUCH_TEXT instead of NO_SUCH_TEXT.  Set it to
KOM_ILL_AUX_DATA if the text number is non-numeric.
* src/server/testsuite/lyskomd.0/00.exp: Updated the expected
error codes for aux-item-related errors.
* src/server/testsuite/lyskomd.0/03.exp: Ditto.
* src/server/testsuite/lyskomd.0/04.exp: Ditto.
* src/server/testsuite/lyskomd.0/14.exp: Ditto.
* src/server/testsuite/lyskomd.0/17.exp: Ditto.
* src/server/testsuite/lyskomd.0/55.exp: Ditto.
* src/server/testsuite/lyskomd.0/aux-items-cov.exp: Ditto.
* src/server/testsuite/lyskomd.0/bug-572.exp: Ditto.
* src/server/testsuite/lyskomd.0/20.exp: Ditto.  Remove the
want_illegal_aux_item proc and simplify the code that checks the
error codes.
* src/server/testsuite/lyskomd.0/23.exp: Ditto.
* src/server/testsuite/lyskomd.0/26.exp: Ditto.
* src/server/testsuite/lyskomd.0/28.exp: Ditto.

Added test cases for handling duplicate faq-text aux-items.
* src/server/testsuite/lyskomd.0/21.exp: Added new tests that
attempt to set duplicate faq-text aux-items on a conference in
various ways, and removing it and re-adding it.  Also test adding
two different faq-text aux-items at the same time.
parent 16e3ba24
2006-09-28 Per Cederqvist <ceder@lysator.liu.se>
Renamed the error code illegal-aux-item to illegal-aux-item-tag.
Added error code 62=aux-exists, 63=aux-bad-object,
64=illegal-aux-data, 65=aux-create-only, 66=aux-modify-only,
67=aux-server-only, 68=aux-data-exists and 69=aux-no-such-text.
Return proper error codes. (Bug 192).
* doc/Protocol-A.texi (Predefined Aux-Item Types): Renamed the
error code illegal-aux-item to illegal-aux-item-tag.
(create-text): Updated the error code section to mention the
aux-related error codes illegal-aux-item-tag, aux-item-permission,
aux-exists, aux-bad-object, illegal-aux-data, aux-modify-only,
aux-server-only, aux-data-exists and aux-no-such-text instead of
only illegal-aux-item and aux-item-permission. Refer to the
"Error Codes" node instead of duplicating the reasons here.
(create-anonymous-text): Ditto.
(create-conf): Ditto.
(create-person): Ditto.
(modify-text-info): Ditto, but with aux-create-only instead of
aux-modify-only.
(modify-conf-info): Ditto.
(modify-system-info): Ditto.
(Error Codes): Renamed error code 48 from illegal-aux-item to
illegal-aux-item-tag, and redefine it to not include errors in the
data. Added error code 62=aux-exists, 63=aux-bad-object,
64=illegal-aux-data, 65=aux-create-only, 66=aux-modify-only,
67=aux-server-only, 68=aux-data-exists and 69=aux-no-such-text.
* doc/Makefile.am (check-doc): Replaced the error code
illegal-aux-item with illegal-aux-item-tag and
illegal-aux-item-data.
* src/include/kom-errno.h (enum kom_err): Renamed KOM_ILL_AUX to
KOM_ILL_AUX_TAG. Added KOM_AUX_EXISTS, KOM_AUX_BAD_OBJECT,
KOM_ILL_AUX_DATA, KOM_AUX_CREATE_ONLY, KOM_AUX_MODIFY_ONLY,
KOM_AUX_SERVER_ONLY, KOM_AUX_DATA_EXISTS and KOM_AUX_NO_SUCH_TEXT.
* src/server/aux-items.c (aux_item_validate): Doc added. Added
missing punctuation in comments. Set kom_errno to
KOM_ILL_AUX_DATA instead of KOM_ILL_AUX when a regexp cannot be
compiled or doesn't match an entry, or when a validator fails.
(aux_item_add_perm): Document that kom_errno is set on failure.
Do not modify kom_errno on success. Track name change of
KOM_ILL_AUX_TAG. Set KOM_AUX_MODIFY_ONLY, KOM_AUX_CREATE_ONLY,
KOM_AUX_SERVER_ONLY when appropriate (used to be KOM_AUX_PERM).
Don't override the error code set by aux_item_check_unique() or
aux_item_validate() when any of those check fails.
(aux_item_check_unique): Set kom_errno to KOM_AUX_EXISTS or
KOM_AUX_DATA_EXISTS on failure (used to sometimes be
KOM_ILL_AUX).
(text_stat_check_add_aux_item_list): Track name change of
KOM_ILL_AUX_TAG. Set kom_errno to KOM_AUX_BAD_OBJECT if the
aux-item is not allowed on the active object (used to be
KOM_AUX_PERM).
(conf_stat_check_add_aux_item_list): Ditto.
(system_check_add_aux_item_list): Ditto.
(aux_item_validate_existing_text): Set kom_errno to
KOM_AUX_NO_SUCH_TEXT instead of NO_SUCH_TEXT. Set it to
KOM_ILL_AUX_DATA if the text number is non-numeric.
* src/server/testsuite/lyskomd.0/00.exp: Updated the expected
error codes for aux-item-related errors.
* src/server/testsuite/lyskomd.0/03.exp: Ditto.
* src/server/testsuite/lyskomd.0/04.exp: Ditto.
* src/server/testsuite/lyskomd.0/14.exp: Ditto.
* src/server/testsuite/lyskomd.0/17.exp: Ditto.
* src/server/testsuite/lyskomd.0/55.exp: Ditto.
* src/server/testsuite/lyskomd.0/aux-items-cov.exp: Ditto.
* src/server/testsuite/lyskomd.0/bug-572.exp: Ditto.
* src/server/testsuite/lyskomd.0/20.exp: Ditto. Remove the
want_illegal_aux_item proc and simplify the code that checks the
error codes.
* src/server/testsuite/lyskomd.0/23.exp: Ditto.
* src/server/testsuite/lyskomd.0/26.exp: Ditto.
* src/server/testsuite/lyskomd.0/28.exp: Ditto.
Added test cases for handling duplicate faq-text aux-items.
* src/server/testsuite/lyskomd.0/21.exp: Added new tests that
attempt to set duplicate faq-text aux-items on a conference in
various ways, and removing it and re-adding it. Also test adding
two different faq-text aux-items at the same time.
2006-09-09 Per Cederqvist <ceder@lysator.liu.se>
Get rid of gcc-4.1.1 warnings by initializing more fields.
......
......@@ -253,7 +253,8 @@ if HAVE_PYTHON
-e 's/ undef-session$$/ undefined-session/' \
-e 's/ tempfail$$/ temporary-failure/' \
-e 's/ anon-rejected$$/ anonymous-rejected/' \
-e 's/ ill-aux$$/ illegal-aux-item/' \
-e 's/ ill-aux-tag$$/ illegal-aux-item-tag/' \
-e 's/ ill-aux-data$$/ illegal-aux-item-data/' \
-e 's/ aux-perm$$/ aux-item-permission/' \
| tee errorcodes-numbered.tmp \
| sed 's/[0-9]* //' \
......
......@@ -833,7 +833,7 @@ 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 (@errorcode{illegal-aux-item}).
return an error (@errorcode{illegal-aux-item-tag}).
Some items with tags in the range 10000-19999 are also predefined.
They are items that initially were reserved for private use for a
......@@ -7242,12 +7242,17 @@ anonymous texts.
Invalid misc-info list. A recipient is listed more than once or there is
an unknown misc item in the misc-info list.
@item illegal-aux-item
One of the aux-items in @rarg{aux-items} is illegal. The tag might be
out of range, the item not applicable to texts or whatever.
@item aux-item-permission
One of the items looks valid but could not be created anyway.
@item illegal-aux-item-tag
@itemx aux-item-permission
@itemx aux-exists
@itemx aux-bad-object
@itemx illegal-aux-data
@itemx aux-modify-only
@itemx aux-server-only
@itemx aux-data-exists
@itemx aux-no-such-text
One of the aux-items in @rarg{aux-items} is illegal. @xref{Error
Codes}, for the meaning of the various errors.
@item long-array
Too many Misc-Info items or aux-items were specified.
......@@ -7310,11 +7315,19 @@ anonymous texts.
@item illegal-misc
Invalid misc-info list. A recipient is listed more than once or there is
an unknown misc item in the misc-info list.
@item illegal-aux-item
One of the aux-items in @rarg{aux-items} is illegal. The tag might be
out of range, the item not applicable to texts or whatever
@item aux-item-permission
One of the items looks valid but could not be created anyway.
@item illegal-aux-item-tag
@itemx aux-item-permission
@itemx aux-exists
@itemx aux-bad-object
@itemx illegal-aux-data
@itemx aux-modify-only
@itemx aux-server-only
@itemx aux-data-exists
@itemx aux-no-such-text
One of the aux-items in @rarg{aux-items} is illegal. @xref{Error
Codes}, for the meaning of the various errors.
@end table
......@@ -7364,12 +7377,17 @@ A conference named @rarg{name} already exists.
The conference type has the @conftype{secret} bit set, but the
@conftype{rd-prot} bit is cleared.
@item illegal-aux-item
One of the aux-items in @rarg{aux-items} is illegal. The tag might be
out of range, the item not applicable to conferences or whatever
@item aux-item-permission
One of the items looks valid but could not be created anyway.
@item illegal-aux-item-tag
@itemx aux-item-permission
@itemx aux-exists
@itemx aux-bad-object
@itemx illegal-aux-data
@itemx aux-modify-only
@itemx aux-server-only
@itemx aux-data-exists
@itemx aux-no-such-text
One of the aux-items in @rarg{aux-items} is illegal. @xref{Error
Codes}, for the meaning of the various errors.
@item index-out-of-range
Attempt to create a conference failed because we reached the maximum
......@@ -7426,13 +7444,17 @@ There is already a person named @rarg{name}.
@item invalid-password
The string @rarg{passwd} is not a valid password.
@item illegal-aux-item
One of the aux-items in @rarg{aux-items} is illegal. The tag might be
out of range, the item not applicable to conferences or mailboxes or
whatever.
@item aux-item-permission
One of the items looks valid but could not be created anyway.
@item illegal-aux-item-tag
@itemx aux-item-permission
@itemx aux-exists
@itemx aux-bad-object
@itemx illegal-aux-data
@itemx aux-modify-only
@itemx aux-server-only
@itemx aux-data-exists
@itemx aux-no-such-text
One of the aux-items in @rarg{aux-items} is illegal. @xref{Error
Codes}, for the meaning of the various errors.
@item index-out-of-range
Attempt to create a person failed because we reached the maximum
......@@ -7518,12 +7540,20 @@ completely fail or completely succeed.
Login required before issuing this call.
@item no-such-text
The text @rarg{text} does not exist or is secret.
@item aux-item-permission
No permission to delete one or more of the items in @rarg{delete}, or
@rarg{delete} indicates a non-existent aux-item, or not enough
permissions to add one or more of the items in @rarg{add}.
@item illegal-aux-item
One of the items in @rarg{add} is illegal for some reason.
@item illegal-aux-item-tag
@itemx aux-item-permission
@itemx aux-exists
@itemx aux-bad-object
@itemx illegal-aux-data
@itemx aux-create-only
@itemx aux-server-only
@itemx aux-data-exists
@itemx aux-no-such-text
One of the aux-items in @rarg{add} is illegal, or one of items in
@rarg{delete} cannot be deleted or does not exist. @xref{Error
Codes}, for the meaning of the various errors.
@end table
......@@ -7554,12 +7584,20 @@ to either completely fail or completely succeed.
Login required before issuing this call.
@item undefined-conference
The conference @rarg{conf} does not exist or is secret.
@item aux-item-permission
No permission to delete one or more of the items in @rarg{delete}, or
@rarg{delete} indicates a non-existent aux-item, or not enough
permissions to add one or more of the items in @rarg{add}.
@item illegal-aux-item
One of the items in @rarg{add} is illegal for some reason.
@item illegal-aux-item-tag
@itemx aux-item-permission
@itemx aux-exists
@itemx aux-bad-object
@itemx illegal-aux-data
@itemx aux-create-only
@itemx aux-server-only
@itemx aux-data-exists
@itemx aux-no-such-text
One of the aux-items in @rarg{add} is illegal, or one of items in
@rarg{delete} cannot be deleted or does not exist. @xref{Error
Codes}, for the meaning of the various errors.
@end table
......@@ -7610,12 +7648,20 @@ deletions or additions succeeded, or none of them is made.
Login requires before issuing this call.
@item permission-denied
Admin bit not set or privileges not enabled.
@item illegal-aux-item
Attempt to create an invalid aux item.
@item aux-item-permission
No permission to delete one or more of the items in @rarg{items-to-delete}, or
@rarg{items-to-delete} indicates a non-existent aux-item, or not enough
permissions to add one or more of the items in @rarg{items-to-add}.
@item illegal-aux-item-tag
@itemx aux-item-permission
@itemx aux-exists
@itemx aux-bad-object
@itemx illegal-aux-data
@itemx aux-create-only
@itemx aux-server-only
@itemx aux-data-exists
@itemx aux-no-such-text
One of the aux-items in @rarg{items-to-add} is illegal, or one of
items in @rarg{items-to-delete} cannot be deleted or does not exist.
@xref{Error Codes}, for the meaning of the various errors.
@end table
......@@ -9664,10 +9710,10 @@ undefined.
Attempt to send an anonymous text to a conference that does not accept
anonymous texts. @field{error-status} is undefined.
@item illegal-aux-item (48)
Attempt to create an invalid aux-item. Probably the tag or data are
invalid. @field{error-status} contains the index in the aux-item list
where the invalid item appears.
@item illegal-aux-item-tag (48)
Attempt to create an invalid aux-item. The tag is invalid.
@field{error-status} contains the index in the aux-item list where the
invalid item appears.
@item aux-item-permission (49)
Attempt to manipulate an aux-item without enough permissions. This
......@@ -9733,6 +9779,59 @@ An argument of type @type{BOOL} was given a value that is neither
@samp{0} nor @samp{1}.
@field{error-status} is undefined.
@item aux-exists (62)
The aux-item tag is already set on the specified object, and that tag
can only be used once (or once per person, and the tag is already set
by you).
@field{error-status} contains the index in the aux-item list where the
invalid item appears.
@item aux-bad-object (63)
The specified aux-item tag cannot be set on the type of object you are
attempting to set it on.
@field{error-status} contains the index in the aux-item list where the
invalid item appears.
@field{error-status} contains the index in the aux-item list where the
invalid item appears.
@item illegal-aux-data (64)
The value of an aux-item is not acceptable. @xref{Aux-Item Types},
for more information.
@field{error-status} contains the index in the aux-item list where the
invalid item appears.
@item aux-create-only (65)
You are attempting to add a an aux-item to a pre-existing object, but
the aux-item type only allows it to be specified when the object is
created.
@field{error-status} contains the index in the aux-item list where the
invalid item appears.
@item aux-modify-only (66)
You are attempting to add a an aux-item while creating an object, but
the aux-item type only allows it to be added at a later time.
@field{error-status} contains the index in the aux-item list where the
invalid item appears.
@item aux-server-only (67)
You are attempting to add an aux-item of a type that can only be added
by the server itself.
@field{error-status} contains the index in the aux-item list where the
invalid item appears.
@item aux-data-exists (68)
You are attempting to add an aux-item whose value must be unique (such
as @aux{faq-text}), and such an aux-item already exists on the object.
@field{error-status} contains the index in the aux-item list where the
invalid item appears.
@item aux-no-such-text (69)
You are attempting to add an aux-item whose value is (or contains) a
text number, and no such text number exists (or the text is not
readable by you).
@field{error-status} contains the index in the aux-item list where the
invalid item appears.
@end table
......
......@@ -85,8 +85,8 @@ enum kom_err
KOM_TEMPFAIL = 45, /* Try again later. */
KOM_LONG_ARRAY = 46, /* Too long array supplied. */
KOM_ANON_REJECTED = 47, /* Anonymous text not allowed in conference. */
KOM_ILL_AUX = 48, /* Bad misc item */
KOM_AUX_PERM = 49, /* No permission to set aux */
KOM_ILL_AUX_TAG = 48, /* Bad aux item tag value. */
KOM_AUX_PERM = 49, /* No permission to set aux item. */
KOM_UNKNOWN_ASYNC = 50, /* Accepting an unknown async message */
KOM_INTERNAL_ERROR = 51, /* Internal server error */
KOM_FEATURE_DISABLED = 52, /* Server feature is disabled */
......@@ -99,6 +99,14 @@ enum kom_err
KOM_WEIGHT_DENIED = 59, /* You cannot increase your weight that much.*/
KOM_WEIGHT_ZERO = 60, /* You cannot increase your weight that much.*/
KOM_BAD_BOOL = 61, /* A Bool must be 0 or 1. */
KOM_AUX_EXISTS = 62, /* Attempt to set use the same tag twice. */
KOM_AUX_BAD_OBJECT = 63, /* Aux item cannot be set on this object. */
KOM_ILL_AUX_DATA = 64, /* Bad aux item value. */
KOM_AUX_CREATE_ONLY = 65, /* Aux item cannot be added later. */
KOM_AUX_MODIFY_ONLY = 66, /* Aux item can only be added later. */
KOM_AUX_SERVER_ONLY = 67, /* Aux item can only be added by the server. */
KOM_AUX_DATA_EXISTS = 68, /* Attempt to set use the same value twice. */
KOM_AUX_NO_SUCH_TEXT = 69, /* Attempt to link to non-existing text. */
KOM_num_errs /* End marker */
};
......
......@@ -888,6 +888,9 @@ prepare_aux_item(Aux_item *item,
/*
* Sets kom_errno when it returns FAILURE.
*/
static Success
aux_item_validate(Aux_item_validation_data validation_data)
{
......@@ -901,10 +904,11 @@ aux_item_validate(Aux_item_validation_data validation_data)
{
case AUX_VALIDATE_FUNCTION:
/*
* Call the validation function
* If it returns FAILURE, then abort validation
* Call the validation function.
* If it returns FAILURE, then abort validation (the
* validation function must set kom_errno).
* If it returns OK, then continue with the
* next validator
* next validator.
*/
if ((*def->validators[i].v.fn.function)(&validation_data) != OK)
......@@ -916,7 +920,7 @@ aux_item_validate(Aux_item_validation_data validation_data)
case AUX_VALIDATE_REGEXP:
/*
* Ensure that the regexp is cached
* Ensure that the regexp is cached.
*/
if (def->validators[i].v.re.cached_re_buf == NULL)
......@@ -925,9 +929,9 @@ aux_item_validate(Aux_item_validation_data validation_data)
}
/*
* 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 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)
......@@ -938,7 +942,7 @@ aux_item_validate(Aux_item_validation_data validation_data)
sfree(def->validators[i].v.re.regexp);
def->validators[i].v.re.regexp = NULL;
def->validators[i].type = AUX_VALIDATE_REJECT;
kom_errno = KOM_ILL_AUX;
kom_errno = KOM_ILL_AUX_DATA;
return FAILURE;
}
......@@ -955,12 +959,12 @@ aux_item_validate(Aux_item_validation_data validation_data)
{
case -1:
/* No match */
kom_errno = KOM_ILL_AUX;
kom_errno = KOM_ILL_AUX_DATA;
return FAILURE;
case -2:
/* Internal error (may be temporary) */
kom_log("Internal error in regex matching aux-item data.\n");
kom_errno = KOM_ILL_AUX;
kom_errno = KOM_ILL_AUX_DATA;
return FAILURE;
break;
default:
......@@ -974,10 +978,10 @@ aux_item_validate(Aux_item_validation_data validation_data)
case AUX_VALIDATE_REJECT:
/*
* Just reject the item. Used when we detect a problem
* with a validator
* with a validator.
*/
kom_errno = KOM_ILL_AUX;
kom_errno = KOM_ILL_AUX_DATA;
return FAILURE;
break;
......@@ -988,7 +992,7 @@ aux_item_validate(Aux_item_validation_data validation_data)
}
/*
* If we got all the way to here we passed all the validators
* If we got all the way to here we passed all the validators.
*/
return OK;
......@@ -1015,6 +1019,8 @@ aux_item_validate(Aux_item_validation_data validation_data)
* CREATING is true if we are checking while creating the object that
* the item will be added to.
* OBJECT_TYPE is the type of the object the item is added to.
*
* Sets kom_errno when it returns FALSE.
*/
static Bool
......@@ -1029,8 +1035,6 @@ aux_item_add_perm(const Aux_item *item,
{
short can_add_when = 0;
kom_errno = KOM_NO_ERROR;
/* Either there is a connection responsible for the creation, or
we are inheriting. If we are inheriting, creating must be true. */
assert(creating_conn != NULL || creating);
......@@ -1042,13 +1046,13 @@ aux_item_add_perm(const Aux_item *item,
if (def == NULL)
{
kom_errno = KOM_ILL_AUX;
kom_errno = KOM_ILL_AUX_TAG;
return FALSE;
}
if (def->disabled)
{
kom_errno = KOM_ILL_AUX;
kom_errno = KOM_ILL_AUX_TAG;
return FALSE;
}
......@@ -1061,17 +1065,27 @@ aux_item_add_perm(const Aux_item *item,
if (can_add_when)
{
if (!((creating && (can_add_when & AUX_ITEM_ADD_ON_CREATE))
|| (!creating && (can_add_when & AUX_ITEM_ADD_ON_MODIFY))))
if (creating)
{
kom_errno = KOM_AUX_PERM;
if (!(can_add_when & AUX_ITEM_ADD_ON_CREATE))
{
kom_errno = KOM_AUX_MODIFY_ONLY;
return FALSE;
}
}
else
{
if (!(can_add_when & AUX_ITEM_ADD_ON_MODIFY))
{
kom_errno = KOM_AUX_CREATE_ONLY;
return FALSE;
}
}
}
if (def->system_only)
{
kom_errno = KOM_AUX_PERM;
kom_errno = KOM_AUX_SERVER_ONLY;
return FALSE;
}
......@@ -1100,12 +1114,8 @@ aux_item_add_perm(const Aux_item *item,
/* Even the administrator can't override this */
kom_errno = KOM_NO_ERROR;
if (!aux_item_check_unique(item, def, add_to_list, start_looking_at))
{
kom_errno = kom_errno?kom_errno:KOM_AUX_PERM;
return FALSE;
}
/* Check the contents */
......@@ -1129,11 +1139,8 @@ aux_item_add_perm(const Aux_item *item,
#endif
if (aux_item_validate(validation_data) != OK)
{
kom_errno = KOM_ILL_AUX;
return FALSE;
}
}
return TRUE;
}
......@@ -1147,6 +1154,8 @@ aux_item_add_perm(const Aux_item *item,
* DEF is the item's definitioon
* ADD_TO_LIST is the list we want to add to
* START_LOOKING_AT is the first index in the list to look at.
*
* Sets kom_errno when it returns FALSE.
*/
static Bool
......@@ -1172,13 +1181,16 @@ aux_item_check_unique(const Aux_item *item,
&& add_to_list->items[i].tag == item->tag
&& add_to_list->items[i].creator == item->creator
&& !add_to_list->items[i].flags.deleted)
{
kom_errno = KOM_AUX_EXISTS;
return FALSE;
}
if (def->unique_data
&& add_to_list->items[i].tag == item->tag
&& s_streq(add_to_list->items[i].data, item->data))
{
kom_errno = KOM_ILL_AUX;
kom_errno = KOM_AUX_DATA_EXISTS;
return FALSE;
}
}
......@@ -1722,7 +1734,14 @@ text_stat_check_add_aux_item_list(Text_stat *text_s,
def = find_aux_item_definition(item);
if (def == NULL)
{
kom_errno = KOM_ILL_AUX;
kom_errno = KOM_ILL_AUX_TAG;
err_stat = i;
return FAILURE;
}
if (!def->texts)
{
kom_errno = KOM_AUX_BAD_OBJECT;
err_stat = i;
return FAILURE;
}
......@@ -1735,8 +1754,7 @@ text_stat_check_add_aux_item_list(Text_stat *text_s,
0,
text_s == NULL,
TEXT_OBJECT_TYPE)
|| !aux_item_check_unique(item, def, list, i + 1)
|| !def->texts)
|| !aux_item_check_unique(item, def, list, i + 1))
{
kom_errno = kom_errno?kom_errno:KOM_AUX_PERM;
err_stat = i;
......@@ -1791,7 +1809,14 @@ conf_stat_check_add_aux_item_list(Conference *conf,
def = find_aux_item_definition(item);
if (def == NULL)
{
kom_errno = KOM_ILL_AUX;
kom_errno = KOM_ILL_AUX_TAG;
err_stat = i;
return FAILURE;
}
if (conf->type.letter_box ? !def->letterboxes : !def->confs)
{
kom_errno = KOM_AUX_BAD_OBJECT;
err_stat = i;
return FAILURE;
}
......@@ -1804,9 +1829,7 @@ conf_stat_check_add_aux_item_list(Conference *conf,
0,
creating,
CONF_OBJECT_TYPE)
|| !aux_item_check_unique(item, def, list, i + 1)
|| (!conf->type.letter_box && !def->confs)
|| (conf->type.letter_box && !def->letterboxes))
|| !aux_item_check_unique(item, def, list, i + 1))
{
kom_errno = kom_errno?kom_errno:KOM_AUX_PERM;
err_stat = i;
......@@ -1855,7 +1878,20 @@ Success system_check_add_aux_item_list(Info *info,
def = find_aux_item_definition(item);
if (def == NULL)
{
kom_errno = KOM_ILL_AUX;
kom_errno = KOM_ILL_AUX_TAG;
err_stat = i;
return FAILURE;
}