Bugzilla – Attachment 214 Details for
Bug 479
add description how to run a ssh tunnel without a full shell on the remote site
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
zzh.c - a minimum server-side shell
zzh.c (text/plain), 2.69 KB, created by
Ralf Hauser
on 2003-01-31 03:02:48 AEDT
(
hide
)
Description:
zzh.c - a minimum server-side shell
Filename:
MIME Type:
Creator:
Ralf Hauser
Created:
2003-01-31 03:02:48 AEDT
Size:
2.69 KB
patch
obsolete
>/* > * zzh.c > * > * Shell for the "SSH Sleeping Beauty" user. > * > * (c) 1999, Tim Hemel <tim@n2it.net> > * > * More info see http://cuba.xs4all.nl/~tim/scvs/ > * > * Modified by Michael Steiner <steiner@acm.org> to add a few safety checks > * > * $Id: zzh.c,v 1.1 2001/03/06 16:38:03 sti Exp $ > */ > >#include <stdio.h> >#include <stdlib.h> >#include <sys/types.h> >#include <sys/time.h> >#include <sys/stat.h> >#include <unistd.h> >#include <fcntl.h> > >/* Timeout in seconds */ >const int ZZZ = 10*60; >#define MAX_CMD_LEN 255 >const char* PREFIX = P_tmpdir"/zzh"; /* prefix for tmpfiles */ > >char cmd[MAX_CMD_LEN+1]; > >/* simple commandline parsing */ >void parse_opt(int argc, char *argv[]) >{ > int i,done; > > done = 0; > for (i=0; (i<argc-1) && !done ; i++) > { > if (!strcmp(argv[i],"-c")) > { > strncpy(cmd,argv[i+1],MAX_CMD_LEN); > cmd[MAX_CMD_LEN] = '\0'; > done = 1; > } > } >} > >int main ( int argc, char* argv[] ) >{ > int i; > char *fn; > int fd; > fd_set fs; > struct timeval to; > struct stat sb; > > /* set cmd to "" */ > cmd[0]='\0'; > > parse_opt(argc, argv); > > /* if no command string, exit */ > if (!strcmp(cmd,"")) exit(0); > > /* check what the command is */ > if (!strcmp(cmd,"open")) > { > /* create a temporary filename, which will be used as a magic word */ > fn = malloc(strlen(PREFIX) + strlen("XXXXXX") + 1); > if (fn==NULL) { > perror("no memory"); exit(1); > } > strcpy(fn, PREFIX); > strcat(fn, "XXXXXX"); > mktemp(fn); > fprintf(stdout,"%s\n",fn); fflush(stdout); > /* create a named pipe with this name */ > if (mkfifo(fn, 0600)) { > perror("mkfifo"); exit(2); > } > if ((fd = open(fn,O_RDONLY)) == 0 ) { > perror("open"); exit(3); > } > /* set up a file descriptor set for select() */ > FD_ZERO(&fs); > FD_SET(fd,&fs); > /* set the ZZZ second timeout */ > to.tv_sec = ZZZ; > > /* wait for input and do nothing with it */ > if (select(fd+1, &fs, 0, 0, &to)>0) { > /* lseek(fd,0,SEEK_END); /* not necessary */ > } > /* remove the temporary file */ > unlink(fn); > } > else /* cmd != "" && cmd != "open" */ > { > /* see if a file named cmd exists, .... */ > if (stat(cmd,&sb)) { > perror("stat"); exit(1); > } > /* ... is a named pipe, ... */ > if (!(sb.st_mode & S_IFIFO)) { > fprintf(stderr, "not named pipe "); exit(2); > } > /* ... is owned by me, ... */ > if (sb.st_uid != getuid()) { > fprintf(stderr, "not owned by me"); exit(3); > } > /* ... and finally is valid tmpfile */ > if (strncmp(cmd, PREFIX, strlen(PREFIX))) { > fprintf(stderr, "wrong place"); exit(4); > } > /* Everything's allright: write to it */ > fd = open(cmd,O_WRONLY); > if (fd > 0) { write(fd, "wake up", 1); } > } > > /* return 0; */ > exit(0); >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 479
:
213
| 214