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
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.
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.
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. */
21 static char *home = NULL;
22 + static uid_t home_uid = 0;
23 + static int changed_uid = 0;
25 + uid_t uid = getuid();
28 + if ( home && home_uid != uid) {
37 - if (!server_active && (env = getenv ("HOME")) != NULL)
38 + if (!server_active && ((env = getenv ("HOME")) != NULL) && !changed_uid)
40 - else if ((pw = (struct passwd *) getpwuid (getuid ()))
41 + else if ((pw = (struct passwd *) getpwuid (uid))
43 home = xstrdup (pw->pw_dir);