Damien Miller | 92ddb7d | 2001-02-14 01:25:23 +1100 | [diff] [blame] | 1 | #include "includes.h" |
| 2 | |
| 3 | #ifdef HAVE_OSF_SIA |
| 4 | #include "ssh.h" |
| 5 | #include "auth-sia.h" |
| 6 | #include "log.h" |
| 7 | #include "servconf.h" |
| 8 | #include "canohost.h" |
| 9 | |
| 10 | #include <sia.h> |
| 11 | #include <siad.h> |
| 12 | #include <pwd.h> |
| 13 | #include <signal.h> |
| 14 | #include <setjmp.h> |
| 15 | #include <sys/resource.h> |
| 16 | #include <unistd.h> |
| 17 | #include <string.h> |
| 18 | |
| 19 | extern ServerOptions options; |
| 20 | extern int saved_argc; |
| 21 | extern char **saved_argv; |
| 22 | |
| 23 | extern int errno; |
| 24 | |
| 25 | int |
| 26 | auth_sia_password(char *user, char *pass) |
| 27 | { |
| 28 | int ret; |
| 29 | SIAENTITY *ent = NULL; |
| 30 | const char *host; |
| 31 | |
| 32 | host = get_canonical_hostname(options.reverse_mapping_check); |
| 33 | |
| 34 | if (!user || !pass) |
| 35 | return(0); |
| 36 | |
| 37 | if (sia_ses_init(&ent, saved_argc, saved_argv, host, user, NULL, 0, |
| 38 | NULL) != SIASUCCESS) |
| 39 | return(0); |
| 40 | |
| 41 | if ((ret = sia_ses_authent(NULL, pass, ent)) != SIASUCCESS) { |
| 42 | error("couldn't authenticate %s from %s", user, host); |
| 43 | if (ret & SIASTOP) |
| 44 | sia_ses_release(&ent); |
| 45 | return(0); |
| 46 | } |
| 47 | |
| 48 | sia_ses_release(&ent); |
| 49 | |
| 50 | return(1); |
| 51 | } |
| 52 | |
| 53 | void |
| 54 | session_setup_sia(char *user, char *tty) |
| 55 | { |
| 56 | int ret; |
| 57 | struct passwd *pw; |
| 58 | SIAENTITY *ent = NULL; |
| 59 | const char *host; |
| 60 | |
| 61 | host = get_canonical_hostname (options.reverse_mapping_check); |
| 62 | |
| 63 | if (sia_ses_init(&ent, saved_argc, saved_argv, host, user, tty, 0, |
Damien Miller | 364a9bd | 2001-04-16 18:37:05 +1000 | [diff] [blame] | 64 | NULL) != SIASUCCESS) { |
| 65 | error("sia_ses_init failed"); |
| 66 | exit(1); |
| 67 | } |
Damien Miller | 92ddb7d | 2001-02-14 01:25:23 +1100 | [diff] [blame] | 68 | |
| 69 | if ((pw = getpwnam(user)) == NULL) { |
| 70 | sia_ses_release(&ent); |
Damien Miller | 364a9bd | 2001-04-16 18:37:05 +1000 | [diff] [blame] | 71 | error("getpwnam(%s) failed: %s", user, strerror(errno)); |
| 72 | exit(1); |
Damien Miller | 92ddb7d | 2001-02-14 01:25:23 +1100 | [diff] [blame] | 73 | } |
| 74 | if (sia_make_entity_pwd(pw, ent) != SIASUCCESS) { |
| 75 | sia_ses_release(&ent); |
Damien Miller | 364a9bd | 2001-04-16 18:37:05 +1000 | [diff] [blame] | 76 | error("sia_make_entity_pwd failed"); |
| 77 | exit(1); |
Damien Miller | 92ddb7d | 2001-02-14 01:25:23 +1100 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | ent->authtype = SIA_A_NONE; |
Damien Miller | 364a9bd | 2001-04-16 18:37:05 +1000 | [diff] [blame] | 81 | if (sia_ses_estab(sia_collect_trm, ent) != SIASUCCESS) { |
| 82 | error("couldn't establish session for %s from %s", user, |
Damien Miller | 92ddb7d | 2001-02-14 01:25:23 +1100 | [diff] [blame] | 83 | host); |
Damien Miller | 364a9bd | 2001-04-16 18:37:05 +1000 | [diff] [blame] | 84 | exit(1); |
| 85 | } |
Damien Miller | 92ddb7d | 2001-02-14 01:25:23 +1100 | [diff] [blame] | 86 | |
| 87 | if (setpriority(PRIO_PROCESS, 0, 0) == -1) { |
| 88 | sia_ses_release(&ent); |
Damien Miller | 364a9bd | 2001-04-16 18:37:05 +1000 | [diff] [blame] | 89 | error("setpriority failed: %s", strerror (errno)); |
| 90 | exit(1); |
Damien Miller | 92ddb7d | 2001-02-14 01:25:23 +1100 | [diff] [blame] | 91 | } |
| 92 | |
Damien Miller | 364a9bd | 2001-04-16 18:37:05 +1000 | [diff] [blame] | 93 | if (sia_ses_launch(sia_collect_trm, ent) != SIASUCCESS) { |
| 94 | error("couldn't launch session for %s from %s", user, host); |
| 95 | exit(1); |
| 96 | } |
Damien Miller | 92ddb7d | 2001-02-14 01:25:23 +1100 | [diff] [blame] | 97 | |
| 98 | sia_ses_release(&ent); |
| 99 | |
Damien Miller | 364a9bd | 2001-04-16 18:37:05 +1000 | [diff] [blame] | 100 | if (setreuid(geteuid(), geteuid()) < 0) { |
| 101 | error("setreuid failed: %s", strerror (errno)); |
| 102 | exit(1); |
| 103 | } |
Damien Miller | 92ddb7d | 2001-02-14 01:25:23 +1100 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | #endif /* HAVE_OSF_SIA */ |
| 107 | |