pidentd-2.7b4
资源名称:socks5.zip [点击查看]
上传用户:sddyfurun
上传日期:2007-01-04
资源大小:525k
文件大小:3k
源码类别:
代理服务器
开发平台:
Unix_Linux
- *** src/parse.c.orig Wed Aug 14 23:02:19 1996
- --- src/parse.c Wed Aug 14 23:02:18 1996
- ***************
- *** 14,19 ****
- --- 14,20 ----
- #endif
- #include <stdio.h>
- + #include <string.h>
- #include <errno.h>
- #include <ctype.h>
- #include <pwd.h>
- ***************
- *** 35,42 ****
- --- 36,48 ----
- #endif
- #include <sys/types.h>
- + #include <sys/file.h>
- #include <sys/stat.h>
- + #ifndef SRVIDT_FILE
- + #define SRVIDT_FILE "/tmp/socks5.ident"
- + #endif
- +
- #if defined(MIPS) || defined(BSD43)
- extern int errno;
- #endif
- ***************
- *** 51,56 ****
- --- 57,63 ----
- #include "crypto.h"
- extern void *malloc();
- + extern char *getenv();
- /*
- ** This function will eat whitespace characters until
- ***************
- *** 154,159 ****
- --- 161,207 ----
- return (rcode == 0);
- }
- + char *socks_user(faddr, fport, laddr, lport)
- + struct in_addr *faddr;
- + u_short fport;
- + struct in_addr *laddr;
- + u_short lport;
- + {
- + char *myfile = getenv("SOCKS5_IDENTFILE"), *end, *fbuf, *offset;
- + char idtentry[2*16+2*6+1];
- + static char *user;
- + struct stat sb;
- + int fd;
- +
- + myfile = myfile?myfile:SRVIDT_FILE;
- + sprintf(idtentry, "%s,%d,", inet_ntoa(*faddr), fport);
- + sprintf(idtentry+strlen(idtentry), "%s,%d,", inet_ntoa(*laddr), lport);
- +
- + if (user) free(user);
- + user = NULL;
- +
- + do {
- + if ((fd = open(myfile, O_RDONLY, 0644)) < 0) break;
- + flock(fd, LOCK_EX);
- +
- + if (fstat(fd, &sb) < 0) break;
- + if ((fbuf = (char *)malloc((sb.st_size+1)*sizeof(char))) == NULL) break;
- +
- + if (read(fd, fbuf, sb.st_size) < 0) break;
- + fbuf[sb.st_size] = ' ';
- +
- + if ((offset = strstr(fbuf, idtentry)) == NULL) break;
- + if ((end = strchr(offset, 'n')) == NULL) break;
- + *end = ' ';
- +
- + user = strdup(offset + strlen(idtentry));
- + } while (0);
- +
- + if (fbuf) free(fbuf);
- + if (fd >= 0) close(fd);
- +
- + return user;
- + }
- int parse(fp, laddr, faddr)
- FILE *fp;
- ***************
- *** 179,184 ****
- --- 227,233 ----
- #endif
- struct in_addr laddr2;
- struct in_addr faddr2;
- + char *name;
- int k_opened;
- k_opened = 0;
- ***************
- *** 463,468 ****
- --- 512,525 ----
- if (debug_flag && syslog_flag)
- syslog(LOG_DEBUG, " After k_open(), before k_getuid()");
- + if ((name = socks_user(&faddr2, fport, laddr, lport)) != NULL) {
- + printf("%d , %d : USERID : %s%s%s :%srn",
- + lport, fport,
- + other_flag ? "OTHER" : "UNIX",
- + charset_name ? " , " : "",
- + charset_name ? charset_name : "",
- + name);
- + } else {
- /*
- ** Get the specific TCP connection and return the uid - user number.
- ***************
- *** 680,685 ****
- --- 737,743 ----
- charset_name ? charset_name : "",
- pwp->pw_name);
- + }
- } while(fflush(stdout), fflush(stderr), multi_flag && eat_whitespace());
- return 0;