bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] move rsh client code to rsh-client.[ch]


From: Alexey Mahotkin
Subject: [PATCH] move rsh client code to rsh-client.[ch]
Date: Thu, 24 Apr 2003 23:08:22 +0400
User-agent: Gnus/5.090006 (Oort Gnus v0.06) XEmacs/21.4 (Common Lisp, i386-debian-linux)


2003-04-24  Alexey Mahotkin <address@hidden>

Move rsh (:ext:) client stuff to rsh-client.[ch]


 src/Makefile.am  |    1 
 src/Makefile.in  |   24 +++---
 src/client.c     |  182 ---------------------------------------------------
 src/client.h     |   16 +++-
 src/rsh-client.c |  195 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/rsh-client.h |   19 +++++
 6 files changed, 241 insertions(+), 196 deletions(-)

--- ccvs/src/client.c~rsh-client        Thu Apr 24 22:39:10 2003
+++ ccvs-alexm/src/client.c     Thu Apr 24 22:43:20 2003
@@ -3389,10 +3389,6 @@ get_responses_and_close ()
     return errs;
 }
        
-#ifndef NO_EXT_METHOD
-static void start_rsh_server PROTO((cvsroot_t *, struct buffer **, struct 
buffer **));
-#endif
-
 int
 supported_request (name)
     char *name;
@@ -4382,184 +4378,6 @@ start_server ()
     if (supported_request ("Set"))
        walklist (variable_list, send_variable_proc, NULL);
 }
-
-#ifndef NO_EXT_METHOD
-
-/* Contact the server by starting it with rsh.  */
-
-/* Right now, we have two different definitions for this function,
-   depending on whether we start the rsh server using popenRW or not.
-   This isn't ideal, and the best thing would probably be to change
-   the OS/2 port to be more like the regular Unix client (i.e., by
-   implementing piped_child)... but I'm doing something else at the
-   moment, and wish to make only one change at a time.  -Karl */
-
-# ifdef START_RSH_WITH_POPEN_RW
-
-/* This is actually a crock -- it's OS/2-specific, for no one else
-   uses it.  If I get time, I want to make piped_child and all the
-   other stuff in os2/run.c work right.  In the meantime, this gets us
-   up and running, and that's most important. */
-
-static void
-start_rsh_server (root, to_server, from_server)
-    cvsroot_t *root;
-    struct buffer **to_server;
-    struct buffer **from_server;
-{
-    int pipes[2];
-    int child_pid;
-
-    /* If you're working through firewalls, you can set the
-       CVS_RSH environment variable to a script which uses rsh to
-       invoke another rsh on a proxy machine.  */
-    char *cvs_rsh = getenv ("CVS_RSH");
-    char *cvs_server = getenv ("CVS_SERVER");
-    int i = 0;
-    /* This needs to fit "rsh", "-b", "-l", "USER", "host",
-       "cmd (w/ args)", and NULL.  We leave some room to grow. */
-    char *rsh_argv[10];
-
-    if (!cvs_rsh)
-       /* People sometimes suggest or assume that this should default
-          to "remsh" on systems like HPUX in which that is the
-          system-supplied name for the rsh program.  However, that
-          causes various problems (keep in mind that systems such as
-          HPUX might have non-system-supplied versions of "rsh", like
-          a Kerberized one, which one might want to use).  If we
-          based the name on what is found in the PATH of the person
-          who runs configure, that would make it harder to
-          consistently produce the same result in the face of
-          different people producing binary distributions.  If we
-          based it on "remsh" always being the default for HPUX
-          (e.g. based on uname), that might be slightly better but
-          would require us to keep track of what the defaults are for
-          each system type, and probably would cope poorly if the
-          existence of remsh or rsh varies from OS version to OS
-          version.  Therefore, it seems best to have the default
-          remain "rsh", and tell HPUX users to specify remsh, for
-          example in CVS_RSH or other such mechanisms to be devised,
-          if that is what they want (the manual already tells them
-          that).  */
-       cvs_rsh = RSH_DFLT;
-    if (!cvs_server)
-       cvs_server = "cvs";
-
-    /* The command line starts out with rsh. */
-    rsh_argv[i++] = cvs_rsh;
-
-#   ifdef RSH_NEEDS_BINARY_FLAG
-    /* "-b" for binary, under OS/2. */
-    rsh_argv[i++] = "-b";
-#   endif /* RSH_NEEDS_BINARY_FLAG */
-
-    /* Then we strcat more things on the end one by one. */
-    if (root->username != NULL)
-    {
-       rsh_argv[i++] = "-l";
-       rsh_argv[i++] = root->username;
-    }
-
-    rsh_argv[i++] = root->hostname;
-    rsh_argv[i++] = cvs_server;
-    rsh_argv[i++] = "server";
-
-    /* Mark the end of the arg list. */
-    rsh_argv[i]   = (char *) NULL;
-
-    if (trace)
-    {
-       fprintf (stderr, " -> Starting server: ");
-       for (i = 0; rsh_argv[i]; i++)
-           fprintf (stderr, "%s ", rsh_argv[i]);
-       putc ('\n', stderr);
-    }
-
-    /* Do the deed. */
-    child_pid = popenRW (rsh_argv, pipes);
-    if (child_pid < 0)
-       error (1, errno, "cannot start server via rsh");
-
-    /* Give caller the file descriptors in a form it can deal with. */
-    make_bufs_from_fds (pipes[0], pipes[1], child_pid, to_server, from_server, 
0);
-}
-
-# else /* ! START_RSH_WITH_POPEN_RW */
-
-static void
-start_rsh_server (root, to_server, from_server)
-    cvsroot_t *root;
-    struct buffer **to_server;
-    struct buffer **from_server;
-{
-    /* If you're working through firewalls, you can set the
-       CVS_RSH environment variable to a script which uses rsh to
-       invoke another rsh on a proxy machine.  */
-    char *cvs_rsh = getenv ("CVS_RSH");
-    char *cvs_server = getenv ("CVS_SERVER");
-    char *command;
-    int tofd, fromfd;
-    int child_pid;
-
-    if (!cvs_rsh)
-       cvs_rsh = RSH_DFLT;
-    if (!cvs_server)
-       cvs_server = "cvs";
-
-    /* Pass the command to rsh as a single string.  This shouldn't
-       affect most rsh servers at all, and will pacify some buggy
-       versions of rsh that grab switches out of the middle of the
-       command (they're calling the GNU getopt routines incorrectly).  */
-    command = xmalloc (strlen (cvs_server) + 8);
-
-    /* If you are running a very old (Nov 3, 1994, before 1.5)
-     * version of the server, you need to make sure that your .bashrc
-     * on the server machine does not set CVSROOT to something
-     * containing a colon (or better yet, upgrade the server).  */
-    sprintf (command, "%s server", cvs_server);
-
-    {
-        char *argv[10];
-       char **p = argv;
-
-       *p++ = cvs_rsh;
-       *p++ = root->hostname;
-
-       /* If the login names differ between client and server
-        * pass it on to rsh.
-        */
-       if (root->username != NULL)
-       {
-           *p++ = "-l";
-           *p++ = root->username;
-       }
-
-       *p++ = command;
-       *p++ = NULL;
-
-       if (trace)
-        {
-           int i;
-
-            fprintf (stderr, " -> Starting server: ");
-           for (i = 0; argv[i]; i++)
-               fprintf (stderr, "%s ", argv[i]);
-           putc ('\n', stderr);
-       }
-       child_pid = piped_child (argv, &tofd, &fromfd);
-
-       if (child_pid < 0)
-           error (1, errno, "cannot start server via rsh");
-    }
-    free (command);
-
-    make_bufs_from_fds (tofd, fromfd, child_pid, to_server, from_server, 0);
-}
-
-# endif /* START_RSH_WITH_POPEN_RW */
-
-#endif /* NO_EXT_METHOD */
-
 
 
 /* Send an argument STRING.  */
--- /dev/null   Wed Jan  1 02:48:46 2003
+++ ccvs-alexm/src/rsh-client.c Thu Apr 24 22:43:36 2003
@@ -0,0 +1,195 @@
+/* CVS rsh client stuff.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.  */
+
+#include <config.h>
+
+#include "cvs.h"
+
+#include "rsh-client.h"
+
+#ifndef NO_EXT_METHOD
+
+/* Contact the server by starting it with rsh.  */
+
+/* Right now, we have two different definitions for this function,
+   depending on whether we start the rsh server using popenRW or not.
+   This isn't ideal, and the best thing would probably be to change
+   the OS/2 port to be more like the regular Unix client (i.e., by
+   implementing piped_child)... but I'm doing something else at the
+   moment, and wish to make only one change at a time.  -Karl */
+
+# ifdef START_RSH_WITH_POPEN_RW
+
+/* This is actually a crock -- it's OS/2-specific, for no one else
+   uses it.  If I get time, I want to make piped_child and all the
+   other stuff in os2/run.c work right.  In the meantime, this gets us
+   up and running, and that's most important. */
+
+void
+start_rsh_server (root, to_server, from_server)
+    cvsroot_t *root;
+    struct buffer **to_server;
+    struct buffer **from_server;
+{
+    int pipes[2];
+    int child_pid;
+
+    /* If you're working through firewalls, you can set the
+       CVS_RSH environment variable to a script which uses rsh to
+       invoke another rsh on a proxy machine.  */
+    char *cvs_rsh = getenv ("CVS_RSH");
+    char *cvs_server = getenv ("CVS_SERVER");
+    int i = 0;
+    /* This needs to fit "rsh", "-b", "-l", "USER", "host",
+       "cmd (w/ args)", and NULL.  We leave some room to grow. */
+    char *rsh_argv[10];
+
+    if (!cvs_rsh)
+       /* People sometimes suggest or assume that this should default
+          to "remsh" on systems like HPUX in which that is the
+          system-supplied name for the rsh program.  However, that
+          causes various problems (keep in mind that systems such as
+          HPUX might have non-system-supplied versions of "rsh", like
+          a Kerberized one, which one might want to use).  If we
+          based the name on what is found in the PATH of the person
+          who runs configure, that would make it harder to
+          consistently produce the same result in the face of
+          different people producing binary distributions.  If we
+          based it on "remsh" always being the default for HPUX
+          (e.g. based on uname), that might be slightly better but
+          would require us to keep track of what the defaults are for
+          each system type, and probably would cope poorly if the
+          existence of remsh or rsh varies from OS version to OS
+          version.  Therefore, it seems best to have the default
+          remain "rsh", and tell HPUX users to specify remsh, for
+          example in CVS_RSH or other such mechanisms to be devised,
+          if that is what they want (the manual already tells them
+          that).  */
+       cvs_rsh = RSH_DFLT;
+    if (!cvs_server)
+       cvs_server = "cvs";
+
+    /* The command line starts out with rsh. */
+    rsh_argv[i++] = cvs_rsh;
+
+#   ifdef RSH_NEEDS_BINARY_FLAG
+    /* "-b" for binary, under OS/2. */
+    rsh_argv[i++] = "-b";
+#   endif /* RSH_NEEDS_BINARY_FLAG */
+
+    /* Then we strcat more things on the end one by one. */
+    if (root->username != NULL)
+    {
+       rsh_argv[i++] = "-l";
+       rsh_argv[i++] = root->username;
+    }
+
+    rsh_argv[i++] = root->hostname;
+    rsh_argv[i++] = cvs_server;
+    rsh_argv[i++] = "server";
+
+    /* Mark the end of the arg list. */
+    rsh_argv[i]   = (char *) NULL;
+
+    if (trace)
+    {
+       fprintf (stderr, " -> Starting server: ");
+       for (i = 0; rsh_argv[i]; i++)
+           fprintf (stderr, "%s ", rsh_argv[i]);
+       putc ('\n', stderr);
+    }
+
+    /* Do the deed. */
+    child_pid = popenRW (rsh_argv, pipes);
+    if (child_pid < 0)
+       error (1, errno, "cannot start server via rsh");
+
+    /* Give caller the file descriptors in a form it can deal with. */
+    make_bufs_from_fds (pipes[0], pipes[1], child_pid, to_server, from_server, 
0);
+}
+
+# else /* ! START_RSH_WITH_POPEN_RW */
+
+void
+start_rsh_server (root, to_server, from_server)
+    cvsroot_t *root;
+    struct buffer **to_server;
+    struct buffer **from_server;
+{
+    /* If you're working through firewalls, you can set the
+       CVS_RSH environment variable to a script which uses rsh to
+       invoke another rsh on a proxy machine.  */
+    char *cvs_rsh = getenv ("CVS_RSH");
+    char *cvs_server = getenv ("CVS_SERVER");
+    char *command;
+    int tofd, fromfd;
+    int child_pid;
+
+    if (!cvs_rsh)
+       cvs_rsh = RSH_DFLT;
+    if (!cvs_server)
+       cvs_server = "cvs";
+
+    /* Pass the command to rsh as a single string.  This shouldn't
+       affect most rsh servers at all, and will pacify some buggy
+       versions of rsh that grab switches out of the middle of the
+       command (they're calling the GNU getopt routines incorrectly).  */
+    command = xmalloc (strlen (cvs_server) + 8);
+
+    /* If you are running a very old (Nov 3, 1994, before 1.5)
+     * version of the server, you need to make sure that your .bashrc
+     * on the server machine does not set CVSROOT to something
+     * containing a colon (or better yet, upgrade the server).  */
+    sprintf (command, "%s server", cvs_server);
+
+    {
+        char *argv[10];
+       char **p = argv;
+
+       *p++ = cvs_rsh;
+       *p++ = root->hostname;
+
+       /* If the login names differ between client and server
+        * pass it on to rsh.
+        */
+       if (root->username != NULL)
+       {
+           *p++ = "-l";
+           *p++ = root->username;
+       }
+
+       *p++ = command;
+       *p++ = NULL;
+
+       if (trace)
+        {
+           int i;
+
+            fprintf (stderr, " -> Starting server: ");
+           for (i = 0; argv[i]; i++)
+               fprintf (stderr, "%s ", argv[i]);
+           putc ('\n', stderr);
+       }
+       child_pid = piped_child (argv, &tofd, &fromfd);
+
+       if (child_pid < 0)
+           error (1, errno, "cannot start server via rsh");
+    }
+    free (command);
+
+    make_bufs_from_fds (tofd, fromfd, child_pid, to_server, from_server, 0);
+}
+
+# endif /* START_RSH_WITH_POPEN_RW */
+
+#endif /* NO_EXT_METHOD */
+
--- /dev/null   Wed Jan  1 02:48:46 2003
+++ ccvs-alexm/src/rsh-client.h Thu Apr 24 22:43:28 2003
@@ -0,0 +1,19 @@
+/* CVS rsh client stuff.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.  */
+
+
+#ifndef RSH_CLIENT_H__
+#define RSH_CLIENT_H__
+
+void start_rsh_server PROTO((cvsroot_t *, struct buffer **, struct buffer **));
+
+#endif
--- ccvs/src/Makefile.am~rsh-client     Thu Apr 24 22:40:29 2003
+++ ccvs-alexm/src/Makefile.am  Thu Apr 24 22:40:33 2003
@@ -70,6 +70,7 @@ cvs_SOURCES = \
        remove.c \
        repos.c \
        root.c \
+       rsh-client.c rsh-client.h \
        run.c \
        scramble.c \
        server.c \
--- ccvs/src/Makefile.in~rsh-client     Thu Apr 24 22:40:31 2003
+++ ccvs-alexm/src/Makefile.in  Thu Apr 24 22:41:47 2003
@@ -162,6 +162,7 @@ cvs_SOURCES = \
        remove.c \
        repos.c \
        root.c \
+       rsh-client.c rsh-client.h \
        run.c \
        scramble.c \
        server.c \
@@ -230,9 +231,10 @@ am_cvs_OBJECTS = add.$(OBJEXT) admin.$(O
        myndbm.$(OBJEXT) no_diff.$(OBJEXT) parseinfo.$(OBJEXT) \
        patch.$(OBJEXT) rcs.$(OBJEXT) rcscmds.$(OBJEXT) \
        recurse.$(OBJEXT) release.$(OBJEXT) remove.$(OBJEXT) \
-       repos.$(OBJEXT) root.$(OBJEXT) run.$(OBJEXT) scramble.$(OBJEXT) \
-       server.$(OBJEXT) socket-client.$(OBJEXT) status.$(OBJEXT) \
-       subr.$(OBJEXT) tag.$(OBJEXT) update.$(OBJEXT) version.$(OBJEXT) \
+       repos.$(OBJEXT) root.$(OBJEXT) rsh-client.$(OBJEXT) \
+       run.$(OBJEXT) scramble.$(OBJEXT) server.$(OBJEXT) \
+       socket-client.$(OBJEXT) status.$(OBJEXT) subr.$(OBJEXT) \
+       tag.$(OBJEXT) update.$(OBJEXT) version.$(OBJEXT) \
        vers_ts.$(OBJEXT) watch.$(OBJEXT) wrapper.$(OBJEXT) \
        zlib.$(OBJEXT)
 cvs_OBJECTS = $(am_cvs_OBJECTS)
@@ -269,13 +271,14 @@ am__depfiles_maybe = depfiles
 @AMDEP_TRUE@   ./$(DEPDIR)/rcs.Po ./$(DEPDIR)/rcscmds.Po \
 @AMDEP_TRUE@   ./$(DEPDIR)/recurse.Po ./$(DEPDIR)/release.Po \
 @AMDEP_TRUE@   ./$(DEPDIR)/remove.Po ./$(DEPDIR)/repos.Po \
address@hidden@ ./$(DEPDIR)/root.Po ./$(DEPDIR)/run.Po \
address@hidden@ ./$(DEPDIR)/scramble.Po ./$(DEPDIR)/server.Po \
address@hidden@ ./$(DEPDIR)/socket-client.Po ./$(DEPDIR)/status.Po \
address@hidden@ ./$(DEPDIR)/subr.Po ./$(DEPDIR)/tag.Po \
address@hidden@ ./$(DEPDIR)/update.Po ./$(DEPDIR)/vers_ts.Po \
address@hidden@ ./$(DEPDIR)/version.Po ./$(DEPDIR)/watch.Po \
address@hidden@ ./$(DEPDIR)/wrapper.Po ./$(DEPDIR)/zlib.Po
address@hidden@ ./$(DEPDIR)/root.Po ./$(DEPDIR)/rsh-client.Po \
address@hidden@ ./$(DEPDIR)/run.Po ./$(DEPDIR)/scramble.Po \
address@hidden@ ./$(DEPDIR)/server.Po ./$(DEPDIR)/socket-client.Po \
address@hidden@ ./$(DEPDIR)/status.Po ./$(DEPDIR)/subr.Po \
address@hidden@ ./$(DEPDIR)/tag.Po ./$(DEPDIR)/update.Po \
address@hidden@ ./$(DEPDIR)/vers_ts.Po ./$(DEPDIR)/version.Po \
address@hidden@ ./$(DEPDIR)/watch.Po ./$(DEPDIR)/wrapper.Po \
address@hidden@ ./$(DEPDIR)/zlib.Po
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
        $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
@@ -396,6 +399,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
 @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
 @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
address@hidden@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
 @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
 @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
 @AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
--- ccvs/src/client.h~rsh-client        Thu Apr 24 22:48:52 2003
+++ ccvs-alexm/src/client.h     Thu Apr 24 22:49:04 2003
@@ -7,6 +7,18 @@ extern int change_mode PROTO((char *, ch
 extern int gzip_level;
 extern int file_gzip_level;
 
+#ifdef __STDC__
+struct buffer;
+#endif
+
+void make_bufs_from_fds PROTO((int tofd,
+                              int fromfd,
+                              int child_pid,
+                              struct buffer **to_server,
+                              struct buffer **from_server,
+                              int is_sock));
+
+
 #if defined (CLIENT_SUPPORT) || defined (SERVER_SUPPORT)
 
 /* Whether the connection should be encrypted.  */
@@ -14,10 +26,6 @@ extern int cvsencrypt;
 
 /* Whether the connection should use per-packet authentication.  */
 extern int cvsauthenticate;
-
-#ifdef __STDC__
-struct buffer;
-#endif
 
 # ifdef ENCRYPTION
 

_


--alexm




reply via email to

[Prev in Thread] Current Thread [Next in Thread]