diff options
author | Adam Tkac <atkac@redhat.com> | 2010-10-29 12:17:19 +0000 |
---|---|---|
committer | Adam Tkac <atkac@redhat.com> | 2010-10-29 12:17:19 +0000 |
commit | 21779fd5e79ceeb5de91665552d7f0cec49c5e79 (patch) | |
tree | e157df4182cab6f7ef08121f595e825b18a2a664 /unix/vncpasswd/vncpasswd.cxx | |
parent | b56a69c7fdc6996b441fa0beac3afeac5e15f8e1 (diff) | |
download | tigervnc-21779fd5e79ceeb5de91665552d7f0cec49c5e79.tar.gz tigervnc-21779fd5e79ceeb5de91665552d7f0cec49c5e79.zip |
[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
Diffstat (limited to 'unix/vncpasswd/vncpasswd.cxx')
-rw-r--r-- | unix/vncpasswd/vncpasswd.cxx | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/unix/vncpasswd/vncpasswd.cxx b/unix/vncpasswd/vncpasswd.cxx index d21ea942..4cdff57c 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 @@ int main(int argc, char** argv) } 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) { |