[Development] Use gethomedir() function in vncpasswd and vncviewer.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4177 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/unix/vncpasswd/Makefile.am b/unix/vncpasswd/Makefile.am
index 00951be..7acc89f 100644
--- a/unix/vncpasswd/Makefile.am
+++ b/unix/vncpasswd/Makefile.am
@@ -7,6 +7,7 @@
vncpasswd_CPPFLAGS = -I$(top_srcdir)/common
vncpasswd_LDADD = $(top_builddir)/common/rfb/librfb.la \
- $(top_builddir)/common/rdr/librdr.la
+ $(top_builddir)/common/rdr/librdr.la \
+ $(top_builddir)/common/os/libos.la
EXTRA_DIST = vncpasswd.man
diff --git a/unix/vncpasswd/vncpasswd.cxx b/unix/vncpasswd/vncpasswd.cxx
index d21ea94..4cdff57 100644
--- a/unix/vncpasswd/vncpasswd.cxx
+++ b/unix/vncpasswd/vncpasswd.cxx
@@ -23,6 +23,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <os/os.h>
#include <rfb/Password.h>
#include <rfb/util.h>
@@ -100,14 +101,16 @@
}
if (!fname) {
- if (!getenv("HOME")) {
- fprintf(stderr,"HOME is not set\n");
+ char *homeDir = NULL;
+ if (gethomedir(&homeDir) == -1) {
+ fprintf(stderr, "Can't obtain home directory\n");
exit(1);
}
- fname = new char[strlen(getenv("HOME")) + 20];
- sprintf(fname, "%s/.vnc", getenv("HOME"));
+ fname = new char[strlen(homeDir) + 20];
+ sprintf(fname, "%s/.vnc", homeDir);
mkdir(fname, 0777);
- sprintf(fname, "%s/.vnc/passwd", getenv("HOME"));
+ sprintf(fname, "%s/.vnc/passwd", homeDir);
+ delete [] homeDir;
}
while (true) {