From fa13467ed4cda7fbce46347d4d4664aa723a2b11 Mon Sep 17 00:00:00 2001 From: cool Date: Thu, 25 Aug 2011 17:20:56 -1100 Subject: [PATCH] temporary commit --- include/freerdp/utils/certstore.h | 27 ++++++++++++ libfreerdp-utils/cerstore.c | 68 +++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 include/freerdp/utils/certstore.h create mode 100644 libfreerdp-utils/cerstore.c diff --git a/include/freerdp/utils/certstore.h b/include/freerdp/utils/certstore.h new file mode 100644 index 000000000..244b9d07b --- /dev/null +++ b/include/freerdp/utils/certstore.h @@ -0,0 +1,27 @@ +#ifndef __CERTSTORE_UTILS_H +#define __CERTSTORE_UTILS_H + +typedef struct rdp_certstore rdpCertstore; +typedef struct rdp_certdata rdpCertdata; + +#include +#include +#include +#include +#include +#include +#include +struct rdp_certdata +{ + char* thumbprint; + char* hostname; +} +struct rdp_certstore +{ + FILE* fp; + char* path; + char* file; + char* home; + boolean available; + struct rdp_certdata* certdata; +}; diff --git a/libfreerdp-utils/cerstore.c b/libfreerdp-utils/cerstore.c new file mode 100644 index 000000000..7e4209762 --- /dev/null +++ b/libfreerdp-utils/cerstore.c @@ -0,0 +1,68 @@ +/** + * FreeRDP: A Remote Desktop Protocol Client + * certstore Utils + * + * Copyright 2011 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifdef _WIN32 +#include +#endif + +static char cert_dir[] = "freerdp"; +static char certstore_file[] = "known_hosts"; + +void certstore_init(rdpCertstore* certstore) +{ + int length; + char* home_path; + struct stat stat_info; + + home_path = getenv("HOME"); + certstore->available = True; + + if (home_path == NULL) + { + printf("could not get home path\n"); + certstore->available = False; + return; + } + + certstore->home = (char*) xstrdup(home_path); + printf("home path: %s\n", certstore->home); + + certstore->path = (char*) xmalloc(strlen(certstore->home) + strlen("/.") + strlen(cert_dir) + 1); + sprintf(certstore->path, "%s/.%s", certstore->home, cert_dir); + printf("certstore path: %s\n", certstore->path); + + if (stat(certstore->path, &stat_info) != 0) + { +#ifndef _WIN32 + mkdir(certstore->path, S_IRUSR | S_IWUSR | S_IXUSR); +#else + CreateDirectory(certstore->path, 0); +#endif + printf("creating directory %s\n", certstore->path); + } + + length = strlen(certstore->path); + certstore->file = (char*) xmalloc(strlen(certstore->path) + strlen("/") + strlen(certstore_file) + 1); + sprintf(certstore->file, "%s/%s", certstore->path, certstore_file); + printf("certstore file: %s\n", certstore->file); + + certstore_open(certstore); +}