Expunge revision histories.
[shells] / cvssh.c
1 /* -*-c-*-
2 *
3 * $Id$
4 *
5 * Login shell for an anonymous CVS user
6 *
7 * (c) 1999 Mark Wooding
8 */
9
10 /*----- Licensing notice --------------------------------------------------*
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software Foundation,
24 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 */
26
27 /*----- Header files ------------------------------------------------------*/
28
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32
33 #include <sys/types.h>
34 #include <netdb.h>
35 #include <unistd.h>
36 #include <pwd.h>
37 #include <sys/utsname.h>
38
39 /*----- Main code ---------------------------------------------------------*/
40
41 const static char help[] = "\
42 Welcome to the anonymous CVS server.\n\
43 \n\
44 To use the CVS server, set your `CVSROOT' environment variable to\n\
45 `%s@%s:%s', and use the `cvs checkout' and `cvs update'\n\
46 commands. See the manual for more information on how to use CVS.\n\
47 ";
48
49 void dummy(void)
50 {
51 char *p;
52 char *host;
53 char *home;
54
55 home = getenv("HOME");
56 p = getenv("USER");
57
58 if (!p || !home) {
59 struct passwd *pw = getpwuid(getuid());
60 if (!p)
61 p = (pw ? pw->pw_name : "anoncvs");
62 if (!home)
63 home = (pw ? pw->pw_dir : "/cvs");
64 }
65
66 {
67 struct utsname u;
68 struct hostent *h;
69 uname(&u);
70 h = gethostbyname(u.nodename);
71 if (h)
72 host = h->h_name;
73 else
74 host = u.nodename;
75 }
76
77 printf(help, p, host, home);
78 exit(0);
79 }
80
81 int main(int argc, char *argv[])
82 {
83 if (argc == 2 && (strcmp(argv[1], ".ssh/rc")) == 0)
84 exit(0);
85 if (argc != 3 || strcmp(argv[1], "-c") || strcmp(argv[2], "cvs server"))
86 dummy();
87 execl("/bin/cvs", "cvs", "-A", "server", (char *)0);
88 perror("cvssh (exec)");
89 exit(1);
90 }
91
92 /*----- That's all, folks -------------------------------------------------*/