1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-20 04:02:27 +00:00
freebsd-ports/devel/cvs-devel/files/patch-homedir
Edwin Groothuis dc2ba353b6 [new port] devel/cvs-devel 1.12.13_8
Latest upstream/feature release, similar to Debian, see the
        ChangeLog excerpts available at
        http://cto.homelinux.net/usr/ports/devel/cvs-devel/ChangeLog page.

        This feature release/version, I think, would be quite useful
        for all those users who want to share and, or transfer their
        existing CVS repositories from Linux to FreeBSD machines.

PR:             ports/118033
Submitted by:   Balwinder S Dheeman <bdheeman@gmail.com>
2008-05-26 04:58:42 +00:00

45 lines
1.5 KiB
Plaintext

# Fix handling of homedirectory for pserver, patch from
# Jim Studt <jim@federated.com>. Closes: Bug#51234
diff -Nur src/filesubr.c src/filesubr.c
--- src/filesubr.c 2005-09-28 23:25:59.000000000 +0800
+++ src/filesubr.c 2006-02-26 22:31:57.000000000 +0800
@@ -795,6 +795,11 @@
The workaround is to put -f in inetd.conf which means that
get_homedir won't get called until after the switch in user ID.
+ NOTE: the above paragraph is not sufficient if the HOME environment
+ variable is set, it overrides the uid based password lookup, hence
+ the change_uid logic path that blocks the HOME environment variable
+ when the uid gets changed.
+
The whole concept of a "home directory" on the server is pretty
iffy, although I suppose some people probably are relying on it for
.cvsrc and such, in the cases where it works. */
@@ -802,15 +807,24 @@
get_homedir (void)
{
static char *home = NULL;
+ static uid_t home_uid = 0;
+ static int changed_uid = 0;
char *env;
+ uid_t uid = getuid();
struct passwd *pw;
+ if ( home && home_uid != uid) {
+ home = 0;
+ home_uid = uid;
+ changed_uid = 1;
+ }
+
if (home != NULL)
return home;
- if (!server_active && (env = getenv ("HOME")) != NULL)
+ if (!server_active && ((env = getenv ("HOME")) != NULL) && !changed_uid)
home = env;
- else if ((pw = (struct passwd *) getpwuid (getuid ()))
+ else if ((pw = (struct passwd *) getpwuid (uid))
&& pw->pw_dir)
home = xstrdup (pw->pw_dir);
else