|
0
|
1 |
/*
|
|
|
2 |
** Copyright 1998 - 1999 Double Precision, Inc. See COPYING for
|
|
|
3 |
** distribution information.
|
|
|
4 |
*/
|
|
|
5 |
|
|
|
6 |
#include "auth.h"
|
|
|
7 |
|
|
|
8 |
#include <stdio.h>
|
|
|
9 |
#include <errno.h>
|
|
|
10 |
#include <stdlib.h>
|
|
|
11 |
#include <string.h>
|
|
|
12 |
|
|
|
13 |
#if HAVE_UNISTD_H
|
|
|
14 |
#include <unistd.h>
|
|
|
15 |
#endif
|
|
|
16 |
|
|
2
|
17 |
static const char rcsid[]="$Id: success.c,v 1.2 2000/12/18 20:20:10 bruce Exp $";
|
|
0
|
18 |
|
|
|
19 |
void authsuccess(const char *homedir,
|
|
|
20 |
const char *username,
|
|
|
21 |
const uid_t *uid,
|
|
|
22 |
const gid_t *gid,
|
|
|
23 |
const char *authaddr,
|
|
|
24 |
const char *authfullname)
|
|
|
25 |
{
|
|
|
26 |
static char *authaddr_buf=0;
|
|
|
27 |
static char *authfullname_buf=0;
|
|
|
28 |
char *p;
|
|
|
29 |
|
|
|
30 |
if (username)
|
|
|
31 |
{
|
|
|
32 |
if (gid)
|
|
|
33 |
authchangegroup(*gid);
|
|
|
34 |
authchangeusername(username, gid);
|
|
|
35 |
}
|
|
|
36 |
else
|
|
|
37 |
{
|
|
|
38 |
if (!uid || !gid)
|
|
|
39 |
{
|
|
|
40 |
write(2, "AUTHFAILURE\n", 12);
|
|
|
41 |
authexit(1);
|
|
|
42 |
}
|
|
|
43 |
authchangeuidgid(*uid, *gid);
|
|
|
44 |
}
|
|
|
45 |
|
|
2
|
46 |
if (chdir(homedir))
|
|
|
47 |
{
|
|
|
48 |
perror("chdir");
|
|
|
49 |
authexit(1);
|
|
|
50 |
}
|
|
|
51 |
|
|
0
|
52 |
if (!authaddr) authaddr="";
|
|
|
53 |
if (authaddr_buf) free(authaddr_buf);
|
|
|
54 |
authaddr_buf=malloc(sizeof("AUTHADDR=")+strlen(authaddr));
|
|
|
55 |
if (!authaddr_buf)
|
|
|
56 |
{
|
|
|
57 |
perror("malloc");
|
|
|
58 |
authexit(1);
|
|
|
59 |
}
|
|
|
60 |
strcat(strcpy(authaddr_buf, "AUTHADDR="), authaddr);
|
|
|
61 |
|
|
|
62 |
if (!authfullname) authfullname="";
|
|
|
63 |
if (authfullname_buf) free(authfullname_buf);
|
|
|
64 |
authfullname_buf=malloc(sizeof("AUTHFULLNAME=")+strlen(authfullname));
|
|
|
65 |
if (!authfullname_buf)
|
|
|
66 |
{
|
|
|
67 |
perror("malloc");
|
|
|
68 |
authexit(1);
|
|
|
69 |
}
|
|
|
70 |
strcat(strcpy(authfullname_buf, "AUTHFULLNAME="), authfullname);
|
|
|
71 |
|
|
|
72 |
/* Get rid of GECOS crud */
|
|
|
73 |
|
|
|
74 |
p=authfullname_buf+strlen(authfullname_buf);
|
|
|
75 |
while (*--p == ',')
|
|
|
76 |
*p=0;
|
|
|
77 |
putenv(authaddr_buf);
|
|
|
78 |
putenv(authfullname_buf);
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
void authdummy()
|
|
|
82 |
{
|
|
|
83 |
}
|
|
|
84 |
|