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> 2006-09-09 Per Cederqvist <ceder@lysator.liu.se>
Get rid of gcc-4.1.1 warnings by initializing more fields. Get rid of gcc-4.1.1 warnings by initializing more fields.
......
...@@ -253,7 +253,8 @@ if HAVE_PYTHON ...@@ -253,7 +253,8 @@ if HAVE_PYTHON
-e 's/ undef-session$$/ undefined-session/' \ -e 's/ undef-session$$/ undefined-session/' \
-e 's/ tempfail$$/ temporary-failure/' \ -e 's/ tempfail$$/ temporary-failure/' \
-e 's/ anon-rejected$$/ anonymous-rejected/' \ -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/' \ -e 's/ aux-perm$$/ aux-item-permission/' \
| tee errorcodes-numbered.tmp \ | tee errorcodes-numbered.tmp \
| sed 's/[0-9]* //' \ | sed 's/[0-9]* //' \
......
...@@ -833,7 +833,7 @@ field of an item, regardless of what the client requests. ...@@ -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 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 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 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. Some items with tags in the range 10000-19999 are also predefined.
They are items that initially were reserved for private use for a They are items that initially were reserved for private use for a
...@@ -7242,12 +7242,17 @@ anonymous texts. ...@@ -7242,12 +7242,17 @@ anonymous texts.
Invalid misc-info list. A recipient is listed more than once or there is Invalid misc-info list. A recipient is listed more than once or there is
an unknown misc item in the misc-info list. an unknown misc item in the misc-info list.
@item illegal-aux-item @item illegal-aux-item-tag
One of the aux-items in @rarg{aux-items} is illegal. The tag might be @itemx aux-item-permission
out of range, the item not applicable to texts or whatever. @itemx aux-exists
@itemx aux-bad-object
@item aux-item-permission @itemx illegal-aux-data
One of the items looks valid but could not be created anyway. @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 @item long-array
Too many Misc-Info items or aux-items were specified. Too many Misc-Info items or aux-items were specified.
...@@ -7310,11 +7315,19 @@ anonymous texts. ...@@ -7310,11 +7315,19 @@ anonymous texts.
@item illegal-misc @item illegal-misc
Invalid misc-info list. A recipient is listed more than once or there is Invalid misc-info list. A recipient is listed more than once or there is
an unknown misc item in the misc-info list. 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 @item illegal-aux-item-tag
out of range, the item not applicable to texts or whatever @itemx aux-item-permission
@item aux-item-permission @itemx aux-exists
One of the items looks valid but could not be created anyway. @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 @end table
...@@ -7364,12 +7377,17 @@ A conference named @rarg{name} already exists. ...@@ -7364,12 +7377,17 @@ A conference named @rarg{name} already exists.
The conference type has the @conftype{secret} bit set, but the The conference type has the @conftype{secret} bit set, but the
@conftype{rd-prot} bit is cleared. @conftype{rd-prot} bit is cleared.
@item illegal-aux-item @item illegal-aux-item-tag
One of the aux-items in @rarg{aux-items} is illegal. The tag might be @itemx aux-item-permission
out of range, the item not applicable to conferences or whatever @itemx aux-exists
@itemx aux-bad-object
@item aux-item-permission @itemx illegal-aux-data
One of the items looks valid but could not be created anyway. @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 @item index-out-of-range
Attempt to create a conference failed because we reached the maximum Attempt to create a conference failed because we reached the maximum
...@@ -7426,13 +7444,17 @@ There is already a person named @rarg{name}. ...@@ -7426,13 +7444,17 @@ There is already a person named @rarg{name}.
@item invalid-password @item invalid-password
The string @rarg{passwd} is not a valid password. The string @rarg{passwd} is not a valid password.
@item illegal-aux-item @item illegal-aux-item-tag
One of the aux-items in @rarg{aux-items} is illegal. The tag might be @itemx aux-item-permission
out of range, the item not applicable to conferences or mailboxes or @itemx aux-exists
whatever. @itemx aux-bad-object
@itemx illegal-aux-data
@item aux-item-permission @itemx aux-modify-only
One of the items looks valid but could not be created anyway. @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 @item index-out-of-range
Attempt to create a person failed because we reached the maximum Attempt to create a person failed because we reached the maximum
...@@ -7518,12 +7540,20 @@ completely fail or completely succeed. ...@@ -7518,12 +7540,20 @@ completely fail or completely succeed.
Login required before issuing this call. Login required before issuing this call.
@item no-such-text @item no-such-text
The text @rarg{text} does not exist or is secret. 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 @item illegal-aux-item-tag
@rarg{delete} indicates a non-existent aux-item, or not enough @itemx aux-item-permission
permissions to add one or more of the items in @rarg{add}. @itemx aux-exists
@item illegal-aux-item @itemx aux-bad-object
One of the items in @rarg{add} is illegal for some reason. @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 @end table
...@@ -7554,12 +7584,20 @@ to either completely fail or completely succeed. ...@@ -7554,12 +7584,20 @@ to either completely fail or completely succeed.
Login required before issuing this call. Login required before issuing this call.
@item undefined-conference @item undefined-conference
The conference @rarg{conf} does not exist or is secret. 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 @item illegal-aux-item-tag
@rarg{delete} indicates a non-existent aux-item, or not enough @itemx aux-item-permission
permissions to add one or more of the items in @rarg{add}. @itemx aux-exists
@item illegal-aux-item @itemx aux-bad-object
One of the items in @rarg{add} is illegal for some reason. @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 @end table
...@@ -7610,12 +7648,20 @@ deletions or additions succeeded, or none of them is made. ...@@ -7610,12 +7648,20 @@ deletions or additions succeeded, or none of them is made.
Login requires before issuing this call. Login requires before issuing this call.
@item permission-denied @item permission-denied
Admin bit not set or privileges not enabled. Admin bit not set or privileges not enabled.
@item illegal-aux-item
Attempt to create an invalid aux item. @item illegal-aux-item-tag
@item aux-item-permission @itemx aux-item-permission
No permission to delete one or more of the items in @rarg{items-to-delete}, or @itemx aux-exists
@rarg{items-to-delete} indicates a non-existent aux-item, or not enough @itemx aux-bad-object
permissions to add one or more of the items in @rarg{items-to-add}. @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 @end table
...@@ -9664,10 +9710,10 @@ undefined. ...@@ -9664,10 +9710,10 @@ undefined.
Attempt to send an anonymous text to a conference that does not accept Attempt to send an anonymous text to a conference that does not accept
anonymous texts. @field{error-status} is undefined. anonymous texts. @field{error-status} is undefined.
@item illegal-aux-item (48) @item illegal-aux-item-tag (48)
Attempt to create an invalid aux-item. Probably the tag or data are Attempt to create an invalid aux-item. The tag is invalid.
invalid. @field{error-status} contains the index in the aux-item list @field{error-status} contains the index in the aux-item list where the
where the invalid item appears. invalid item appears.
@item aux-item-permission (49) @item aux-item-permission (49)
Attempt to manipulate an aux-item without enough permissions. This 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 ...@@ -9733,6 +9779,59 @@ An argument of type @type{BOOL} was given a value that is neither
@samp{0} nor @samp{1}. @samp{0} nor @samp{1}.
@field{error-status} is undefined. @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 @end table
......
...@@ -85,8 +85,8 @@ enum kom_err ...@@ -85,8 +85,8 @@ enum kom_err
KOM_TEMPFAIL = 45, /* Try again later. */ KOM_TEMPFAIL = 45, /* Try again later. */
KOM_LONG_ARRAY = 46, /* Too long array supplied. */ KOM_LONG_ARRAY = 46, /* Too long array supplied. */
KOM_ANON_REJECTED = 47, /* Anonymous text not allowed in conference. */ KOM_ANON_REJECTED = 47, /* Anonymous text not allowed in conference. */
KOM_ILL_AUX = 48, /* Bad misc item */ KOM_ILL_AUX_TAG = 48, /* Bad aux item tag value. */
KOM_AUX_PERM = 49, /* No permission to set aux */ KOM_AUX_PERM = 49, /* No permission to set aux item. */
KOM_UNKNOWN_ASYNC = 50, /* Accepting an unknown async message */ KOM_UNKNOWN_ASYNC = 50, /* Accepting an unknown async message */
KOM_INTERNAL_ERROR = 51, /* Internal server error */ KOM_INTERNAL_ERROR = 51, /* Internal server error */
KOM_FEATURE_DISABLED = 52, /* Server feature is disabled */ KOM_FEATURE_DISABLED = 52, /* Server feature is disabled */
...@@ -99,6 +99,14 @@ enum kom_err ...@@ -99,6 +99,14 @@ enum kom_err
KOM_WEIGHT_DENIED = 59, /* You cannot increase your weight that much.*/ KOM_WEIGHT_DENIED = 59, /* You cannot increase your weight that much.*/
KOM_WEIGHT_ZERO = 60, /* 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_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 */ KOM_num_errs /* End marker */
}; };
......
...@@ -888,6 +888,9 @@ prepare_aux_item(Aux_item *item, ...@@ -888,6 +888,9 @@ prepare_aux_item(Aux_item *item,
/*
* Sets kom_errno when it returns FAILURE.
*/
static Success static Success
aux_item_validate(Aux_item_validation_data validation_data) aux_item_validate(Aux_item_validation_data validation_data)
{ {
...@@ -901,10 +904,11 @@ 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: case AUX_VALIDATE_FUNCTION:
/* /*
* Call the validation function * Call the validation function.
* If it returns FAILURE, then abort validation * If it returns FAILURE, then abort validation (the
* validation function must set kom_errno).
* If it returns OK, then continue with the * If it returns OK, then continue with the
* next validator * next validator.
*/ */
if ((*def->validators[i].v.fn.function)(&validation_data) != OK) if ((*def->validators[i].v.fn.function)(&validation_data) != OK)
...@@ -916,7 +920,7 @@ aux_item_validate(Aux_item_validation_data validation_data) ...@@ -916,7 +920,7 @@ aux_item_validate(Aux_item_validation_data validation_data)
case AUX_VALIDATE_REGEXP: 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) if (def->validators[i].v.re.cached_re_buf == NULL)
...@@ -925,9 +929,9 @@ aux_item_validate(Aux_item_validation_data validation_data) ...@@ -925,9 +929,9 @@ aux_item_validate(Aux_item_validation_data validation_data)
} }
/* /*
* If the RE is still not cached there is a problem * If the RE is still not cached there is a problem.
* in this case to not validate the item at all and * In this case to not validate the item at all and
* log a problem * log a problem.
*/ */
if (def->validators[i].v.re.cached_re_buf == NULL) if (def->validators[i].v.re.cached_re_buf == NULL)
...@@ -938,7 +942,7 @@ aux_item_validate(Aux_item_validation_data validation_data) ...@@ -938,7 +942,7 @@ aux_item_validate(Aux_item_validation_data validation_data)
sfree(def->validators[i].v.re.regexp); sfree(def->validators[i].v.re.regexp);
def->validators[i].v.re.regexp = NULL; def->validators[i].v.re.regexp = NULL;
def->validators[i].type = AUX_VALIDATE_REJECT; def->validators[i].type = AUX_VALIDATE_REJECT;
kom_errno = KOM_ILL_AUX; kom_errno = KOM_ILL_AUX_DATA;
return FAILURE; return FAILURE;
} }
...@@ -955,12 +959,12 @@ aux_item_validate(Aux_item_validation_data validation_data) ...@@ -955,12 +959,12 @@ aux_item_validate(Aux_item_validation_data validation_data)
{ {
case -1: case -1:
/* No match */ /* No match */
kom_errno = KOM_ILL_AUX; kom_errno = KOM_ILL_AUX_DATA;
return FAILURE; return FAILURE;
case -2: case -2:
/* Internal error (may be temporary) */ /* Internal error (may be temporary) */
kom_log("Internal error in regex matching aux-item data.\n"); kom_log("Internal error in regex matching aux-item data.\n");
kom_errno = KOM_ILL_AUX; kom_errno = KOM_ILL_AUX_DATA;
return FAILURE; return FAILURE;
break; break;
default: default:
...@@ -974,10 +978,10 @@ aux_item_validate(Aux_item_validation_data validation_data) ...@@ -974,10 +978,10 @@ aux_item_validate(Aux_item_validation_data validation_data)
case AUX_VALIDATE_REJECT: case AUX_VALIDATE_REJECT:
/* /*
* Just reject the item. Used when we detect a problem * 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; return FAILURE;
break; break;
...@@ -988,7 +992,7 @@ aux_item_validate(Aux_item_validation_data validation_data) ...@@ -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; return OK;
...@@ -1015,6 +1019,8 @@ aux_item_validate(Aux_item_validation_data validation_data) ...@@ -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 * CREATING is true if we are checking while creating the object that
* the item will be added to. * the item will be added to.
* OBJECT_TYPE is the type of the object the item is added to. * OBJECT_TYPE is the type of the object the item is added to.
*
* Sets kom_errno when it returns FALSE.
*/ */
static Bool static Bool
...@@ -1029,8 +1035,6 @@ aux_item_add_perm(const Aux_item *item, ...@@ -1029,8 +1035,6 @@ aux_item_add_perm(const Aux_item *item,
{ {
short can_add_when = 0; short can_add_when = 0;
kom_errno = KOM_NO_ERROR;
/* Either there is a connection responsible for the creation, or /* Either there is a connection responsible for the creation, or
we are inheriting. If we are inheriting, creating must be true. */ we are inheriting. If we are inheriting, creating must be true. */
assert(creating_conn != NULL || creating); assert(creating_conn != NULL || creating);
...@@ -1042,13 +1046,13 @@ aux_item_add_perm(const Aux_item *item, ...@@ -1042,13 +1046,13 @@ aux_item_add_perm(const Aux_item *item,
if (def == NULL) if (def == NULL)
{ {
kom_errno = KOM_ILL_AUX; kom_errno = KOM_ILL_AUX_TAG;
return FALSE; return FALSE;
} }
if (def->disabled) if (def->disabled)
{ {
kom_errno = KOM_ILL_AUX; kom_errno = KOM_ILL_AUX_TAG;
return FALSE; return FALSE;
} }
...@@ -1061,17 +1065,27 @@ aux_item_add_perm(const Aux_item *item, ...@@ -1061,17 +1065,27 @@ aux_item_add_perm(const Aux_item *item,
if (can_add_when) if (can_add_when)
{ {
if (!((creating && (can_add_when & AUX_ITEM_ADD_ON_CREATE)) if (creating)
|| (!creating && (can_add_when & AUX_ITEM_ADD_ON_MODIFY)))) {
if (!(can_add_when & AUX_ITEM_ADD_ON_CREATE))
{
kom_errno = KOM_AUX_MODIFY_ONLY;
return FALSE;
}
}
else
{ {
kom_errno = KOM_AUX_PERM; if (!(can_add_when & AUX_ITEM_ADD_ON_MODIFY))
return FALSE; {
} kom_errno = KOM_AUX_CREATE_ONLY;
return FALSE;
}
}