ftpd.c (25187) | ftpd.c (25283) |
---|---|
1/* 2 * Copyright (c) 1985, 1988, 1990, 1992, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * | 1/* 2 * Copyright (c) 1985, 1988, 1990, 1992, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * |
33 * $Id: ftpd.c,v 1.36 1997/04/26 12:12:10 davidn Exp $ | 33 * $Id: ftpd.c,v 1.37 1997/04/27 08:29:21 davidn Exp $ |
34 */ 35 36#if 0 37#ifndef lint 38static char copyright[] = 39"@(#) Copyright (c) 1985, 1988, 1990, 1992, 1993, 1994\n\ 40 The Regents of the University of California. All rights reserved.\n"; 41#endif /* not lint */ --- 104 unchanged lines hidden (view full) --- 146off_t file_size; 147off_t byte_count; 148#if !defined(CMASK) || CMASK == 0 149#undef CMASK 150#define CMASK 027 151#endif 152int defumask = CMASK; /* default umask value */ 153char tmpline[7]; | 34 */ 35 36#if 0 37#ifndef lint 38static char copyright[] = 39"@(#) Copyright (c) 1985, 1988, 1990, 1992, 1993, 1994\n\ 40 The Regents of the University of California. All rights reserved.\n"; 41#endif /* not lint */ --- 104 unchanged lines hidden (view full) --- 146off_t file_size; 147off_t byte_count; 148#if !defined(CMASK) || CMASK == 0 149#undef CMASK 150#define CMASK 027 151#endif 152int defumask = CMASK; /* default umask value */ 153char tmpline[7]; |
154#ifdef VIRTUAL_HOSTING 155char *hostname; 156char *ftpuser; 157 158static struct ftphost { 159 struct ftphost *next; 160 struct in_addr hostaddr; 161 char *hostname; 162 char *anonuser; 163 char *statfile; 164 char *welcome; 165 char *loginmsg; 166} *thishost, *firsthost; 167 168#else |
|
154char hostname[MAXHOSTNAMELEN]; | 169char hostname[MAXHOSTNAMELEN]; |
170#endif |
|
155char remotehost[MAXHOSTNAMELEN]; 156char *ident = NULL; 157 158static char ttyline[20]; 159char *tty = ttyline; /* for klogin */ 160 161#ifdef KERBEROS 162int klogin __P((struct passwd *, char *, char *, char *)); --- 46 unchanged lines hidden (view full) --- 209 if (cnt == (off_t)-1) \ 210 syslog(LOG_INFO,"%s %s%s", cmd, \ 211 *(file) == '/' ? "" : curdir(), file); \ 212 else \ 213 syslog(LOG_INFO, "%s %s%s = %qd bytes", \ 214 cmd, (*(file) == '/') ? "" : curdir(), file, cnt); \ 215 } 216 | 171char remotehost[MAXHOSTNAMELEN]; 172char *ident = NULL; 173 174static char ttyline[20]; 175char *tty = ttyline; /* for klogin */ 176 177#ifdef KERBEROS 178int klogin __P((struct passwd *, char *, char *, char *)); --- 46 unchanged lines hidden (view full) --- 225 if (cnt == (off_t)-1) \ 226 syslog(LOG_INFO,"%s %s%s", cmd, \ 227 *(file) == '/' ? "" : curdir(), file); \ 228 else \ 229 syslog(LOG_INFO, "%s %s%s = %qd bytes", \ 230 cmd, (*(file) == '/') ? "" : curdir(), file, cnt); \ 231 } 232 |
233#ifdef VIRTUAL_HOSTING 234static void inithosts __P((void)); 235static void selecthost __P((struct in_addr *)); 236#endif |
|
217static void ack __P((char *)); 218static void myoob __P((int)); 219static int checkuser __P((char *, char *)); 220static FILE *dataconn __P((char *, off_t, char *)); 221static void dolog __P((struct sockaddr_in *)); 222static char *curdir __P((void)); 223static void end_login __P((void)); 224static FILE *getdatasock __P((char *)); --- 111 unchanged lines hidden (view full) --- 336 break; 337 338 default: 339 warnx("unknown flag -%c ignored", optopt); 340 break; 341 } 342 } 343 | 237static void ack __P((char *)); 238static void myoob __P((int)); 239static int checkuser __P((char *, char *)); 240static FILE *dataconn __P((char *, off_t, char *)); 241static void dolog __P((struct sockaddr_in *)); 242static char *curdir __P((void)); 243static void end_login __P((void)); 244static FILE *getdatasock __P((char *)); --- 111 unchanged lines hidden (view full) --- 356 break; 357 358 default: 359 warnx("unknown flag -%c ignored", optopt); 360 break; 361 } 362 } 363 |
364#ifdef VIRTUAL_HOSTING 365 inithosts(); 366#endif |
|
344 (void) freopen(_PATH_DEVNULL, "w", stderr); 345 346 /* 347 * LOG_NDELAY sets up the logging connection immediately, 348 * necessary for anonymous ftp's that chroot and can't do it later. 349 */ 350 openlog("ftpd", LOG_PID | LOG_NDELAY, LOG_FTP); 351 --- 93 unchanged lines hidden (view full) --- 445#ifdef SKEY 446 strncpy(addr_string, inet_ntoa(his_addr.sin_addr), sizeof(addr_string)); 447#endif 448 addrlen = sizeof(ctrl_addr); 449 if (getsockname(0, (struct sockaddr *)&ctrl_addr, &addrlen) < 0) { 450 syslog(LOG_ERR, "getsockname (%s): %m",argv[0]); 451 exit(1); 452 } | 367 (void) freopen(_PATH_DEVNULL, "w", stderr); 368 369 /* 370 * LOG_NDELAY sets up the logging connection immediately, 371 * necessary for anonymous ftp's that chroot and can't do it later. 372 */ 373 openlog("ftpd", LOG_PID | LOG_NDELAY, LOG_FTP); 374 --- 93 unchanged lines hidden (view full) --- 468#ifdef SKEY 469 strncpy(addr_string, inet_ntoa(his_addr.sin_addr), sizeof(addr_string)); 470#endif 471 addrlen = sizeof(ctrl_addr); 472 if (getsockname(0, (struct sockaddr *)&ctrl_addr, &addrlen) < 0) { 473 syslog(LOG_ERR, "getsockname (%s): %m",argv[0]); 474 exit(1); 475 } |
476#ifdef VIRTUAL_HOSTING 477 /* select our identity from virtual host table */ 478 selecthost(&ctrl_addr.sin_addr); 479#endif |
|
453#ifdef IP_TOS 454 tos = IPTOS_LOWDELAY; 455 if (setsockopt(0, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)) < 0) 456 syslog(LOG_WARNING, "setsockopt (IP_TOS): %m"); 457#endif 458 data_source.sin_port = htons(ntohs(ctrl_addr.sin_port) - 1); 459 460 /* set this here so klogin can use it... */ --- 27 unchanged lines hidden (view full) --- 488 *cp = '\0'; 489 lreply(530, "%s", line); 490 } 491 (void) fflush(stdout); 492 (void) fclose(fd); 493 reply(530, "System not available."); 494 exit(0); 495 } | 480#ifdef IP_TOS 481 tos = IPTOS_LOWDELAY; 482 if (setsockopt(0, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)) < 0) 483 syslog(LOG_WARNING, "setsockopt (IP_TOS): %m"); 484#endif 485 data_source.sin_port = htons(ntohs(ctrl_addr.sin_port) - 1); 486 487 /* set this here so klogin can use it... */ --- 27 unchanged lines hidden (view full) --- 515 *cp = '\0'; 516 lreply(530, "%s", line); 517 } 518 (void) fflush(stdout); 519 (void) fclose(fd); 520 reply(530, "System not available."); 521 exit(0); 522 } |
523#ifdef VIRTUAL_HOSTING 524 if ((fd = fopen(thishost->welcome, "r")) != NULL) { 525#else |
|
496 if ((fd = fopen(_PATH_FTPWELCOME, "r")) != NULL) { | 526 if ((fd = fopen(_PATH_FTPWELCOME, "r")) != NULL) { |
527#endif |
|
497 while (fgets(line, sizeof(line), fd) != NULL) { 498 if ((cp = strchr(line, '\n')) != NULL) 499 *cp = '\0'; 500 lreply(220, "%s", line); 501 } 502 (void) fflush(stdout); 503 (void) fclose(fd); 504 /* reply(220,) must follow */ 505 } | 528 while (fgets(line, sizeof(line), fd) != NULL) { 529 if ((cp = strchr(line, '\n')) != NULL) 530 *cp = '\0'; 531 lreply(220, "%s", line); 532 } 533 (void) fflush(stdout); 534 (void) fclose(fd); 535 /* reply(220,) must follow */ 536 } |
537#ifndef VIRTUAL_HOSTING |
|
506 (void) gethostname(hostname, sizeof(hostname)); | 538 (void) gethostname(hostname, sizeof(hostname)); |
539#endif |
|
507 reply(220, "%s FTP server (%s) ready.", hostname, version); 508 (void) setjmp(errcatch); 509 for (;;) 510 (void) yyparse(); 511 /* NOTREACHED */ 512} 513 514static void 515lostconn(signo) 516 int signo; 517{ 518 519 if (debug) 520 syslog(LOG_DEBUG, "lost connection"); 521 dologout(-1); 522} 523 | 540 reply(220, "%s FTP server (%s) ready.", hostname, version); 541 (void) setjmp(errcatch); 542 for (;;) 543 (void) yyparse(); 544 /* NOTREACHED */ 545} 546 547static void 548lostconn(signo) 549 int signo; 550{ 551 552 if (debug) 553 syslog(LOG_DEBUG, "lost connection"); 554 dologout(-1); 555} 556 |
557#ifdef VIRTUAL_HOSTING |
|
524/* | 558/* |
559 * read in virtual host tables (if they exist) 560 */ 561 562static void 563inithosts() 564{ 565 FILE *fp; 566 char *cp; 567 struct hostent *hp; 568 struct ftphost *hrp, *lhrp; 569 char line[1024]; 570 571 /* 572 * Fill in the default host information 573 */ 574 if (gethostname(line, sizeof(line)) < 0) 575 line[0] = '\0'; 576 if ((hrp = malloc(sizeof(struct ftphost))) == NULL || 577 (hrp->hostname = strdup(line)) == NULL) 578 fatal("Ran out of memory."); 579 memset(&hrp->hostaddr, 0, sizeof hrp->hostaddr); 580 if ((hp = gethostbyname(hrp->hostname)) != NULL) 581 (void) memcpy(&hrp->hostaddr, 582 hp->h_addr_list[0], 583 sizeof(hrp->hostaddr)); 584 hrp->statfile = _PATH_FTPDSTATFILE; 585 hrp->welcome = _PATH_FTPWELCOME; 586 hrp->loginmsg = _PATH_FTPLOGINMESG; 587 hrp->anonuser = "ftp"; 588 hrp->next = NULL; 589 thishost = firsthost = lhrp = hrp; 590 if ((fp = fopen(_PATH_FTPHOSTS, "r")) != NULL) { 591 while (fgets(line, sizeof(line), fp) != NULL) { 592 int i; 593 594 if ((cp = strchr(line, '\n')) == NULL) { 595 /* ignore long lines */ 596 while (fgets(line, sizeof(line), fp) != NULL && 597 strchr(line, '\n') == NULL) 598 ; 599 continue; 600 } 601 *cp = '\0'; 602 cp = strtok(line, " \t"); 603 /* skip comments and empty lines */ 604 if (cp == NULL || line[0] == '#') 605 continue; 606 /* first, try a standard gethostbyname() */ 607 if ((hp = gethostbyname(cp)) == NULL) 608 continue; 609 for (hrp = firsthost; hrp != NULL; hrp = hrp->next) { 610 if (memcmp(&hrp->hostaddr, 611 hp->h_addr_list[0], 612 sizeof(hrp->hostaddr)) == 0) 613 break; 614 } 615 if (hrp == NULL) { 616 if ((hrp = malloc(sizeof(struct ftphost))) == NULL) 617 continue; 618 /* defaults */ 619 hrp->statfile = _PATH_FTPDSTATFILE; 620 hrp->welcome = _PATH_FTPWELCOME; 621 hrp->loginmsg = _PATH_FTPLOGINMESG; 622 hrp->anonuser = "ftp"; 623 hrp->next = NULL; 624 lhrp->next = hrp; 625 lhrp = hrp; 626 } 627 (void) memcpy(&hrp->hostaddr, 628 hp->h_addr_list[0], 629 sizeof(hrp->hostaddr)); 630 /* 631 * determine hostname to use. 632 * force defined name if it is a valid alias 633 * otherwise fallback to primary hostname 634 */ 635 if ((hp = gethostbyaddr((char*)&hrp->hostaddr, 636 sizeof(hrp->hostaddr), 637 AF_INET)) != NULL) { 638 if (strcmp(cp, hp->h_name) != 0) { 639 if (hp->h_aliases == NULL) 640 cp = hp->h_name; 641 else { 642 i = 0; 643 while (hp->h_aliases[i] && 644 strcmp(cp, hp->h_aliases[i]) != 0) 645 ++i; 646 if (hp->h_aliases[i] == NULL) 647 cp = hp->h_name; 648 } 649 } 650 } 651 hrp->hostname = strdup(cp); 652 /* ok, now we now peel off the rest */ 653 i = 0; 654 while (i < 4 && (cp = strtok(NULL, " \t")) != NULL) { 655 if (*cp != '-' && (cp = strdup(cp)) != NULL) { 656 switch (i) { 657 case 0: /* anon user permissions */ 658 hrp->anonuser = cp; 659 break; 660 case 1: /* statistics file */ 661 hrp->statfile = cp; 662 break; 663 case 2: /* welcome message */ 664 hrp->welcome = cp; 665 break; 666 case 3: /* login message */ 667 hrp->loginmsg = cp; 668 break; 669 } 670 } 671 ++i; 672 } 673 } 674 (void) fclose(fp); 675 } 676} 677 678static void 679selecthost(a) 680 struct in_addr *a; 681{ 682 struct ftphost *hrp; 683 684 hrp = thishost = firsthost; /* default */ 685 while (hrp != NULL) { 686 if (memcmp(a, &hrp->hostaddr, sizeof(hrp->hostaddr)) == 0) { 687 thishost = hrp; 688 break; 689 } 690 hrp = hrp->next; 691 } 692 /* setup static variables as appropriate */ 693 hostname = thishost->hostname; 694 ftpuser = thishost->anonuser; 695} 696#endif 697 698/* |
|
525 * Helper function for sgetpwnam(). 526 */ 527static char * 528sgetsave(s) 529 char *s; 530{ 531 char *new = malloc((unsigned) strlen(s) + 1); 532 --- 68 unchanged lines hidden (view full) --- 601 end_login(); 602 } 603 604 guest = 0; 605 if (strcmp(name, "ftp") == 0 || strcmp(name, "anonymous") == 0) { 606 if (checkuser(_PATH_FTPUSERS, "ftp") || 607 checkuser(_PATH_FTPUSERS, "anonymous")) 608 reply(530, "User %s access denied.", name); | 699 * Helper function for sgetpwnam(). 700 */ 701static char * 702sgetsave(s) 703 char *s; 704{ 705 char *new = malloc((unsigned) strlen(s) + 1); 706 --- 68 unchanged lines hidden (view full) --- 775 end_login(); 776 } 777 778 guest = 0; 779 if (strcmp(name, "ftp") == 0 || strcmp(name, "anonymous") == 0) { 780 if (checkuser(_PATH_FTPUSERS, "ftp") || 781 checkuser(_PATH_FTPUSERS, "anonymous")) 782 reply(530, "User %s access denied.", name); |
783#ifdef VIRTUAL_HOSTING 784 else if ((pw = sgetpwnam(thishost->anonuser)) != NULL) { 785#else |
|
609 else if ((pw = sgetpwnam("ftp")) != NULL) { | 786 else if ((pw = sgetpwnam("ftp")) != NULL) { |
787#endif |
|
610 guest = 1; 611 askpasswd = 1; 612 reply(331, 613 "Guest login ok, send your email address as password."); 614 } else 615 reply(530, "User %s unknown.", name); 616 if (!askpasswd && logging) 617 syslog(LOG_NOTICE, --- 197 unchanged lines hidden (view full) --- 815 (void) initgroups(pw->pw_name, pw->pw_gid); 816#endif 817 818 /* open wtmp before chroot */ 819 logwtmp(ttyline, pw->pw_name, remotehost); 820 logged_in = 1; 821 822 if (guest && stats && statfd < 0) | 788 guest = 1; 789 askpasswd = 1; 790 reply(331, 791 "Guest login ok, send your email address as password."); 792 } else 793 reply(530, "User %s unknown.", name); 794 if (!askpasswd && logging) 795 syslog(LOG_NOTICE, --- 197 unchanged lines hidden (view full) --- 993 (void) initgroups(pw->pw_name, pw->pw_gid); 994#endif 995 996 /* open wtmp before chroot */ 997 logwtmp(ttyline, pw->pw_name, remotehost); 998 logged_in = 1; 999 1000 if (guest && stats && statfd < 0) |
1001#ifdef VIRTUAL_HOSTING 1002 if ((statfd = open(thishost->statfile, O_WRONLY|O_APPEND)) < 0) 1003#else |
|
823 if ((statfd = open(_PATH_FTPDSTATFILE, O_WRONLY|O_APPEND)) < 0) | 1004 if ((statfd = open(_PATH_FTPDSTATFILE, O_WRONLY|O_APPEND)) < 0) |
1005#endif |
|
824 stats = 0; 825 826 dochroot = 827#ifdef LOGIN_CAP /* Allow login.conf configuration as well */ 828 login_getcapbool(lc, "ftp-chroot", 0) || 829#endif 830 checkuser(_PATH_FTPCHROOT, pw->pw_name); 831 if (guest) { --- 29 unchanged lines hidden (view full) --- 861 */ 862 if (getcwd(homedir, MAXPATHLEN) != NULL) 863 setenv("HOME", homedir, 1); 864 865 /* 866 * Display a login message, if it exists. 867 * N.B. reply(230,) must follow the message. 868 */ | 1006 stats = 0; 1007 1008 dochroot = 1009#ifdef LOGIN_CAP /* Allow login.conf configuration as well */ 1010 login_getcapbool(lc, "ftp-chroot", 0) || 1011#endif 1012 checkuser(_PATH_FTPCHROOT, pw->pw_name); 1013 if (guest) { --- 29 unchanged lines hidden (view full) --- 1043 */ 1044 if (getcwd(homedir, MAXPATHLEN) != NULL) 1045 setenv("HOME", homedir, 1); 1046 1047 /* 1048 * Display a login message, if it exists. 1049 * N.B. reply(230,) must follow the message. 1050 */ |
1051#ifdef VIRTUAL_HOSTING 1052 if ((fd = fopen(thishost->loginmsg, "r")) != NULL) { 1053#else |
|
869 if ((fd = fopen(_PATH_FTPLOGINMESG, "r")) != NULL) { | 1054 if ((fd = fopen(_PATH_FTPLOGINMESG, "r")) != NULL) { |
1055#endif |
|
870 char *cp, line[LINE_MAX]; 871 872 while (fgets(line, sizeof(line), fd) != NULL) { 873 if ((cp = strchr(line, '\n')) != NULL) 874 *cp = '\0'; 875 lreply(230, "%s", line); 876 } 877 (void) fflush(stdout); 878 (void) fclose(fd); 879 } 880 if (guest) { 881 if (ident != NULL) 882 free(ident); 883 ident = strdup(passwd); 884 if (ident == NULL) 885 fatal("Ran out of memory."); 886 887 reply(230, "Guest login ok, access restrictions apply."); 888#ifdef SETPROCTITLE | 1056 char *cp, line[LINE_MAX]; 1057 1058 while (fgets(line, sizeof(line), fd) != NULL) { 1059 if ((cp = strchr(line, '\n')) != NULL) 1060 *cp = '\0'; 1061 lreply(230, "%s", line); 1062 } 1063 (void) fflush(stdout); 1064 (void) fclose(fd); 1065 } 1066 if (guest) { 1067 if (ident != NULL) 1068 free(ident); 1069 ident = strdup(passwd); 1070 if (ident == NULL) 1071 fatal("Ran out of memory."); 1072 1073 reply(230, "Guest login ok, access restrictions apply."); 1074#ifdef SETPROCTITLE |
889 snprintf(proctitle, sizeof(proctitle), 890 "%s: anonymous/%.*s", remotehost, 891 sizeof(proctitle) - sizeof(remotehost) - 892 sizeof(": anonymous/"), passwd); | 1075#ifdef VIRTUAL_HOSTING 1076 if (thishost != firsthost) 1077 snprintf(proctitle, sizeof(proctitle), 1078 "%s: anonymous(%s)/%.*s", remotehost, hostname, 1079 sizeof(proctitle) - sizeof(remotehost) - 1080 sizeof(": anonymous/"), passwd); 1081 else 1082#endif 1083 snprintf(proctitle, sizeof(proctitle), 1084 "%s: anonymous/%.*s", remotehost, 1085 sizeof(proctitle) - sizeof(remotehost) - 1086 sizeof(": anonymous/"), passwd); |
893 setproctitle("%s", proctitle); 894#endif /* SETPROCTITLE */ 895 if (logging) 896 syslog(LOG_INFO, "ANONYMOUS FTP LOGIN FROM %s, %s", 897 remotehost, passwd); 898 } else { 899 reply(230, "User %s logged in.", pw->pw_name); 900#ifdef SETPROCTITLE 901 snprintf(proctitle, sizeof(proctitle), | 1087 setproctitle("%s", proctitle); 1088#endif /* SETPROCTITLE */ 1089 if (logging) 1090 syslog(LOG_INFO, "ANONYMOUS FTP LOGIN FROM %s, %s", 1091 remotehost, passwd); 1092 } else { 1093 reply(230, "User %s logged in.", pw->pw_name); 1094#ifdef SETPROCTITLE 1095 snprintf(proctitle, sizeof(proctitle), |
902 "%s: %s", remotehost, pw->pw_name); | 1096 "%s: %s", remotehost, pw->pw_name); |
903 setproctitle("%s", proctitle); 904#endif /* SETPROCTITLE */ 905 if (logging) 906 syslog(LOG_INFO, "FTP LOGIN FROM %s as %s", 907 remotehost, pw->pw_name); 908 } 909#ifdef LOGIN_CAP 910 login_close(lc); --- 779 unchanged lines hidden (view full) --- 1690 sizeof(struct in_addr), AF_INET); 1691 1692 if (hp) 1693 (void) strncpy(remotehost, hp->h_name, sizeof(remotehost)); 1694 else 1695 (void) strncpy(remotehost, inet_ntoa(sin->sin_addr), 1696 sizeof(remotehost)); 1697#ifdef SETPROCTITLE | 1097 setproctitle("%s", proctitle); 1098#endif /* SETPROCTITLE */ 1099 if (logging) 1100 syslog(LOG_INFO, "FTP LOGIN FROM %s as %s", 1101 remotehost, pw->pw_name); 1102 } 1103#ifdef LOGIN_CAP 1104 login_close(lc); --- 779 unchanged lines hidden (view full) --- 1884 sizeof(struct in_addr), AF_INET); 1885 1886 if (hp) 1887 (void) strncpy(remotehost, hp->h_name, sizeof(remotehost)); 1888 else 1889 (void) strncpy(remotehost, inet_ntoa(sin->sin_addr), 1890 sizeof(remotehost)); 1891#ifdef SETPROCTITLE |
1698 snprintf(proctitle, sizeof(proctitle), "%s: connected", remotehost); | 1892#ifdef VIRTUAL_HOSTING 1893 if (thishost != firsthost) 1894 snprintf(proctitle, sizeof(proctitle), "%s: connected (to %s)", 1895 remotehost, hostname); 1896 else 1897#endif 1898 snprintf(proctitle, sizeof(proctitle), "%s: connected", 1899 remotehost); |
1699 setproctitle("%s", proctitle); 1700#endif /* SETPROCTITLE */ 1701 | 1900 setproctitle("%s", proctitle); 1901#endif /* SETPROCTITLE */ 1902 |
1702 if (logging) 1703 syslog(LOG_INFO, "connection from %s", remotehost); | 1903 if (logging) { 1904#ifdef VIRTUAL_HOSTING 1905 if (thishost != firsthost) 1906 syslog(LOG_INFO, "connection from %s (to %s)", 1907 remotehost, hostname); 1908 else 1909#endif 1910 syslog(LOG_INFO, "connection from %s", remotehost); 1911 } |
1704} 1705 1706/* 1707 * Record logout in wtmp file 1708 * and exit with supplied status. 1709 */ 1710void 1711dologout(status) --- 366 unchanged lines hidden --- | 1912} 1913 1914/* 1915 * Record logout in wtmp file 1916 * and exit with supplied status. 1917 */ 1918void 1919dologout(status) --- 366 unchanged lines hidden --- |