mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
dtsession/SmRestore: redo defaultCwd detection in StartClient() to be safer
This commit is contained in:
parent
a657f302f7
commit
7c702bff6e
1 changed files with 15 additions and 8 deletions
|
@ -58,6 +58,7 @@
|
|||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#ifdef _SUN_OS /* to get the define for NOFILE */
|
||||
#include <sys/param.h>
|
||||
#endif /* _SUN_OS */
|
||||
|
@ -3503,14 +3504,20 @@ StartClient(
|
|||
smRes.ignoreEnvironment, ',');
|
||||
}
|
||||
|
||||
if (!defaultCwd) {
|
||||
if (getenv ("HOME"))
|
||||
defaultCwd = strndup (getenv("HOME"), MAXPATHLEN);
|
||||
else
|
||||
defaultCwd = getcwd (NULL, MAXPATHLEN + 1);
|
||||
|
||||
(void) gethostname (localHost, MAXHOSTNAMELEN);
|
||||
}
|
||||
if (!defaultCwd)
|
||||
{
|
||||
char *tstr = getenv("HOME");
|
||||
if (tstr)
|
||||
{
|
||||
int slen = strlen(tstr) + 1;
|
||||
defaultCwd = XtCalloc(1, slen);
|
||||
strncpy(defaultCwd, tstr, slen - 1);
|
||||
}
|
||||
else
|
||||
defaultCwd = getcwd (NULL, MAXPATHLEN + 1);
|
||||
|
||||
(void) gethostname (localHost, MAXHOSTNAMELEN);
|
||||
}
|
||||
|
||||
if (!cwd) {
|
||||
cwdNull = True;
|
||||
|
|
Loading…
Reference in a new issue