*** spawn.cc.orig Tue Dec 01 21:24:52 1998 --- spawn.cc Thu Sep 02 22:09:47 1999 *************** *** 490,496 **** si.lpDesktop = wstname; /* force the new process to reread /etc/passwd and /etc/group */ myself->uid = USHRT_MAX; ! rc = CreateProcessAsUser (hToken, real_path, /* image name - with full path */ copy, /* what was passed to exec */ &sec_all_nih, /* process security attrs */ --- 490,526 ---- si.lpDesktop = wstname; /* force the new process to reread /etc/passwd and /etc/group */ myself->uid = USHRT_MAX; ! ! /* carry out a quick and dirty hack to check that what we exec is an EXE */ ! HANDLE hnd = CreateFileA (real_path, ! GENERIC_READ, ! FILE_SHARE_READ | FILE_SHARE_WRITE, ! &sec_none_nih, ! OPEN_EXISTING, ! FILE_ATTRIBUTE_NORMAL, ! 0); ! if (hnd == INVALID_HANDLE_VALUE) ! { ! __seterrno (); ! return -1; ! } ! ! DWORD done; ! ! char buf[3]; ! buf[0] = buf[1] = buf[2] = '\0'; ! if (! ReadFile (hnd, buf, sizeof (buf) - 1, &done, 0)) ! { ! CloseHandle (hnd); ! __seterrno (); ! return -1; ! } ! ! CloseHandle (hnd); ! ! if (buf[0] == 'M' && buf[1] == 'Z') ! { ! rc = CreateProcessAsUser (hToken, real_path, /* image name - with full path */ copy, /* what was passed to exec */ &sec_all_nih, /* process security attrs */ *************** *** 501,509 **** 0, /* use current drive/directory */ &si, &pi); } else ! rc = CreateProcessA (real_path, /* image name - with full path */ copy, /* what was passed to exec */ &sec_all_nih, /* process security attrs */ &sec_all_nih, /* thread security attrs */ --- 531,574 ---- 0, /* use current drive/directory */ &si, &pi); + } + else + { + rc = 0; /* report an error */ + } } else ! { ! /* carry out a quick and dirty hack to check that what we exec is an EXE */ ! HANDLE hnd = CreateFileA (real_path, ! GENERIC_READ, ! FILE_SHARE_READ | FILE_SHARE_WRITE, ! &sec_none_nih, ! OPEN_EXISTING, ! FILE_ATTRIBUTE_NORMAL, ! 0); ! if (hnd == INVALID_HANDLE_VALUE) ! { ! __seterrno (); ! return -1; ! } ! ! DWORD done; ! ! char buf[3]; ! buf[0] = buf[1] = buf[2] = '\0'; ! if (! ReadFile (hnd, buf, sizeof (buf) - 1, &done, 0)) ! { ! CloseHandle (hnd); ! __seterrno (); ! return -1; ! } ! ! CloseHandle (hnd); ! ! if (buf[0] == 'M' && buf[1] == 'Z') ! { ! rc = CreateProcessA (real_path, /* image name - with full path */ copy, /* what was passed to exec */ &sec_all_nih, /* process security attrs */ &sec_all_nih, /* thread security attrs */ *************** *** 513,519 **** --- 578,591 ---- 0, /* use current drive/directory */ &si, &pi); + } + else + { + rc = 0; /* report an error */ + } + } + free (envblock); /* Set errno now so that debugging messages from it appear before our