summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'session.c')
-rw-r--r--session.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/session.c b/session.c
index 1e22f477f..ca4a994e3 100644
--- a/session.c
+++ b/session.c
@@ -32,6 +32,11 @@ RCSID("$OpenBSD: session.c,v 1.20 2000/06/18 04:42:54 markus Exp $");
32#include <proj.h> 32#include <proj.h>
33#endif /* WITH_IRIX_PROJECT */ 33#endif /* WITH_IRIX_PROJECT */
34 34
35#ifdef HAVE_OSF_SIA
36# include <sia.h>
37# include <siad.h>
38#endif
39
35/* types */ 40/* types */
36 41
37#define TTYSZ 64 42#define TTYSZ 64
@@ -823,14 +828,32 @@ do_child(const char *command, struct passwd * pw, const char *term,
823 } 828 }
824#endif /* USE_PAM */ 829#endif /* USE_PAM */
825 830
831#ifndef HAVE_OSF_SIA
826 /* Set login name in the kernel. */ 832 /* Set login name in the kernel. */
827 if (setlogin(pw->pw_name) < 0) 833 if (setlogin(pw->pw_name) < 0)
828 error("setlogin failed: %s", strerror(errno)); 834 error("setlogin failed: %s", strerror(errno));
835#endif
829 836
830 /* Set uid, gid, and groups. */ 837 /* Set uid, gid, and groups. */
831 /* Login(1) does this as well, and it needs uid 0 for the "-h" 838 /* Login(1) does this as well, and it needs uid 0 for the "-h"
832 switch, so we let login(1) to this for us. */ 839 switch, so we let login(1) to this for us. */
833 if (!options.use_login) { 840 if (!options.use_login) {
841#ifdef HAVE_OSF_SIA
842 extern char **saved_argv;
843 extern int saved_argc;
844 char *host = get_canonical_hostname ();
845
846 if (sia_become_user(NULL, saved_argc, saved_argv, host,
847 pw->pw_name, ttyname, 0, NULL, NULL, SIA_BEU_SETLUID) !=
848 SIASUCCESS) {
849 perror("sia_become_user");
850 exit(1);
851 }
852 if (setreuid(geteuid(), geteuid()) < 0) {
853 perror("setreuid");
854 exit(1);
855 }
856#else /* HAVE_OSF_SIA */
834 if (getuid() == 0 || geteuid() == 0) { 857 if (getuid() == 0 || geteuid() == 0) {
835 if (setgid(pw->pw_gid) < 0) { 858 if (setgid(pw->pw_gid) < 0) {
836 perror("setgid"); 859 perror("setgid");
@@ -867,6 +890,7 @@ do_child(const char *command, struct passwd * pw, const char *term,
867 } 890 }
868 if (getuid() != pw->pw_uid || geteuid() != pw->pw_uid) 891 if (getuid() != pw->pw_uid || geteuid() != pw->pw_uid)
869 fatal("Failed to set uids to %d.", (int) pw->pw_uid); 892 fatal("Failed to set uids to %d.", (int) pw->pw_uid);
893#endif /* HAVE_OSF_SIA */
870 } 894 }
871 /* 895 /*
872 * Get the shell from the password data. An empty shell field is 896 * Get the shell from the password data. An empty shell field is