summaryrefslogtreecommitdiff
path: root/usr.bin/cvs
diff options
context:
space:
mode:
authorJean-Francois Brousseau <jfb@cvs.openbsd.org>2004-08-05 13:24:38 +0000
committerJean-Francois Brousseau <jfb@cvs.openbsd.org>2004-08-05 13:24:38 +0000
commit0e97993420e1086e5f69f5c28f5eb62a599d9a36 (patch)
tree8a1f29cf30e44a6c039b548c28e9990188248121 /usr.bin/cvs
parentdcaadce93d0cc4377d9bca3684a542120103c8b5 (diff)
When spawning the subprocess for the connection, attach a pipe to its
standard error as well
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r--usr.bin/cvs/cvs.h4
-rw-r--r--usr.bin/cvs/proto.c27
2 files changed, 26 insertions, 5 deletions
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h
index 5db341c1d22..3cc5c94c922 100644
--- a/usr.bin/cvs/cvs.h
+++ b/usr.bin/cvs/cvs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.h,v 1.20 2004/08/03 00:05:54 jfb Exp $ */
+/* $OpenBSD: cvs.h,v 1.21 2004/08/05 13:24:37 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -84,6 +84,7 @@
/* defaults */
+#define CVS_SERVER_DEFAULT "cvs"
#define CVS_RSH_DEFAULT "ssh"
#define CVS_EDITOR_DEFAULT "vi"
@@ -142,6 +143,7 @@ struct cvsroot {
/* connection data */
FILE *cr_srvin;
FILE *cr_srvout;
+ FILE *cr_srverr;
char *cr_version; /* version of remote server */
u_char cr_vrmask[10]; /* mask of valid requests supported by server */
};
diff --git a/usr.bin/cvs/proto.c b/usr.bin/cvs/proto.c
index 5e3bd4570f5..86e84876636 100644
--- a/usr.bin/cvs/proto.c
+++ b/usr.bin/cvs/proto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: proto.c,v 1.19 2004/08/04 13:26:02 jfb Exp $ */
+/* $OpenBSD: proto.c,v 1.20 2004/08/05 13:24:37 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -194,7 +194,7 @@ static FILE *cvs_server_outlog = NULL;
int
cvs_connect(struct cvsroot *root)
{
- int argc, infd[2], outfd[2];
+ int argc, infd[2], outfd[2], errfd[2];
pid_t pid;
char *argv[16], *cvs_server_cmd, *vresp;
@@ -212,6 +212,16 @@ cvs_connect(struct cvsroot *root)
return (-1);
}
+ if (pipe(errfd) == -1) {
+ cvs_log(LP_ERRNO,
+ "failed to create error pipe for client connection");
+ (void)close(infd[0]);
+ (void)close(infd[1]);
+ (void)close(outfd[0]);
+ (void)close(outfd[1]);
+ return (-1);
+ }
+
pid = fork();
if (pid == -1) {
cvs_log(LP_ERRNO, "failed to fork for cvs server connection");
@@ -219,13 +229,15 @@ cvs_connect(struct cvsroot *root)
}
if (pid == 0) {
if ((dup2(infd[0], STDIN_FILENO) == -1) ||
- (dup2(outfd[1], STDOUT_FILENO) == -1)) {
+ (dup2(outfd[1], STDOUT_FILENO) == -1) ||
+ (dup2(errfd[1], STDERR_FILENO) == -1)) {
cvs_log(LP_ERRNO,
"failed to setup standard streams for cvs server");
return (-1);
}
(void)close(infd[1]);
(void)close(outfd[0]);
+ (void)close(errfd[0]);
argc = 0;
argv[argc++] = cvs_rsh;
@@ -238,7 +250,7 @@ cvs_connect(struct cvsroot *root)
cvs_server_cmd = getenv("CVS_SERVER");
if (cvs_server_cmd == NULL)
- cvs_server_cmd = "cvs";
+ cvs_server_cmd = CVS_SERVER_DEFAULT;
argv[argc++] = root->cr_host;
argv[argc++] = cvs_server_cmd;
@@ -253,6 +265,7 @@ cvs_connect(struct cvsroot *root)
/* we are the parent */
(void)close(infd[0]);
(void)close(outfd[1]);
+ (void)close(errfd[1]);
root->cr_srvin = fdopen(infd[1], "w");
if (root->cr_srvin == NULL) {
@@ -266,6 +279,12 @@ cvs_connect(struct cvsroot *root)
return (-1);
}
+ root->cr_srverr = fdopen(errfd[0], "r");
+ if (root->cr_srverr == NULL) {
+ cvs_log(LP_ERR, "failed to create pipe stream");
+ return (-1);
+ }
+
/* make the streams line-buffered */
(void)setvbuf(root->cr_srvin, NULL, _IOLBF, 0);
(void)setvbuf(root->cr_srvout, NULL, _IOLBF, 0);