public inbox for linux-audit@redhat.com
 help / color / mirror / Atom feed
* [PATCH 1/2] auparse: Remove quotes from parsed fields
@ 2012-02-08 17:04 Marcelo Cerri
  2012-02-08 17:04 ` [PATCH 2/2] auvirt: Remove workaround for VM name searching Marcelo Cerri
  2012-02-08 18:54 ` [PATCH 1/2] auparse: Remove quotes from parsed fields Steve Grubb
  0 siblings, 2 replies; 8+ messages in thread
From: Marcelo Cerri @ 2012-02-08 17:04 UTC (permalink / raw)
  To: linux-audit; +Cc: gcwilson, bryntcor

Auparse just removes single quotes at the end of a field value and leaves
quotes at the beginning. With this patch, auparse removes quotes at the
beggining of a parsed field value and handles double quotes at the same way as
single quotes.

This is a simple test program to reproduce the problem:

-----
int main() {
	const char *buffer= "type=VIRT_RESOURCE msg=audit(1327574186.046:174): user pid=6748 uid=0 auid=500 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0 msg='virt=kvm resrc=net reason=start vm=\"CentOS\" uuid=fb4149f5-9ff6-4095-f6d3-a1d03936fdfa old-net='?' new-net='52:54:00:DB:AE:B4 test': exe=\"/usr/sbin/libvirtd\" hostname=? addr=? terminal=? res=success'\n";
	auparse_state_t *au = auparse_init(AUSOURCE_BUFFER, buffer);
	if (au == NULL) return -1;
	while (auparse_next_event(au) > 0) {
		printf("%s\n", auparse_find_field(au, "new-net"));
	}
	auparse_destroy(au);
	return 0;
}

-----
---
 auparse/ellist.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/auparse/ellist.c b/auparse/ellist.c
index eafcfee..8c3061d 100644
--- a/auparse/ellist.c
+++ b/auparse/ellist.c
@@ -137,6 +137,9 @@ static int parse_up_record(rnode* r)
 			// Remove beginning cruft of name
 			if (*ptr == '(')
 				ptr++;
+			// Remove quotes
+			if (*val == '\'' || *val == '"')
+				val++;
 			n.name = strdup(ptr);
 			n.val = strdup(val);
 			// Remove trailing punctuation
@@ -149,7 +152,8 @@ static int parse_up_record(rnode* r)
 				n.val[len-1] = 0;
 				len--;
 			}
-			if (len && n.val[len-1] == '\'') {
+			if (len && (n.val[len - 1] == '\''
+					|| n.val[len - 1] == '"')) {
 				n.val[len-1] = 0;
 				len--;
 			}
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-02-09 18:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-08 17:04 [PATCH 1/2] auparse: Remove quotes from parsed fields Marcelo Cerri
2012-02-08 17:04 ` [PATCH 2/2] auvirt: Remove workaround for VM name searching Marcelo Cerri
2012-02-08 19:06   ` Steve Grubb
2012-02-09 13:22     ` Marcelo Cerri
2012-02-09 13:35       ` Steve Grubb
2012-02-09 17:51         ` Marcelo Cerri
2012-02-09 18:04           ` Steve Grubb
2012-02-08 18:54 ` [PATCH 1/2] auparse: Remove quotes from parsed fields Steve Grubb

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox