aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorAdam Tkac <atkac@redhat.com>2011-02-07 10:45:15 +0000
committerAdam Tkac <atkac@redhat.com>2011-02-07 10:45:15 +0000
commitaf0817220ee171837b4c15019fe16c2d5de180ad (patch)
treec7915b28be52f72dbcc864dffa42340ff86266e5 /common
parenta6da9f388fd66b4f52bedde44dbc2655413e5a4e (diff)
downloadtigervnc-af0817220ee171837b4c15019fe16c2d5de180ad.tar.gz
tigervnc-af0817220ee171837b4c15019fe16c2d5de180ad.zip
[Development] Rename function "gethomedir" to "getvnchomedir" and rewrite it in
platform-intependent manner. Thanks to Guillaume Destuynder. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4252 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'common')
-rw-r--r--common/os/os.cxx11
-rw-r--r--common/os/os.h5
-rw-r--r--common/rfb/CSecurityTLS.cxx31
3 files changed, 21 insertions, 26 deletions
diff --git a/common/os/os.cxx b/common/os/os.cxx
index fb07dcf6..c08b5728 100644
--- a/common/os/os.cxx
+++ b/common/os/os.cxx
@@ -36,7 +36,7 @@
#include <shlobj.h>
#endif
-int gethomedir(char **dirp)
+int getvnchomedir(char **dirp)
{
#ifndef WIN32
char *homedir, *dir;
@@ -62,12 +62,13 @@ int gethomedir(char **dirp)
homedir = passwd->pw_dir;
}
- len = strlen(homedir) + 1;
- dir = new char[len];
+ len = strlen(homedir);
+ dir = new char[len+7];
if (dir == NULL)
return -1;
memcpy(dir, homedir, len);
+ memcpy(dir + len, "/.vnc/\0", 7);
#else
dir = new TCHAR[MAX_PATH];
if (dir == NULL)
@@ -78,10 +79,8 @@ int gethomedir(char **dirp)
delete [] dir;
return -1;
}
-
-
+ memcpy(dir+strlen(dir), (TCHAR *)"\\vnc\\\0", 6);
#endif
-
*dirp = dir;
return 0;
}
diff --git a/common/os/os.h b/common/os/os.h
index 18e61e23..d011764e 100644
--- a/common/os/os.h
+++ b/common/os/os.h
@@ -24,7 +24,8 @@
#endif
/*
- * Get home directory. If HOME environment variable is set then it is returned.
+ * Get VNC home directory ($HOME/.vnc or %APPDATA%/vnc/).
+ * If HOME environment variable is set then it is used.
* Otherwise home directory is obtained via getpwuid function.
*
* Note for Windows:
@@ -34,6 +35,6 @@
* 0 - Success
* -1 - Failure
*/
-int gethomedir(char **dirp);
+int getvnchomedir(char **dirp);
#endif /* OS_OS_H */
diff --git a/common/rfb/CSecurityTLS.cxx b/common/rfb/CSecurityTLS.cxx
index 88408686..427d2005 100644
--- a/common/rfb/CSecurityTLS.cxx
+++ b/common/rfb/CSecurityTLS.cxx
@@ -89,25 +89,20 @@ void CSecurityTLS::setDefaults()
{
char* homeDir = NULL;
- if (gethomedir(&homeDir) == -1) {
- vlog.error("Could not obtain home directory path");
+ if (getvnchomedir(&homeDir) == -1) {
+ vlog.error("Could not obtain VNC home directory path");
return;
}
- CharArray caDefault(strlen(homeDir)+17);
- sprintf(caDefault.buf, "%s/.vnc/x509_certs", homeDir);
+ int len = strlen(homeDir) + 1;
+ CharArray caDefault(len + 7);
+ CharArray crlDefault(len + 8);
+ sprintf(caDefault.buf, "%sx509_ca", homeDir);
+ sprintf(crlDefault.buf, "%s509_crl", homeDir);
delete [] homeDir;
-#ifndef WIN32
- /* XXX Do we need access() check here? */
- if (!access(caDefault.buf, R_OK))
- x509ca.setDefaultStr(strdup(caDefault.buf));
- else
- vlog.error("Failed to open ~/.vnc/x509_certs");
-#else
- /* Windows doesn't have access() function. */
x509ca.setDefaultStr(strdup(caDefault.buf));
-#endif
+ x509crl.setDefaultStr(strdup(crlDefault.buf));
}
void CSecurityTLS::shutdown()
@@ -349,13 +344,13 @@ void CSecurityTLS::checkSession()
< 0)
AuthFailureException("certificate issuer unknown, and certificate "
"export failed");
-
- if (gethomedir(&homeDir) == -1)
- vlog.error("Could not obtain home directory path");
+
+ if (getvnchomedir(&homeDir) == -1)
+ vlog.error("Could not obtain VNC home directory path");
else {
FILE *f;
- CharArray caSave(strlen(homeDir)+17);
- sprintf(caSave.buf, "%s/.vnc/x509_certs", homeDir);
+ CharArray caSave(strlen(homeDir) + 11);
+ sprintf(caSave.buf, "%sx509_certs", homeDir);
delete [] homeDir;
f = fopen(caSave.buf, "a+");
if (!f)