Advertisement
FlyFar

pop3.h

May 16th, 2024
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.25 KB | Cybersecurity | 0 0
  1. /*
  2.  *  pop3d       - IP/TCP/POP3 server for UNIX 4.3BSD
  3.  *            Post Office Protocol - Version 3 (RFC1225)
  4.  *
  5.  *      (C) Copyright 1991 Regents of the University of California
  6.  *
  7.  *      Permission to use, copy, modify, and distribute this program
  8.  *      for any purpose and without fee is hereby granted, provided
  9.  *      that this copyright and permission notice appear on all copies
  10.  *      and supporting documentation, the name of University of California
  11.  *      not be used in advertising or publicity pertaining to distribution
  12.  *      of the program without specific prior permission, and notice be
  13.  *      given in supporting documentation that copying and distribution is
  14.  *      by permission of the University of California.
  15.  *      The University of California makes no representations about
  16.  *      the suitability of this software for any purpose.  It is provided
  17.  *      "as is" without express or implied warranty.
  18.  *
  19.  *  Katie Stevens
  20.  *  dkstevens@ucdavis.edu
  21.  *  Information Technology -- Campus Access Point
  22.  *  University of California, Davis
  23.  *
  24.  **************************************
  25.  *
  26.  *  pop3.h
  27.  *
  28.  *  REVISIONS:
  29.  *      02-27-90 [ks]   original implementation
  30.  *  1.000   03-04-90 [ks]
  31.  *  1.001   06-24-90 [ks]   allow TRANS state if 0 msgs in folder
  32.  *              implement optional TOP command
  33.  *  1.002   07-22-91 [ks]   -- reset index counter after folder rewind
  34.  *                 in fld_release (Thanks to John Briggs,
  35.  *                 Vitro Corporation, Silver Spring, MD
  36.  *                 for finding this bug!)
  37.  *              -- set umask() value explicitly (Thanks to
  38.  *                 Vikas Aggarwal, JvNCnet, Princeton, NJ
  39.  *                 for suggesting this)
  40.  *              -- remove unnecessary 'return' at end
  41.  *                 of void functions
  42.  *  1.003   03-92    [ks]   close folder before return from main()
  43.  *  1.004   11-13-91 [ks]   leave original mailbox intact during POP
  44.  *              session (Thanks to Dave Cooley,
  45.  *              dwcooley@colby.edu, for suggesting this)
  46.  *  1.005   01-04-96 [dts]  change mktemp to mkstemp to avoid security
  47.  *              hole with mktemp (timing attack).
  48.  *  (See header of main.c for current revision info.)
  49.  */
  50. extern char *malloc();
  51. extern char *realloc();
  52. extern char *crypt();
  53.  
  54. /* In folder.c: */
  55. extern int fld_fromsp();
  56.  
  57. extern void fld_delete();
  58. extern void fld_last();
  59. extern void fld_list();
  60. extern void fld_uidl();
  61. extern void fld_reset();
  62. extern void fld_retr();
  63. extern void fld_stat();
  64. extern void fld_top();
  65.  
  66. extern void fld_release();
  67.  
  68. /* In util.c: */
  69. extern int verify_user();
  70. extern char *fgetl();
  71. extern void cmd_prepare();
  72. extern void fail();
  73. extern char *get_fdqn();
  74.  
  75. /* In md5.c */
  76. extern void do_md5_file(FILE *src, long start, long end, char *hash);
  77. extern void do_md5_string(char *pass, int passlen, char *hash);
  78.  
  79. /* In apop.c: */
  80. extern int verify_user_apop();
  81. extern char *apop_timestamp();
  82.  
  83. #define SVR_LISTEN_STATE    0x00        /* Wait for client connection */
  84. #define SVR_AUTH_STATE      0x01        /* Expecting USER command */
  85. #define SVR_PASS_STATE      0x02        /* Expecting PASS command */
  86. #define SVR_TRANS_STATE     0x03        /* Process mailbox commands */
  87. #define SVR_FOLD_STATE      0x04        /* Need to open another mbox */
  88. #define SVR_DONE_STATE      -1
  89.  
  90. #define SVR_TIMEOUT_CLI     600     /* 10 minutes */
  91. #define SVR_TIMEOUT_SEND    120     /* 02 minutes */
  92. #define SVR_BUFSIZ      1024
  93. #define CLI_BUFSIZ      128
  94.  
  95. #ifdef QMAIL        /* moved to pwd->pw_dir */
  96. #  undef DEF_MAIL_DIR
  97. #  undef DEF_POP3_DIR
  98. #endif
  99.  
  100. /* Comment out for no debug file  */
  101. #define LOGFILE         "/var/log/pop3.log"
  102.  
  103. #define POP3_RCPT_HDR       "X-POP3-Rcpt:"
  104.  
  105. /* Set the following to be the prefix to your suspended user shells */
  106. #define ACCT_SUSP_STR       "/bin/acct_susp"
  107.  
  108. struct fld_item {
  109.     long fmsg_entry;        /* Index in file of start of msg */
  110.     long bcount;            /* #bytes this msg (for scan listing) */
  111.     long count;         /* #bytes this msg (for UIDL purposes) */
  112.     int status;         /* Status of this message */
  113. #define MSG_DELETED 0x01        /* Msg marked for deletion */
  114.     char *id;           /* Unique ID of msg */
  115.     char *pop_hdr;          /* Extra header for POP3 client */
  116. };
  117. #define FLD_ENTRY_BLOCK     16
  118. #define get_e_array(a,m) {\
  119.     a = (struct fld_item *)malloc(sizeof(struct fld_item)*( (m) + 1));\
  120. }
  121. #define chk_e_size(a,m,i) {\
  122.     if ( ( (i) ) && (!( (i) % (m) )) ) {\
  123.         a = (struct fld_item *)realloc( (a), (sizeof(struct fld_item)*( (i) + (m) + 1)));\
  124.     }\
  125. }
  126.  
  127. #define FAIL_CONFUSION      51      /* unknown error */
  128. #define FAIL_FILE_ERROR     52      /* file read/write error */
  129. #define FAIL_HANGUP     53      /* client hung up on us */
  130. #define FAIL_LOST_CLIENT    54      /* timeout waiting for client */
  131. #define FAIL_OUT_OF_MEMORY  55      /* out of system memory */
  132. #define FAIL_PROGERR        56      /* unexpected program error */
  133. #define FAIL_PIPE       57      /* DTS 28Jul96 - usually */
  134.                         /*     while sending a msg */
  135. #define FAIL_DUP_READ       58      /* DTS 10Oct96 1.005d */
  136.  
  137. #define NULL_CHAR   '\0'
  138. #define LF_CHAR     '\n'
  139. #define CR_CHAR     '\r'
  140. #define DOT_CHAR    '.'
  141. #define LANKLE_CHAR '<'
  142. #define RANKLE_CHAR '>'
  143.  
  144. #define APOP_PASSWORD_FILE  "/etc/apop" /* file of *unencrypted* passwords */
  145.  
  146. #define EATSPACE(s) while (isspace(*s)&&(*s != NULL_CHAR)) ++s
  147.  
  148. #ifndef min
  149. #define min(a, b)   ((a) < (b) ? (a) : (b))
  150. #endif
  151.  
  152. #define SYSLOGPRI   (LOG_MAIL | LOG_INFO)
  153.  
  154. /* DTS 01Jul98 - added delay before returning failed pass notice to
  155.  *  slow/prevent guessing attacks
  156.  */
  157. #define FAILPASS_DELAY  5
  158.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement