aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-10-18 11:03:13 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-10-18 11:03:13 +0800
commit50e16acfc84ea193c58997dc128c72cfbb5b15e9 (patch)
tree8ed4ff7299086b604249e60765910acaed301eb0
parente581b1f3b4dae45f42b444b8f8b9dfe7fb375fa1 (diff)
downloadgsoc2013-evolution-50e16acfc84ea193c58997dc128c72cfbb5b15e9.tar
gsoc2013-evolution-50e16acfc84ea193c58997dc128c72cfbb5b15e9.tar.gz
gsoc2013-evolution-50e16acfc84ea193c58997dc128c72cfbb5b15e9.tar.bz2
gsoc2013-evolution-50e16acfc84ea193c58997dc128c72cfbb5b15e9.tar.lz
gsoc2013-evolution-50e16acfc84ea193c58997dc128c72cfbb5b15e9.tar.xz
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
-rw-r--r--camel/ChangeLog5
-rw-r--r--camel/camel-tcp-stream-ssl.c21
2 files changed, 20 insertions, 6 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 625f86ba05..4723610114 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,8 @@
+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.
+
2002-10-15 Not Zed <NotZed@Ximian.com>
* camel-tcp-stream-ssl.c (cert_fingerprint): helper, build
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);
}