w32: Change directory on daemon startup.

* agent/gpg-agent.c [HAVE_W32_SYSTEM]: Include <direct.h>.
(main) [HAVE_W32_SYSTEM]: Change working directory to \.
* dirmngr/dirmngr.c [HAVE_W32_SYSTEM]: Include <direct.h>.
(main) [HAVE_W32_SYSTEM]: Change working directory to \.
* scd/scdaemon.c [HAVE_W32_SYSTEM]: Include <direct.h>.
(main) [HAVE_W32_SYSTEM]: Change working directory to \.

Signed-off-by: Marcus Brinkmann <mb@g10code.com>
GnuPG-bug-id: 2670
This commit is contained in:
Marcus Brinkmann 2017-07-24 16:31:55 +02:00
parent d8e46f1069
commit 78ebc62604
3 changed files with 26 additions and 6 deletions

View File

@ -39,6 +39,7 @@
# endif # endif
# include <aclapi.h> # include <aclapi.h>
# include <sddl.h> # include <sddl.h>
# include <direct.h>
#else /*!HAVE_W32_SYSTEM*/ #else /*!HAVE_W32_SYSTEM*/
# include <sys/socket.h> # include <sys/socket.h>
# include <sys/un.h> # include <sys/un.h>
@ -1558,6 +1559,11 @@ main (int argc, char **argv )
(void)csh_style; (void)csh_style;
(void)nodetach; (void)nodetach;
initialize_modules (); initialize_modules ();
if (_chdir("\\"))
{
log_error ("chdir to / failed: %s\n", strerror (errno));
exit (1);
}
#else /*!HAVE_W32_SYSTEM*/ #else /*!HAVE_W32_SYSTEM*/

View File

@ -30,9 +30,11 @@
#include <assert.h> #include <assert.h>
#include <time.h> #include <time.h>
#include <fcntl.h> #include <fcntl.h>
#ifndef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
#include <sys/socket.h> # include <direct.h>
#include <sys/un.h> #else
# include <sys/socket.h>
# include <sys/un.h>
#endif #endif
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
@ -1268,6 +1270,11 @@ main (int argc, char **argv)
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
(void)csh_style; (void)csh_style;
(void)nodetach; (void)nodetach;
if (_chdir("\\"))
{
log_error ("chdir to / failed: %s\n", strerror (errno));
exit (1);
}
pid = getpid (); pid = getpid ();
es_printf ("set %s=%s;%lu;1\n", es_printf ("set %s=%s;%lu;1\n",

View File

@ -29,9 +29,11 @@
#include <assert.h> #include <assert.h>
#include <time.h> #include <time.h>
#include <fcntl.h> #include <fcntl.h>
#ifndef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
#include <sys/socket.h> # include <direct.h>
#include <sys/un.h> #else
# include <sys/socket.h>
# include <sys/un.h>
#endif /*HAVE_W32_SYSTEM*/ #endif /*HAVE_W32_SYSTEM*/
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
@ -811,6 +813,11 @@ main (int argc, char **argv )
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
(void)csh_style; (void)csh_style;
(void)nodetach; (void)nodetach;
if (_chdir("\\"))
{
log_error ("chdir to / failed: %s\n", strerror (errno));
exit (1);
}
#else #else
pid = fork (); pid = fork ();
if (pid == (pid_t)-1) if (pid == (pid_t)-1)