# include <siad.h>
#endif
+#ifdef HAVE_CYGWIN
+#include <windows.h>
+#include <sys/cygwin.h>
+#define is_winnt (GetVersion() < 0x80000000)
+#endif
+
/* AIX limits */
#if defined(HAVE_GETUSERATTR) && !defined(S_UFSIZE_HARD) && defined(S_UFSIZE)
# define S_UFSIZE_HARD S_UFSIZE "_hard"
do_child(command, pw, NULL, s->display, s->auth_proto, s->auth_data, NULL);
/* NOTREACHED */
}
+#ifdef HAVE_CYGWIN
+ if (is_winnt)
+ cygwin_set_impersonation_token(INVALID_HANDLE_VALUE);
+#endif
if (pid < 0)
packet_disconnect("fork failed: %.100s", strerror(errno));
s->pid = pid;
s->auth_data, s->tty);
/* NOTREACHED */
}
+#ifdef HAVE_CYGWIN
+ if (is_winnt)
+ cygwin_set_impersonation_token(INVALID_HANDLE_VALUE);
+#endif
if (pid < 0)
packet_disconnect("fork failed: %.100s", strerror(errno));
s->pid = pid;
exit(1);
}
#else /* HAVE_OSF_SIA */
+#ifdef HAVE_CYGWIN
+ if (is_winnt) {
+#else
if (getuid() == 0 || geteuid() == 0) {
+#endif
# ifdef HAVE_GETUSERATTR
set_limits_from_userattr(pw->pw_name);
# endif /* HAVE_GETUSERATTR */
}
#endif /* HAVE_OSF_SIA */
+#ifdef HAVE_CYGWIN
+ if (is_winnt)
+#endif
if (getuid() != pw->pw_uid || geteuid() != pw->pw_uid)
fatal("Failed to set uids to %u.", (u_int) pw->pw_uid);
}
env = xmalloc(envsize * sizeof(char *));
env[0] = NULL;
+#ifdef HAVE_CYGWIN
+ /*
+ * The Windows environment contains some setting which are
+ * important for a running system. They must not be dropped.
+ */
+ {
+ char **ep;
+ for (ep = environ; *ep; ++ep) {
+ char *esp = strchr(*ep, '=');
+ *esp = '\0';
+ child_set_env(&env, &envsize, *ep, esp + 1);
+ *esp = '=';
+ }
+ }
+#endif
+
if (!options.use_login) {
/* Set basic environment. */
child_set_env(&env, &envsize, "USER", pw->pw_name);
(void) setusercontext(lc, pw, pw->pw_uid, LOGIN_SETPATH);
child_set_env(&env, &envsize, "PATH", getenv("PATH"));
#else
+#ifndef HAVE_CYGWIN
+ /*
+ * There's no standard path on Windows. The path contains
+ * important components pointing to the system directories,
+ * needed for loading shared libraries. So the path better
+ * remains intact here.
+ */
child_set_env(&env, &envsize, "PATH", _PATH_STDPATH);
+#endif
#endif
snprintf(buf, sizeof buf, "%.200s/%.50s",
"Running %.100s add %.100s %.100s %.100s\n",
options.xauth_location, display,
auth_proto, auth_data);
+#ifndef HAVE_CYGWIN
if (screen != NULL)
fprintf(stderr,
"Adding %.*s/unix%s %s %s\n",
(int)(screen-display), display,
screen, auth_proto, auth_data);
+#endif
}
snprintf(cmd, sizeof cmd, "%s -q -",
options.xauth_location);
if (f) {
fprintf(f, "add %s %s %s\n", display,
auth_proto, auth_data);
+#ifndef HAVE_CYGWIN
if (screen != NULL)
fprintf(f, "add %.*s/unix%s %s %s\n",
(int)(screen-display), display,
screen, auth_proto, auth_data);
+#endif
pclose(f);
} else {
fprintf(stderr, "Could not run %s\n",