Merge from vendor branch TNF:
[pkgsrc.git] / devel / cvs / patches / patch-ar
1 $NetBSD: patch-ar,v 1.2 1999/04/20 15:09:44 mycroft Exp $
2
3 --- src/server.c.orig   Thu Aug  6 20:46:38 1998
4 +++ src/server.c        Wed Feb 23 01:18:51 2000
5 @@ -597,31 +597,34 @@
6         nothing.  But for rsh, we need to do it now.  */
7      parse_config (CVSroot_directory);
8  
9 -    path = xmalloc (strlen (CVSroot_directory)
10 -                   + sizeof (CVSROOTADM)
11 -                   + sizeof (CVSROOTADM_HISTORY)
12 -                   + 10);
13 -    (void) sprintf (path, "%s/%s", CVSroot_directory, CVSROOTADM);
14 -    if (!isaccessible (path, R_OK | X_OK))
15 -    {
16 -       save_errno = errno;
17 -       pending_error_text = malloc (80 + strlen (path));
18 -       if (pending_error_text != NULL)
19 -           sprintf (pending_error_text, "E Cannot access %s", path);
20 -       pending_error = save_errno;
21 -    }
22 -    (void) strcat (path, "/");
23 -    (void) strcat (path, CVSROOTADM_HISTORY);
24 -    if (isfile (path) && !isaccessible (path, R_OK | W_OK))
25 -    {
26 -       save_errno = errno;
27 -       pending_error_text = malloc (80 + strlen (path));
28 -       if (pending_error_text != NULL)
29 -           sprintf (pending_error_text, "E \
30 +    if (!nolock)
31 +    {
32 +       path = xmalloc (strlen (CVSroot_directory)
33 +                       + sizeof (CVSROOTADM)
34 +                       + sizeof (CVSROOTADM_HISTORY)
35 +                       + 10);
36 +       (void) sprintf (path, "%s/%s", CVSroot_directory, CVSROOTADM);
37 +       if (!isaccessible (path, R_OK | X_OK))
38 +       {
39 +           save_errno = errno;
40 +           pending_error_text = malloc (80 + strlen (path));
41 +           if (pending_error_text != NULL)
42 +               sprintf (pending_error_text, "E Cannot access %s", path);
43 +           pending_error = save_errno;
44 +       }
45 +       (void) strcat (path, "/");
46 +       (void) strcat (path, CVSROOTADM_HISTORY);
47 +       if (isfile (path) && !isaccessible (path, R_OK | W_OK))
48 +       {
49 +           save_errno = errno;
50 +           pending_error_text = malloc (80 + strlen (path));
51 +           if (pending_error_text != NULL)
52 +               sprintf (pending_error_text, "E \
53  Sorry, you don't have read/write access to the history file %s", path);
54 -       pending_error = save_errno;
55 +           pending_error = save_errno;
56 +       }
57 +       free (path);
58      }
59 -    free (path);
60  
61  #ifdef HAVE_PUTENV
62      env = malloc (strlen (CVSROOT_ENV) + strlen (CVSroot_directory) + 1 + 1);
63 @@ -1759,6 +1762,8 @@
64      {
65         case 'n':
66             noexec = 1;
67 +       case 'u':
68 +           nolock = 1;
69             break;
70         case 'q':
71             quiet = 1;
72 @@ -4663,19 +4668,23 @@
73  #endif /* HAVE_INITGROUPS */
74  
75  #ifdef SETXID_SUPPORT
76 -    /* honor the setgid bit iff set*/
77 +    /* Honor the setgid bit iff set. */
78      if (getgid() != getegid())
79 -    {
80         setgid (getegid ());
81 -    }
82      else
83  #else
84 -    {
85         setgid (pw->pw_gid);
86 -    }
87  #endif
88      
89 -    setuid (pw->pw_uid);
90 +#ifdef SETXID_SUPPORT
91 +    /* Honor the setuid bit iff set. */
92 +    if (getuid() != geteuid())
93 +       setuid (geteuid ());
94 +    else
95 +#else
96 +       setuid (pw->pw_uid);
97 +#endif
98 +
99      /* We don't want our umask to change file modes.  The modes should
100         be set by the modes used in the repository, and by the umask of
101         the client.  */