int search_in_netrc (struct netrc_entry * entry_ptr, char * filename) { int filename_alloc = 0; if (filename == NULL) { filename = default_path (); filename_alloc = 1; } check_permission (filename); FILE * in; int encoded = suffix (".gpg", filename); int status; if (encoded) in = decode (filename); else in = fopen (filename, "r"); if (in == NULL) { error (0, 0, "failed to open file: %s", filename); status = NETRC_FAILURE; } else { status = parse (entry_ptr, in); if ((encoded ? pclose (in) : fclose (in)) != 0) { error (0, 0, "error closing netrc file"); status = NETRC_FAILURE; } } if (filename_alloc) free (filename); return status; }
static void update_default (GkdSecretService *self, gboolean force) { gchar *contents = NULL; const gchar *identifier; gchar *path; if (!force) { identifier = g_hash_table_lookup (self->aliases, "default"); if (identifier) return; } path = default_path (self); if (g_file_get_contents (path, &contents, NULL, NULL)) { g_strstrip (contents); if (!contents[0]) { g_free (contents); contents = NULL; } } g_free (path); g_hash_table_replace (self->aliases, g_strdup ("default"), contents); }
static void store_default (GkdSecretService *self) { GError *error = NULL; const gchar *identifier; gchar *path; identifier = g_hash_table_lookup (self->aliases, "default"); if (!identifier) return; path = default_path (self); if (!g_file_set_contents (path, identifier, -1, &error)) g_message ("couldn't store default keyring: %s", egg_error_message (error)); g_free (path); }
static void update_default (GkdSecretService *self, gboolean force) { gchar *contents = NULL; const gchar *identifier; gchar *path; identifier = gkd_secret_objects_get_alias (self->objects, "default"); if (!force && identifier) return; path = default_path (); if (g_file_get_contents (path, &contents, NULL, NULL)) { g_strstrip (contents); if (!contents[0]) { g_free (contents); contents = NULL; } } g_free (path); gkd_secret_objects_set_alias (self->objects, "default", contents); g_free (contents); }