diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/os/os.cxx | 29 | ||||
-rw-r--r-- | common/os/os.h | 14 | ||||
-rw-r--r-- | common/rfb/CSecurityTLS.cxx | 4 |
3 files changed, 41 insertions, 6 deletions
diff --git a/common/os/os.cxx b/common/os/os.cxx index 409a2ec6..aa9e2bae 100644 --- a/common/os/os.cxx +++ b/common/os/os.cxx @@ -36,7 +36,7 @@ #include <shlobj.h> #endif -int getvnchomedir(char **dirp) +static int gethomedir(char **dirp, bool userDir) { #ifndef WIN32 char *homedir, *dir; @@ -68,19 +68,40 @@ int getvnchomedir(char **dirp) return -1; memcpy(dir, homedir, len); - memcpy(dir + len, "/.vnc/\0", 7); + if (userDir) + dir[len]='\0'; + else + memcpy(dir + len, "/.vnc/\0", 7); #else dir = new TCHAR[MAX_PATH]; if (dir == NULL) return -1; - ret = SHGetSpecialFolderPath(NULL, dir, CSIDL_APPDATA, FALSE); + if (userDir) + ret = SHGetSpecialFolderPath(NULL, dir, CSIDL_PROFILE, FALSE); + else + ret = SHGetSpecialFolderPath(NULL, dir, CSIDL_APPDATA, FALSE); + if (ret == FALSE) { delete [] dir; return -1; } - memcpy(dir+strlen(dir), (TCHAR *)"\\vnc\\\0", 6); + if (userDir) + dir[strlen(dir)+1] = '\0'; + else + memcpy(dir+strlen(dir), (TCHAR *)"\\vnc\\\0", 6); #endif *dirp = dir; return 0; } + +int getvnchomedir(char **dirp) +{ + return gethomedir(dirp, false); +} + +int getuserhomedir(char **dirp) +{ + return gethomedir(dirp, true); +} + diff --git a/common/os/os.h b/common/os/os.h index fcca20e1..6a8272f1 100644 --- a/common/os/os.h +++ b/common/os/os.h @@ -39,4 +39,18 @@ */ int getvnchomedir(char **dirp); +/* + * Get user home directory. + * If HOME environment variable is set then it is used. + * Otherwise home directory is obtained via getpwuid function. + * + * Note for Windows: + * This functions returns array of TCHARs, not array of chars. + * + * Returns: + * 0 - Success + * -1 - Failure + */ +int getuserhomedir(char **dirp); + #endif /* OS_OS_H */ diff --git a/common/rfb/CSecurityTLS.cxx b/common/rfb/CSecurityTLS.cxx index be70c559..d0af1410 100644 --- a/common/rfb/CSecurityTLS.cxx +++ b/common/rfb/CSecurityTLS.cxx @@ -288,10 +288,10 @@ void CSecurityTLS::setParam() vlog.error("Could not load system certificate trust store"); if (*cafile && gnutls_certificate_set_x509_trust_file(cert_cred,cafile,GNUTLS_X509_FMT_PEM) < 0) - throw AuthFailureException("load of CA cert failed"); + vlog.error("Could not load user specified certificate authority"); if (*crlfile && gnutls_certificate_set_x509_crl_file(cert_cred,crlfile,GNUTLS_X509_FMT_PEM) < 0) - throw AuthFailureException("load of CRL failed"); + vlog.error("Could not load user specified certificate revocation list"); if (gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, cert_cred) != GNUTLS_E_SUCCESS) throw AuthFailureException("gnutls_credentials_set failed"); |