1 --- cvs-1.12.13.orig/debian/patches/80_cvs-repouid-0.1
2 +++ cvs-1.12.13/debian/patches/80_cvs-repouid-0.1
5 +# cvs-repouid patch for controlling pserver access. See
6 +# README.Debian for details.
8 +# Original patch by Wichert Akkerman <wakkerma@debian.org>, fixes by
9 +# Steve McIntyre <steve@einval.com> with help from Alberto Garcia
10 +# <agarcia@igalia.com>
11 +diff -ruN cvs-1.12.13-old/src/cvs.h cvs-1.12.13/src/cvs.h
12 +--- cvs-1.12.13-old/src/cvs.h 2005-10-02 23:17:20.000000000 +0800
13 ++++ cvs-1.12.13/src/cvs.h 2006-02-26 22:08:16.000000000 +0800
15 + #define CVSADM_TEMPLATE "CVS/Template"
16 + #endif /* USE_VMS_FILENAMES */
18 ++/* Global configuration file mapping repositories to uids. This can be
19 ++ used instead of getting the unix user. This is prevents a security
20 ++ problem where anyone with commit access can basically become any
21 ++ user on the machine. Combined with the insecure pserver that is a
22 ++ problem waiting to happen. */
23 ++#define CVS_REPOUIDFILE "/etc/cvs-repouids"
25 + /* This is the special directory which we use to store various extra
26 + per-directory information in the repository. It must be the same as
27 + CVSADM to avoid creating a new reserved directory name which users cannot
28 +diff -ruN cvs-1.12.13-old/src/server.c cvs-1.12.13/src/server.c
29 +--- cvs-1.12.13-old/src/server.c 2005-09-28 23:25:59.000000000 +0800
30 ++++ cvs-1.12.13/src/server.c 2006-02-26 22:08:16.000000000 +0800
31 +@@ -6570,6 +6570,12 @@
32 + exit (EXIT_FAILURE);
35 ++ if (pw->pw_uid == 0)
37 ++ printf("error 0: root not allowed\n");
38 ++ exit (EXIT_FAILURE);
42 + if (initgroups (pw->pw_name, pw->pw_gid) < 0
44 +@@ -6667,6 +6673,51 @@
49 ++global_repo_uid(const char* repository)
52 ++ char *linebuf = NULL;
53 ++ size_t linebuf_len;
55 ++ size_t repolen = strlen (repository);
58 ++ fp = fopen (CVS_REPOUIDFILE, "r");
61 ++ if (!existence_error (errno))
62 ++ error (0, errno, "cannot open %s", CVS_REPOUIDFILE);
66 ++ while (getline (&linebuf, &linebuf_len, fp) >= 0)
68 ++ if ((strncmp (linebuf, repository, repolen) == 0)
69 ++ && (linebuf[repolen] == ':'))
77 ++ error (0, errno, "cannot read %s", CVS_REPOUIDFILE);
78 ++ if (fclose (fp) < 0)
79 ++ error (0, errno, "cannot close %s", CVS_REPOUIDFILE);
86 ++ strtok (linebuf + repolen, "\n");
87 ++ user = xstrdup (linebuf + repolen + 1);
93 + #ifdef AUTH_SERVER_SUPPORT
95 + extern char *crypt (const char *, const char *);
96 +@@ -6738,7 +6789,7 @@
97 + /* If found_it, then linebuf contains the information we need. */
100 +- char *found_password, *host_user_tmp;
101 ++ char *found_password, *host_user_tmp, *user_override;
102 + char *non_cvsuser_portion;
104 + /* We need to make sure lines such as
105 +@@ -6805,6 +6856,9 @@
106 + /* Give host_user_ptr permanent storage. */
107 + *host_user_ptr = xstrdup (host_user_tmp);
109 ++ user_override = global_repo_uid (repository);
110 ++ if (user_override)
111 ++ *host_user_ptr = user_override;