lib/courier-authlib/success.c
changeset 2 b3afb9f1e801
parent 0 6f7a81934006
equal deleted inserted replaced
1:30113bfbe723 2:b3afb9f1e801
    12 
    12 
    13 #if	HAVE_UNISTD_H
    13 #if	HAVE_UNISTD_H
    14 #include	<unistd.h>
    14 #include	<unistd.h>
    15 #endif
    15 #endif
    16 
    16 
    17 static const char rcsid[]="$Id: success.c,v 1.1 2000/04/13 17:55:05 bruce Exp $";
    17 static const char rcsid[]="$Id: success.c,v 1.2 2000/12/18 20:20:10 bruce Exp $";
    18 
    18 
    19 void authsuccess(const char *homedir,
    19 void authsuccess(const char *homedir,
    20 	const char *username,
    20 	const char *username,
    21 	const uid_t	*uid,
    21 	const uid_t	*uid,
    22 	const gid_t	*gid,
    22 	const gid_t	*gid,
    24 	const char	*authfullname)
    24 	const char	*authfullname)
    25 {
    25 {
    26 static char	*authaddr_buf=0;
    26 static char	*authaddr_buf=0;
    27 static char	*authfullname_buf=0;
    27 static char	*authfullname_buf=0;
    28 char	*p;
    28 char	*p;
    29 
       
    30 	if (chdir(homedir))
       
    31 	{
       
    32 		perror("chdir");
       
    33 		authexit(1);
       
    34 	}
       
    35 
    29 
    36 	if (username)
    30 	if (username)
    37 	{
    31 	{
    38 		if (gid)
    32 		if (gid)
    39 			authchangegroup(*gid);
    33 			authchangegroup(*gid);
    45 		{
    39 		{
    46 			write(2, "AUTHFAILURE\n", 12);
    40 			write(2, "AUTHFAILURE\n", 12);
    47 			authexit(1);
    41 			authexit(1);
    48 		}
    42 		}
    49 		authchangeuidgid(*uid, *gid);
    43 		authchangeuidgid(*uid, *gid);
       
    44 	}
       
    45 
       
    46 	if (chdir(homedir))
       
    47 	{
       
    48 		perror("chdir");
       
    49 		authexit(1);
    50 	}
    50 	}
    51 
    51 
    52 	if (!authaddr)	authaddr="";
    52 	if (!authaddr)	authaddr="";
    53 	if (authaddr_buf)	free(authaddr_buf);
    53 	if (authaddr_buf)	free(authaddr_buf);
    54 	authaddr_buf=malloc(sizeof("AUTHADDR=")+strlen(authaddr));
    54 	authaddr_buf=malloc(sizeof("AUTHADDR=")+strlen(authaddr));