1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-17 03:25:46 +00:00
freebsd-ports/security/ssh2/files/patch-lib::sshsession::sshunixuser.c
Alexander Leidinger 610d298652 HEADS-UP: Traditionally this port automatically installs a start-up script for
sshd2 unless it detects an entry for ssh in /etc/inetd.conf. As there
	  are three ways to automatically start sshd2 and /etc/rc.conf is the
	  simplest one (at least on FreeBSD 4, with rcNG once /etc/rc.d/sshd is
	  fixed to not be tailored to the base sshd) this version of the port
	  is the last one to do so. Beginning with next version it will only
	  install a sample start-up script. To prevent foot shooting when
	  updating to the next version this port won't remove an existing
	  start-up scripting on deinstall. Please see also the pkg-message that
	  gets displayed on installation.

- Update to 3.2.9.1. This is _not_ a security update. For the non-commercial
  version the only change worth mentioning since 3.2.5 is the addition of the
  config option "DisableVersionFallback", see sshd2_config(5) for further
  details.
- Use sites from the official list of mirrors for MASTER_SITES.
- Adjust COMMENT to justify why this port is security/ssh2, not security/ssh3.
- Revise list of installed documentation. No longer install MANIFEST (list of
  source files) and INSTALL, install RFCs referenced in sshd2_config(5) and
  HOWTO.anonymous.sftp (patched to better fit FreeBSD).
- Remove WITH_STATIC_SFTP knob. Using the internal sftp-server instead of the
  external (static) one is much simpler to set up and maintain (using the
  external one requires to install a copy of it in the home directory of the
  anonymous sftp user which has to be manually updated when installing a newer
  version of the port).
- Remove WITHOUT_TCPWRAP knob, libwarp is part of FreeBSD since 3.2.
- Install examples scripts for the ExternalAuthorizationProgram and
  AuthKbdInt.Plugin config options in EXAMPLESDIR. See sshd2_config(5) for
  further information.
- Replace references to /etc/ssh2/* in config files with PREFIX/etc/ssh2/*.
- Add a pkg-message displaying the different methods to automatically start
  sshd2.
- Switch to the start-up script for Solaris which is part of the tarball, it
  handles the name of the pidfile better.
- Fix detection of X11 headers, this enables compilation with support for X11
  SECURITY extension. See TrustX11Applications in ssh2_config(5) for further
  information.
- Add a test target to the Makefile of the port, the tests seem a bit outdated
  and buggy but it's enough to e.g. do a bit of speed comparison when building
  with different compilers.
- Minor changes and clean-up (sort pkg-plist, don't add /usr/local/lib to
  the library search path when compiling, etc.).

Revive some local modifications lost with the update to 3.1.0:
- Use login_cap(3)/login_class(3) facilities to set environment variables,
  prority and shell, get motd, copyright, hushlogin and nologin, respect
  ignorenologin and requirehome. This changes are roughly based on former
  patch-ah and patch-ai and patches of security/openssh.
- Don't print "No mail.", it's not FreeBSD login style.

Submitted by:	maintainer
2004-01-04 14:03:52 +00:00

70 lines
2.1 KiB
C

--- lib/sshsession/sshunixuser.c.orig Wed Dec 3 14:17:21 2003
+++ lib/sshsession/sshunixuser.c Mon Dec 29 20:57:45 2003
@@ -104,6 +104,10 @@
#define SSH_DEBUG_MODULE "SshUnixUser"
+#if defined (__FreeBSD__) && defined(HAVE_LOGIN_CAP_H)
+#include <login_cap.h>
+#endif /* __FreeBSD && HAVE_LOGIN_CAP_H */
+
extern char *crypt(const char *key, const char *salt);
/* Group structure. */
@@ -1477,6 +1481,37 @@
/* Set uid, gid, and groups. */
if (getuid() == UID_ROOT || geteuid() == UID_ROOT)
{
+#if defined (__FreeBSD__) && defined(HAVE_LOGIN_CAP_H)
+ struct passwd *pw;
+
+ pw = getpwuid(ssh_user_uid(uc));
+ if (setusercontext(NULL, pw, ssh_user_uid(uc),
+ LOGIN_SETALL & ~(LOGIN_SETLOGIN | LOGIN_SETUSER |
+ LOGIN_SETPATH | LOGIN_SETENV)) < 0)
+ {
+ SSH_DEBUG(2, ("setusercontext: unable to set user context"));
+ return FALSE;
+ }
+ endgrent();
+
+ /* chrooting at this point. */
+ if (chroot_dir)
+ {
+ if (chroot(chroot_dir) < 0)
+ {
+ ssh_warning("Chroot to '%s' failed: %s", chroot_dir,
+ strerror(errno));
+ return FALSE;
+ }
+ }
+
+ if (setusercontext(NULL, pw, ssh_user_uid(uc), LOGIN_SETUSER) < 0)
+ {
+ SSH_DEBUG(2, ("setusercontext: unable to set user context"));
+ return FALSE;
+ }
+ endpwent();
+#else /* ! (__FreeBSD && HAVE_LOGIN_CAP_H) */
if (setgid(ssh_user_gid(uc)) < 0)
{
SSH_DEBUG(2, ("setgid: %s", strerror(errno)));
@@ -1524,7 +1559,8 @@
{
if (chroot(chroot_dir) < 0)
{
- ssh_warning("Chroot to '%s' failed!", chroot_dir);
+ ssh_warning("Chroot to '%s' failed: %s", chroot_dir,
+ strerror(errno));
return FALSE;
}
}
@@ -1578,6 +1614,7 @@
return FALSE;
}
#endif /* HAVE_SIA */
+#endif /* __FreeBSD && HAVE_LOGIN_CAP_H */
}
#ifdef KERBEROS