success.c
上传用户:s81996212
上传日期:2007-01-04
资源大小:722k
文件大小:2k
源码类别:

WEB邮件程序

开发平台:

C/C++

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