1 /* CVS rsh client stuff.
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details. */
20 #include "rsh-client.h"
24 /* Contact the server by starting it with rsh. */
26 /* Right now, we have two different definitions for this function,
27 depending on whether we start the rsh server using popenRW or not.
28 This isn't ideal, and the best thing would probably be to change
29 the OS/2 port to be more like the regular Unix client (i.e., by
30 implementing piped_child)... but I'm doing something else at the
31 moment, and wish to make only one change at a time. -Karl */
33 # ifdef START_RSH_WITH_POPEN_RW
35 /* This is actually a crock -- it's OS/2-specific, for no one else
36 uses it. If I get time, I want to make piped_child and all the
37 other stuff in os2/run.c work right. In the meantime, this gets us
38 up and running, and that's most important. */
41 start_rsh_server( cvsroot_t *root, struct buffer **to_server_p,
42 struct buffer **from_server_p )
47 /* If you're working through firewalls, you can set the
48 CVS_RSH environment variable to a script which uses rsh to
49 invoke another rsh on a proxy machine. */
50 char *cvs_rsh = getenv ("CVS_RSH");
51 char *cvs_server = getenv ("CVS_SERVER");
53 /* This needs to fit "rsh", "-b", "-l", "USER", "host",
54 "cmd (w/ args)", and NULL. We leave some room to grow. */
58 /* People sometimes suggest or assume that this should default
59 to "remsh" on systems like HPUX in which that is the
60 system-supplied name for the rsh program. However, that
61 causes various problems (keep in mind that systems such as
62 HPUX might have non-system-supplied versions of "rsh", like
63 a Kerberized one, which one might want to use). If we
64 based the name on what is found in the PATH of the person
65 who runs configure, that would make it harder to
66 consistently produce the same result in the face of
67 different people producing binary distributions. If we
68 based it on "remsh" always being the default for HPUX
69 (e.g. based on uname), that might be slightly better but
70 would require us to keep track of what the defaults are for
71 each system type, and probably would cope poorly if the
72 existence of remsh or rsh varies from OS version to OS
73 version. Therefore, it seems best to have the default
74 remain "rsh", and tell HPUX users to specify remsh, for
75 example in CVS_RSH or other such mechanisms to be devised,
76 if that is what they want (the manual already tells them
82 /* The command line starts out with rsh. */
83 rsh_argv[i++] = cvs_rsh;
85 # ifdef RSH_NEEDS_BINARY_FLAG
86 /* "-b" for binary, under OS/2. */
88 # endif /* RSH_NEEDS_BINARY_FLAG */
90 /* Then we strcat more things on the end one by one. */
91 if (root->username != NULL)
94 rsh_argv[i++] = root->username;
97 rsh_argv[i++] = root->hostname;
98 rsh_argv[i++] = cvs_server;
99 rsh_argv[i++] = "server";
101 /* Mark the end of the arg list. */
102 rsh_argv[i] = (char *) NULL;
106 fprintf (stderr, " -> Starting server: ");
107 for (i = 0; rsh_argv[i]; i++)
108 fprintf (stderr, "%s ", rsh_argv[i]);
113 child_pid = popenRW (rsh_argv, pipes);
115 error (1, errno, "cannot start server via rsh");
117 /* Give caller the file descriptors in a form it can deal with. */
118 make_bufs_from_fds (pipes[0], pipes[1], child_pid, to_server_p, from_server_p, 0);
121 # else /* ! START_RSH_WITH_POPEN_RW */
124 start_rsh_server (cvsroot_t *root, struct buffer **to_server_p, struct buffer **from_server_p)
126 /* If you're working through firewalls, you can set the
127 CVS_RSH environment variable to a script which uses rsh to
128 invoke another rsh on a proxy machine. */
129 char *cvs_rsh = getenv ("CVS_RSH");
130 char *cvs_server = getenv ("CVS_SERVER");
140 /* Pass the command to rsh as a single string. This shouldn't
141 affect most rsh servers at all, and will pacify some buggy
142 versions of rsh that grab switches out of the middle of the
143 command (they're calling the GNU getopt routines incorrectly). */
144 command = xmalloc (strlen (cvs_server) + 8);
146 /* If you are running a very old (Nov 3, 1994, before 1.5)
147 * version of the server, you need to make sure that your .bashrc
148 * on the server machine does not set CVSROOT to something
149 * containing a colon (or better yet, upgrade the server). */
150 sprintf (command, "%s server", cvs_server);
158 /* If the login names differ between client and server
161 if (root->username != NULL)
164 *p++ = root->username;
167 *p++ = root->hostname;
175 fprintf (stderr, " -> Starting server: ");
176 for (i = 0; argv[i]; i++)
177 fprintf (stderr, "%s ", argv[i]);
180 child_pid = piped_child (argv, &tofd, &fromfd);
183 error (1, errno, "cannot start server via rsh");
187 make_bufs_from_fds (tofd, fromfd, child_pid, to_server_p, from_server_p, 0);
190 # endif /* START_RSH_WITH_POPEN_RW */
192 #endif /* NO_EXT_METHOD */
194 #endif /* CLIENT_SUPPORT */