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 <stdio.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
#ifdef _SUN_OS /* to get the define for NOFILE */
|
#ifdef _SUN_OS /* to get the define for NOFILE */
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#endif /* _SUN_OS */
|
#endif /* _SUN_OS */
|
||||||
|
@ -3503,14 +3504,20 @@ StartClient(
|
||||||
smRes.ignoreEnvironment, ',');
|
smRes.ignoreEnvironment, ',');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!defaultCwd) {
|
if (!defaultCwd)
|
||||||
if (getenv ("HOME"))
|
{
|
||||||
defaultCwd = strndup (getenv("HOME"), MAXPATHLEN);
|
char *tstr = getenv("HOME");
|
||||||
else
|
if (tstr)
|
||||||
defaultCwd = getcwd (NULL, MAXPATHLEN + 1);
|
{
|
||||||
|
int slen = strlen(tstr) + 1;
|
||||||
|
defaultCwd = XtCalloc(1, slen);
|
||||||
|
strncpy(defaultCwd, tstr, slen - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
defaultCwd = getcwd (NULL, MAXPATHLEN + 1);
|
||||||
|
|
||||||
(void) gethostname (localHost, MAXHOSTNAMELEN);
|
(void) gethostname (localHost, MAXHOSTNAMELEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cwd) {
|
if (!cwd) {
|
||||||
cwdNull = True;
|
cwdNull = True;
|
||||||
|
|
Loading…
Reference in a new issue