summaryrefslogtreecommitdiff
path: root/debian/patches/tac_add_attrib_truncate.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/tac_add_attrib_truncate.patch')
-rw-r--r--debian/patches/tac_add_attrib_truncate.patch76
1 files changed, 76 insertions, 0 deletions
diff --git a/debian/patches/tac_add_attrib_truncate.patch b/debian/patches/tac_add_attrib_truncate.patch
new file mode 100644
index 0000000..ee64fff
--- /dev/null
+++ b/debian/patches/tac_add_attrib_truncate.patch
@@ -0,0 +1,76 @@
+--- a/libtac/include/libtac.h
++++ b/libtac/include/libtac.h
+@@ -154,6 +154,8 @@ int tac_author_send(int, const char *, c
+ int tac_author_read(int, struct areply *);
+ int tac_add_attrib_pair(struct tac_attrib **, char *, char,
+ char *);
++int tac_add_attrib_truncate(struct tac_attrib **attr, char *name, char *value);
++int tac_add_attrib_pair_truncate(struct tac_attrib **attr, char *name, char sep, char *value);
+ int tac_read_wait(int, int, int, int *);
+
+ /* magic.c */
+--- a/libtac/lib/attrib.c
++++ b/libtac/lib/attrib.c
+@@ -20,14 +20,14 @@
+ * See `CHANGES' file for revision history.
+ */
+
++#include <stdbool.h>
++
+ #include "libtac.h"
+ #include "xalloc.h"
+
+-int tac_add_attrib(struct tac_attrib **attr, char *name, char *value) {
+- return tac_add_attrib_pair(attr, name, '=', value);
+-}
+-
+-int tac_add_attrib_pair(struct tac_attrib **attr, char *name, char sep, char *value) {
++static int _tac_add_attrib_pair(struct tac_attrib **attr, char *name,
++ char sep, char *value, bool truncate)
++{
+ struct tac_attrib *a;
+ size_t l1 = strlen(name);
+ size_t l2;
+@@ -49,10 +49,15 @@ int tac_add_attrib_pair(struct tac_attri
+ }
+
+ if (l2 > TAC_PLUS_ATTRIB_MAX_LEN-total_len) {
+- TACSYSLOG((LOG_WARNING,\
+- "%s: attribute `%s' total length exceeds %d characters, skipping",\
+- __FUNCTION__, name, TAC_PLUS_ATTRIB_MAX_LEN))
+- return LIBTAC_STATUS_ATTRIB_TOO_LONG;
++ if (truncate) {
++ l2 = TAC_PLUS_ATTRIB_MAX_LEN-total_len;
++ }
++ else {
++ TACSYSLOG((LOG_WARNING,\
++ "%s: attribute `%s' total length exceeds %d characters, skipping",\
++ __FUNCTION__, name, TAC_PLUS_ATTRIB_MAX_LEN))
++ return LIBTAC_STATUS_ATTRIB_TOO_LONG;
++ }
+ }
+
+ total_len += l2;
+@@ -89,6 +94,22 @@ int tac_add_attrib_pair(struct tac_attri
+ return 0;
+ }
+
++int tac_add_attrib(struct tac_attrib **attr, char *name, char *value) {
++ return tac_add_attrib_pair(attr, name, '=', value);
++}
++
++int tac_add_attrib_pair(struct tac_attrib **attr, char *name, char sep, char *value) {
++ return _tac_add_attrib_pair(attr, name, sep, value, false);
++}
++
++int tac_add_attrib_truncate(struct tac_attrib **attr, char *name, char *value) {
++ return tac_add_attrib_pair_truncate(attr, name, '=', value);
++}
++
++int tac_add_attrib_pair_truncate(struct tac_attrib **attr, char *name, char sep, char *value) {
++ return _tac_add_attrib_pair(attr, name, sep, value, true);
++}
++
+ void tac_free_attrib(struct tac_attrib **attr) {
+ struct tac_attrib *a;
+ struct tac_attrib *b;