ucspi-proxy-0.99/0000775000076400007640000000000012122145100013306 5ustar bruceguenterucspi-proxy-0.99/TARGETS0000664000076400007640000000067112122145100014346 0ustar bruceguenterall auth-lib.o base64.o clean clean-spac compile docs http-xlate-filter.o imap-filter.o install libraries load log-filter.o makelib null-filter.o pop3-filter.o programs relay-filter.o tcp-connect.o ucspi-proxy ucspi-proxy-http-xlate ucspi-proxy-http-xlate.1.html ucspi-proxy-http-xlate.o ucspi-proxy-imap ucspi-proxy-imap.o ucspi-proxy-log ucspi-proxy-log.o ucspi-proxy-pop3 ucspi-proxy-pop3.o ucspi-proxy.1.html ucspi-proxy.a ucspi-proxy.o ucspi-proxy-0.99/ucspi-proxy.c0000664000076400007640000001434512122145100015763 0ustar bruceguenter#include #include #include #include #include #include #include #include #include #include #include #include #include "ucspi-proxy.h" const int msg_show_pid = 1; static unsigned long bytes_client_in = 0; static unsigned long bytes_client_out = 0; static unsigned long bytes_server_in = 0; static unsigned long bytes_server_out = 0; int opt_verbose = 0; int opt_maxline = MAXLINE; static unsigned opt_timeout = 30; pid_t pid; int SERVER_FD = -1; struct filter_node { int fd; filter_fn filter; eof_fn at_eof; char* name; struct filter_node* next; }; struct filter_node* filters = 0; static bool new_filter(int fd, filter_fn filter, eof_fn at_eof) { struct filter_node* newnode = malloc(sizeof *filters); if(!newnode) return false; newnode->fd = fd; newnode->filter = filter; newnode->at_eof = at_eof; newnode->next = 0; if (fd == CLIENT_IN) newnode->name = "client"; else if (fd == SERVER_FD) newnode->name = "server"; else { newnode->name = malloc(4 + fmt_udec(0, fd)); strcpy(newnode->name, "FD#"); newnode->name[fmt_udec(newnode->name+3, fd)+3] = 0; } if(!filters) filters = newnode; else { struct filter_node* ptr = filters; while(ptr->next) ptr = ptr->next; ptr->next = newnode; } return true; } bool set_filter(int fd, filter_fn filter, eof_fn at_eof) { struct filter_node* node; for (node = filters; node != 0; node = node->next) { if (node->fd == fd) { node->filter = filter; node->at_eof = at_eof; return true; } } return new_filter(fd, filter, at_eof); } bool del_filter(int fd) { struct filter_node* prev = 0; struct filter_node* curr = filters; while(curr) { if(curr->fd == fd) { if(prev) prev->next = curr->next; else filters = curr->next; free(curr->name); free(curr); return true; } } return false; } static void handle_fd(struct filter_node* filter) { char buf[BUFSIZE+1]; ssize_t rd = read(filter->fd, buf, BUFSIZE); if(rd == -1) { if (errno == EAGAIN || errno == EINTR) return; die2sys(1, "Error reading from ", filter->name); exit(1); } if(rd == 0) { if (opt_verbose) msg2(filter->name, " hangup"); if(filter->at_eof) filter->at_eof(); else exit(0); } else { buf[rd] = 0; /* Add an extra NUL for string searches in filter */ if (filter->fd == CLIENT_IN) bytes_client_in += rd; else if (filter->fd == SERVER_FD) bytes_server_in += rd; filter->filter(buf, rd); } } static void retry_write(const char* data, ssize_t size, int fd, const char* name, unsigned long* counter) { ssize_t wr; iopoll_fd io; io.fd = fd; while(size > 0) { io.events = IOPOLL_WRITE; io.revents = 0; switch (iopoll_restart(&io, 1, -1)) { case -1: die1sys(1, "Poll failed"); case 0: die2(1, "Connection closed during write to ", name); } switch (wr = write(fd, data, size)) { case 0: die2(1, "Short write to ", name); case -1: die2sys(1, "Error writing to ", name); default: data += wr; size -= wr; *counter += wr; } } } void write_client(const char* data, ssize_t size) { retry_write(data, size, CLIENT_OUT, "client", &bytes_client_out); } void write_server(const char* data, ssize_t size) { retry_write(data, size, SERVER_FD, "server", &bytes_server_out); } void log_line(const char* data, ssize_t size) { ssize_t i; int dots = 0; for (i = 0; i < size; i++) { if (data[i] == '\r' || data[i] == '\n') break; if (i >= opt_maxline) { dots = 1; break; } } char buf[i+1]; memcpy(buf, data, i); if (dots) buf[i-1] = buf[i-2] = buf[i-3] = '.'; buf[i] = 0; msg1(buf); } static void exitfn(void) { char line[42+FMT_ULONG_LEN*4]; int i; memcpy(line, "bytes: client->server ", 22); i = 22; i += fmt_udec(line+i, bytes_client_in); line[i++] = '-'; line[i++] = '>'; i += fmt_udec(line+i, bytes_server_out); memcpy(line+i, " server->client ", 16); i += 16; i += fmt_udec(line+i, bytes_server_in); line[i++] = '-'; line[i++] = '>'; i += fmt_udec(line+i, bytes_client_out); line[i] = 0; msg1(line); filter_deinit(); } void usage(const char* message) { if(message) msg1(message); obuf_put4s(&errbuf, "usage: ", program, " [-v] [-t timeout] [host port] ", filter_usage); obuf_endl(&errbuf); exit(1); } static void connfail(void) { str buf = {0,0,0}; str_copy4s(&buf, filter_connfail_prefix, "Connection to server failed: ", strerror(errno), filter_connfail_suffix); write_client(buf.s, buf.len); exit(0); } static void parse_args(int argc, char* argv[]) { int opt; unsigned tmp; char* end; while((opt = getopt(argc, argv, "vl:t:")) != EOF) { switch(opt) { case 'v': opt_verbose++; break; case 'l': tmp = strtoul(optarg, &end, 10); if (tmp == 0 || *end != 0) usage("Invalid maximum line length"); opt_maxline = tmp; break; case 't': tmp = strtoul(optarg, &end, 10); if (tmp == 0 || *end != 0) usage("Invalid timeout"); opt_timeout = tmp; break; default: usage("Unknown option."); break; } } if (argc - optind == 0) SERVER_FD = 6; else if (argc - optind >= 2) { if ((SERVER_FD = tcp_connect(argv[optind], argv[optind+1], opt_timeout)) == -1) connfail(); } else usage("Incorrect usage"); optind += 2; filter_init(argc-optind, argv+optind); } int main(int argc, char* argv[]) { fd_set fds; signal(SIGALRM, SIG_IGN); signal(SIGHUP, SIG_IGN); signal(SIGPIPE, SIG_IGN); parse_args(argc, argv); atexit(exitfn); pid = getpid(); for(;;) { struct filter_node* filter; int maxfd = -1; FD_ZERO(&fds); for(filter = filters; filter; filter = filter->next) { int fd = filter->fd; FD_SET(fd, &fds); if(fd > maxfd) maxfd = fd; } while(select(maxfd+1, &fds, 0, 0, 0) == -1) { if(errno != EINTR) usage("select failed!"); } for(filter = filters; filter; filter = filter->next) if(FD_ISSET(filter->fd, &fds)) { handle_fd(filter); break; } } } ucspi-proxy-0.99/base64.c0000664000076400007640000000171412122145100014541 0ustar bruceguenter#include #include #include #include #include #include "ucspi-proxy.h" int base64decode(const char* data, unsigned long size, str* dest) { unsigned char bin[3]; int decoded; dest->len = 0; while (size) { if (data[0] == CR || data[0] == LF) size = 0; if (size < 4) break; if ((decoded = base64_decode_part(data, bin)) <= 0) break; data += 4; size -= 4; if (!str_catb(dest, (char*)bin, decoded)) die_oom(111); } return size ? 0 : 1; } int base64encode(const char* data, unsigned long size, str* dest) { return base64_encode_line((const unsigned char*)data, size, dest); } #ifdef MAIN #include #include int main(int argc, char* argv[]) { int i; int r; str d = {0,0,0}; for (i = 1; i < argc; i++) { int r = base64decode(argv[i], strlen(argv[i]), &d); printf("argv[%d] = %d: '%s'\n", i, r, d.s); } return 0; } #endif ucspi-proxy-0.99/conf-ld0000664000076400007640000000012712122145100014553 0ustar bruceguentergcc -g -L/usr/local/lib This will be used to link .o and .a files into an executable. ucspi-proxy-0.99/FILES0000664000076400007640000000100712122145100014071 0ustar bruceguenterANNOUNCEMENT AUTOFILES COPYING ChangeLog FILES INSTHIER Makefile NEWS README SRCFILES TARGETS TODO VERSION auth-lib.c auth-lib.h base64.c conf-bgincs conf-bglibs conf-bin conf-cc conf-ld conf-man http-xlate-filter.c imap-filter.c log-filter.c null-filter.c pop3-filter.c relay-filter.c tcp-connect.c ucspi-proxy-0.99.spec ucspi-proxy-http-xlate.1 ucspi-proxy-http-xlate.1.html ucspi-proxy-http-xlate.c ucspi-proxy-imap.c ucspi-proxy-log.c ucspi-proxy-pop3.c ucspi-proxy.1 ucspi-proxy.1.html ucspi-proxy.c ucspi-proxy.h ucspi-proxy-0.99/ucspi-proxy-log.c0000664000076400007640000000014412122145100016532 0ustar bruceguenter#include "ucspi-proxy.h" const char program[] = "ucspi-proxy-log"; const char filter_usage[] = ""; ucspi-proxy-0.99/conf-man0000664000076400007640000000021412122145100014724 0ustar bruceguenter/usr/local/man Man pages will be installed in subdirectories of this directory. An unformatted man page foo.1 will go into .../man1/foo.1. ucspi-proxy-0.99/COPYING0000664000076400007640000004311012122145100014340 0ustar bruceguenter GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. ucspi-proxy-0.99/SRCFILES0000664000076400007640000000044412122145100014445 0ustar bruceguenterINSTHIER auth-lib.c auth-lib.h base64.c http-xlate-filter.c imap-filter.c log-filter.c null-filter.c pop3-filter.c relay-filter.c tcp-connect.c ucspi-proxy-http-xlate.1 ucspi-proxy-http-xlate.c ucspi-proxy-imap.c ucspi-proxy-log.c ucspi-proxy-pop3.c ucspi-proxy.1 ucspi-proxy.c ucspi-proxy.h ucspi-proxy-0.99/TODO0000664000076400007640000000050112122145100013772 0ustar bruceguenter- Switch from select to iopoll - Write/fix man pages - Support UCSPI PROTO other than TCP - Support connecting to UNIX domain socket. - Complete FTP proxy module - NEWS NOTE: - Added FTP proxy, which should be able to handle all combinations of the APPE, LIST, NLST, PASV, PORT, RETR, STOR, and STOU commands. ucspi-proxy-0.99/http-xlate-filter.c0000664000076400007640000001632012122145100017031 0ustar bruceguenter#include #include #include #include #include #include #include "ucspi-proxy.h" // FIXME: make sure this is the right error number const char filter_connfail_prefix[] = "503 "; const char filter_connfail_suffix[] = CRLF; struct replacement { const char* src; size_t srclen; const char* dst; size_t dstlen; }; typedef struct replacement replacement; struct buffer { size_t len; char* buf; struct buffer* next; }; typedef struct buffer buffer; struct buffer_list { buffer* head; buffer* tail; }; typedef struct buffer_list buffer_list; static int content_html; static size_t content_length; static size_t content_length_offset; static size_t content_length_end; static size_t content_left; static buffer_list buffers; static int state = 0; static replacement* repls; static buffer* header = 0; static size_t min_src_repl; static size_t max_dst_repl; static void calc_lengths(void) { replacement* ptr; for (ptr = repls; ptr->src; ++ptr) { ptr->srclen = strlen(ptr->src); ptr->dstlen = strlen(ptr->dst); } min_src_repl = strlen(repls->src); max_dst_repl = strlen(repls->dst); for (ptr = repls+1; ptr->src; ++ptr) { if (ptr->srclen < min_src_repl) min_src_repl = ptr->srclen; if (ptr->dstlen > max_dst_repl) max_dst_repl = ptr->dstlen; } } static buffer* new_buffer(ssize_t size, const char* data) { buffer* newbuf = malloc(sizeof(buffer)); newbuf->len = size; newbuf->buf = malloc(size); newbuf->next = 0; if (data) memcpy(newbuf->buf, data, size); return newbuf; } static buffer* add_buffer(buffer* newbuf, buffer_list* list) { if(list->tail) list->tail->next = newbuf; else list->head = newbuf; list->tail = newbuf; return newbuf; } static void free_buffer(buffer* buf) { free(buf->buf); free(buf); } static void free_buffers(buffer_list* list) { buffer* curr; buffer* next; for (curr = list->head; curr; curr = next) { next = curr->next; free_buffer(curr); curr = next; } list->head = list->tail = 0; } static buffer* merge_buffers(buffer_list* blist) { buffer* newbuf; size_t total; char* ptr; buffer* buf; total = 0; for (buf = blist->head; buf; buf = buf->next) total += buf->len; newbuf = new_buffer(total, 0); for (ptr=newbuf->buf, buf=blist->head; buf; ptr+=buf->len, buf=buf->next) memcpy(ptr, buf->buf, buf->len); return newbuf; } static void parse_header(buffer_list* blist) { size_t left; char* data; header = merge_buffers(blist); left = header->len; data = header->buf; content_html = 0; content_length = content_length_offset = content_length_end = 0; while(left > 0) { char* nl = memchr(data, '\n', left); if(!nl) break; if(!strncasecmp(data, "Content-Length:", 15)) { const char* ptr = data + 15; char* tmp; while(isspace(*ptr)) ++ptr; content_length = strtoul(ptr, &tmp, 10); if(!isspace(*tmp)) content_length = 0; else { content_length_offset = ptr - header->buf; content_length_end = tmp - header->buf; } content_left = content_length; } else if(!strncasecmp(data, "Content-Type:", 13)) { const char* ptr = data + 13; while(isspace(*ptr)) ++ptr; if(!strncasecmp(ptr, "text/html", 9) && isspace(ptr[9])) content_html = 1; } left -= nl + 1 - data; data = nl + 1; } } static char* find_replacement(char* ptr, size_t left, replacement** repl) { replacement* r; char* tmp; char* end; char* found; for (end = ptr+left, found = 0, *repl = 0, r = repls; r->src; r++) { if ((tmp = strstr(ptr, r->src)) == 0 || tmp > end) continue; if (!*repl || tmp < found) { found = tmp; *repl = r; } } return found; } static buffer* xlate_buffer(buffer* in) { size_t diff; char* ptr; size_t left; buffer* out; char* found; replacement* repl; out = new_buffer(in->len * max_dst_repl / min_src_repl, 0); out->len = 0; ptr = in->buf; left = in->len; while (left > 0) { found = find_replacement(ptr, left, &repl); if(!found) break; diff = found - ptr; memcpy(out->buf+out->len, ptr, diff); out->len += diff; memcpy(out->buf+out->len, repl->dst, repl->dstlen); out->len += repl->dstlen; ptr += diff + repl->srclen; left -= diff + repl->srclen; } if(left > 0) { memcpy(out->buf+out->len, ptr, left); out->len += left; } return out; } static void write_response(buffer* hdrbuf, buffer* content) { static char buf[30]; char* ptr; size_t i; if (content_length_offset) { for (i = content->len, ptr = buf+29; i; i /= 10) *--ptr = (i % 10) + '0'; buf[29] = 0; write_client(hdrbuf->buf, content_length_offset); write_client(ptr, buf+30-ptr); write_client(hdrbuf->buf + content_length_end, hdrbuf->len - content_length_end); } else write_client(hdrbuf->buf, hdrbuf->len); write_client(content->buf, content->len); } static void parse_content(buffer_list* blist) { buffer* content; buffer* xlated; content = merge_buffers(blist); xlated = xlate_buffer(content); free_buffer(content); write_response(header, xlated); free_buffer(xlated); } static void filter_server_data(char* data, ssize_t size) { const char* ptr; size_t left; size_t used; const char* tmp; for (used=0, ptr=data, left=size; left; left-=used, ptr+=used) { used = 1; /* Use up one byte by default */ switch (state) { case 0: /* In header, looing for CR */ tmp = memchr(ptr, CR, left); if (tmp) { used = tmp - ptr + 1; state = 1; } else used = left; break; case 1: /* Read first CR, looking for first LF */ state = (*ptr == LF) ? 2 : 0; break; case 2: /* Read first LF, looking for second CR */ state = (*ptr == CR) ? 3 : 0; break; case 3: /* Read second CR, looking for second LF */ if (*ptr == LF) { add_buffer(new_buffer(ptr-data+1, data), &buffers); size -= ptr - data + 1; data += ptr - data + 1; parse_header(&buffers); free_buffers(&buffers); state = 4; } else state = 0; break; case 4: /* Read second LF, reading body */ if (content_length && left >= content_left) { add_buffer(new_buffer(content_left, data), &buffers); used = content_left; size -= content_left; data += content_left; content_left = 0; parse_content(&buffers); free_buffers(&buffers); state = 0; } else used = left; break; } } /* Add any remaining data to the buffer chain before returning */ if (size) { add_buffer(new_buffer(size, data), &buffers); if (state == 4) content_left -= size; } } static void filter_server_eof(void) { if (!content_length && state == 4) { parse_content(&buffers); } exit(0); } void filter_init(int argc, char** argv) { int i; if (!argc) usage("Too few arguments."); if (argc % 2) usage("Arguments must be paired."); repls = malloc((argc/2 + 1) * sizeof(replacement)); for (i = 0; i < argc/2; i++) { repls[i].src = argv[i*2]; repls[i].dst = argv[i*2+1]; } repls[i].src = repls[i].dst = 0; set_filter(CLIENT_IN, (filter_fn)write_server, 0); set_filter(SERVER_FD, filter_server_data, filter_server_eof); calc_lengths(); } void filter_deinit(void) { } ucspi-proxy-0.99/conf-bin0000664000076400007640000000007612122145100014727 0ustar bruceguenter/usr/local/bin Programs will be installed in this directory. ucspi-proxy-0.99/tcp-connect.c0000664000076400007640000000244112122145100015670 0ustar bruceguenter#include #include #include #include #include #include #include #include #include "ucspi-proxy.h" static ipv4addr addr; static long port; int tcp_connect(const char* host, const char* portstr, unsigned timeout) { struct servent* se; const char* end; int fd; iopoll_fd pf; if (!resolve_ipv4name(host, &addr)) die3(111, "Could not resolve '", host, "'"); if ((se = getservbyname(portstr, "tcp")) != 0) port = ntohs(se->s_port); else if ((port = strtol(portstr, (char**)&end, 10)) <= 0 || port >= 0xffff || *end != 0) die2(111, "Invalid port number: ", portstr); if ((fd = socket_tcp()) == -1) warn1sys("Could not create outgoing socket"); else if (!nonblock_on(fd)) warn1sys("Could not set flags on new outgoing socket"); else if (socket_connect4(fd, &addr, port)) return fd; else if (errno == EINPROGRESS || errno == EWOULDBLOCK) { pf.fd = fd; pf.events = IOPOLL_WRITE; switch (iopoll_restart(&pf, 1, timeout * 1000)) { case 0: warn1("Connection timed out"); errno = ETIMEDOUT; break; case 1: if (socket_connected(fd)) return fd; } } warn1sys("Connection to server rejected"); close(fd); return -1; } ucspi-proxy-0.99/imap-filter.c0000664000076400007640000000516012122145100015665 0ustar bruceguenter#include #include #include #include #include #include #include #include "auth-lib.h" #include "ucspi-proxy.h" const char filter_connfail_prefix[] = "* NO "; const char filter_connfail_suffix[] = "\r\n"; extern const char* local_name; static str label; static str saved_label; static str linebuf; static int parse_label(void) { int end; if ((end = str_findfirst(&linebuf, ' ')) <= 0) return 0; str_copyb(&label, linebuf.s, end); return end + 1; } static void handle_login(int offset) { const char* start; const char* end; start = linebuf.s + offset; while (isspace(*start)) ++start; if (*start == '"') { end = ++start; while (*end != '"') ++end; } else { end = start; while (!isspace(*end)) ++end; } make_username(start, end - start, "LOGIN "); str_splice(&linebuf, start-linebuf.s, end-start, &username); str_copy(&saved_label, &label); str_truncate(&label, 0); } static void filter_client_line(void) { int offset; const char* cmd; if (!handle_auth_response(&linebuf, 0)) { if ((offset = parse_label()) > 0) { cmd = linebuf.s + offset; /* If we see a "AUTHENTICATE" or "LOGIN" command, save the preceding * label for reference when looking for the corresponding "OK" */ if(!strncasecmp(cmd, "AUTHENTICATE ", 13)) { if (handle_auth_parameter(&linebuf, offset + 13)) str_copy(&saved_label, &label); } else if (!strncasecmp(cmd, "LOGIN ", 6)) handle_login(offset + 6); } } } static void filter_client_data(char* data, ssize_t size) { char* lf; while ((lf = memchr(data, LF, size)) != 0) { str_catb(&linebuf, data, lf - data + 1); filter_client_line(); write_server(linebuf.s, linebuf.len); linebuf.len = 0; size -= lf - data + 1; data = lf + 1; } str_catb(&linebuf, data, size); } static void filter_server_data(char* data, ssize_t size) { if(saved_label.len > 0) { /* Skip continuation data */ if(data[0] != '+') { int resp; /* Check if the response is tagged with the saved label */ str_copyb(&linebuf, data, size); resp = parse_label(); if(resp > 0) { if(!str_diff(&label, &saved_label)) { log_line(data, size); /* Check if the response was an OK */ if(!strncasecmp(linebuf.s + resp, "OK ", 3)) accept_client(username.s); else deny_client(username.s); str_truncate(&saved_label, 0); } } } } write_client(data, size); } void imap_filter_init(void) { set_filter(CLIENT_IN, filter_client_data, 0); set_filter(SERVER_FD, filter_server_data, 0); } ucspi-proxy-0.99/ucspi-proxy-pop3.c0000664000076400007640000000056112122145100016635 0ustar bruceguenter#include #include "ucspi-proxy.h" const char program[] = "ucspi-proxy-pop3"; const char filter_usage[] = "[command [args ...]]"; const char* local_name = 0; extern void pop3_filter_init(void); void filter_init(int argc, char** argv) { local_name = getenv("TCPLOCALHOST"); relay_init(argc, argv); pop3_filter_init(); } void filter_deinit(void) { } ucspi-proxy-0.99/conf-bglibs0000664000076400007640000000002612122145100015414 0ustar bruceguenter/usr/local/bglibs/lib ucspi-proxy-0.99/ucspi-proxy-http-xlate.1.html0000664000076400007640000000311612122145100020726 0ustar bruceguenterContent-type: text/html Manpage of ucspi-proxy-http-xlate

ucspi-proxy-http-xlate

Section: User Commands (1)
Index Return to Main Contents
 

NAME

ucspi-proxy-http-xlate - Translating HTTP proxy  

SYNOPSIS

ucspi-proxy-http-xlate [ -v ] search replace [ search replace [...]]  

DESCRIPTION

ucspi-proxy-http-xlate is a HTTP proxy for a UCSPI client/server pair that can translate strings within HTTP content on the fly. All occurrences of search are replaced with replace. If the HTTP response from the server contained a Content-Length header, it is replaced with the length of the translated content.  

SEE ALSO

ucspi-proxy(1)  

CAVEATS

All content is translated. This could cause some odd side-effects if a search string is found in a binary response, such as an image.


 

Index

NAME
SYNOPSIS
DESCRIPTION
SEE ALSO
CAVEATS

This document was created by man2html, using the manual pages.
Time: 20:27:44 GMT, March 19, 2013 ucspi-proxy-0.99/ANNOUNCEMENT0000664000076400007640000000361312122145100015126 0ustar bruceguenterVersion 0.99 of ucspi-proxy is now available at: http://untroubled.org/ucspi-proxy/ ------------------------------------------------------------------------------ Changes in version 0.99 - Added logging of final response to authentication commands. - Fixed core bug in command-line argument handling which prevented use of relay-ctrl. - Fixed exporting client environment variables when not in verbose mode. Development of this version has been sponsored by FutureQuest, Inc. ossi@FutureQuest.net http://www.FutureQuest.net/ ------------------------------------------------------------------------------- ucspi-proxy Connection proxy for UCSPI tools Bruce Guenter Version 0.99 2013-03-19 This package contains a proxy program that passes data back and forth between two connections set up by a UCSPI server and a UCSPI client. A mailing list has been set up to discuss this and other packages. To subscribe, send an email to: bgware-subscribe@lists.untroubled.org A mailing list archive is available at: http://lists.untroubled.org/?list=bgware Development versions of ucspi-proxy are available via git at: git://untroubled.org/git/ucspi-proxy.git Requirements: - bglibs version 1.025 or later How to install: - As root, run "make install" Usage: The simple usage is: UCSPIserver [address] UCSPIclient [address] ucspi-proxy Replace "UCSPIserver" with the program that will accept connections, and "UCSPIclient" with the program that will make connections. See the "tcp-proxy" script for a TCP-TCP proxy example. To make the POP3 and IMAP relay proxies work, you may need to edit the constants at the top of the relay-filter.c file. This program is Copyright(C) 2013 Bruce Guenter, and may be copied according to the GNU GENERAL PUBLIC LICENSE (GPL) Version 2 or a later version. A copy of this license is included with this package. This package comes with no warranty of any kind. ucspi-proxy-0.99/ucspi-proxy-http-xlate.c0000664000076400007640000000021612122145100020043 0ustar bruceguenter#include "ucspi-proxy.h" const char filter_usage[] = "search replace [search replace ...]"; const char program[] = "ucspi-proxy-http-xlate"; ucspi-proxy-0.99/ucspi-proxy.10000664000076400007640000000227312122145100015676 0ustar bruceguenter.TH ucspi-proxy 1 .SH NAME ucspi-proxy \- Copy data between a UCSPI client and server .SH SYNOPSIS .B ucspi-proxy [ .I \-v ] [ .I \-t TIMEOUT ] [ .I HOST PORT ] .SH DESCRIPTION This program is a simple loop copying data from a UCSPI server (file descriptor 0) to a client, and from a client to a server (FD 1). If either socket closes, .B ucspi-proxy exits. The other .B ucspi-proxy-* programs are based on this simple loop and have similar usage. If .I HOST and .I PORT are given on the command line, .B ucspi-proxy will make a TCP connection with the given parameters. If neither are present, .B ucspi-proxy will use file descriptor 6 for the client socket, as provided by UCSPI client programs. .SH OPTIONS .TP .I \-l MAXLINE The maximum length of lines (from either server or client) to copy to the log. Defaults to 64. .TP .I \-t TIMEOUT When making an connection, .B ucspi-proxy will wait a maximum of .I TIMEOUT seconds before giving up. Defaults to 30. .TP .I \-v Print messages about errors and byte counts. Without this option, .B ucspi-proxy is silent. .SH RETURN VALUE Exits 0 if a normal end of file was reached on one of the sockets. Otherwise it exits 1. .SH SEE ALSO ucspi-unix, ucspi-tcp ucspi-proxy-0.99/auth-lib.c0000664000076400007640000000514612122145100015165 0ustar bruceguenter#include #include #include #include #include #include #include #include #include "auth-lib.h" #include "ucspi-proxy.h" extern const char* local_name; str username = {0,0,0}; static bool saw_auth_login = 0; static bool saw_auth_plain = 0; static str tmpstr; static str msgstr; void make_username(const char* start, ssize_t len, const char* msgprefix) { str_copyb(&username, start, len); if (local_name && str_findfirst(&username, AT) < 0) { str_catc(&username, AT); str_cats(&username, local_name); } str_copy2s(&msgstr, msgprefix, username.s); log_line(msgstr.s, msgstr.len); } static const char* skipspace(const char* ptr) { while (*ptr == ' ') ++ptr; return ptr; } static int iseol(char ch) { return ch == CR || ch == LF; } static void handle_auth_login_response(str* line, ssize_t offset) { saw_auth_login = 0; if (!base64decode(line->s + offset, line->len + offset, &tmpstr)) username.len = 0; else { make_username(tmpstr.s, tmpstr.len, "AUTH LOGIN "); line->len = offset; base64encode(username.s, username.len, line); str_catb(line, CRLF, 2); } } static void handle_auth_plain_response(str* line, ssize_t offset) { int start; int end; saw_auth_plain = 0; if (base64decode(line->s + offset, line->len - offset, &tmpstr)) { /* tmpstr should now contain "AUTHORIZATION\0AUTHENTICATION\0PASSWORD" */ if ((start = str_findfirst(&tmpstr, NUL)) >= 0 && (end = str_findnext(&tmpstr, NUL, ++start)) > start) { make_username(tmpstr.s + start, end - start, "AUTH PLAIN "); str_splice(&tmpstr, start, end - start, &username); line->len = offset; base64encode(tmpstr.s, tmpstr.len, line); str_catb(line, CRLF, 2); } } } int handle_auth_response(str* line, ssize_t offset) { if (saw_auth_login) handle_auth_login_response(line, offset); else if (saw_auth_plain) handle_auth_plain_response(line, offset); else return 0; return 1; } int handle_auth_parameter(str* line, ssize_t offset) { const char* ptr; ptr = skipspace(line->s + offset); /* No parameter, so just pass it through. */ if (iseol(*ptr)) return 0; if (strncasecmp(ptr, "LOGIN", 5) == 0) { if (ptr[5] == ' ' && !iseol(*(ptr = skipspace(ptr + 5)))) handle_auth_login_response(line, ptr - line->s); else saw_auth_login = 1; } else if (strncasecmp(ptr, "PLAIN", 5) == 0) { if (ptr[5] == ' ' && !iseol(*(ptr = skipspace(ptr + 5)))) handle_auth_plain_response(line, ptr - line->s); else saw_auth_plain = 1; } return 1; } ucspi-proxy-0.99/ucspi-proxy.1.html0000664000076400007640000000423612122145100016642 0ustar bruceguenterContent-type: text/html Manpage of ucspi-proxy

ucspi-proxy

Section: User Commands (1)
Index Return to Main Contents
 

NAME

ucspi-proxy - Copy data between a UCSPI client and server  

SYNOPSIS

ucspi-proxy [ -v ] [ -t TIMEOUT ] [ HOST PORT ]  

DESCRIPTION

This program is a simple loop copying data from a UCSPI server (file descriptor 0) to a client, and from a client to a server (FD 1). If either socket closes, ucspi-proxy exits. The other ucspi-proxy-* programs are based on this simple loop and have similar usage.

If HOST and PORT are given on the command line, ucspi-proxy will make a TCP connection with the given parameters. If neither are present, ucspi-proxy will use file descriptor 6 for the client socket, as provided by UCSPI client programs.  

OPTIONS

-l MAXLINE
The maximum length of lines (from either server or client) to copy to the log. Defaults to 64.
-t TIMEOUT
When making an connection, ucspi-proxy will wait a maximum of TIMEOUT seconds before giving up. Defaults to 30.
-v
Print messages about errors and byte counts. Without this option, ucspi-proxy is silent.
 

RETURN VALUE

Exits 0 if a normal end of file was reached on one of the sockets. Otherwise it exits 1.  

SEE ALSO

ucspi-unix, ucspi-tcp


 

Index

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
RETURN VALUE
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 20:27:44 GMT, March 19, 2013 ucspi-proxy-0.99/ChangeLog0000664000076400007640000014345012122145100015067 0ustar bruceguentercommit 9c050d2b0ca9469a291679a1280b71ccd6baba32 Author: Bruce Guenter Date: Mon Nov 16 15:57:15 2009 -0600 Add the plain ucspi-proxy to the installed programs INSTHIER | 1 + NEWS | 2 ++ 2 files changed, 3 insertions(+), 0 deletions(-) commit dc2309791851ff61712694ab58eafa35d1a2300f Author: Bruce Guenter Date: Mon Nov 16 15:43:55 2009 -0600 Fix imap-filter.c for older compilers There was a C99 type variable initialization in filter_server_data that came after another statement. New compilers handle this, but old ones choke. imap-filter.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) commit f58097018937dbd09dec3b86e95a60b4375b9295 Author: Bruce Guenter Date: Mon Nov 16 15:02:29 2009 -0600 Fix the man page for ucspi-proxy to match current usage ucspi-proxy.1 | 38 ++++++++++++++++++++++++++++++++------ 1 files changed, 32 insertions(+), 6 deletions(-) commit 600e21cffe2f08c98012b3db82d65189f97435e4 Author: Bruce Guenter Date: Mon Nov 16 14:08:57 2009 -0600 Support both UCSPI client and internal TCP connection NEWS | 3 +++ ucspi-proxy.c | 17 +++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) commit 35a6a54af98261b732dfbda8f034171cfb8cbb5a Author: Bruce Guenter Date: Fri Mar 6 10:54:38 2009 -0600 Merged the POP3 and IMAP auth filter functions. auth-lib.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++ auth-lib.h | 13 ++++++ imap-filter.c | 111 +++++++--------------------------------------------- pop3-filter.c | 111 +++++++-------------------------------------------- ucspi-proxy-imap=x | 1 + ucspi-proxy-pop3=x | 1 + 6 files changed, 151 insertions(+), 192 deletions(-) create mode 100644 auth-lib.c create mode 100644 auth-lib.h commit a1ad991f1f884e6ee727d09316ddaec4c6fa15ba Author: Bruce Guenter Date: Fri Mar 6 10:54:27 2009 -0600 Added note about IMAP additions in the NEWS. NEWS | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) commit dc394846cb5a76ec0a1835869be6513437b2a3f2 Author: Bruce Guenter Date: Fri Mar 6 10:53:32 2009 -0600 Fixed NULL pointer dereference when accepting relay clients with unknown username. relay-filter.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) commit 4384fb2e22200a8ecbddfe8e220e357ea5229ab1 Author: Bruce Guenter Date: Thu Mar 5 19:52:49 2009 -0600 Added the AUTHENTICATE LOGIN/PLAIN handling from pop3-filter to imap-filter imap-filter.c | 102 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 77 insertions(+), 25 deletions(-) commit d69e45f3aeb8c8801c419e9c3d17629c1dc68c6c Author: Bruce Guenter Date: Thu Mar 5 16:27:08 2009 -0600 Break up filter_client_line into subroutines in imap-filter imap-filter.c | 94 ++++++++++++++++++++++++++++++++------------------------ 1 files changed, 54 insertions(+), 40 deletions(-) commit cdc3c1db667deacd3db9afcc023b8f05d81e1237 Author: Bruce Guenter Date: Wed Mar 4 21:14:29 2009 -0600 Reordered the IMAP filter to make sure auth responses get handled. imap-filter.c | 40 +++++++++++++++++++++------------------- 1 files changed, 21 insertions(+), 19 deletions(-) commit 2a9a8f1bb00e41fe4c8077ea42ff712311e2b049 Author: Bruce Guenter Date: Wed Mar 4 16:16:33 2009 -0600 Switch the IMAP filter to line buffer the client input, like the POP filter. imap-filter.c | 91 +++++++++++++++++++++++++++++++++------------------------ 1 files changed, 53 insertions(+), 38 deletions(-) commit 3aaac6ca1ca723a24e714859e4c75e9c6e3030f0 Author: Bruce Guenter Date: Wed Feb 25 09:58:34 2009 -0600 Undo the previous strict single-space changes to pop3-filter. This makes the parser more resilient to whitespace abuse or attacks. pop3-filter.c | 24 ++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 deletions(-) commit 0e599de67a1623073a04fba81ead21e444196512 Author: Bruce Guenter Date: Wed Feb 25 09:57:28 2009 -0600 Be a little pickier with decoding base64 data. Data must end either at the end of size bytes, or with a newline. base64.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-) commit c6a74266edc2d572c2001b2e52f1ff4fda32de12 Author: Bruce Guenter Date: Wed Feb 25 09:36:03 2009 -0600 Fix handling of the command "AUTH " in pop3-filter. The logic would think this was the start of an authentication command, and set the state appropriately, but never get a valid username. When the +OK was received from the server, this would cause a crash due to the username being NULL. pop3-filter.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) commit 1b50da5af9dc585fc85bc3479ffb1048bff17ccc Author: Bruce Guenter Date: Tue Feb 24 21:57:56 2009 -0600 Moved some character constants into the header file. http-xlate-filter.c | 5 +---- pop3-filter.c | 6 ------ ucspi-proxy.h | 8 ++++++++ 3 files changed, 9 insertions(+), 10 deletions(-) commit b595c94c4ad71c17d9ae60f8a0743f596a301642 Author: Bruce Guenter Date: Tue Feb 24 16:48:44 2009 -0600 Simplify the POP3 logic a bit. POP3 parameters must be separated by a single space. Skipping multiple whitespace characters is completely unnecessary. pop3-filter.c | 31 +++++++------------------------ 1 files changed, 7 insertions(+), 24 deletions(-) commit 6e410048870f2a968619dca73dad75b99a57c81b Author: Bruce Guenter Date: Tue Feb 24 16:39:10 2009 -0600 Added note about POP3 AUTH changes to NEWS. NEWS | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) commit c0f73752b0981d40850580a3f55ee1801ba5020f Author: Bruce Guenter Date: Tue Feb 24 16:38:28 2009 -0600 Bumped version to 0.98 NEWS | 5 +++++ VERSION | 2 +- 2 files changed, 6 insertions(+), 1 deletions(-) commit 4a7cf7ef034b9e910cb2de1246c72cd16d49f3b5 Author: Bruce Guenter Date: Tue Feb 24 16:37:53 2009 -0600 Handle POP3 AUTH LOGIN and PLAIN initial responses. pop3-filter.c | 52 ++++++++++++++++++++++++++++++++-------------------- 1 files changed, 32 insertions(+), 20 deletions(-) commit 145506a452980a7e6172063ae173026c6da9f9b7 Author: Bruce Guenter Date: Tue Feb 24 16:33:41 2009 -0600 Handle recoding the user name in POP3 AUTH LOGIN and PLAIN responses. base64.c | 5 ++ pop3-filter.c | 114 +++++++++++++++++++++++++++++++++++++++++++++----------- ucspi-proxy.h | 1 + 3 files changed, 97 insertions(+), 23 deletions(-) commit bd5476621a31df65d7bca817f1baad9176c71d3a Author: Bruce Guenter Date: Tue Feb 24 15:55:25 2009 -0600 Converted the POP3 filter to fully handle split/merged lines from the client. pop3-filter.c | 62 ++++++++++++++++++++++++++++++++------------------------ 1 files changed, 35 insertions(+), 27 deletions(-) commit f0039c42fdb253a6fc0d0201f72fae05ecfb09ae Author: Bruce Guenter Date: Tue Feb 24 14:42:29 2009 -0600 Added base64 to the ucspi-proxy.a library. base64.c | 2 ++ imap-filter.c | 2 -- pop3-filter.c | 2 -- ucspi-proxy-imap=x | 1 - ucspi-proxy-pop3=x | 1 - ucspi-proxy.h | 5 +++++ ucspi-proxy=l | 3 ++- 7 files changed, 9 insertions(+), 7 deletions(-) commit d37bc1a25fcbcc77c928256a756627bc84eba1e8 Author: Bruce Guenter Date: Tue Feb 24 14:38:53 2009 -0600 Switch base64 decoding to use parts of bglibs' base64 code. base64.c | 46 +++++++++++----------------------------------- 1 files changed, 11 insertions(+), 35 deletions(-) commit 86899d693ad8fa3619427ff8b6e0eb931b8e6165 Author: Bruce Guenter Date: Tue Feb 24 14:23:21 2009 -0600 Switch base64decode to send output to a str. base64.c | 19 +++++++++---------- imap-filter.c | 8 ++++---- pop3-filter.c | 6 +++--- 3 files changed, 16 insertions(+), 17 deletions(-) commit 91b44bb6299e5ad1d30a7b0dc4cf88f9223fb72f Author: Bruce Guenter Date: Tue Feb 24 14:23:15 2009 -0600 Ignore generated files. .gitignore | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) create mode 100644 .gitignore commit be14c6c71b10e2d3bec1f45ef68e1316332fbd5c Author: Bruce Guenter Date: Tue Feb 24 14:22:24 2009 -0600 Update the README file. README.in | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) commit ad382ecd1e852c9bf9028a6b54455b37ff3ae850 Author: Bruce Guenter Date: Tue Feb 24 13:13:49 2009 -0600 Fix two unused argument warnings. log-filter.c | 1 + null-filter.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-) commit eb22e93b1d099f890f131cdc72e5a7786cca3805 Author: Bruce Guenter Date: Tue Feb 24 13:01:48 2009 -0600 Added missing ucspi-proxy=l file. ucspi-proxy=l | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) create mode 100644 ucspi-proxy=l commit 047c65419ed24e6a0ec480fd9b57c7b1b6b6aaeb Author: Bruce Guenter Date: Mon Dec 18 06:07:35 2006 +0000 Tagged version 0.97 commit c2b30f1d60a6f7c14a78eb208f7f3b9355b08fbf Author: Bruce Guenter Date: Mon Dec 18 05:43:47 2006 +0000 Minor tweaks to the README and spec. README.in | 2 +- spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) commit d9f29d4c4a1032bee00da731e0c16bee523d4e9b Author: Bruce Guenter Date: Mon Dec 18 05:42:14 2006 +0000 Export $USER and $DOMAIN when invoking relay-ctrl. NEWS | 1 + relay-filter.c | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletions(-) commit d8d71979496cd89875ed4a4dfe3e33fd3d2ecf32 Author: Bruce Guenter Date: Mon Dec 18 05:25:46 2006 +0000 Bumped version to 0.97 NEWS | 6 ++++++ VERSION | 2 +- 2 files changed, 7 insertions(+), 1 deletions(-) commit 89cde797020d94acfa0f479b6befbceb46ec2141 Author: Bruce Guenter Date: Thu Aug 18 18:57:19 2005 +0000 Fixed install mechanism in spec. spec | 11 ++++------- 1 files changed, 4 insertions(+), 7 deletions(-) commit f22f65856d49826a4670e4f14cae9ce8ab76d965 Author: Bruce Guenter Date: Thu Aug 18 18:54:43 2005 +0000 Fixed type ${_tmppath} to %{_tmppath} in spec. spec | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) commit a46b8047bcaba7ae1c97187697388604d547348f Author: Bruce Guenter Date: Thu Aug 18 18:53:39 2005 +0000 Removed TODO note about catching SIGCHLD, since we already do it. TODO | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-) commit 936d6b121f73b10d289e9753b04ffc0ed3cb31db Author: Bruce Guenter Date: Thu Aug 18 18:51:30 2005 +0000 Added note about bglibs requirement. README.in | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) commit e7a5edc479d9641b93c8415e349f9d6f5f0a1bbf Author: Bruce Guenter Date: Thu Aug 18 18:50:57 2005 +0000 Removed extraneous alarm catch call in relay-filter.c relay-filter.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) commit ec261382ba662317c8331f5666de2058df587573 Author: Bruce Guenter Date: Thu Aug 18 18:24:40 2005 +0000 Renamed some parameters to avoid global-local name conflicts. http-xlate-filter.c | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-) commit 036e77834294f6ccddc977c300b776e7db075ff2 Author: Bruce Guenter Date: Thu Aug 18 18:22:15 2005 +0000 Updated email addresses, copyright year, requirements, etc. README.in | 4 ++-- TODO | 4 ++++ spec | 8 ++++---- 3 files changed, 10 insertions(+), 6 deletions(-) commit 9006ca497a1b5d0cb2ee22217f636fd774522521 Author: Bruce Guenter Date: Thu Aug 18 18:18:24 2005 +0000 Switched to new bg-installer install mechanism. INSTHIER | 10 ++++++++++ insthier.c | 18 ------------------ 2 files changed, 10 insertions(+), 18 deletions(-) create mode 100644 INSTHIER delete mode 100644 insthier.c commit 27cc56eaa65d4ca3ec39299786ac5038045ad746 Author: Bruce Guenter Date: Sat Mar 6 03:33:41 2004 +0000 Make note that the command is optional in the command-line usage. ucspi-proxy-imap.c | 2 +- ucspi-proxy-pop3.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) commit ff56668bbae23cb6931256fbe9d2565a7c650604 Author: Bruce Guenter Date: Sat Mar 6 03:32:39 2004 +0000 Run the command in the background (instead of waiting for it) in case it takes non-trivial time to exit. relay-filter.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) commit 603558189502f8234f5a648d6ab47a04a96428b7 Author: Bruce Guenter Date: Sat Mar 6 03:05:48 2004 +0000 use iopoll_restart to make sure errant signals don't kill the proxy. ucspi-proxy.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) commit 3e3e106b05daba07b2f609a509da7301c3ebc511 Author: Bruce Guenter Date: Wed Mar 3 16:43:48 2004 +0000 Since the server socket is opened in non-blocking mode, make sure to poll for writeability before actually writing. This fixes problems with uploading large messages to slow IMAP servers. ucspi-proxy.c | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) commit 0bd17fc6e3b8cd42cd7be875504d5cc6f885ea80 Author: Bruce Guenter Date: Fri Feb 27 20:43:00 2004 +0000 Always show the byte counts on exit. ucspi-proxy.c | 26 ++++++++++++-------------- 1 files changed, 12 insertions(+), 14 deletions(-) commit 97aa0888abb94405b4e75ddfe876f9df0c569746 Author: Bruce Guenter Date: Fri Feb 27 20:42:38 2004 +0000 Make write_client and write_server use a common retry write function. ucspi-proxy.c | 20 ++++++++++++-------- 1 files changed, 12 insertions(+), 8 deletions(-) commit 7cfb12a32aa2e88c3186aa951d52607e122112dc Author: Bruce Guenter Date: Fri Feb 27 20:27:20 2004 +0000 Changes to messages: 1) always show error messages 2) give filters appropriate names ucspi-proxy.c | 34 +++++++++++++++++----------------- 1 files changed, 17 insertions(+), 17 deletions(-) commit f818fda673db25171b0e3e9880f608c67fe691e6 Author: Bruce Guenter Date: Fri Feb 27 20:15:49 2004 +0000 Only emit the relay messages if opt_verbose is set. relay-filter.c | 23 ++++++++++++++--------- 1 files changed, 14 insertions(+), 9 deletions(-) commit 12d4c874d860f1550ca3eb9bd678e5f57b7dec54 Author: Bruce Guenter Date: Fri Feb 27 19:00:29 2004 +0000 Changed name and semantics of add_filter to set_filter (replace if exists). ftp-filter.c | 8 ++++---- http-xlate-filter.c | 4 ++-- imap-filter.c | 4 ++-- log-filter.c | 4 ++-- null-filter.c | 4 ++-- pop3-filter.c | 4 ++-- relay-filter.c | 6 ++---- ucspi-proxy.c | 15 ++++++++++++++- ucspi-proxy.h | 2 +- 9 files changed, 31 insertions(+), 20 deletions(-) commit ea621c0a1289594855993ce91e546e12d3048869 Author: Bruce Guenter Date: Fri Feb 27 17:42:55 2004 +0000 Fixed up what really needs to be done. TODO | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) commit 8613f970a8115d9e61b99aa2f7f7ecc4cbfe0a87 Author: Bruce Guenter Date: Fri Feb 27 17:15:41 2004 +0000 Provide better byte counters. ucspi-proxy.c | 31 ++++++++++++++++++++++--------- 1 files changed, 22 insertions(+), 9 deletions(-) commit c7805de295e0c4f921df8634b95265a9765c86a3 Author: Bruce Guenter Date: Fri Feb 27 06:20:36 2004 +0000 Converted opt_verbose to a counter instead of just a flag. ucspi-proxy.c | 4 ++-- ucspi-proxy.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) commit db2fc64ac9637a6f7e5a0299026619493c1b97bd Author: Bruce Guenter Date: Fri Feb 27 05:38:12 2004 +0000 Handle quoted usernames. imap-filter.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) commit 68b1d381d469ef06021d9cfed33986da85889877 Author: Bruce Guenter Date: Thu Feb 26 23:06:41 2004 +0000 Added missing makedist.py script. makedist.py | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-) create mode 100644 makedist.py commit c340a07a88df7bc7395349f79b9bb93e1adebb11 Author: Bruce Guenter Date: Thu Feb 26 23:06:26 2004 +0000 Added manual targets to insthier. insthier.c | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-) commit b471d568c7b773759a5457e28fe2e8ae82819e38 Author: Bruce Guenter Date: Thu Feb 26 23:06:07 2004 +0000 Modernized spec, including use of installer/instcheck. spec | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) commit 3743d6522d087226c8c2bfed4219e3fc7dcadadd Author: Bruce Guenter Date: Thu Feb 26 23:04:30 2004 +0000 Converted to templated README. README => README.in | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) rename README => README.in (65%) commit 37968e55e0572a5ef97a615c6d6afbe9feb23e17 Author: Bruce Guenter Date: Thu Feb 26 17:44:51 2004 +0000 Replaced usages of stdio with iobuf/fmt/msg calls. ftp-filter.c | 27 +++++++++++++++++++++------ http-xlate-filter.c | 5 ----- relay-filter.c | 15 ++++++--------- ucspi-proxy.c | 35 ++++++++++++++++++++++++++--------- ucspi-proxy.h | 18 ------------------ 5 files changed, 53 insertions(+), 47 deletions(-) commit 900b43cc47f867e0d4b9610dbdc1365fbc6c1a02 Author: Bruce Guenter Date: Thu Feb 26 17:09:37 2004 +0000 Switch to use of bglibs 1.015 and libbg.a spec | 1 + ucspi-proxy-http-xlate=x | 6 +----- ucspi-proxy-imap=x | 6 +----- ucspi-proxy-log=x | 6 +----- ucspi-proxy-pop3=x | 6 +----- ucspi-proxy=x | 6 +----- 6 files changed, 6 insertions(+), 25 deletions(-) commit 53cb0abd6406ba88a8acdd10fb35473f9eb92058 Author: Bruce Guenter Date: Tue Jan 27 17:15:36 2004 +0000 Since the FD handler function can potentially reorder the filter linked list, don't process any FDs after the first ready one. ucspi-proxy.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) commit 57f24697c6da29350e3f70af4e641062a5716b5e Author: Bruce Guenter Date: Tue Jan 27 17:13:30 2004 +0000 Use a temporary str buffer to write out the error message all in one go. ucspi-proxy-http-xlate=x | 1 + ucspi-proxy-log=x | 1 + ucspi-proxy.c | 11 ++++++++--- ucspi-proxy=x | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) commit b1f61da426de55432508e522b0dc8f47bb9a771b Author: Bruce Guenter Date: Tue Jan 27 16:12:33 2004 +0000 Look up port names with getservbyname. tcp-connect.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) commit a3d0c594439a1d7f0c19d574a829518ba95c406d Author: Bruce Guenter Date: Tue Jan 27 06:03:20 2004 +0000 Accept timeout as a command-line option instead of env var. tcp-connect.c | 12 +----------- ucspi-proxy.c | 17 ++++++++++++++--- ucspi-proxy.h | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) commit d727a2e894a96c2408aa52f26e41b51babe72356 Author: Bruce Guenter Date: Mon Jan 26 23:59:03 2004 +0000 Take host/port parameters from command-line instead of environment variables. ftp-proxy | 6 +++--- imap-proxy | 5 ++--- log-proxy | 6 +++--- pop3-proxy | 5 ++--- tcp-connect.c | 22 ++++++---------------- tcp-proxy | 6 +++--- ucspi-proxy.c | 7 +++++-- ucspi-proxy.h | 2 +- 8 files changed, 25 insertions(+), 34 deletions(-) commit a9dcdddd479048c167cd20488ffb1edf9d115127 Author: Bruce Guenter Date: Mon Jan 26 23:36:24 2004 +0000 Allow specification of a host name instead of just numerical IP through $PROXY_CONNECT_HOST. tcp-connect.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) commit 742e04a464f2903cd35f8366320298210323404f Author: Bruce Guenter Date: Mon Jan 26 23:05:27 2004 +0000 Fixed several bugs in handling of the username. pop3-filter.c | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-) commit e3f7a705115232454403e3ad11aca24ca56055d1 Author: Bruce Guenter Date: Mon Jan 26 22:56:21 2004 +0000 Added hostname suffixing support to the IMAP proxy. NEWS | 6 +++--- imap-filter.c | 21 ++++++++++++++++++--- ucspi-proxy-imap.c | 6 +++++- 3 files changed, 26 insertions(+), 7 deletions(-) commit 288e4deeb3889ea73a0a0cd8edb2465d5082662e Author: Bruce Guenter Date: Mon Jan 26 22:46:37 2004 +0000 Fixed typo in prototype for pop3_filter_init. ucspi-proxy-pop3.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) commit ac76e911ac413109b4eca49087077eb99aee17ad Author: Bruce Guenter Date: Mon Jan 26 22:41:27 2004 +0000 When the command isn't present, relay_command will be a NULL pointer, making this buggy test cause a seg fault. relay-filter.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) commit 207fc9001f53e1ceb19a1c3205589f32a9518305 Author: Bruce Guenter Date: Mon Jan 26 22:40:45 2004 +0000 Make sure to ignore EAGAIN or EINTR errors when reading from a FD. ucspi-proxy.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) commit d2465dea39f04da9594cc117c2e1389404a8e4f9 Author: Bruce Guenter Date: Mon Jan 26 21:39:40 2004 +0000 Moved primary initialization routine to main C file. imap-filter.c | 7 +------ ucspi-proxy-imap.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) commit 1a6161e520dede71eaca68767b533c9a37599cab Author: Bruce Guenter Date: Mon Jan 26 21:37:37 2004 +0000 Converted to using string functions instead of manual memory management. imap-filter.c | 44 +++++++++++++++++++------------------------- ucspi-proxy-imap=x | 3 ++- 2 files changed, 21 insertions(+), 26 deletions(-) commit 3798fdaff18421a576ec0f043606300383250f05 Author: Bruce Guenter Date: Mon Jan 26 21:16:04 2004 +0000 Renamed imap-relay-filter to imap-filter, and ucspi-proxy-imap-relay to just ucspi-proxy-imap. The username fixups will come as a later step. imap-relay-filter.c => imap-filter.c | 0 imap-relay-proxy => imap-proxy | 11 ++++++----- ucspi-proxy-imap-relay.c => ucspi-proxy-imap.c | 0 ucspi-proxy-imap-relay=x => ucspi-proxy-imap=x | 0 4 files changed, 6 insertions(+), 5 deletions(-) rename imap-relay-filter.c => imap-filter.c (100%) rename imap-relay-proxy => imap-proxy (56%) rename ucspi-proxy-imap-relay.c => ucspi-proxy-imap.c (100%) rename ucspi-proxy-imap-relay=x => ucspi-proxy-imap=x (100%) commit 0ea3942d24fcb39df21329a7045f56c83f32f07e Author: Bruce Guenter Date: Mon Jan 26 21:11:15 2004 +0000 Added hostname suffixing support to the POP3 proxy, removing the "relay" from the filename since it does more than just relay control now. NEWS | 3 + pop3-relay-filter.c => pop3-filter.c | 60 ++++++++++++++--------- pop3-relay-proxy => pop3-proxy | 11 ++-- ucspi-proxy-pop3-relay.c | 4 -- ucspi-proxy-pop3.c | 20 ++++++++ ucspi-proxy-pop3-relay=x => ucspi-proxy-pop3=x | 3 +- 6 files changed, 67 insertions(+), 34 deletions(-) rename pop3-relay-filter.c => pop3-filter.c (55%) rename pop3-relay-proxy => pop3-proxy (56%) delete mode 100644 ucspi-proxy-pop3-relay.c create mode 100644 ucspi-proxy-pop3.c rename ucspi-proxy-pop3-relay=x => ucspi-proxy-pop3=x (77%) commit f314be6343098d63b29a9ec6bf30d114eded1c71 Author: Bruce Guenter Date: Mon Jan 26 20:18:38 2004 +0000 Reverted much of the previous relay filter change. In particular, the command now goes on the command line again, but the delay parameter has been moved to an environment variable. NEWS | 2 ++ imap-relay-filter.c | 2 +- pop3-relay-filter.c | 2 +- relay-filter.c | 22 +++++++++++----------- ucspi-proxy-imap-relay.c | 2 +- ucspi-proxy-pop3-relay.c | 2 +- ucspi-proxy.h | 2 +- 7 files changed, 18 insertions(+), 16 deletions(-) commit d192e39b4ada450531422150105affc796d19d4c Author: Bruce Guenter Date: Mon Jan 26 19:25:33 2004 +0000 Introduced a typedef for the filter/eof functions; used that typedef to get rid of some erroneous type differences. http-xlate-filter.c | 2 +- null-filter.c | 4 ++-- relay-filter.c | 4 ++-- ucspi-proxy.c | 6 +++--- ucspi-proxy.h | 6 ++++-- 5 files changed, 12 insertions(+), 10 deletions(-) commit 48ba2800a006eebca351804102fc66802862e6f9 Author: Bruce Guenter Date: Mon Jan 26 18:30:04 2004 +0000 Modified relay-ctrl to pull its configuration from environment variables. imap-relay-filter.c | 7 ++----- pop3-relay-filter.c | 7 ++----- relay-filter.c | 37 ++++++++++++++++++++++++------------- ucspi-proxy-imap-relay.c | 2 +- ucspi-proxy-pop3-relay.c | 2 +- ucspi-proxy.h | 5 +++++ 6 files changed, 35 insertions(+), 25 deletions(-) commit 2538c6f2cca9d7dcd8c08ddb1af9c83db6a24abb Author: Bruce Guenter Date: Sun Jan 25 05:20:52 2004 +0000 Added spac version file. VERSION | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 VERSION commit f374d0d43c2761930080cfec45792a5d52147fa7 Author: Bruce Guenter Date: Sun Jan 25 05:17:00 2004 +0000 Since tcpclient is no longer overwriting environment variables, the relay filter can rely on $TCPREMOTEIP again. relay-filter.c | 5 ++--- ucspi-proxy-imap-relay.c | 2 +- ucspi-proxy-pop3-relay.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) commit 4d9cf082e85efb3d607dbf4dc07b94fe9a4a497e Author: Bruce Guenter Date: Sun Jan 25 05:12:19 2004 +0000 Moved the server connect handler into the proxy program. NEWS | 4 +++ ftp-filter.c | 2 +- http-xlate-filter.c | 6 ++++- imap-relay-filter.c | 5 +++- log-filter.c | 5 +++- null-filter.c | 7 ++++- pop3-relay-filter.c | 5 +++- relay-filter.c | 4 +- tcp-connect.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++ ucspi-proxy-http-xlate=x | 6 ++++- ucspi-proxy-imap-relay=x | 6 ++++- ucspi-proxy-log=x | 6 ++++- ucspi-proxy-pop3-relay=x | 6 ++++- ucspi-proxy.c | 35 +++++++++++++++++++++----- ucspi-proxy.h | 14 +++++++--- ucspi-proxy=x | 5 ++++ 16 files changed, 152 insertions(+), 23 deletions(-) create mode 100644 tcp-connect.c commit 66022b317027e6195b89f7ac596a954585af6b87 Author: Bruce Guenter Date: Sun Jan 25 04:23:17 2004 +0000 Moved the program and filter_usage strings into their own source file to complete the spac build requirements. http-xlate-filter.c | 2 -- imap-relay-filter.c | 3 --- log-filter.c | 3 --- pop3-relay-filter.c | 3 --- ucspi-proxy-http-xlate.c | 4 ++++ ucspi-proxy-imap-relay.c | 4 ++++ ucspi-proxy-log.c | 4 ++++ ucspi-proxy-pop3-relay.c | 4 ++++ 8 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 ucspi-proxy-http-xlate.c create mode 100644 ucspi-proxy-imap-relay.c create mode 100644 ucspi-proxy-log.c create mode 100644 ucspi-proxy-pop3-relay.c commit 53d4b45468fc5cb5604271dacf01f631e5fc53db Author: Bruce Guenter Date: Sat Jan 24 18:13:02 2004 +0000 Added necessary install script. insthier.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) create mode 100644 insthier.c commit 204848ab3695b92b9d8965a7c84f70d153613587 Author: Bruce Guenter Date: Sat Jan 24 18:12:38 2004 +0000 Switched to spac to build the Makefile automatically. Makefile | 71 ---------------------------------------------- ucspi-proxy-http-xlate=x | 2 + ucspi-proxy-imap-relay=x | 4 ++ ucspi-proxy-log=x | 2 + ucspi-proxy-pop3-relay=x | 4 ++ ucspi-proxy=x | 1 + 6 files changed, 13 insertions(+), 71 deletions(-) delete mode 100644 Makefile create mode 100644 ucspi-proxy-http-xlate=x create mode 100644 ucspi-proxy-imap-relay=x create mode 100644 ucspi-proxy-log=x create mode 100644 ucspi-proxy-pop3-relay=x create mode 100644 ucspi-proxy=x commit e3f3d8ab7c7d70a0d86daf4cf24c5bcd9bf515f0 Author: Bruce Guenter Date: Sat Jan 24 17:47:26 2004 +0000 Renamed filter_name to program to match bglibs usage, and changed type of filter_usage to const char[]. ftp-filter.c | 6 +++--- http-xlate-filter.c | 3 +-- imap-relay-filter.c | 4 ++-- log-filter.c | 4 ++-- null-filter.c | 4 ++-- pop3-relay-filter.c | 4 ++-- relay-filter.c | 8 ++++---- ucspi-proxy.c | 4 ++-- ucspi-proxy.h | 24 ++++++++++++------------ 9 files changed, 30 insertions(+), 31 deletions(-) commit ee20060d6ec4384e99f702531bec289d1a5f4586 Author: Bruce Guenter Date: Wed Jan 21 23:40:29 2004 +0000 Allow the server FD numbers to be overridden. ucspi-proxy.c | 4 ++++ ucspi-proxy.h | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) commit 9d9d3a89e1cb7fe87b907137a83dcafa34e6a890 Author: Bruce Guenter Date: Thu Nov 27 22:50:40 2003 +0000 *** empty log message *** TODO | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) commit 2b9410e6a3140eb7d8d95e9606f59be5364e73a5 Author: Bruce Guenter Date: Thu Mar 15 19:37:32 2001 +0000 *** empty log message *** NEWS | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) commit ea6e50d08c669bd854e208b8923fe6927c1f0bbc Author: Bruce Guenter Date: Thu Mar 15 19:37:29 2001 +0000 Updated the list URL. makedist.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) commit 7b0f0d661089b4b9d2f3f5218360b26b1e8fbbda Author: Bruce Guenter Date: Thu Mar 15 19:32:40 2001 +0000 Write the PID with all output messages. ucspi-proxy.c | 7 +++---- ucspi-proxy.h | 13 ++++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) commit 634e7bf1c16778e3c4000855223fe08013bd51de Author: Bruce Guenter Date: Wed Dec 20 20:39:13 2000 +0000 *** empty log message *** Makefile | 14 +++++++------- README | 4 ++-- makedist.in | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) commit 5e97f856ee448a6cdbd878c07f5652db24c61353 Author: Bruce Guenter Date: Wed Dec 20 20:37:24 2000 +0000 Parse and display the username on login. Makefile | 13 ++++++--- NEWS | 5 +++ base64.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++ imap-relay-filter.c | 44 ++++++++++++++++++++++++++------ pop3-relay-filter.c | 38 +++++++++++++++++++++++----- relay-filter.c | 11 ++++++-- 6 files changed, 156 insertions(+), 24 deletions(-) create mode 100644 base64.c commit 45ce3b5db3fdf4b8276fb08f80154b01f1d3b9c8 Author: Bruce Guenter Date: Thu Dec 14 22:32:46 2000 +0000 *** empty log message *** makedist.in | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) commit 338ca3602e385123041b3e35cd6eebe172ccb50f Author: Bruce Guenter Date: Thu Dec 14 22:31:57 2000 +0000 Updated date. README | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) commit 22af7a3b499f873dec4bba14c05ab2b1bbb4a254 Author: Bruce Guenter Date: Thu Dec 14 22:31:21 2000 +0000 Added man page for ucspi-proxy-http-xlate. Makefile | 2 +- ucspi-proxy-http-xlate.1 | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletions(-) create mode 100644 ucspi-proxy-http-xlate.1 commit a350de8704454590ee76ba21cfc816d2444edab8 Author: Bruce Guenter Date: Thu Dec 14 22:30:12 2000 +0000 Added note about ucspi-http-xlate-proxy. NEWS | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) commit f3aed109321c291bf2070f8b274d4266586ba5ca Author: Bruce Guenter Date: Thu Dec 14 22:20:05 2000 +0000 Added a translating HTTP filter. Makefile | 7 +- http-xlate-filter.c | 339 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 345 insertions(+), 1 deletions(-) create mode 100644 http-xlate-filter.c commit 4082baefb267beff9b77f3b8992836e81930645d Author: Bruce Guenter Date: Thu Dec 14 22:19:45 2000 +0000 Renamed the DEBUG* macros to MSG, and added some new DEBUG macros. ucspi-proxy.c | 16 ++++++---------- ucspi-proxy.h | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 10 deletions(-) commit cb931c57c395e1ba8301c20bf5582ca01214ad46 Author: Bruce Guenter Date: Fri Oct 13 04:42:20 2000 +0000 Fixed a bug in write_client that treated a short write as a failure. Makefile | 2 +- NEWS | 5 +++++ README | 4 ++-- ucspi-proxy.c | 16 +++++++++++++--- 4 files changed, 21 insertions(+), 6 deletions(-) commit 4371afd97feec7642ae748eaeb76e0d03f7910ab Author: Bruce Guenter Date: Fri Oct 6 16:19:18 2000 +0000 *** empty log message *** Makefile | 2 +- README | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) commit 850cc3c47b6b5e750ebcbd51dfffa71647f0fcbd Author: Bruce Guenter Date: Fri Oct 6 16:05:48 2000 +0000 Made the relay rerun delay and command into command-line arguments. NEWS | 9 +++++++++ imap-relay-filter.c | 8 +++----- imap-relay-proxy | 3 ++- pop3-relay-filter.c | 6 ++---- pop3-relay-proxy | 3 ++- relay-filter.c | 23 +++++++++++++++++------ 6 files changed, 35 insertions(+), 17 deletions(-) commit e1792ece6ddbbd5bd4129f1719c96b76e9ef0098 Author: Bruce Guenter Date: Fri Oct 6 16:04:37 2000 +0000 Fixed a couple of bugs. Makefile | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) commit 45a3b8ea11695569e30ba999c7e4f652897bf0dd Author: Bruce Guenter Date: Mon Oct 2 18:59:05 2000 +0000 *** empty log message *** Makefile | 2 +- NEWS | 8 ++++++++ README | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) commit 998305970857a35fb76659bf352baac9576ec19e Author: Bruce Guenter Date: Mon Oct 2 18:54:56 2000 +0000 Added support for POP3 CRAM-MD5 authentication. pop3-relay-filter.c | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) commit 4ab255a6341acff94c7a543cb2c61afaccc9c99b Author: Bruce Guenter Date: Mon Oct 2 18:41:24 2000 +0000 Ignore several harmless signals that could otherwise crash the proxy. ucspi-proxy.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) commit 673141ea6ffce5ab4698ed9ededdd31946f83fce Author: Bruce Guenter Date: Thu Sep 21 20:05:49 2000 +0000 *** empty log message *** README | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) commit a501d775811427e9acb69f927fd363165bdbc882 Author: Bruce Guenter Date: Wed Sep 20 19:38:17 2000 +0000 Compacted the options to tcpserver and tcpclient. ftp-proxy | 4 ++-- imap-relay-proxy | 4 ++-- log-proxy | 4 ++-- pop3-relay-proxy | 4 ++-- tcp-proxy | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) commit b159a4988a74d50a58d7b0ff6b56e2e0d78f7218 Author: Bruce Guenter Date: Tue Sep 19 17:23:39 2000 +0000 Fixed bug in handling the AUTHENTICATE command sequence. imap-relay-filter.c | 48 +++++++++++++++++++++++++----------------------- 1 files changed, 25 insertions(+), 23 deletions(-) commit a5121de74e0d6baa5ed6013246895a216a9e0bb4 Author: Bruce Guenter Date: Tue Sep 19 17:23:18 2000 +0000 Added logging via relay-filter.c pop3-relay-filter.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) commit 7a21f48037e78da3d7430ed3fdd3e9b563052053 Author: Bruce Guenter Date: Tue Sep 19 17:23:03 2000 +0000 Added logging. relay-filter.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) commit 066b1e2a6e75e59bcde9f90545ab99c28cf7c47c Author: Bruce Guenter Date: Tue Sep 19 16:15:34 2000 +0000 *** empty log message *** Makefile | 3 ++- NEWS | 2 +- README | 2 +- makedist.in | 15 ++++++--------- 4 files changed, 10 insertions(+), 12 deletions(-) commit e54db66e868fdec7e7703e081aee138283c65a09 Author: Bruce Guenter Date: Tue Sep 19 16:11:57 2000 +0000 Renamed the duplicate "true". relay-filter.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) commit 300fd340bac5a56127759d54d5e35056d0fdbc79 Author: Bruce Guenter Date: Tue Sep 19 16:07:49 2000 +0000 Moved the various paths and time constants to the start of the file. relay-filter.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) commit 8e398948afa177ec21e1336e4f3a7ccca1581711 Author: Bruce Guenter Date: Tue Sep 19 16:08:44 2000 +0000 Documentation updates. NEWS | 4 ++-- README | 7 +++++-- TODO | 4 ++++ 3 files changed, 11 insertions(+), 4 deletions(-) commit e67334bd21a990fad893a82b6eb96994e2ba0000 Author: Bruce Guenter Date: Tue Sep 19 16:00:56 2000 +0000 Renamed accept_ip to accept_client for relay control. imap-relay-filter.c | 6 +++--- pop3-relay-filter.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) commit e537873bf6e85e3b7d100ea0de9ca029e4a25976 Author: Bruce Guenter Date: Tue Sep 19 16:00:05 2000 +0000 Added code to re-run relay-ctrl-allow every 5 minutes. relay-filter.c | 34 ++++++++++++++++++++++++---------- 1 files changed, 24 insertions(+), 10 deletions(-) commit bab13353d914d1d28713bbeae88362858fad714a Author: Bruce Guenter Date: Tue Sep 19 15:59:42 2000 +0000 Fixed problem with handling signals during select. ucspi-proxy.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) commit fc14f19f92cac4d99accaec8293988b89f414658 Author: Bruce Guenter Date: Mon Sep 18 23:28:06 2000 +0000 Completed POP3 relay, started IMAP relay filters. Makefile | 25 ++++++++++++---- imap-relay-filter.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++ pop3-relay-filter.c | 29 ++++++------------ relay-filter.c | 30 ++++++++++++++++++ 4 files changed, 141 insertions(+), 25 deletions(-) create mode 100644 imap-relay-filter.c create mode 100644 relay-filter.c commit 92760c39ad82d20e37cb87354b22fdf14e2dc74c Author: Bruce Guenter Date: Mon Sep 18 23:27:32 2000 +0000 Fixed usage to add a prefix to executing the ucspi-proxy-* programs. Added scripts for imap-relay and pop3-relay. ftp-proxy | 17 ++++++++--------- imap-relay-proxy | 14 ++++++++++++++ log-proxy | 3 ++- pop3-relay-proxy | 14 ++++++++++++++ tcp-proxy | 3 ++- 5 files changed, 40 insertions(+), 11 deletions(-) create mode 100755 imap-relay-proxy create mode 100755 pop3-relay-proxy commit 0937cade78b6b6623acfa52f983a7dc907f08a4e Author: Bruce Guenter Date: Mon Sep 18 23:25:34 2000 +0000 Added proxy usage string to filters. ftp-filter.c | 1 + log-filter.c | 1 + null-filter.c | 1 + ucspi-proxy.c | 2 +- ucspi-proxy.h | 1 + 5 files changed, 5 insertions(+), 1 deletions(-) commit 5944de5deea8beb9c763db72ede0a274e90da581 Author: Bruce Guenter Date: Mon Sep 18 19:58:04 2000 +0000 Completed basic POP3 relay implementation. Makefile | 13 ++++++++++--- pop3-relay-filter.c | 16 +++++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) commit 9e5e1bf9d45473942261bdf658b5228db202c4c9 Author: Bruce Guenter Date: Fri Sep 15 22:46:38 2000 +0000 *** empty log message *** NEWS | 4 ++-- makedist.in | 4 ++-- ucspi-proxy.h | 14 +++++++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) commit f82534e533c40abe5a0d520c56baa930b51cd350 Author: Bruce Guenter Date: Fri Sep 15 22:46:32 2000 +0000 Started a SMTP-after-POP3 relaying filter. log-filter.c => pop3-relay-filter.c | 26 ++++++++++++-------------- 1 files changed, 12 insertions(+), 14 deletions(-) copy log-filter.c => pop3-relay-filter.c (59%) commit aac771f313ea181b2c3ad8e497490093fe8228f1 Author: Bruce Guenter Date: Fri Sep 15 22:46:15 2000 +0000 Continuing progress on this filter. ftp-filter.c | 195 +++++++++++++++++++++++++++++++++------------------------- 1 files changed, 112 insertions(+), 83 deletions(-) commit 324686516c549eda5564b6b989c09f93b968d04f Author: Bruce Guenter Date: Fri Sep 15 22:45:34 2000 +0000 Overhauled the I/O system. log-filter.c | 30 ++++++++------ null-filter.c | 10 +---- ucspi-proxy.c | 115 ++++++++++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 112 insertions(+), 43 deletions(-) commit 6aaa71ee2f751c44e3d2097b5fe9ac1aa424d67d Author: Bruce Guenter Date: Fri Jul 7 19:30:15 2000 +0000 Added filter_name global to filter modules, used in all output. ftp-filter.c | 3 +++ log-filter.c | 2 ++ null-filter.c | 2 ++ ucspi-proxy.c | 12 +++++------- ucspi-proxy.h | 12 ++++++++---- 5 files changed, 20 insertions(+), 11 deletions(-) commit 65f7c994bbf8a9366c673565042c9cd4b5dd216c Author: Bruce Guenter Date: Fri Jul 7 17:13:35 2000 +0000 Further work on FTP proxy code. NEWS | 3 + TODO | 3 +- ftp-filter.c | 194 +++++++++++++++++++++++++++++++++++++++++++--------------- 3 files changed, 149 insertions(+), 51 deletions(-) commit 5e16a676fefd96e7dffb003bd0f0f234d21fbbd3 Author: Bruce Guenter Date: Fri Jul 7 17:13:02 2000 +0000 Turned multiply-defined true/false constants into macros. ucspi-proxy.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) commit 87508fc69664d7200b67b843b86f53c39bde9067 Author: Bruce Guenter Date: Thu Jul 6 21:48:54 2000 +0000 Renamed ucspi-proxy-null back to just ucspi-proxy. Makefile | 4 ++-- tcp-proxy | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) commit 7aae6f815578fd9f1e39427c311a428d0118a73d Author: Bruce Guenter Date: Thu Jul 6 21:47:59 2000 +0000 Renamed plain ucspi-proxy to ucspi-proxy-null Started implementation of FTP proxy. Makefile | 6 ++-- NEWS | 4 ++- ftp-filter.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- tcp-proxy | 2 +- 4 files changed, 91 insertions(+), 6 deletions(-) commit b3d0ffd4e6a44e1efd0d0469c095fbb139b64f55 Author: Bruce Guenter Date: Thu Jul 6 21:43:22 2000 +0000 Added new logging proxy. Makefile | 9 ++++++--- tcp-proxy => ftp-proxy | 2 +- log-filter.c | 38 ++++++++++++++++++++++++++++++++++++++ tcp-proxy => log-proxy | 2 +- 4 files changed, 46 insertions(+), 5 deletions(-) copy tcp-proxy => ftp-proxy (95%) create mode 100644 log-filter.c copy tcp-proxy => log-proxy (95%) mode change 100755 => 100644 commit b3f1a4e91191118cc75bdcf2fdb2caa790da2f58 Author: Bruce Guenter Date: Thu Jul 6 21:23:58 2000 +0000 Add an extra (unused) NUL byte to the data buffer for string searches in filter. Add definition of BUFSIZE to ucspi-proxy.h. ucspi-proxy.c | 4 ++-- ucspi-proxy.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) commit 73ec8bf356a86311e6b00c46398e2c04f52e1429 Author: Bruce Guenter Date: Wed Jun 28 22:29:33 2000 +0000 *** empty log message *** NEWS | 5 +++++ makedist.in | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) commit bceb0fa2df0b41bceff01ee6785e5fecdd05afd8 Author: Bruce Guenter Date: Wed Jun 28 22:29:02 2000 +0000 Added build rules for FTP proxy. Makefile | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) commit 4ee063756a7610cb4783f47bb090b5e8f079b3fc Author: Bruce Guenter Date: Wed Jun 28 22:27:46 2000 +0000 Fixed missing options. tcp-proxy | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) commit bcfd30558aa8bda9f8a8fdb07762e132171e8283 Author: Bruce Guenter Date: Wed Jun 28 22:27:19 2000 +0000 Fixed typo. tcp-proxy | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) commit 716f642bd93aafd119d536f1a28a77ace5622dac Author: Bruce Guenter Date: Wed Jun 21 20:32:30 2000 +0000 *** empty log message *** makedist.in | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) commit 5911bf488c8384e70088e5785b26e3a47a808f7a Author: Bruce Guenter Date: Wed Jun 21 19:35:35 2000 +0000 *** empty log message *** Makefile | 4 ++-- makedist.in | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) commit 7457af6ba26f6e7ad145432c19d838deef648967 Author: Bruce Guenter Date: Wed Jun 21 19:33:34 2000 +0000 Added RPM spec. spec | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 insertions(+), 0 deletions(-) create mode 100644 spec commit 3bc517ff68dd9fc617b01a7bd2d5e4f28484a768 Author: Bruce Guenter Date: Wed Jun 21 19:31:20 2000 +0000 *** empty log message *** Makefile | 3 +-- makedist.in | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) commit e5fc0dddac5ac8c14de0fcd1f0295957a32b95be Author: Bruce Guenter Date: Wed Jun 21 19:29:03 2000 +0000 Finalized the proxy module API and build model. Makefile | 6 +++--- filter.h | 14 -------------- ftp-filter.c | 16 ++++------------ null-filter.c | 20 ++++++++++++++++++++ ucspi-proxy.c | 15 +++++++++------ ucspi-proxy.h | 10 ++++++++++ 6 files changed, 46 insertions(+), 35 deletions(-) delete mode 100644 filter.h create mode 100644 null-filter.c create mode 100644 ucspi-proxy.h commit 9054ffa2f3d781ea159c7b0f961ad1985e49c0c6 Author: Bruce Guenter Date: Wed Jun 21 19:10:39 2000 +0000 Prepared package for distribution. COPYING | 340 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 35 +++++- README | 25 +++++ TODO | 2 + makedist.in | 43 ++++++++ 5 files changed, 440 insertions(+), 5 deletions(-) create mode 100644 COPYING create mode 100644 NEWS create mode 100644 README create mode 100644 TODO create mode 100644 makedist.in commit 02c33cc61d4b2671f1bf94c5f3d004e254fbb5c0 Author: Bruce Guenter Date: Wed Jun 21 19:00:53 2000 +0000 Use "envuidgid", and fix a documentation typo. tcp-proxy | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) commit fd50dff5b9eb0dc2db53b107e87a450239207019 Author: Bruce Guenter Date: Thu Jun 15 23:06:25 2000 +0000 Added a proxy filter framework. filter.h | 14 ++++++++++++++ ftp-filter.c | 26 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 0 deletions(-) create mode 100644 filter.h create mode 100644 ftp-filter.c commit d13b4d2fee73f6486c58435168e6d3053277031b Author: Bruce Guenter Date: Thu Jun 15 22:51:34 2000 +0000 Added man page, parse options. ucspi-proxy.1 | 24 ++++++++++++++++++++++++ ucspi-proxy.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 ucspi-proxy.1 commit af78b15672091b4c62f924b7cf9637ed9c1500fe Author: Bruce Guenter Date: Thu Jun 15 05:57:01 2000 +0000 Initial revision Makefile | 12 ++++++++++++ tcp-proxy | 16 ++++++++++++++++ ucspi-proxy.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 0 deletions(-) create mode 100644 Makefile create mode 100755 tcp-proxy create mode 100644 ucspi-proxy.c ucspi-proxy-0.99/VERSION0000664000076400007640000000002112122145100014347 0ustar bruceguenterucspi-proxy 0.99 ucspi-proxy-0.99/null-filter.c0000664000076400007640000000075312122145100015714 0ustar bruceguenter#include #include #include #include "ucspi-proxy.h" const char program[] = "ucspi-proxy"; const char filter_usage[] = ""; const char filter_connfail_prefix[] = ""; const char filter_connfail_suffix[] = "\r\n"; void filter_init(int argc, char** argv) { if(argc > 0) usage("Too many arguments."); set_filter(CLIENT_IN, (filter_fn)write_server, 0); set_filter(SERVER_FD, (filter_fn)write_client, 0); (void)argv; } void filter_deinit(void) { } ucspi-proxy-0.99/auth-lib.h0000664000076400007640000000047512122145100015172 0ustar bruceguenter#ifndef AUTH_LIB__H__ #define AUTH_LIB__H__ struct str; extern struct str username; extern void make_username(const char* start, ssize_t len, const char* msgprefix); extern int handle_auth_response(struct str* line, ssize_t offset); extern int handle_auth_parameter(struct str* line, ssize_t offset); #endif ucspi-proxy-0.99/AUTOFILES0000664000076400007640000000013612122145100014564 0ustar bruceguenterAUTOFILES Makefile SRCFILES TARGETS conf-bgincs conf-bglibs conf-bin conf-cc conf-ld conf-man ucspi-proxy-0.99/ucspi-proxy.h0000664000076400007640000000303012122145100015755 0ustar bruceguenter#ifndef UCSPI_PROXY__H__ #define UCSPI_PROXY__H__ #include #ifndef CRLF #define CR '\r' #define LF '\n' #define CRLF "\r\n" #endif #define AT '@' #define NUL '\0' #define BUFSIZE 4096 #define MAXLINE 64 #define CLIENT_IN 0 #define CLIENT_OUT 1 extern int SERVER_FD; struct str; typedef int bool; #define true ((bool)(0==0)) #define false ((bool)0) typedef void (*filter_fn)(char*, ssize_t); typedef void (*eof_fn)(void); /* Functions and globals declared by the filter */ extern const char program[]; extern const char filter_usage[]; extern const char filter_connfail_prefix[]; extern const char filter_connfail_suffix[]; extern void filter_init(int argc, char** argv); extern void filter_deinit(void); /* Functions from base64.c */ extern int base64decode(const char* data, unsigned long size, struct str* dest); extern int base64encode(const char* data, unsigned long size, struct str* dest); /* Functions from ucspi-proxy.c */ extern void usage(const char*); extern int opt_verbose; extern pid_t pid; extern void write_client(const char*, ssize_t); extern void write_server(const char*, ssize_t); extern bool set_filter(int fd, filter_fn filter, eof_fn at_eof); extern bool del_filter(int fd); extern void log_line(const char* data, ssize_t size); /* Functions from tcp-connect.c */ extern int tcp_connect(const char*, const char*, unsigned); /* Functions from relay-filter.c */ extern void relay_init(int argc, char* argv[]); extern void accept_client(const char* username); extern void deny_client(const char* username); #endif ucspi-proxy-0.99/conf-cc0000664000076400007640000000014112122145100014535 0ustar bruceguentergcc -W -Wall -Wshadow -O -g -I/usr/local/include -DDEBUG This will be used to compile .c files. ucspi-proxy-0.99/relay-filter.c0000664000076400007640000000534312122145100016056 0ustar bruceguenter#include #include #include #include #include #include #include #include #include #include "ucspi-proxy.h" static unsigned relay_rerun_delay; static const char* client_ip; static char** relay_command; static void run_relay_ctrl(void) { /* Run relay-ctrl-allow to allow the client's IP to relay */ const pid_t p = fork(); switch (p) { case -1: error1sys("Could not fork"); return; case 0: execvp(relay_command[0], relay_command); exit(1); } } static void catch_child(int ignored) { waitpid(-1, 0, WNOHANG); ignored = 0; } static void catch_alarm(int ignored) { if (relay_command == 0) return; /* Run the relay-ctrl process, and then set it up to re-run */ if (opt_verbose) msg2("Running ", relay_command[0]); run_relay_ctrl(); alarm(relay_rerun_delay); ignored = 0; } void relay_init(int argc, char* argv[]) { char* tmp; client_ip = getenv("TCPREMOTEIP"); if (argc >= 1) { relay_command = argv; if ((tmp = getenv("PROXY_RELAY_INTERVAL")) != 0) { relay_rerun_delay = strtoul(tmp, &tmp, 10); if (*tmp != 0) usage("Delay parameter is not a positive number"); } if (relay_rerun_delay == 0) relay_rerun_delay = 300; } } static void setenvb(const char* name, const char* value, size_t len) { char* s; size_t nlen = strlen(name); if ((s = malloc(len + nlen + 2)) == 0) die_oom(111); memcpy(s, name, nlen); s[nlen++] = '='; memcpy(s + nlen, value, len); s[nlen + len] = 0; if (putenv(s) != 0) die_oom(111); } /* Export the username through $USER and $DOMAIN */ static void export_client(const char* username) { const char* at; if ((at = strrchr(username, '@')) == 0) { setenvb("USER", username, strlen(username)); setenvb("DOMAIN", 0, 0); } else { setenvb("USER", username, at - username); ++at; setenvb("DOMAIN", at, strlen(at)); } } void accept_client(const char* username) { if (opt_verbose) { if (username) msg5("Accepted relay client ", client_ip, ", username '", username, "'"); else msg3("Accepted relay client ", client_ip, ", username unknown"); } if (username) export_client(username); /* Turn off all further filtering, as this IP has already authenticated */ set_filter(CLIENT_IN, (filter_fn)write_server, 0); set_filter(SERVER_FD, (filter_fn)write_client, 0); sig_child_catch(catch_child); sig_alarm_catch(catch_alarm); catch_alarm(0); } void deny_client(const char* username) { if (opt_verbose) { if (username) msg5("Failed login from ", client_ip, ", username '", username, "'"); else msg3("Failed login from ", client_ip, ", username unknown"); } } ucspi-proxy-0.99/conf-bgincs0000664000076400007640000000003212122145100015414 0ustar bruceguenter/usr/local/bglibs/include ucspi-proxy-0.99/pop3-filter.c0000664000076400007640000000360612122145100015623 0ustar bruceguenter#include #include #include #include #include #include #include #include "auth-lib.h" #include "ucspi-proxy.h" const char filter_connfail_prefix[] = "-ERR "; const char filter_connfail_suffix[] = "\r\n"; extern const char* local_name; static bool saw_command = 0; static str linebuf; static void handle_user(void) { const char* ptr; const char* end; saw_command = 0; ptr = linebuf.s + 5; while (*ptr == ' ') ++ptr; end = linebuf.s + linebuf.len - 1; while (isspace(*end)) --end; make_username(ptr, end - ptr + 1, "USER "); str_copys(&linebuf, "USER "); str_cat(&linebuf, &username); str_catb(&linebuf, CRLF, 2); } static void handle_pass(void) { saw_command = 1; } static void filter_client_line(void) { if (!handle_auth_response(&linebuf, 0)) { if (str_case_starts(&linebuf, "PASS ")) handle_pass(); else if (str_case_starts(&linebuf, "AUTH ")) saw_command = handle_auth_parameter(&linebuf, 5); else if (str_case_starts(&linebuf, "USER ")) handle_user(); } } static void filter_client_data(char* data, ssize_t size) { char* lf; while ((lf = memchr(data, LF, size)) != 0) { str_catb(&linebuf, data, lf - data + 1); filter_client_line(); write_server(linebuf.s, linebuf.len); linebuf.len = 0; size -= lf - data + 1; data = lf + 1; } str_catb(&linebuf, data, size); } static void filter_server_data(char* data, ssize_t size) { if (saw_command) { log_line(data, size); if (!strncasecmp(data, "+OK ", 4)) { accept_client(username.s); saw_command = 0; } else if (!strncasecmp(data, "-ERR ", 5)) { deny_client(username.s); saw_command = 0; } } write_client(data, size); } void pop3_filter_init(void) { set_filter(CLIENT_IN, filter_client_data, 0); set_filter(SERVER_FD, filter_server_data, 0); } ucspi-proxy-0.99/NEWS0000664000076400007640000000645712122145100014021 0ustar bruceguenter------------------------------------------------------------------------------- Changes in version 0.99 - Added logging of final response to authentication commands. - Fixed core bug in command-line argument handling which prevented use of relay-ctrl. - Fixed exporting client environment variables when not in verbose mode. Development of this version has been sponsored by FutureQuest, Inc. ossi@FutureQuest.net http://www.FutureQuest.net/ ------------------------------------------------------------------------------- Changes in version 0.98 - Added support for rewriting usernames in POP3 and IMAP AUTH LOGIN and PLAIN commands and subsequent responses. - Modified the core library to work either with a UCSPI client or with the internal TCP connection support. - Added the plain ucspi-proxy to the installed programs. Development of this version has been sponsored by FutureQuest, Inc. ossi@FutureQuest.net http://www.FutureQuest.net/ ------------------------------------------------------------------------------- Changes in version 0.97 - Export $USER and $DOMAIN when invoking relay-ctrl. Development of this version has been sponsored by FutureQuest, Inc. ossi@FutureQuest.net http://www.FutureQuest.net/ ------------------------------------------------------------------------------- Changes in version 0.96 - Major internal rewrite. - Moved the server connect handler into the proxy program. This allows for useful custom error messages (including system error strings) when the connection fails. - Add the PID to all output messages, to allow for correlation. - Moved the "delay" parameter from the relay filters to an environment variable, defaulting to 5 minutes. - Added hostname suffixing support to the POP3 and IMAP proxies, removing the "relay" from their filenames since they do more than just relay control now. ------------------------------------------------------------------------------- Changes in version 0.95 - The relay proxy programs now parse the username and display it (including extracting data from base64-encoded strings). ------------------------------------------------------------------------------- Changes in version 0.94 - Added a translating HTTP proxy. - Fixed a bug in the core ucspi-proxy client write routine that treated an interrupted (short) write as a failure. ------------------------------------------------------------------------------- Changes in version 0.93 - The relay proxy programs now take the relay rerun delay and relay authorization command as command-line parameters, rather than being hard-coded into the programs. - Fixed a bug in the Makefile that would make "make install" fail if you didn't run "make" first. ------------------------------------------------------------------------------- Changes in version 0.92 - Added support in the POP3 relay proxy for the "AUTH" command, used by CRAM-MD5 logins. - All proxies now ignore several harmless signals that otherwise would kill the proxy. ------------------------------------------------------------------------------- Changes in version 0.91 - Added POP3 and IMAP proxies which trigger relay-ctrl-allow on successful logins. - Added logging proxy, which writes all data to stderr. - Fixed typo in tcp-proxy script. ------------------------------------------------------------------------------- ucspi-proxy-0.99/INSTHIER0000664000076400007640000000033312122145100014455 0ustar bruceguenter>bin c:::755::ucspi-proxy c:::755::ucspi-proxy-http-xlate c:::755::ucspi-proxy-imap c:::755::ucspi-proxy-log c:::755::ucspi-proxy-pop3 >man d:::755:man1 c:::644:man1:ucspi-proxy-http-xlate.1 c:::644:man1:ucspi-proxy.1 ucspi-proxy-0.99/ucspi-proxy-0.99.spec0000664000076400007640000000165212122145100017065 0ustar bruceguenterName: ucspi-proxy Summary: Connection proxy for UCSPI tools Version: 0.99 Release: 1 License: GPL Group: Utilities/System Source: http://untroubled.org/ucspi-proxy/ucspi-proxy-%{version}.tar.gz BuildRoot: %{_tmppath}/ucspi-proxy-root URL: http://untroubled.org/ucspi-proxy/ Packager: Bruce Guenter BuildRequires: bglibs >= 1.025 %description This package contains a proxy program that passes data back and forth between two connections set up by a UCSPI server and a UCSPI client. %prep %setup %build echo "gcc $RPM_OPT_FLAGS" >conf-cc echo "gcc $RPM_OPT_FLAGS -s" >conf-ld echo %{_bindir} >conf-bin echo %{_mandir} >conf-man make %install rm -fr $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/%{_bindir} mkdir -p $RPM_BUILD_ROOT/%{_mandir} make install install_prefix=$RPM_BUILD_ROOT %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) %doc ANNOUNCEMENT COPYING NEWS README TODO %{_bindir}/* %{_mandir}/*/* ucspi-proxy-0.99/Makefile0000664000076400007640000000674412122145100014761 0ustar bruceguenter# Don't edit Makefile! Use conf-* for configuration. # # Generated by spac see http://untroubled.org/spac/ SHELL=/bin/sh DEFAULT: all all: libraries programs docs auth-lib.o: compile auth-lib.c auth-lib.h ucspi-proxy.h ./compile auth-lib.c base64.o: compile base64.c ucspi-proxy.h ./compile base64.c clean: TARGETS rm -f `cat TARGETS` clean-spac: clean AUTOFILES rm -f `cat AUTOFILES` compile: conf-cc conf-bgincs ( bgincs=`head -n 1 conf-bgincs`; \ echo '#!/bin/sh'; \ echo 'source=$$1; shift'; \ echo 'base=`echo "$$source" | sed -e s:\\\\.c$$::`'; \ echo exec `head -n 1 conf-cc` -I. "-I'$${bgincs}'" '-o $${base}.o -c $$source $${1+"$$@"}'; \ ) >compile chmod 755 compile docs: ucspi-proxy.1.html ucspi-proxy-http-xlate.1.html http-xlate-filter.o: compile http-xlate-filter.c ucspi-proxy.h ./compile http-xlate-filter.c imap-filter.o: compile imap-filter.c auth-lib.h ucspi-proxy.h ./compile imap-filter.c install: INSTHIER conf-bin conf-man bg-installer -v load chmod 755 load log-filter.o: compile log-filter.c ucspi-proxy.h ./compile log-filter.c makelib: ( echo '#!/bin/sh'; \ echo 'lib="$$1"; shift';\ echo 'rm -f "$$lib"';\ echo 'ar cr "$$lib" $${1+"$$@"}';\ echo 'ranlib "$$lib"';\ ) >makelib chmod 755 makelib null-filter.o: compile null-filter.c ucspi-proxy.h ./compile null-filter.c pop3-filter.o: compile pop3-filter.c auth-lib.h ucspi-proxy.h ./compile pop3-filter.c programs: ucspi-proxy-pop3 ucspi-proxy-http-xlate ucspi-proxy ucspi-proxy-log ucspi-proxy-imap relay-filter.o: compile relay-filter.c ucspi-proxy.h ./compile relay-filter.c tcp-connect.o: compile tcp-connect.c ucspi-proxy.h ./compile tcp-connect.c ucspi-proxy: ucspi-proxy.o load null-filter.o ucspi-proxy.a ./load ucspi-proxy null-filter.o ucspi-proxy.a -lbg ucspi-proxy-http-xlate: ucspi-proxy-http-xlate.o load http-xlate-filter.o ucspi-proxy.a ./load ucspi-proxy-http-xlate http-xlate-filter.o ucspi-proxy.a -lbg ucspi-proxy-http-xlate.1.html: ucspi-proxy-http-xlate.1 man2html ucspi-proxy-http-xlate.1 >ucspi-proxy-http-xlate.1.html ucspi-proxy-http-xlate.o: compile ucspi-proxy-http-xlate.c ucspi-proxy.h ./compile ucspi-proxy-http-xlate.c ucspi-proxy-imap: ucspi-proxy-imap.o load imap-filter.o relay-filter.o auth-lib.o ucspi-proxy.a ./load ucspi-proxy-imap imap-filter.o relay-filter.o auth-lib.o ucspi-proxy.a -lbg ucspi-proxy-imap.o: compile ucspi-proxy-imap.c ucspi-proxy.h ./compile ucspi-proxy-imap.c ucspi-proxy-log: ucspi-proxy-log.o load log-filter.o ucspi-proxy.a ./load ucspi-proxy-log log-filter.o ucspi-proxy.a -lbg ucspi-proxy-log.o: compile ucspi-proxy-log.c ucspi-proxy.h ./compile ucspi-proxy-log.c ucspi-proxy-pop3: ucspi-proxy-pop3.o load pop3-filter.o relay-filter.o auth-lib.o ucspi-proxy.a ./load ucspi-proxy-pop3 pop3-filter.o relay-filter.o auth-lib.o ucspi-proxy.a -lbg ucspi-proxy-pop3.o: compile ucspi-proxy-pop3.c ucspi-proxy.h ./compile ucspi-proxy-pop3.c ucspi-proxy.1.html: ucspi-proxy.1 man2html ucspi-proxy.1 >ucspi-proxy.1.html ucspi-proxy.a: makelib base64.o tcp-connect.o ucspi-proxy.o ./makelib ucspi-proxy.a base64.o tcp-connect.o ucspi-proxy.o ucspi-proxy.o: compile ucspi-proxy.c ucspi-proxy.h ./compile ucspi-proxy.c ucspi-proxy-0.99/ucspi-proxy-imap.c0000664000076400007640000000056112122145100016702 0ustar bruceguenter#include #include "ucspi-proxy.h" const char program[] = "ucspi-proxy-imap"; const char filter_usage[] = "[command [args ...]]"; const char* local_name = 0; extern void imap_filter_init(void); void filter_init(int argc, char** argv) { local_name = getenv("TCPLOCALHOST"); relay_init(argc, argv); imap_filter_init(); } void filter_deinit(void) { } ucspi-proxy-0.99/ucspi-proxy-http-xlate.10000664000076400007640000000126612122145100017767 0ustar bruceguenter.TH ucspi-proxy-http-xlate 1 .SH NAME ucspi-proxy-http-xlate \- Translating HTTP proxy .SH SYNOPSIS .B ucspi-proxy-http-xlate [ .B -v ] .I search replace [ search replace [...]] .SH DESCRIPTION .B ucspi-proxy-http-xlate is a HTTP proxy for a UCSPI client/server pair that can translate strings within HTTP content on the fly. All occurrences of .I search are replaced with .IR replace . If the HTTP response from the server contained a .B Content-Length header, it is replaced with the length of the translated content. .SH SEE ALSO ucspi-proxy(1) .SH CAVEATS All content is translated. This could cause some odd side-effects if a search string is found in a binary response, such as an image. ucspi-proxy-0.99/README0000664000076400007640000000244612122145100014174 0ustar bruceguenterucspi-proxy Connection proxy for UCSPI tools Bruce Guenter Version 0.99 2013-03-19 This package contains a proxy program that passes data back and forth between two connections set up by a UCSPI server and a UCSPI client. A mailing list has been set up to discuss this and other packages. To subscribe, send an email to: bgware-subscribe@lists.untroubled.org A mailing list archive is available at: http://lists.untroubled.org/?list=bgware Development versions of ucspi-proxy are available via git at: git://untroubled.org/git/ucspi-proxy.git Requirements: - bglibs version 1.025 or later How to install: - As root, run "make install" Usage: The simple usage is: UCSPIserver [address] UCSPIclient [address] ucspi-proxy Replace "UCSPIserver" with the program that will accept connections, and "UCSPIclient" with the program that will make connections. See the "tcp-proxy" script for a TCP-TCP proxy example. To make the POP3 and IMAP relay proxies work, you may need to edit the constants at the top of the relay-filter.c file. This program is Copyright(C) 2013 Bruce Guenter, and may be copied according to the GNU GENERAL PUBLIC LICENSE (GPL) Version 2 or a later version. A copy of this license is included with this package. This package comes with no warranty of any kind. ucspi-proxy-0.99/log-filter.c0000664000076400007640000000163312122145100015521 0ustar bruceguenter#include #include #include "ucspi-proxy.h" const char filter_connfail_prefix[] = ""; const char filter_connfail_suffix[] = "\r\n"; static void show(const char* data, ssize_t size, char prefix) { ssize_t i; static char buf[BUFSIZE+4]; char* ptr = buf; *ptr++ = prefix; *ptr++ = ' '; for(i = 0; i < size; i++) *ptr++ = data[i]; if(data[size-1] != '\n') *ptr++ = '+'; *ptr++ = '\n'; write(2, buf, ptr-buf); } static void filter_client_data(char* data, ssize_t size) { show(data, size, '>'); write_server(data, size); } static void filter_server_data(char* data, ssize_t size) { show(data, size, '<'); write_client(data, size); } void filter_init(int argc, char** argv) { if(argc > 0) usage("Too many arguments."); set_filter(CLIENT_IN, filter_client_data, 0); set_filter(SERVER_FD, filter_server_data, 0); (void)argv; } void filter_deinit(void) { }