diff options
Diffstat (limited to 'src/nm-core-utils.c')
| -rw-r--r-- | src/nm-core-utils.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c index b1a4cc25..54ccdb83 100644 --- a/src/nm-core-utils.c +++ b/src/nm-core-utils.c @@ -2521,20 +2521,20 @@ nm_utils_machine_id_read (void) */ if ( !g_file_get_contents ("/etc/machine-id", &contents, NULL, NULL) && !g_file_get_contents (LOCALSTATEDIR "/lib/dbus/machine-id", &contents, NULL, NULL)) - return FALSE; + return NULL; contents = g_strstrip (contents); for (i = 0; i < 32; i++) { if (!g_ascii_isxdigit (contents[i])) - return FALSE; + return NULL; if (contents[i] >= 'A' && contents[i] <= 'F') { /* canonicalize to lower-case */ contents[i] = 'a' + (contents[i] - 'A'); } } if (contents[i] != '\0') - return FALSE; + return NULL; return g_steal_pointer (&contents); } @@ -2896,6 +2896,22 @@ nm_utils_secret_key_get (const guint8 **out_secret_key, return secret_key->is_good; } +gint64 +nm_utils_secret_key_get_timestamp (void) +{ + struct stat stat_buf; + const guint8 *key; + gsize key_len; + + if (!nm_utils_secret_key_get (&key, &key_len)) + return 0; + + if (stat (NMSTATEDIR "/secret_key", &stat_buf) != 0) + return 0; + + return stat_buf.st_mtim.tv_sec; +} + /*****************************************************************************/ const char * |