From 4b82be77aa2f1499aff9d777893aba1aaa72101e Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 10 Apr 2019 11:30:53 +0200 Subject: [syslog] Set UUID = null if seemingly invalid --- modules-available/syslog/api.inc.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules-available/syslog/api.inc.php b/modules-available/syslog/api.inc.php index 945f9d09..a8a8b0da 100644 --- a/modules-available/syslog/api.inc.php +++ b/modules-available/syslog/api.inc.php @@ -48,7 +48,9 @@ if (substr($ip, 0, 7) === '::ffff:') $ip = substr($ip, 7); // TODO: Handle UUID in appropriate modules (optional) $uuid = Request::post('uuid', '', 'string'); if (strlen($uuid) !== 36) { - // Probably invalid UUID. What to do? Set empty or ignore? + // Probably invalid UUID. What to do? Set NULL for now so the insert will succeed + $uuid = null; + error_log("Client log event $type without UUID"); } /* @@ -70,13 +72,17 @@ if ($type{0} !== '.' && $type{0} !== '~') { exit(0); } - Database::exec('INSERT INTO clientlog (dateline, logtypeid, clientip, machineuuid, description, extra) VALUES (UNIX_TIMESTAMP(), :type, :client, :uuid, :description, :longdesc)', array( + $ret = Database::exec('INSERT INTO clientlog (dateline, logtypeid, clientip, machineuuid, description, extra) VALUES (UNIX_TIMESTAMP(), :type, :client, :uuid, :description, :longdesc)', array( 'type' => $type, 'client' => $ip, 'description' => $description, 'longdesc' => $longdesc, 'uuid' => $uuid, - )); + ), true); + if ($ret === false) { + error_log("Constraint failed for client log from $uuid for $type : $description"); + die("NOPE.\n"); + } } -- cgit v1.2.3-55-g7522