Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef VIRTUAL
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
- #include <netdb.h>
- #include <stdio.h>
- #include "pop3.h"
- /* Real globals used in other files. */
- int virtual_mode=0;
- extern char *svr_hostname;
- char *virt_spooldir=0;
- char *virt_workdir=0;
- /* Local globals only seen in this file */
- static struct sockaddr_in virtual_addr;
- static struct sockaddr_in *virtual_ptr;
- struct virttable {
- char *ipaddr;
- char *spooldir;
- char *workdir;
- };
- static struct virttable virt_table[]={
- {"127.0.0.1", "/usr/spool/mail/", "/usr/tmp/.pop/"},
- {"204.181.147.2", "/usr/spool/mail/", "/usr/tmp/.pop/"},
- {NULL, NULL}
- };
- void
- get_virt(char *ip) {
- int i;
- if(virtual_mode) {
- for(i=0; virt_table[i].ipaddr; ++i) {
- if( !strcmp(virt_table[i].ipaddr,ip) ) {
- virt_workdir = virt_table[i].workdir;
- virt_spooldir= virt_table[i].spooldir;
- return;
- }
- } /* end for */
- } /* end if*/
- return;
- } /* end get_virt */
- void
- virt_init() {
- int virtual_len;
- char *cptr;
- struct hostent *hostent;
- virtual_len = sizeof(virtual_addr);
- if (getsockname(0, (struct sockaddr *) &virtual_addr,
- &virtual_len) >= 0) {
- virtual_mode = 1;
- virtual_ptr = (struct sockaddr_in *) &virtual_addr;
- free(svr_hostname);
- cptr = inet_ntoa(virtual_ptr->sin_addr);
- if(hostent=gethostbyaddr((char *) &virtual_ptr->sin_addr,
- sizeof(struct in_addr),AF_INET)) {
- svr_hostname = malloc(strlen(hostent->h_name)+1);
- if (svr_hostname == NULL)
- fail(FAIL_OUT_OF_MEMORY);
- strcpy(svr_hostname,hostent->h_name);
- } else {
- svr_hostname = malloc(strlen(cptr)+1);
- if (svr_hostname == NULL)
- fail(FAIL_OUT_OF_MEMORY);
- strcpy(svr_hostname,cptr);
- }
- }
- get_virt(cptr);
- } /* end virt_init */
- #endif
- #if 0
- unix_pass(name, passwd)
- char *name;
- char *passwd;
- {
- struct passwd *pwd;
- struct passwd *getpwnam();
- char *encpw;
- char *crypt();
- char *encrypted_pass;
- #if !defined(NOSHADOW)
- struct spwd *spwd;
- if((spwd = fgetspnam(name)) == NULL) {
- return(-1);
- }
- encrypted_pass = spwd->sp_pwdp;
- #else /* !NOSHADOW */
- if((pwd = fgetpwnam(name)) == NULL) {
- return(-1);
- }
- encrypted_pass = pwd->pw_passwd;
- #endif /* !NOSHADOW */
- encpw = crypt(passwd, encrypted_pass);
- /* Check it */
- if(strcmp(encpw, encrypted_pass)) {
- return(-1);
- }
- return(0);
- }
- struct passwd *
- fgetpwnam(char *name)
- {
- struct passwd *pw;
- FILE *fp;
- if( (fp=fopen(RAD_PASSWD,"r")) == NULL ) {
- perror("Couldn't open radius passwd file");
- exit(1);
- }
- while ( pw=fgetpwent(fp) ) {
- if( !strcmp(name,pw->pw_name) ) {
- fclose(fp);
- return( pw );
- }
- }
- fclose(fp);
- return( NULL );
- } /* end fgetpwnam */
- struct spwd *
- fgetspnam(char *name)
- {
- struct spwd *pw;
- FILE *fp;
- if( (fp=fopen(RAD_SHADOW,"r")) == NULL ) {
- perror("Couldn't open radius shadow file");
- exit(1);
- }
- while ( pw=fgetspent(fp) ) {
- if( !strcmp(name,pw->sp_namp) ) {
- fclose(fp);
- return( pw );
- }
- }
- fclose(fp);
- return( NULL );
- } /* end fgetspnam */
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement