summaryrefslogtreecommitdiff
path: root/sys/src/cmd/ip/rlogind.c
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
commite5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch)
treed8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/cmd/ip/rlogind.c
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/cmd/ip/rlogind.c')
-rwxr-xr-xsys/src/cmd/ip/rlogind.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/sys/src/cmd/ip/rlogind.c b/sys/src/cmd/ip/rlogind.c
new file mode 100755
index 000000000..ecc38f859
--- /dev/null
+++ b/sys/src/cmd/ip/rlogind.c
@@ -0,0 +1,43 @@
+#include <u.h>
+#include <libc.h>
+
+void getstr(int, char*, int);
+
+void
+main(void)
+{
+ char luser[128], ruser[128], term[128], err[128];
+
+ getstr(0, err, sizeof(err));
+ getstr(0, ruser, sizeof(ruser));
+ getstr(0, luser, sizeof(luser));
+ getstr(0, term, sizeof(term));
+ write(0, "", 1);
+
+ if(luser[0] == '\0')
+ strncpy(luser, ruser, sizeof luser);
+ luser[sizeof luser-1] = '\0';
+ syslog(0, "telnet", "rlogind %s", luser);
+ execl("/bin/ip/telnetd", "telnetd", "-n", "-u", luser, nil);
+ fprint(2, "can't exec con service: %r\n");
+ exits("can't exec");
+}
+
+void
+getstr(int fd, char *str, int len)
+{
+ char c;
+ int n;
+
+ while(--len > 0){
+ n = read(fd, &c, 1);
+ if(n < 0)
+ return;
+ if(n == 0)
+ continue;
+ *str++ = c;
+ if(c == 0)
+ break;
+ }
+ *str = '\0';
+}