]> andersk Git - openssh.git/blame - auth-sia.c
- (stevesk) [auth-pam.c auth-pam.h auth-passwd.c auth-sia.c auth-sia.h
[openssh.git] / auth-sia.c
CommitLineData
b7ccb051 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"
fde58bd4 9#include "auth.h"
b7ccb051 10
11#include <sia.h>
12#include <siad.h>
13#include <pwd.h>
14#include <signal.h>
15#include <setjmp.h>
16#include <sys/resource.h>
17#include <unistd.h>
18#include <string.h>
19
20extern ServerOptions options;
21extern int saved_argc;
22extern char **saved_argv;
23
24extern int errno;
25
26int
fde58bd4 27auth_sia_password(Authctxt *authctxt, char *pass)
b7ccb051 28{
29 int ret;
30 SIAENTITY *ent = NULL;
31 const char *host;
fde58bd4 32 char *user = authctxt->user;
b7ccb051 33
983784a1 34 host = get_canonical_hostname(options.verify_reverse_mapping);
b7ccb051 35
fde58bd4 36 if (!user || !pass || pass[0] == '\0')
b7ccb051 37 return(0);
38
39 if (sia_ses_init(&ent, saved_argc, saved_argv, host, user, NULL, 0,
40 NULL) != SIASUCCESS)
41 return(0);
42
43 if ((ret = sia_ses_authent(NULL, pass, ent)) != SIASUCCESS) {
44 error("couldn't authenticate %s from %s", user, host);
45 if (ret & SIASTOP)
46 sia_ses_release(&ent);
47 return(0);
48 }
49
50 sia_ses_release(&ent);
51
52 return(1);
53}
54
55void
56session_setup_sia(char *user, char *tty)
57{
58 int ret;
59 struct passwd *pw;
60 SIAENTITY *ent = NULL;
61 const char *host;
62
983784a1 63 host = get_canonical_hostname (options.verify_reverse_mapping);
b7ccb051 64
65 if (sia_ses_init(&ent, saved_argc, saved_argv, host, user, tty, 0,
c96a4aaf 66 NULL) != SIASUCCESS) {
67 error("sia_ses_init failed");
68 exit(1);
69 }
b7ccb051 70
71 if ((pw = getpwnam(user)) == NULL) {
72 sia_ses_release(&ent);
c96a4aaf 73 error("getpwnam(%s) failed: %s", user, strerror(errno));
74 exit(1);
b7ccb051 75 }
76 if (sia_make_entity_pwd(pw, ent) != SIASUCCESS) {
77 sia_ses_release(&ent);
c96a4aaf 78 error("sia_make_entity_pwd failed");
79 exit(1);
b7ccb051 80 }
81
82 ent->authtype = SIA_A_NONE;
c96a4aaf 83 if (sia_ses_estab(sia_collect_trm, ent) != SIASUCCESS) {
84 error("couldn't establish session for %s from %s", user,
b7ccb051 85 host);
c96a4aaf 86 exit(1);
87 }
b7ccb051 88
89 if (setpriority(PRIO_PROCESS, 0, 0) == -1) {
90 sia_ses_release(&ent);
c96a4aaf 91 error("setpriority failed: %s", strerror (errno));
92 exit(1);
b7ccb051 93 }
94
c96a4aaf 95 if (sia_ses_launch(sia_collect_trm, ent) != SIASUCCESS) {
96 error("couldn't launch session for %s from %s", user, host);
97 exit(1);
98 }
b7ccb051 99
100 sia_ses_release(&ent);
101
c96a4aaf 102 if (setreuid(geteuid(), geteuid()) < 0) {
103 error("setreuid failed: %s", strerror (errno));
104 exit(1);
105 }
b7ccb051 106}
107
108#endif /* HAVE_OSF_SIA */
109
This page took 0.098012 seconds and 5 git commands to generate.