timestamp = arg_timestamp != USEC_INFINITY ? arg_timestamp : now(CLOCK_REALTIME);
- if (arg_not_after != USEC_INFINITY && arg_not_after < timestamp)
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Credential is invalidated before it is valid.");
+ if (arg_not_after != USEC_INFINITY && arg_not_after <= timestamp)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Credential is invalidated before or when it becomes valid.");
if (geteuid() != 0 && !sd_id128_equal(arg_with_key, CRED_AES256_GCM_BY_NULL)) {
(void) polkit_agent_open_if_enabled(BUS_TRANSPORT_LOCAL, arg_ask_password);
timestamp_fresh = true;
} else
timestamp_fresh = timestamp_is_fresh(p.timestamp);
- if (p.not_after != UINT64_MAX && p.not_after < p.timestamp)
+ if (p.not_after != UINT64_MAX && p.not_after <= p.timestamp)
return sd_varlink_error_invalid_parameter_name(link, "notAfter");
r = settle_scope(link, &p.scope, &p.uid, &cflags, /* any_scope_after_polkit= */ NULL);
if (name && !credential_name_valid(name))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid credential name: %s", name);
- if (not_after != USEC_INFINITY && timestamp != USEC_INFINITY && not_after < timestamp)
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Credential is invalidated before it is valid (" USEC_FMT " < " USEC_FMT ").", not_after, timestamp);
+ if (not_after != USEC_INFINITY && timestamp != USEC_INFINITY && not_after <= timestamp)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Credential is invalidated before or when it becomes valid (" USEC_FMT " <= " USEC_FMT ").", not_after, timestamp);
if (DEBUG_LOGGING) {
char buf[FORMAT_TIMESTAMP_MAX];
systemd-creds decrypt /tmp/cred.enc /tmp/cred.dec
diff /tmp/cred.orig /tmp/cred.dec
rm -f /tmp/cred.{enc,dec}
+ts="$(date -u '+%Y-%m-%d %H:%M:%S UTC')"
+(! systemd-creds --with-key=null --timestamp="$ts" --not-after="$ts" encrypt /tmp/cred.orig /tmp/cred.enc)
# Null-key credentials and the systemd.credentials_boot_policy= setting.
#