mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-12 13:17:58 +03:00
Add audit helper for escaping log message strings
Add a helper API for ecscaping the value in audit log messages * src/util/virtaudit.h, src/util/virtaudit.c, src/libvirt_private.syms: Add virAuditEncode
This commit is contained in:
parent
e06772f006
commit
6a75a3fa3d
@ -794,6 +794,7 @@ virUUIDParse;
|
||||
|
||||
# virtaudit.h
|
||||
virAuditClose;
|
||||
virAuditEncode;
|
||||
virAuditLog;
|
||||
virAuditOpen;
|
||||
virAuditSend;
|
||||
|
@ -136,3 +136,15 @@ void virAuditClose(void)
|
||||
close(auditfd);
|
||||
#endif
|
||||
}
|
||||
|
||||
char *virAuditEncode(const char *key, const char *value)
|
||||
{
|
||||
#if HAVE_AUDIT
|
||||
return audit_encode_nv_string(key, value, 0);
|
||||
#else
|
||||
char *str;
|
||||
if (virAsprintf(&str, "%s=%s", key, value) < 0)
|
||||
return NULL;
|
||||
return str;
|
||||
#endif
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ void virAuditSend(const char *file, const char *func, size_t linenr,
|
||||
enum virAuditRecordType type, bool success,
|
||||
const char *fmt, ...);
|
||||
|
||||
char *virAuditEncode(const char *key, const char *value);
|
||||
|
||||
void virAuditClose(void);
|
||||
|
||||
# define VIR_AUDIT(type, success, ...) \
|
||||
@ -51,5 +53,7 @@ void virAuditClose(void);
|
||||
virAuditSend(__FILE__, __func__, __LINE__, \
|
||||
clienttty, clientaddr, type, success, __VA_ARGS__);
|
||||
|
||||
# define VIR_AUDIT_STR(str) \
|
||||
((str) ? (str) : "?")
|
||||
|
||||
#endif /* __LIBVIRT_AUDIT_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user