Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
23796494
Commit
23796494
authored
Aug 16, 2005
by
Russ Fish
Browse files
Enable slothd on Windows.
parent
30b2e1f0
Changes
6
Hide whitespace changes
Inline
Side-by-side
sensors/slothd/GNUmakefile.in
View file @
23796494
...
...
@@ -14,17 +14,26 @@ TBLIB = $(OBJDIR)/lib/libtb/libtb.a
SBIN_SCRIPTS = sdisrunning sddeploy
SDPROGS = sdcollectd slothd
SYSTEM := $(shell uname -s)
include $(OBJDIR)/Makeconf
CC?=gcc
## For debug compilation
##CFLAGS+= -g
CFLAGS+= -Wall -I${OBJDIR} -I/usr/local/include -I$(TESTBED_SRCDIR)/lib/libtb \
-DCLIENT_BINDIR='"$(CLIENT_BINDIR)"' \
-DLOG_TESTBED=$(LOG_TESTBED)
LDFLAGS+= -L${OBJDIR}/lib/libtb -L/usr/local/lib/mysql
SDLIBS+= -ltb -lmysqlclient
LIBS=
LIBS=
$(MLIBS)
CP= cp -pf
ifeq ($(SYSTEM),CYGWIN_NT-5.1)
# Cygwin on Windows XP (a.k.a. NT 5.1).
MLIBS += -liphlpapi
endif
all: $(SDPROGS) client
include ${TESTBED_SRCDIR}/GNUmakerules
...
...
@@ -49,7 +58,7 @@ install: $(addprefix $(INSTALL_SBINDIR)/, $(SBIN_SCRIPTS) sdcollectd) webfeedbac
$(INSTALL_PROGRAM) webfeedback $(INSTALL_LIBEXECDIR)
client-install: client
$(INSTALL_PROGRAM) slothd$(EXE) $(DESTDIR)$(CLIENT_BINDIR)$(EXE)
$(INSTALL_PROGRAM) slothd$(EXE) $(DESTDIR)$(CLIENT_BINDIR)
/slothd
$(EXE)
control-install:
...
...
sensors/slothd/slothd.c
View file @
23796494
...
...
@@ -37,7 +37,8 @@ void sigunkhandler(int signum) {
sprintf
(
message
,
"Unhandled signal: %d. Exiting."
,
signum
);
lerror
(
message
);
unlink
(
PIDFILE
);
if
(
!
opts
->
debug
)
unlink
(
PIDFILE
);
while
(
wait
(
&
status
)
!=
-
1
);
exit
(
signum
);
}
...
...
@@ -198,7 +199,7 @@ int parse_args(int argc, char **argv) {
case
'g'
:
if
((
opts
->
agg_interval
=
atol
(
optarg
))
<
MIN_AINTVL
)
{
lwarn
(
"Warning! Aggressive interval set too low, defaulting."
);
opts
->
re
g_interval
=
MIN_AINTVL
;
opts
->
ag
g_interval
=
MIN_AINTVL
;
}
break
;
...
...
@@ -254,11 +255,14 @@ int parse_args(int argc, char **argv) {
int
init_slothd
(
void
)
{
DIR
*
devs
;
int
pfd
;
char
pidbuf
[
10
];
#ifndef __CYGWIN__
DIR
*
devs
;
char
bufstr
[
MAXDEVLEN
];
struct
dirent
*
dptr
;
#endif
/* __CYGWIN__ */
int
pfd
;
char
pidbuf
[
10
];
struct
hostent
*
hent
;
char
*
ciprog
[]
=
{
"control_interface"
,
NULL
};
...
...
@@ -302,13 +306,26 @@ DIR *devs;
parms
->
ifd
=
socket
(
PF_INET
,
SOCK_DGRAM
,
0
);
#endif
#ifndef __CYGWIN__
/* enum tty special files */
if
((
devs
=
opendir
(
"/dev"
))
==
0
)
{
lerror
(
"Can't open directory /dev for processing"
);
return
-
1
;
}
parms
->
ttys
[
parms
->
numttys
]
=
strdup
(
"/dev/console"
);
parms
->
numttys
++
;
#else
/* __CYGWIN__ */
/* On Cygwin, `tty` returns /dev/console under RDP, and /dev/tty$n under SSH.
* However, stat on anything under /dev always returns the current time, so
* it's no help detecting user input. Instead, we patch sshd to change the
* modtime on a file when input is received and stat that.
*/
parms
->
ttys
[
parms
->
numttys
]
=
strdup
(
"/var/run/ssh_input"
);
parms
->
numttys
++
;
#endif
/* __CYGWIN__ */
#ifdef __linux__
/*
Include the pts mux device to check for activity on
...
...
@@ -318,6 +335,7 @@ DIR *devs;
parms
->
ttys
[
parms
->
numttys
]
=
strdup
(
"/dev/ptmx"
);
parms
->
numttys
++
;
#endif
#ifndef __CYGWIN__
while
(
parms
->
numttys
<
MAXTTYS
&&
(
dptr
=
readdir
(
devs
)))
{
if
(
strstr
(
dptr
->
d_name
,
"tty"
)
||
strstr
(
dptr
->
d_name
,
"pty"
))
{
snprintf
(
bufstr
,
MAXDEVLEN
,
"/dev/%s"
,
dptr
->
d_name
);
...
...
@@ -327,6 +345,7 @@ DIR *devs;
}
}
closedir
(
devs
);
#endif
/* __CYGWIN__ */
/* prepare UDP connection to server */
if
((
parms
->
sd
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
))
<
0
)
{
...
...
@@ -370,8 +389,8 @@ DIR *devs;
void
do_exit
(
void
)
{
int
status
;
unlink
(
PIDFILE
);
if
(
!
opts
->
debug
)
unlink
(
PIDFILE
);
while
(
wait
(
&
status
)
!=
-
1
);
lnotice
(
"exiting."
);
exit
(
0
);
...
...
@@ -383,10 +402,25 @@ int grab_cifname(char *buf, void *data) {
char
*
tmpptr
;
SLOTHD_PARAMS
*
myparms
=
(
SLOTHD_PARAMS
*
)
data
;
#ifdef __CYGWIN__
if
(
buf
&&
isalnum
(
buf
[
0
]))
{
/* The MAC addr precedes the cifname on Cygwin. */
tmpptr
=
myparms
->
cifaddr
=
strdup
(
buf
);
strsep
(
&
tmpptr
,
" "
);
/* Allow embedded spaces in the cifname on Cygwin. */
myparms
->
cifname
=
tmpptr
;
while
(
isalnum
(
*
tmpptr
)
||
*
tmpptr
==
' '
)
tmpptr
++
;
*
tmpptr
=
'\0'
;
#else
/* Trim trailing whitespace from the cifname. */
if
(
buf
&&
isalpha
(
buf
[
0
]))
{
tmpptr
=
myparms
->
cifname
=
strdup
(
buf
);
while
(
isalnum
(
*
tmpptr
))
tmpptr
++
;
while
(
isalnum
(
*
tmpptr
))
tmpptr
++
;
*
tmpptr
=
'\0'
;
#endif
/* __CYGWIN__ */
retval
=
0
;
}
else
{
...
...
@@ -466,16 +500,7 @@ void get_min_tty_idle(SLOTHD_PACKET *pkt) {
return
;
}
#ifdef __CYGWIN__
int
getloadavg
(
double
loadavg
[],
int
nelem
)
{
FILE
*
f
=
fopen
(
"/proc/loadavg"
,
"r"
);
fscanf
(
f
,
"%lf %lf %lf"
,
&
loadavg
[
0
],
&
loadavg
[
1
],
&
loadavg
[
2
]);
fclose
(
f
);
return
3
;
}
#endif
/* __CYGWIN__ */
#ifndef __CYGWIN__
void
get_load
(
SLOTHD_PACKET
*
pkt
)
{
...
...
@@ -492,6 +517,36 @@ void get_load(SLOTHD_PACKET *pkt) {
return
;
}
#else
/* ifndef __CYGWIN__ */
/* A perfmon log is dribbling out the processor load once a minute. */
char
*
ldavg_prog
[]
=
{
"tail"
,
"-1"
,
"/var/run/ldavg.csv"
,
NULL
};
int
get_ldavg
(
char
*
,
void
*
);
void
get_load
(
SLOTHD_PACKET
*
pkt
)
{
pkt
->
loadavg
[
0
]
=
pkt
->
loadavg
[
1
]
=
pkt
->
loadavg
[
2
]
=
-
1
.
0
;
if
(
procpipe
(
ldavg_prog
,
&
get_ldavg
,
(
void
*
)
pkt
))
lwarn
(
"get_ldavg exec failed."
);
}
int
get_ldavg
(
char
*
buf
,
void
*
data
)
{
SLOTHD_PACKET
*
pkt
=
(
SLOTHD_PACKET
*
)
data
;
double
load
=
-
1
.
0
;
if
(
sscanf
(
buf
,
"%*[^,],
\"
%lf
\"
"
,
&
load
)
!=
1
)
{
lerror
(
"unable to obtain processor load."
);
return
-
1
;
}
/* NT reports load as a percent, e.g. 44.5; we want a fraction, e.g. 0.445 */
pkt
->
loadavg
[
0
]
=
pkt
->
loadavg
[
1
]
=
pkt
->
loadavg
[
2
]
=
load
/
100
.
0
;
if
(
opts
->
debug
)
printf
(
"load averages: %f, %f, %f
\n
"
,
pkt
->
loadavg
[
0
],
pkt
->
loadavg
[
1
],
pkt
->
loadavg
[
2
]);
return
0
;
}
#endif
/* __CYGWIN__ */
int
get_active_bits
(
SLOTHD_PACKET
*
pkt
,
SLOTHD_PACKET
*
opkt
)
{
...
...
@@ -518,26 +573,30 @@ int get_active_bits(SLOTHD_PACKET *pkt, SLOTHD_PACKET *opkt) {
* Have the packet counters exceeded the threshold? Make sure we don't
* count the incoming packets on the control net interface.
*/
u_long
od
,
id
;
for
(
i
=
0
;
i
<
pkt
->
ifcnt
;
++
i
)
{
if
(
strcmp
(
parms
->
cifname
,
pkt
->
ifaces
[
i
].
ifname
)
==
0
)
{
if
((
pkt
->
ifaces
[
i
].
opkts
-
opkt
->
ifaces
[
i
].
opkts
)
>=
if
((
od
=
pkt
->
ifaces
[
i
].
opkts
-
opkt
->
ifaces
[
i
].
opkts
)
>=
opts
->
cif_thresh
)
{
if
(
opts
->
debug
)
{
printf
(
"Packet threshold exceeded on %s interface %s, %lu>=%lu
\n
"
,
"ctl net"
,
pkt
->
ifaces
[
i
].
ifname
,
od
,
opts
->
cif_thresh
);
}
break
;
}
}
else
if
(((
pkt
->
ifaces
[
i
].
opkts
-
opkt
->
ifaces
[
i
].
opkts
)
>=
else
if
(((
od
=
pkt
->
ifaces
[
i
].
opkts
-
opkt
->
ifaces
[
i
].
opkts
)
>=
opts
->
pkt_thresh
)
||
((
pkt
->
ifaces
[
i
].
ipkts
-
opkt
->
ifaces
[
i
].
ipkts
)
>=
((
id
=
pkt
->
ifaces
[
i
].
ipkts
-
opkt
->
ifaces
[
i
].
ipkts
)
>=
opts
->
pkt_thresh
))
{
printf
(
"Packet threshold exceeded on %s interface %s, %lu|%lu>=%lu
\n
"
,
"exp net"
,
pkt
->
ifaces
[
i
].
ifname
,
od
,
id
,
opts
->
pkt_thresh
);
break
;
}
}
if
(
i
<
pkt
->
ifcnt
)
{
pkt
->
actbits
|=
PKTACT
;
if
(
opts
->
debug
)
{
printf
(
"Packet threshold exceeded on %s
\n
"
,
pkt
->
ifaces
[
i
].
ifname
);
}
}
else
{
pkt
->
actbits
&=
~
PKTACT
;
...
...
@@ -550,16 +609,15 @@ int get_active_bits(SLOTHD_PACKET *pkt, SLOTHD_PACKET *opkt) {
return
pkt
->
actbits
;
}
void
get_packet_counts
(
SLOTHD_PACKET
*
pkt
)
{
#ifndef __CYGWIN__
void
get_packet_counts
(
SLOTHD_PACKET
*
pkt
)
{
int
i
;
char
*
niprog
[]
=
{
"netstat"
,
"-ni"
,
NULL
};
#endif
/* __CYGWIN__ */
pkt
->
ifcnt
=
0
;
#ifndef __CYGWIN__
if
(
procpipe
(
niprog
,
&
get_counters
,
(
void
*
)
pkt
))
{
lwarn
(
"Netinfo exec failed."
);
pkt
->
ifcnt
=
0
;
...
...
@@ -572,44 +630,54 @@ void get_packet_counts(SLOTHD_PACKET *pkt) {
pkt
->
ifaces
[
i
].
opkts
);
}
}
#endif
/* __CYGWIN__ */
return
;
}
#if
n
def __
CYGWIN
__
#ifdef __
FreeBSD
__
int
get_counters
(
char
*
buf
,
void
*
data
)
{
SLOTHD_PACKET
*
pkt
=
(
SLOTHD_PACKET
*
)
data
;
#ifdef __linux__
struct
ifreq
ifr
;
bzero
(
&
ifr
,
sizeof
(
struct
ifreq
));
#endif
if
(
pkt
->
ifcnt
<
MAXNUMIFACES
&&
!
strstr
(
buf
,
"lo"
)
#ifdef __FreeBSD__
#if __FreeBSD__ >= 5
&&
!
strstr
(
buf
,
"plip"
)
#endif
&&
!
strstr
(
buf
,
"*"
)
&&
strstr
(
buf
,
"<Link"
))
#endif
#ifdef __linux__
&&
(
strstr
(
buf
,
"eth"
)
||
strstr
(
buf
,
"wlan"
)
||
strstr
(
buf
,
"ath"
)))
#endif
{
if
(
sscanf
(
buf
,
CNTFMTSTR
,
if
(
sscanf
(
buf
,
"%s %*s %*s %s %lu %*s %lu"
,
pkt
->
ifaces
[
pkt
->
ifcnt
].
ifname
,
#ifdef __FreeBSD__
pkt
->
ifaces
[
pkt
->
ifcnt
].
addr
,
#endif
&
pkt
->
ifaces
[
pkt
->
ifcnt
].
ipkts
,
&
pkt
->
ifaces
[
pkt
->
ifcnt
].
opkts
)
!=
NUMSCAN
)
{
&
pkt
->
ifaces
[
pkt
->
ifcnt
].
opkts
)
!=
4
)
{
printf
(
"Failed to parse netinfo output.
\n
"
);
return
-
1
;
}
pkt
->
ifcnt
++
;
}
return
0
;
}
#endif
/* __FreeBSD__ */
#ifdef __linux__
int
get_counters
(
char
*
buf
,
void
*
data
)
{
SLOTHD_PACKET
*
pkt
=
(
SLOTHD_PACKET
*
)
data
;
struct
ifreq
ifr
;
bzero
(
&
ifr
,
sizeof
(
struct
ifreq
));
if
(
pkt
->
ifcnt
<
MAXNUMIFACES
&&
!
strstr
(
buf
,
"lo"
)
&&
(
strstr
(
buf
,
"eth"
)
||
strstr
(
buf
,
"wlan"
)
||
strstr
(
buf
,
"ath"
)))
{
if
(
sscanf
(
buf
,
"%s %*s %*s %lu %*s %*s %*s %lu"
,
pkt
->
ifaces
[
pkt
->
ifcnt
].
ifname
,
&
pkt
->
ifaces
[
pkt
->
ifcnt
].
ipkts
,
&
pkt
->
ifaces
[
pkt
->
ifcnt
].
opkts
)
!=
3
)
{
printf
(
"Failed to parse netinfo output.
\n
"
);
return
-
1
;
}
strcpy
(
ifr
.
ifr_name
,
pkt
->
ifaces
[
pkt
->
ifcnt
].
ifname
);
if
(
ioctl
(
parms
->
ifd
,
SIOCGIFHWADDR
,
&
ifr
)
<
0
)
{
perror
(
"error getting HWADDR"
);
...
...
@@ -622,13 +690,76 @@ int get_counters(char *buf, void *data) {
if
(
opts
->
debug
)
{
printf
(
"macaddr: %s
\n
"
,
pkt
->
ifaces
[
pkt
->
ifcnt
].
addr
);
}
#endif
pkt
->
ifcnt
++
;
}
return
0
;
}
#endif
/* __linux__ */
#else
/* __CYGWIN__ */
#include <windows.h>
#include <iphlpapi.h>
void
get_packet_counts
(
SLOTHD_PACKET
*
pkt
)
{
static
DWORD
dwSize
;
DWORD
ret
;
int
i
;
/* Call GetIfTable(), an MS IP Helper Function, to get packet counters. */
PMIB_IFTABLE
iftable
;
PMIB_IFROW
ifrow
;
dwSize
=
sizeof
(
MIB_IFTABLE
);
iftable
=
(
PMIB_IFTABLE
)
malloc
(
dwSize
);
while
((
ret
=
GetIfTable
(
iftable
,
&
dwSize
,
0
))
==
ERROR_INSUFFICIENT_BUFFER
)
iftable
=
(
PMIB_IFTABLE
)
realloc
(
iftable
,
dwSize
);
if
(
ret
!=
NO_ERROR
)
{
char
msg
[
LINEBUFLEN
];
sprintf
(
msg
,
"get_packet_counts: GetIfTable error %lu"
,
ret
);
free
(
iftable
);
lerror
(
msg
);
}
/* Scan through the interface table. */
pkt
->
ifcnt
=
0
;
for
(
i
=
0
;
i
<
min
(
iftable
->
dwNumEntries
,
MAXNUMIFACES
);
i
++
)
{
ifrow
=
&
(
iftable
->
table
[
i
]);
if
(
ifrow
->
dwType
!=
MIB_IF_TYPE_LOOPBACK
&&
/* Exclude loopback. */
ifrow
->
dwOperStatus
==
MIB_IF_OPER_STATUS_OPERATIONAL
)
{
/* Format the MAC address. We don't have ether_ntoa(). */
snprintf
(
pkt
->
ifaces
[
pkt
->
ifcnt
].
addr
,
MACADDRLEN
,
"%02x:%02x:%02x:%02x:%02x:%02x"
,
ifrow
->
bPhysAddr
[
0
],
ifrow
->
bPhysAddr
[
1
],
ifrow
->
bPhysAddr
[
2
],
ifrow
->
bPhysAddr
[
3
],
ifrow
->
bPhysAddr
[
4
],
ifrow
->
bPhysAddr
[
5
]);
if
(
opts
->
debug
)
printf
(
"macaddr: %s
\n
"
,
pkt
->
ifaces
[
pkt
->
ifcnt
].
addr
);
/* Grumble. ifrow->wszName is empty.
* Recognize the control interface by its MAC address.
*/
if
(
strncmp
(
pkt
->
ifaces
[
pkt
->
ifcnt
].
addr
,
parms
->
cifaddr
,
MACADDRLEN
)
==
0
)
strncpy
(
pkt
->
ifaces
[
pkt
->
ifcnt
].
ifname
,
parms
->
cifname
,
MAXIFNAMELEN
);
else
/* If it isn't the control interface, just show the MAC address. */
strncpy
(
pkt
->
ifaces
[
pkt
->
ifcnt
].
ifname
,
parms
->
cifaddr
,
MAXIFNAMELEN
);
if
(
opts
->
debug
)
printf
(
"ifname: %s
\n
"
,
pkt
->
ifaces
[
pkt
->
ifcnt
].
ifname
);
/* Packet counters, including unicast, broadcast, and multicast. */
pkt
->
ifaces
[
pkt
->
ifcnt
].
ipkts
=
ifrow
->
dwInUcastPkts
+
ifrow
->
dwInNUcastPkts
;
pkt
->
ifaces
[
pkt
->
ifcnt
].
opkts
=
ifrow
->
dwOutUcastPkts
+
ifrow
->
dwOutNUcastPkts
;
pkt
->
ifcnt
++
;
}
}
free
(
iftable
);
}
#endif
/* __CYGWIN__ */
/* XXX change to combine last return value of procfunc with exec'ed process'
exit status & write macros for access.
*/
...
...
sensors/slothd/slothd.h
View file @
23796494
...
...
@@ -45,7 +45,7 @@
#define PIDFILE "/var/run/slothd.pid"
#define MACADDRLEN 18
#define MAXNUMIFACES 10
#define MAXIFNAMELEN
10
#define MAXIFNAMELEN
30
/* On Windows, "Local Area Connection 16". */
#define LINEBUFLEN 256
#define MAXTTYS 2000
#define MAXDEVLEN 50
...
...
@@ -65,16 +65,6 @@
#define LOG_TESTBED LOG_DAEMON
#endif
#ifdef __FreeBSD__
#define CNTFMTSTR "%s %*s %*s %s %lu %*s %lu"
#define NUMSCAN 4
#endif
#ifdef __linux__
#define CNTFMTSTR "%s %*s %*s %lu %*s %*s %*s %lu"
#define NUMSCAN 3
#endif
#define TTYACT (1<<0)
#define LOADACT (1<<1)
#define PKTACT (1<<2)
...
...
@@ -86,6 +76,9 @@ typedef struct {
#endif
u_int
cnt
;
char
*
cifname
;
#ifdef __CYGWIN__
char
*
cifaddr
;
#endif
/* __CYGWIN__ */
u_char
dolast
;
time_t
lastrpt
;
time_t
startup
;
...
...
tmcd/cygwinxp/rc.cygwinxp
View file @
23796494
...
...
@@ -21,7 +21,17 @@ uname -r > $iscygwin
chmod
g+w
$iscygwin
chmod
-f
g-w /etc/emulab
# Make sure the computer name is right, reboots to change it if necessary.
# NetBT (Netbios over TCP) chatters, messes up slothd, and is not needed for
# SMB, so disable it. This doesn't take effect until TCP/IP is restarted, so
# do it before the computer name change below, which reboots the first time.
svcs
=
/HKLM/SYSTEM/CurrentControlSet/Services
pi
=
Parameters/Interfaces
nbtif
=
$svcs
/NetBT/
$pi
for
ifc
in
`
regtool list
$nbtif
`
;
do
# Set the NetBT interface NetbiosOptions to Disable (2.)
regtool
set
-i
$nbtif
/
$ifc
/NetbiosOptions 2
done
# Make sure the computer name is right. Reboots to change it if necessary.
nodeid
=
while
[
-z
$nodeid
]
;
do
nodeid
=
`
tmcc nodeid
`
...
...
@@ -74,7 +84,7 @@ else
# Last resort!!! tsshutdn
datehost
=
"
`
date
`
: Host name '
$hostname
'"
# msg="$datehost didn't /bin/shutdown changing to '$nodeid'! Trying tsshutdn."
msg
=
"
$datehost
didn't reboot changing to '
$nodeid
'! Trying
reboot
."
msg
=
"
$datehost
didn't reboot changing to '
$nodeid
'! Trying
tsshutdn
."
echo
"
$msg
"
>>
$logfile
echo
"
$msg
"
tsshutdn 1 /REBOOT /DELAY:1
...
...
@@ -98,6 +108,16 @@ ipconfig /all | awk \
'/^ *Connection-specific DNS Suffix/{print "search", $NF} \
/^ *DNS Servers/{print "nameserver", $NF}'
>
/etc/resolv.conf
# Remember the control net interface MAC address and Local Area Connection name for
# slothd. It's the one whose IP address is returned by looking up the nodeid (pc%d).
cif
=
/var/emulab/boot/controlif
nodeid
=
`
cat
/var/emulab/boot/nodeid
`
ipaddr
=
`
nslookup
$nodeid
|
awk
'NR>2 && /Address:/{print $2}'
`
ipconfig /all |
tr
-d
'\r'
|
awk
\
'/^Ethernet adapter/{ ifc = gensub("Ethernet adapter (.*):", "\\1", 1); next }\
/Physical Address/{ gsub("-", ":"); mac = tolower($NF); next}\
/IP Address/ && $NF=="'
$ipaddr
'"{ print mac, ifc > "'
$cif
'"; exit }'
# Start up the service which will deliver a SHUTDOWN state event on reboot.
cygrunsrv
-S
EmulabShutdown
...
...
tmcd/cygwinxp/sshd-client-input-time.patch
0 → 100644
View file @
23796494
***
openssh-4.1p1-2/channels.h.orig Tue Mar 1 03:24:33 2005
--- openssh-4.1p1-2/channels.h Thu Aug 11 14:43:12 2005
***************
*** 183,188 ****
--- 183,193 ----
void channel_input_port_open(int, u_int32_t, void *);
void channel_input_window_adjust(int, u_int32_t, void *);
+ #ifdef HAVE_CYGWIN
+ /* Emulab patch - Touch a file so we know when input happens. */
+ void input_occurred();
+ #endif
+
/* file descriptor handling (read/write) */
void channel_prepare_select(fd_set **, fd_set **, int *, u_int*, int);
***
openssh-4.1p1-2/channels.c.orig Mon Mar 14 05:22:26 2005
--- openssh-4.1p1-2/channels.c Thu Aug 11 17:13:33 2005
***************
*** 1896,1902 ****
--- 1896,1936 ----
packet_check_eom();
buffer_append(&c->output, data, data_len);
xfree(data);
+ #ifdef HAVE_CYGWIN
+ input_occurred();
+ #endif
}
+
+ #ifdef HAVE_CYGWIN
+ /* Emulab patch - Touch a file so we know when input happens. */
+ char *ssh_time_file = "/var/run/ssh_input";
+ int input_occurred_fd = 0;
+ time_t last_time = 0;
+ void
+ input_occurred()
+ {
+ if (input_occurred_fd == 0)
+ /* No init yet. */
+ input_occurred_fd = open(
+ ssh_time_file, O_CREAT | O_TRUNC | O_WRONLY, 0666);
+ if (input_occurred_fd == -1) {
+ logit("Failed to open ssh_time_file %s.", ssh_time_file);
+ input_occurred_fd = -2;
+ }
+ if (input_occurred_fd > 0
+ /* Don't do it more than once a second. */
+ && time(NULL) != last_time) {
+ last_time = time(NULL);
+
+ /* It would be nice to use futimes(), but there's not one
+ * on Cygwin. Instead, use ftruncate() to set the modtime.
+ */
+ if (ftruncate(input_occurred_fd, 0))
+ logit("Error touching ssh input time file, %s.",
+ strerror(errno));
+ }
+ }
+ #endif
void
channel_input_extended_data(int type, u_int32_t seq, void *ctxt)
***
openssh-4.1p1-2/serverloop.c.orig Fri Aug 13 05:18:01 2004
--- openssh-4.1p1-2/serverloop.c Thu Aug 11 15:52:45 2005
***************
*** 821,826 ****
--- 821,829 ----
buffer_append(&stdin_buffer, data, data_len);
memset(data, 0, data_len);
xfree(data);
+ #ifdef HAVE_CYGWIN
+ input_occurred();
+ #endif
}
static void
tmcd/cygwinxp/xpimage-notes.txt
View file @
23796494
...
...
@@ -83,9 +83,10 @@ alias rootrd 'rd -K -g 1280x1024 -u root pc\!^.$en &'
. Mirror is http://mirrors.xmission.com .
. Click [View] to "Not Installed" (alphabetical.)
Click on the Skip in the "New" column to add a binary version of:
agetty, bison, cvs, cygrunsrv, ed, file, flex, gcc, gdb, make, minires-devel, nano,
openssh, openssl-devel, patch, perl, perl-libwin32, python, rpm, rpm-build,
rsync, shutdown, tcsh, vim, wget, zip .
agetty, bison, cvs, cygrunsrv, ed, file, flex, gcc, gdb, inetutils,
make, minires-devel, nano, openssh, openssl-devel,
patch, perl, perl-libwin32, python, rpm, rpm-build, rsync,
shutdown, tcsh, vim, wget, zip .
. Don't "Create an icon on the Desktop", do "Add icon to Start Menu".
. Add ;C:\cygwin\bin to the end of the System PATH in
...
...
@@ -127,6 +128,16 @@ alias rootrd 'rd -K -g 1280x1024 -u root pc\!^.$en &'
cp -p /etc/passwd{.new,}
chown root /etc/{passwd,group}*
. Set up the syslog daemon. (See usr/share/doc/Cygwin/inetutils-1.3.2.README)
# Make sure /etc isn't owned by SYSTEM, which will prevent making syslogd.conf .
chown root /etc
syslogd-config -y
# Start the daemon. It starts automatically at reboot.
net start syslogd
# Test.
logger "Test syslogd."
tail /var/log/messages
. Set up sshd.
- Edit /bin/ssh-host-config to add a -i argument to the "cygrunsrv -I sshd" lines.
grep cygrunsrv /bin/ssh-host-config
...
...
@@ -136,9 +147,10 @@ alias rootrd 'rd -K -g 1280x1024 -u root pc\!^.$en &'
w
q
- Then start a cygwin shell, stop sshd and remove its entry, run ssh-host-config:
cygrunsrv -VQ sshd
cygrunsrv -E sshd
cygrunsrv -R sshd
(You must be logged in as root over RDP, not ssh when you do this.)
cygrunsrv -VQ sshd
cygrunsrv -E sshd
cygrunsrv -R sshd
# May need to do some unmounts before running ssh-host-config.
# It does a mount, and there's a hard-wired limit of 31 mount table entries.
...
...
@@ -146,7 +158,7 @@ alias rootrd 'rd -K -g 1280x1024 -u root pc\!^.$en &'
## mount: /ssh-host-config.3048: Too many mount entries
for s in /users/s*; do umount $s; done
# Should be NO ssh processes running
.
# Should be NO ssh processes running
, not even ssh-agent!
ps -Welf | grep ssh
# Make sure /etc is writable by root.
...
...
@@ -183,8 +195,9 @@ q
kill -HUP `cat /var/run/sshd.pid`
. LogLevel defaults to INFO, can be set to VERBOSE, DEBUG1, etc.
Debug events are logged under Event View / Application / sshd,
One line per event (ugh.) Refresh to see new events with F5.
With the syslogd service running, debug events are logged to /var/log/messages .
[Otherwise, they show up under Event Viewer / Application / sshd,
with one line per event (ugh.) Refresh to see new events with F5.]
## sshd service debugging.