Gnome Keyring Tools (fiz algumas pequenas ferramentas para verificar e controlar o chaveiro do gnome)
Fontes e amp; Lançamento: link
Bloqueio de chaveiro - gkey-lock.c
#include <stdio.h>
#include <gnome-keyring.h>
int main() {
GnomeKeyringResult lock_result = gnome_keyring_lock_all_sync();
if (lock_result == GNOME_KEYRING_RESULT_OK) {
printf("Successfully locked\n");
return 0;
} else {
printf("Error locking keyring: %d\n", lock_result);
return 1;
}
}
Desbloqueio de chaveiro - gkey-unlock.c
#include <stdio.h>
#include <gnome-keyring.h>
int main() {
GnomeKeyringResult lock_result = gnome_keyring_unlock_sync(NULL,NULL);
if (lock_result == GNOME_KEYRING_RESULT_OK) {
printf("Successfully unlocked\n");
return 0;
} else {
printf("Error unlocking keyring: %d\n", lock_result);
return 1;
}
}
Ver chaveiro - gkey-check.c
#include <stdio.h>
#include <gnome-keyring.h>
int main() {
GnomeKeyringInfo *info;
GnomeKeyringResult gkr;
gkr = gnome_keyring_get_info_sync(NULL, &info);
if (gkr != GNOME_KEYRING_RESULT_OK) {
printf("error\n");
return -1;
}
if (gnome_keyring_info_get_is_locked(info)) {
printf("locked\n");
return 0;
}
else {
printf("unlocked\n");
return -1;
}
gnome_keyring_info_free(info);
}
Como construir
cc gkey-lock.c -o gkey-lock -Wall -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgnome-keyring -lglib-2.0
cc gkey-unlock.c -o gkey-unlock -Wall -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgnome-keyring -lglib-2.0
cc gkey-check.c -o gkey-check -Wall -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgnome-keyring -lglib-2.0
Bônus - Verifique com o Python - gkey-check.py
import gnomekeyring
print gnomekeyring.get_info_sync(gnomekeyring.get_default_keyring_sync()).get_is_locked()
Bônus II - Monitorar o estado do keyring do Gnome Na barra de tarefas / bandeja do KDE
Eu fiz o erro de retorno gkey-check quando seu desbloqueio além da string unlocked
i poderia então usar o KDE Server Status
widget para monitorar o estado do keyring bloqueado / desbloqueado com um ícone visual :) com o comando gkey-check