diff options
| author | Charles.Forsyth <devnull@localhost> | 2006-12-23 00:30:12 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2006-12-23 00:30:12 +0000 |
| commit | 6e425a9de8c003b5a733621a6b6730ec3cc902b8 (patch) | |
| tree | 314123bcab78ff295f38f85f31dc141e5fe22d15 /emu/FreeBSD | |
| parent | 74a4d8c26dd3c1e9febcb717cfd6cb6512991a7a (diff) | |
20061220
Diffstat (limited to 'emu/FreeBSD')
| -rw-r--r-- | emu/FreeBSD/asm-386.S | 3 | ||||
| -rw-r--r-- | emu/FreeBSD/cmd.c | 25 | ||||
| -rw-r--r-- | emu/FreeBSD/ipif.c | 5 |
3 files changed, 20 insertions, 13 deletions
diff --git a/emu/FreeBSD/asm-386.S b/emu/FreeBSD/asm-386.S index 2d11c6da..35269c8f 100644 --- a/emu/FreeBSD/asm-386.S +++ b/emu/FreeBSD/asm-386.S @@ -95,10 +95,7 @@ FPrestore: .type getcallerpc,@function .global getcallerpc getcallerpc: - pushl %ebp - movl %esp, %ebp movl 4(%ebp), %eax - popl %ebp ret .type _tas,@function diff --git a/emu/FreeBSD/cmd.c b/emu/FreeBSD/cmd.c index 55ead029..ed4cabab 100644 --- a/emu/FreeBSD/cmd.c +++ b/emu/FreeBSD/cmd.c @@ -21,7 +21,7 @@ enum typedef struct Targ Targ; struct Targ { - int fd[2]; /* fd[0] is standard input, fd[1] is standard output */ + int fd[3]; /* fd[0] is standard input, fd[1] is standard output, fd[2] is standard error */ char** args; char* dir; int pid; @@ -43,15 +43,17 @@ childproc(Targ *t) nfd = getdtablesize(); for(i = 0; i < nfd; i++) - if(i != t->fd[0] && i != t->fd[1] && i != t->wfd) + if(i != t->fd[0] && i != t->fd[1] && i != t->fd[2] && i != t->wfd) close(i); dup2(t->fd[0], 0); dup2(t->fd[1], 1); - dup2(t->fd[1], 2); + dup2(t->fd[2], 2); close(t->fd[0]); close(t->fd[1]); + close(t->fd[2]); + /* should have an auth file to do host-specific authorisation? */ if(t->gid != -1){ if(setgid(t->gid) < 0 && getegid() == 0){ fprint(t->wfd, "can't set gid %d: %s", t->gid, strerror(errno)); @@ -82,10 +84,10 @@ childproc(Targ *t) } void* -oscmd(char **args, int nice, char *dir, int *rfd, int *sfd) +oscmd(char **args, int nice, char *dir, int *fd) { Targ *t; - int r, fd0[2], fd1[2], wfd[2], n, pid; + int r, fd0[2], fd1[2], fd2[2], wfd[2], n, pid; t = mallocz(sizeof(*t), 1); if(t == nil) @@ -93,14 +95,16 @@ oscmd(char **args, int nice, char *dir, int *rfd, int *sfd) fd0[0] = fd0[1] = -1; fd1[0] = fd1[1] = -1; + fd2[0] = fd2[1] = -1; wfd[0] = wfd[1] = -1; - if(pipe(fd0) < 0 || pipe(fd1) < 0 || pipe(wfd) < 0) + if(pipe(fd0) < 0 || pipe(fd1) < 0 || pipe(fd2) < 0 || pipe(wfd) < 0) goto Error; if(fcntl(wfd[1], F_SETFD, FD_CLOEXEC) < 0) /* close on exec to give end of file on success */ goto Error; t->fd[0] = fd0[0]; t->fd[1] = fd1[1]; + t->fd[2] = fd2[1]; t->wfd = wfd[1]; t->args = args; t->dir = dir; @@ -130,6 +134,7 @@ oscmd(char **args, int nice, char *dir, int *rfd, int *sfd) close(fd0[0]); close(fd1[1]); + close(fd2[1]); close(wfd[1]); n = read(wfd[0], up->genbuf, sizeof(up->genbuf)-1); @@ -137,6 +142,7 @@ oscmd(char **args, int nice, char *dir, int *rfd, int *sfd) if(n > 0){ close(fd0[1]); close(fd1[0]); + close(fd2[0]); free(t); up->genbuf[n] = 0; if(Debug) @@ -145,8 +151,9 @@ oscmd(char **args, int nice, char *dir, int *rfd, int *sfd) return nil; } - *sfd = fd0[1]; - *rfd = fd1[0]; + fd[0] = fd0[1]; + fd[1] = fd1[0]; + fd[2] = fd2[0]; return t; Error: @@ -157,6 +164,8 @@ Error: close(fd0[1]); close(fd1[0]); close(fd1[1]); + close(fd2[0]); + close(fd2[1]); close(wfd[0]); close(wfd[1]); error(strerror(r)); diff --git a/emu/FreeBSD/ipif.c b/emu/FreeBSD/ipif.c index 491eff15..07065714 100644 --- a/emu/FreeBSD/ipif.c +++ b/emu/FreeBSD/ipif.c @@ -273,7 +273,8 @@ int so_gethostbyname(char *host, char**hostv, int n) { int i; - unsigned char buf[32], *p; + char buf[32]; + uchar *p; struct hostent *hp; hp = gethostbyname(host); @@ -282,7 +283,7 @@ so_gethostbyname(char *host, char**hostv, int n) for(i = 0; hp->h_addr_list[i] && i < n; i++) { p = hp->h_addr_list[i]; - sprint(buf, "%ud.%ud.%ud.%ud", p[0], p[1], p[2], p[3]); + snprint(buf, sizeof(buf), "%ud.%ud.%ud.%ud", p[0], p[1], p[2], p[3]); hostv[i] = strdup(buf); if(hostv[i] == 0) break; |
