]> git.pld-linux.org Git - packages/cvs.git/blob - cvs-debian-repouid.patch
- patches from debian
[packages/cvs.git] / cvs-debian-repouid.patch
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
3 @@ -0,0 +1,111 @@
4 +# 
5 +# cvs-repouid patch for controlling pserver access.  See
6 +# README.Debian for details.
7 +#
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
14 +@@ -145,6 +145,13 @@
15 + #define CVSADM_TEMPLATE "CVS/Template"
16 + #endif /* USE_VMS_FILENAMES */
17
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"
24 ++
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);
33 +     }
34
35 ++    if (pw->pw_uid == 0)
36 ++    {
37 ++        printf("error 0: root not allowed\n");
38 ++        exit (EXIT_FAILURE);
39 ++    }
40 ++
41 + #if HAVE_INITGROUPS
42 +     if (initgroups (pw->pw_name, pw->pw_gid) < 0
43 + #  ifdef EPERM
44 +@@ -6667,6 +6673,51 @@
45 + }
46 + #endif
47
48 ++static char*
49 ++global_repo_uid(const char* repository)
50 ++{
51 ++    FILE *fp;
52 ++    char *linebuf = NULL;
53 ++    size_t linebuf_len;
54 ++    int found_it = 0;
55 ++    size_t repolen = strlen (repository);
56 ++    char *user;
57 ++
58 ++    fp = fopen (CVS_REPOUIDFILE, "r");
59 ++    if (fp == NULL)
60 ++    {
61 ++        if (!existence_error (errno))
62 ++            error (0, errno, "cannot open %s", CVS_REPOUIDFILE);
63 ++        return NULL;
64 ++    }
65 ++
66 ++    while (getline (&linebuf, &linebuf_len, fp) >= 0)
67 ++    {
68 ++        if ((strncmp (linebuf, repository, repolen) == 0)
69 ++            && (linebuf[repolen] == ':'))
70 ++        {
71 ++            found_it = 1;
72 ++            break;
73 ++        }
74 ++    }
75 ++
76 ++    if (ferror (fp))
77 ++        error (0, errno, "cannot read %s", CVS_REPOUIDFILE);
78 ++    if (fclose (fp) < 0)
79 ++        error (0, errno, "cannot close %s", CVS_REPOUIDFILE);
80 ++
81 ++    if (!found_it) {
82 ++        free (linebuf);
83 ++        return NULL;
84 ++    }
85 ++
86 ++    strtok (linebuf + repolen, "\n");
87 ++    user = xstrdup (linebuf + repolen + 1);
88 ++    free (linebuf);
89 ++
90 ++    return user;
91 ++}
92 ++
93 + #ifdef AUTH_SERVER_SUPPORT
94
95 + extern char *crypt (const char *, const char *);
96 +@@ -6738,7 +6789,7 @@
97 +     /* If found_it, then linebuf contains the information we need. */
98 +     if (found_it)
99 +     {
100 +-      char *found_password, *host_user_tmp;
101 ++      char *found_password, *host_user_tmp, *user_override;
102 +       char *non_cvsuser_portion;
103
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);
108 +           retval = 1;
109 ++        user_override = global_repo_uid (repository);
110 ++        if (user_override)
111 ++            *host_user_ptr = user_override;
112 +       }
113 +       else
114 +       {
This page took 0.223382 seconds and 3 git commands to generate.