Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/cs/rsh.c
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1990-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
#pragma prototyped
21
/*
22
* Glenn Fowler
23
* AT&T Bell Laboratories
24
*
25
* cs remote shell service
26
* no tty/pty but good enough for nt
27
* if its the only way in
28
*/
29
30
static const char id[] = "@(#)$Id: cs.rsh (AT&T Bell Laboratories) 1995-10-13 $\0\n";
31
32
#include <cs.h>
33
#include <proc.h>
34
#include <wait.h>
35
36
static int
37
svc_connect(void* handle, int fd, Cs_id_t* id, int clone, char** argv)
38
{
39
Proc_t* p;
40
int n;
41
long ops[4];
42
43
static char* args[] = { "sh", "-i", 0 };
44
45
NoP(handle);
46
NoP(clone);
47
waitpid(-1, NiL, WNOHANG);
48
n = 0;
49
ops[n++] = PROC_FD_DUP(fd, 0, 0);
50
ops[n++] = PROC_FD_DUP(fd, 1, 0);
51
ops[n++] = PROC_FD_DUP(fd, 2, PROC_FD_CHILD);
52
ops[n] = 0;
53
if (!(p = procopen(NiL, args, NiL, ops, 0)))
54
return(-1);
55
procfree(p);
56
csfd(fd, CS_POLL_CLOSE);
57
return(0);
58
}
59
60
int
61
main(int argc, char** argv)
62
{
63
NoP(argc);
64
csserve(NiL, argv[1], NiL, NiL, svc_connect, NiL, NiL, NiL);
65
exit(1);
66
}
67
68