/** Initializes a new pwstorage context. */ const dt_pwstorage_t* dt_pwstorage_new() { dt_pwstorage_t *pwstorage = g_malloc(sizeof(dt_pwstorage_t)); dt_print(DT_DEBUG_PWSTORAGE,"[pwstorage_new] Creating new context %lx\n",(unsigned long int)pwstorage); if(pwstorage == NULL) return NULL; gint _backend = dt_conf_get_int( "plugins/pwstorage/pwstorage_backend" ); switch(_backend) { default: dt_print(DT_DEBUG_PWSTORAGE,"[pwstorage_new] unknown storage backend. Using none.\n"); case PW_STORAGE_BACKEND_NONE: pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE; pwstorage->backend_context = NULL; dt_print(DT_DEBUG_PWSTORAGE,"[pwstorage_new] no storage backend. not storing username/password. please change in gconf: \"plugins/pwstorage/pwstorage_backend\".\n"); break; case PW_STORAGE_BACKEND_GCONF: // this is so important that I want it to be printed in any case. so g_printerr() instead of dt_print() g_printerr("[pwstorage_new] WARNING: you are using gconf for username/password storage! they are being stored unencrypted on your hard disk.\n"); pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_GCONF; pwstorage->backend_context = NULL; break; case PW_STORAGE_BACKEND_KWALLET: #ifdef HAVE_KWALLET dt_print(DT_DEBUG_PWSTORAGE,"[pwstorage_new] using kwallet backend for username/password storage"); pwstorage->backend_context = (void*)dt_pwstorage_kwallet_new(); if(pwstorage->backend_context == NULL) { dt_print(DT_DEBUG_PWSTORAGE,"[pwstorage_new] error starting kwallet. using no storage backend.\n"); pwstorage->backend_context = NULL; pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE; } else { pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_KWALLET; } dt_print(DT_DEBUG_PWSTORAGE," done.\n"); #else dt_print(DT_DEBUG_PWSTORAGE,"[pwstorage_new] kwallet storage not available. using no storage backend.\n"); pwstorage->backend_context = NULL; pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE; #endif break; #ifdef HAVE_GKEYRING case PW_STORAGE_BACKEND_GNOME_KEYRING: dt_print (DT_DEBUG_PWSTORAGE,"[pwstorage_new] using gnome keyring backend for usersname/password storage.\n"); pwstorage->backend_context = (void*)dt_pwstorage_gkeyring_new (); if (pwstorage->backend_context == NULL) { dt_print (DT_DEBUG_PWSTORAGE,"[pwstorage_new] error starting gnome keyring. using no storage backend.\n"); pwstorage->backend_context = NULL; pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE; } else pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_GNOME_KEYRING; #else dt_print(DT_DEBUG_PWSTORAGE,"[pwstorage_new] gnome keyring storage not available. using no storage backend.\n"); pwstorage->backend_context = NULL; pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE; #endif break; } dt_conf_set_int( "plugins/pwstorage/pwstorage_backend", pwstorage->pw_storage_backend ); return pwstorage; }
/** Initializes a new pwstorage context. */ const dt_pwstorage_t* dt_pwstorage_new() { dt_pwstorage_t *pwstorage = g_malloc(sizeof(dt_pwstorage_t)); dt_print(DT_DEBUG_PWSTORAGE,"[pwstorage_new] Creating new context %p\n", pwstorage); if(pwstorage == NULL) return NULL; gchar* _backend_str = dt_conf_get_string( "plugins/pwstorage/pwstorage_backend" ); gint _backend = -1; if (strcmp(_backend_str, "auto") == 0) { const gchar *desktop = getenv("XDG_CURRENT_DESKTOP"); if (g_strcmp0(desktop, "KDE") == 0) _backend = PW_STORAGE_BACKEND_KWALLET; else if (g_strcmp0(desktop, "GNOME") == 0) _backend = PW_STORAGE_BACKEND_GNOME_KEYRING; else if (g_strcmp0(desktop, "Unity") == 0) _backend = PW_STORAGE_BACKEND_GNOME_KEYRING; else if (g_strcmp0(desktop, "XFCE") == 0) _backend = PW_STORAGE_BACKEND_GNOME_KEYRING; else _backend = PW_STORAGE_BACKEND_NONE; dt_print(DT_DEBUG_PWSTORAGE,"[pwstorage_new] autodetected storage backend.\n"); } else if(strcmp(_backend_str, "none") == 0) _backend = PW_STORAGE_BACKEND_NONE; else if(strcmp(_backend_str, "kwallet") == 0) _backend = PW_STORAGE_BACKEND_KWALLET; else if(strcmp(_backend_str, "gnome keyring") == 0) _backend = PW_STORAGE_BACKEND_GNOME_KEYRING; g_free(_backend_str); switch(_backend) { default: dt_print(DT_DEBUG_PWSTORAGE,"[pwstorage_new] unknown storage backend. Using none.\n"); case PW_STORAGE_BACKEND_NONE: pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE; pwstorage->backend_context = NULL; dt_print(DT_DEBUG_PWSTORAGE,"[pwstorage_new] no storage backend. not storing username/password. please change in preferences, core tab.\n"); break; case PW_STORAGE_BACKEND_KWALLET: dt_print(DT_DEBUG_PWSTORAGE,"[pwstorage_new] using kwallet backend for username/password storage"); pwstorage->backend_context = (void*)dt_pwstorage_kwallet_new(); if(pwstorage->backend_context == NULL) { dt_print(DT_DEBUG_PWSTORAGE,"[pwstorage_new] error starting kwallet. using no storage backend.\n"); pwstorage->backend_context = NULL; pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE; } else { pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_KWALLET; } dt_print(DT_DEBUG_PWSTORAGE," done.\n"); break; #ifdef HAVE_GKEYRING case PW_STORAGE_BACKEND_GNOME_KEYRING: dt_print (DT_DEBUG_PWSTORAGE,"[pwstorage_new] using gnome keyring backend for usersname/password storage.\n"); pwstorage->backend_context = (void*)dt_pwstorage_gkeyring_new (); if (pwstorage->backend_context == NULL) { dt_print (DT_DEBUG_PWSTORAGE,"[pwstorage_new] error starting gnome keyring. using no storage backend.\n"); pwstorage->backend_context = NULL; pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE; } else pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_GNOME_KEYRING; #else dt_print(DT_DEBUG_PWSTORAGE,"[pwstorage_new] gnome keyring storage not available. using no storage backend.\n"); pwstorage->backend_context = NULL; pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE; #endif break; } switch(pwstorage->pw_storage_backend) { case PW_STORAGE_BACKEND_NONE: dt_conf_set_string( "plugins/pwstorage/pwstorage_backend", "none" ); break; case PW_STORAGE_BACKEND_KWALLET: dt_conf_set_string( "plugins/pwstorage/pwstorage_backend", "kwallet" ); break; case PW_STORAGE_BACKEND_GNOME_KEYRING: dt_conf_set_string( "plugins/pwstorage/pwstorage_backend", "gnome keyring" ); break; } return pwstorage; }
/** Initializes a new pwstorage context. */ const dt_pwstorage_t *dt_pwstorage_new() { /* add password storage capabilities */ #ifdef HAVE_LIBSECRET dt_capabilities_add("libsecret"); #endif #ifdef HAVE_KWALLET dt_capabilities_add("kwallet"); #endif dt_pwstorage_t *pwstorage = g_malloc(sizeof(dt_pwstorage_t)); dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] Creating new context %p\n", pwstorage); if(pwstorage == NULL) return NULL; gchar *_backend_str = dt_conf_get_string("plugins/pwstorage/pwstorage_backend"); gint _backend = PW_STORAGE_BACKEND_NONE; if(strcmp(_backend_str, "auto") == 0) { const gchar *desktop = getenv("XDG_CURRENT_DESKTOP"); if(g_strcmp0(desktop, "KDE") == 0) _backend = PW_STORAGE_BACKEND_KWALLET; else if(g_strcmp0(desktop, "GNOME") == 0) _backend = PW_STORAGE_BACKEND_LIBSECRET; else if(g_strcmp0(desktop, "Unity") == 0) _backend = PW_STORAGE_BACKEND_LIBSECRET; else if(g_strcmp0(desktop, "XFCE") == 0) _backend = PW_STORAGE_BACKEND_LIBSECRET; dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] autodetected storage backend.\n"); } else if(strcmp(_backend_str, "none") == 0) _backend = PW_STORAGE_BACKEND_NONE; #ifdef HAVE_LIBSECRET else if(strcmp(_backend_str, "libsecret") == 0) _backend = PW_STORAGE_BACKEND_LIBSECRET; #endif #ifdef HAVE_KWALLET else if(strcmp(_backend_str, "kwallet") == 0) _backend = PW_STORAGE_BACKEND_KWALLET; #endif else if(strcmp(_backend_str, "gnome keyring") == 0) { fprintf(stderr, "[pwstorage_new] GNOME Keyring backend is no longer supported.\n"); dt_control_log(_("GNOME Keyring backend is no longer supported. configure a different one")); _backend = PW_STORAGE_BACKEND_NONE; } g_free(_backend_str); switch(_backend) { default: dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] unknown storage backend. Using none.\n"); case PW_STORAGE_BACKEND_NONE: pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE; pwstorage->backend_context = NULL; dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] no storage backend. not storing username/password. " "please change in preferences, core tab.\n"); break; case PW_STORAGE_BACKEND_LIBSECRET: #ifdef HAVE_LIBSECRET dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] using libsecret backend for username/password storage"); pwstorage->backend_context = (void *)dt_pwstorage_libsecret_new(); if(pwstorage->backend_context == NULL) { dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] error starting libsecret. using no storage backend.\n"); pwstorage->backend_context = NULL; pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE; } else { pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_LIBSECRET; } break; #else dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] libsecret backend not available. using no storage backend.\n"); pwstorage->backend_context = NULL; pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE; #endif case PW_STORAGE_BACKEND_KWALLET: #ifdef HAVE_KWALLET dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] using kwallet backend for username/password storage"); pwstorage->backend_context = (void *)dt_pwstorage_kwallet_new(); if(pwstorage->backend_context == NULL) { dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] error starting kwallet. using no storage backend.\n"); pwstorage->backend_context = NULL; pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE; } else { pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_KWALLET; } dt_print(DT_DEBUG_PWSTORAGE, " done.\n"); break; #else dt_print(DT_DEBUG_PWSTORAGE, "[pwstorage_new] kwallet backend not available. using no storage backend.\n"); pwstorage->backend_context = NULL; pwstorage->pw_storage_backend = PW_STORAGE_BACKEND_NONE; #endif } switch(pwstorage->pw_storage_backend) { case PW_STORAGE_BACKEND_NONE: dt_conf_set_string("plugins/pwstorage/pwstorage_backend", "none"); break; case PW_STORAGE_BACKEND_LIBSECRET: dt_conf_set_string("plugins/pwstorage/pwstorage_backend", "libsecret"); break; case PW_STORAGE_BACKEND_KWALLET: dt_conf_set_string("plugins/pwstorage/pwstorage_backend", "kwallet"); break; } return pwstorage; }