pidentd-2.7a4
资源名称:socks5.zip [点击查看]
上传用户:sddyfurun
上传日期:2007-01-04
资源大小:525k
文件大小:3k
源码类别:
代理服务器
开发平台:
Unix_Linux
- *** src/parse.c.orig Thu Aug 3 10:57:49 1995
- --- src/parse.c Thu Oct 12 18:40:20 1995
- ***************
- *** 14,19 ****
- --- 14,20 ----
- #endif
- #include <stdio.h>
- + #include <string.h>
- #include <errno.h>
- #include <ctype.h>
- #include <pwd.h>
- ***************
- *** 32,39 ****
- --- 33,45 ----
- #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
- ***************
- *** 48,53 ****
- --- 54,60 ----
- #include "crypto.h"
- extern void *malloc();
- + extern char *getenv();
- /*
- ** This function will eat whitespace characters until
- ***************
- *** 151,156 ****
- --- 158,199 ----
- return (rcode == 0);
- }
- + char *socks_user(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;
- ***************
- *** 170,175 ****
- --- 213,219 ----
- #endif
- struct in_addr laddr2;
- struct in_addr faddr2;
- + char *name;
- if (debug_flag && syslog_flag)
- ***************
- *** 425,430 ****
- --- 469,482 ----
- if (debug_flag && syslog_flag)
- syslog(LOG_DEBUG, " After fscanf(), 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 {
- /*
- ** Next - get the specific TCP connection and return the
- ** uid - user number.
- ***************
- *** 433,438 ****
- --- 485,491 ----
- ** kernel changed beneath us and we missed or took
- ** a fault.
- */
- +
- for (try = 0;
- (try < 5 &&
- k_getuid(&faddr2, htons(fport), laddr, htons(lport), &uid) == -1);
- ***************
- *** 517,523 ****
- charset_name ? " , " : "",
- charset_name ? charset_name : "",
- pwp->pw_name);
- !
- } while(fflush(stdout), fflush(stderr), multi_flag && eat_whitespace());
- return 0;
- --- 570,576 ----
- charset_name ? " , " : "",
- charset_name ? charset_name : "",
- pwp->pw_name);
- ! }
- } while(fflush(stdout), fflush(stderr), multi_flag && eat_whitespace());
- return 0;