Commit 42871b0d authored by Russ Fish's avatar Russ Fish
Browse files

Adapt the Cygwin sshd patch to enable commands to see mounted file systems on Windows.

parent ab6402d9
......@@ -42,6 +42,10 @@
#include "systemf.h"
#include "event.h"
#include <elvin/elvin.h>
#ifdef __CYGWIN__
#include <w32api/windows.h>
#include <sys/cygwin.h>
#endif /* __CYGWIN__ */
/**
* We expressly do _not_ put the logs in /tmp since a reboot might clear them
......@@ -553,6 +557,38 @@ main(int argc, char **argv)
* Flip to the user, but only if we are currently root.
*/
if (getuid() == 0) {
#ifdef __CYGWIN__
/*
* Present the plain-text password from the tmcc accounts file
* so remote Samba directory mounts like /proj can be accessed.
*/
FILE *pwd_file = fopen("/var/emulab/boot/tmcc/accounts", "r");
static char line[255], name[30], password[30];
int matched = 0;
while (pwd_file && fgets(line, 255, pwd_file)) {
if (sscanf(line, "ADDUSER LOGIN=%30s PSWD=%30s ",
name, password) == 2 &&
(matched = (strncmp(user, name, 30) == 0)))
break; /* Found it. */
}
fclose(pwd_file);
if (matched) {
info("cygwin_logon_user: name %s, password '%s'...",
pw->pw_name, password);
HANDLE hToken = cygwin_logon_user(pw, password);
if (hToken != INVALID_HANDLE_VALUE) {
info(" suceeded\n");
/* This sets context for setuid() below. */
cygwin_set_impersonation_token(hToken);
}
else
info(" failed\n");
}
else
info("AGENT: user %s, %s", pw->pw_name, "password not found\n");
#endif /* __CYGWIN__ */
/*
* Initialize the group list, and then flip to uid.
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment