]> git.pld-linux.org Git - packages/cvs.git/blob - cvs-debian-homedir.patch
- outdated by debian patch
[packages/cvs.git] / cvs-debian-homedir.patch
1 # Fix handling of homedirectory for pserver, patch from
2 #  Jim Studt <jim@federated.com>. Closes: Bug#51234
3 diff -ruN cvs-1.12.13-old/src/filesubr.c cvs-1.12.13/src/filesubr.c
4 --- cvs-1.12.13-old/src/filesubr.c      2005-09-28 23:25:59.000000000 +0800
5 +++ cvs-1.12.13/src/filesubr.c  2006-02-26 22:31:57.000000000 +0800
6 @@ -795,6 +795,11 @@
7     The workaround is to put -f in inetd.conf which means that
8     get_homedir won't get called until after the switch in user ID.
9  
10 +   NOTE: the above paragraph is not sufficient if the HOME environment
11 +   variable is set, it overrides the uid based password lookup, hence
12 +   the change_uid logic path that blocks the HOME environment variable
13 +   when the uid gets changed.
14 +
15     The whole concept of a "home directory" on the server is pretty
16     iffy, although I suppose some people probably are relying on it for
17     .cvsrc and such, in the cases where it works.  */
18 @@ -802,15 +807,24 @@
19  get_homedir (void)
20  {
21      static char *home = NULL;
22 +    static uid_t home_uid = 0;
23 +    static int changed_uid = 0;
24      char *env;
25 +    uid_t uid = getuid();
26      struct passwd *pw;
27  
28 +    if ( home && home_uid != uid) {
29 +        home = 0;
30 +        home_uid = uid;
31 +        changed_uid = 1;
32 +    }
33 +
34      if (home != NULL)
35         return home;
36  
37 -    if (!server_active && (env = getenv ("HOME")) != NULL)
38 +    if (!server_active && ((env = getenv ("HOME")) != NULL) && !changed_uid)
39         home = env;
40 -    else if ((pw = (struct passwd *) getpwuid (getuid ()))
41 +    else if ((pw = (struct passwd *) getpwuid (uid))
42              && pw->pw_dir)
43         home = xstrdup (pw->pw_dir);
44      else
This page took 0.023137 seconds and 3 git commands to generate.