pidentd-2.8a4
资源名称:socks5.zip [点击查看]
上传用户:sddyfurun
上传日期:2007-01-04
资源大小:525k
文件大小:4k
源码类别:
代理服务器
开发平台:
Unix_Linux
- *** parse.c.orig Mon Jul 28 16:01:28 1997
- --- parse.c Tue Nov 11 09:35:31 1997
- ***************
- *** 14,19 ****
- --- 14,20 ----
- #endif
- #include <stdio.h>
- + #include <string.h>
- #include <errno.h>
- #include <ctype.h>
- #include <pwd.h>
- ***************
- *** 35,42 ****
- --- 36,53 ----
- #endif
- #include <sys/types.h>
- + #include <sys/file.h>
- #include <sys/stat.h>
- + #ifndef AIX4
- + #include <sys/fcntl.h>
- + #endif
- + #ifndef SRVIDT_FILE
- + #define SRVIDT_FILE "/tmp/socks5.ident"
- + #endif
- +
- +
- +
- #if defined(MIPS) || defined(BSD43)
- extern int errno;
- #endif
- ***************
- *** 51,56 ****
- --- 62,68 ----
- #include "crypto.h"
- extern void *malloc();
- + extern char *getenv();
- /*
- ** This function will eat whitespace characters until
- ***************
- *** 154,159 ****
- --- 166,218 ----
- return (rcode == 0);
- }
- + char *socks_user(struct in_addr *faddr, unsigned short fport, struct in_addr *laddr, unsigned 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;
- + #ifndef HAVE_FLOCK
- + struct flock fl;
- + fl.l_type = F_RDLCK;
- + fl.l_whence = SEEK_SET;
- + fl.l_start = 0;
- + fl.l_len = 0;
- + #endif
- +
- + 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;
- + #ifndef HAVE_FLOCK
- + fcntl(fd, F_SETLKW, &fl);
- + #else
- + flock(fd, LOCK_EX);
- + #endif
- +
- + 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;
- + }
- #ifdef INCLUDE_CRYPT
- /*
- ** Checks address of incoming call against network/mask pairs of trusted
- ***************
- *** 198,203 ****
- --- 257,263 ----
- #endif
- struct in_addr laddr2;
- struct in_addr faddr2;
- + char *name;
- int k_opened;
- k_opened = 0;
- ***************
- *** 457,465 ****
- if (debug_flag && syslog_flag)
- syslog(LOG_DEBUG, " After fscanf(), before k_open()");
- if (! k_opened)
- ! {
- /*
- ** Open the kernel memory device and read the nlist table
- **
- --- 517,537 ----
- if (debug_flag && syslog_flag)
- syslog(LOG_DEBUG, " After fscanf(), before k_open()");
- + 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 {
- if (! k_opened)
- ! {
- /*
- ** Open the kernel memory device and read the nlist table
- **
- ***************
- *** 702,708 ****
- charset_name ? " , " : "",
- charset_name ? charset_name : "",
- pwp->pw_name);
- !
- } while(fflush(stdout), fflush(stderr), multi_flag && eat_whitespace());
- return 0;
- --- 774,780 ----
- charset_name ? " , " : "",
- charset_name ? charset_name : "",
- pwp->pw_name);
- ! }
- } while(fflush(stdout), fflush(stderr), multi_flag && eat_whitespace());
- return 0;