diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-10-18 11:03:13 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-10-18 11:03:13 +0800 |
commit | 50e16acfc84ea193c58997dc128c72cfbb5b15e9 (patch) | |
tree | 8ed4ff7299086b604249e60765910acaed301eb0 /camel/camel-tcp-stream-ssl.c | |
parent | e581b1f3b4dae45f42b444b8f8b9dfe7fb375fa1 (diff) | |
download | gsoc2013-evolution-50e16acfc84ea193c58997dc128c72cfbb5b15e9.tar.gz gsoc2013-evolution-50e16acfc84ea193c58997dc128c72cfbb5b15e9.tar.zst gsoc2013-evolution-50e16acfc84ea193c58997dc128c72cfbb5b15e9.zip |
If ~/.camel_certs doesn't exist, create it.
2002-10-17 Jeffrey Stedfast <fejj@ximian.com>
* camel-tcp-stream-ssl.c (camel_certdb_nss_cert_set): If
~/.camel_certs doesn't exist, create it.
svn path=/trunk/; revision=18391
Diffstat (limited to 'camel/camel-tcp-stream-ssl.c')
-rw-r--r-- | camel/camel-tcp-stream-ssl.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c index c5e6ad9160..3fef8c9ac7 100644 --- a/camel/camel-tcp-stream-ssl.c +++ b/camel/camel-tcp-stream-ssl.c @@ -580,18 +580,27 @@ camel_certdb_nss_cert_add(CamelCertDB *certdb, CERTCertificate *cert) void camel_certdb_nss_cert_set(CamelCertDB *certdb, CamelCert *ccert, CERTCertificate *cert) { - char *path, *fingerprint; + char *dir, *path, *fingerprint; CamelStream *stream; - + struct stat st; + fingerprint = ccert->fingerprint; if (ccert->rawcert == NULL) ccert->rawcert = g_byte_array_new(); g_byte_array_set_size(ccert->rawcert, cert->derCert.len); memcpy(ccert->rawcert->data, cert->derCert.data, cert->derCert.len); - - path = g_strdup_printf("%s/.camel_certs/%s", getenv("HOME"), fingerprint); - + + dir = g_strdup_printf ("%s/.camel_certs", getenv ("HOME")); + if (stat (dir, &st) == -1 && mkdir (dir, 0700) == -1) { + g_warning ("Could not create cert directory '%s': %s", dir, strerror (errno)); + g_free (dir); + return; + } + + path = g_strdup_printf ("%s/%s", dir, fingerprint); + g_free (dir); + stream = camel_stream_fs_new_with_name(path, O_WRONLY|O_CREAT|O_TRUNC, 0600); if (stream != NULL) { if (camel_stream_write(stream, ccert->rawcert->data, ccert->rawcert->len) != ccert->rawcert->len) { @@ -603,7 +612,7 @@ camel_certdb_nss_cert_set(CamelCertDB *certdb, CamelCert *ccert, CERTCertificate } else { g_warning("Could not save cert: %s: %s", path, strerror(errno)); } - + g_free(path); } |