#!/usr/bin/env bash

{
  DATE=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")
  FDATE=$(date "+%Y-%m-%d")
  LOG="/data/log/auth/${FDATE}.log"

  echo "${DATE} ${IP} (${USER}) [imap]" >> "${LOG}"
  /bin/chmod 664 "${LOG}" 2> /dev/null
} || {
  : # noop
}

exec "$@"
