+/* -*-c-*-
+ *
+ * $Id: cvssh.c,v 1.1 1999/04/21 09:04:24 mdw Exp $
+ *
+ * Login shell for an anonymous CVS user
+ *
+ * (c) 1999 Mark Wooding
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of the background resolver (resolve).
+ *
+ * resolve 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 of the License, or
+ * (at your option) any later version.
+ *
+ * resolve 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with resolve; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/*----- Revision history --------------------------------------------------*
+ *
+ * $Log: cvssh.c,v $
+ * Revision 1.1 1999/04/21 09:04:24 mdw
+ * Add `cvssh' shell for anonymous CVS support.
+ *
+ */
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <netdb.h>
+#include <unistd.h>
+#include <pwd.h>
+#include <sys/utsname.h>
+
+/*----- Main code ---------------------------------------------------------*/
+
+const static char help[] = "\
+Welcome to the anonymous CVS server.\n\
+\n\
+To use the CVS server, set your `CVSROOT' environment variable to\n\
+`%s@%s:%s', and use the `cvs checkout' and `cvs update'\n\
+commands. See the manual for more information on how to use CVS.\n\
+";
+
+void dummy(void)
+{
+ char *p;
+ char *host;
+ char *home;
+
+ home = getenv("HOME");
+ p = getenv("USER");
+
+ if (!p || !home) {
+ struct passwd *pw = getpwuid(getuid());
+ if (!p)
+ p = (pw ? pw->pw_name : "anoncvs");
+ if (!home)
+ home = (pw ? pw->pw_dir : "/cvs");
+ }
+
+ {
+ struct utsname u;
+ struct hostent *h;
+ uname(&u);
+ h = gethostbyname(u.nodename);
+ if (h)
+ host = h->h_name;
+ else
+ host = u.nodename;
+ }
+
+ printf(help, p, host, home);
+ exit(0);
+}
+
+int main(int argc, char *argv[])
+{
+ if (argc == 2 && (strcmp(argv[1], ".ssh/rc")) == 0)
+ exit(0);
+ if (argc != 3 || strcmp(argv[1], "-c") || strcmp(argv[2], "cvs server"))
+ dummy();
+ execl("/bin/cvs", "cvs", "-A", "server", (char *)0);
+ perror("cvssh (exec)");
+ exit(1);
+}
+
+/*----- That's all, folks -------------------------------------------------*/