#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'wu-2.4.2-upd13-difs' <<'END_OF_FILE' Xdiff -cbrw wu-ftpd-2.4.2-beta-13-ORIG/config.h wu-ftpd-2.4.2-beta-13/config.h X*** wu-ftpd-2.4.2-beta-13-ORIG/config.h Mon Mar 3 09:39:34 1997 X--- wu-ftpd-2.4.2-beta-13/config.h Wed Jun 11 22:38:27 1997 X*************** X*** 74,76 **** X--- 74,147 ---- X X #undef SKEY X X+ /* X+ * SKEY_CRIMELAB X+ * Add SKEY support -- REQUIRES Crimelab SKEY libraries. X+ * (See crimelab.com [198.64.127.1] Directory: /pub/skey). X+ */ X+ X+ #define SKEY_CRIMELAB X+ #ifdef SKEY_CRIMELAB X+ #undef SKEY X+ #endif X+ X+ /* X+ * DAEMON X+ * If ftpd called with -D then run as a standalone daemon listing on the X+ * ftp port. This can speed up ftpd response as all ftpd then needs to X+ * do is fork off a copy to handle an incoming request. Under inetd X+ * a new copy has to be opened and exec'd. X+ */ X+ #define DAEMON X+ X+ /* X+ * MAX_BACKLOG X+ * Only used in DAEMON mode. X+ * This is second parameter to listen. It defines the number of incoming X+ * processes to allow to backlog, prior to being accept() processing them, X+ * before rejecting. X+ */ X+ #define MAX_BACKLOG 100 X+ X+ /* X+ * MAPPING_CHDIR X+ * Keep track of the path the user has chdir'd into and respond with X+ * that to pwd commands. This is to avoid having the absolue disk X+ * path returned. This helps avoid returning dirs like '.1/fred' X+ * when lots of disks make up the ftp area. X+ */ X+ X+ #define MAPPING_CHDIR X+ X+ /* X+ * PLUS_PW X+ * Some ftptool type packages are all graphical and don't allow you X+ * to type commands so you cannot type 'get file' where file X+ * is really a .Z/.z/.gz file to auto-uncompress. X+ * A leading + in the passwd causes ls output to have X+ * any trailing .Z/.z/.gz's stripped to allow these tools to work. X+ * (All that happens is that the environment variable NODOTZ is set X+ * and an ls shell script runs the real ls output thru sed.) X+ */ X+ X+ #define PLUS_PW X+ X+ /* X+ * FILEWHAT X+ * If SETPROCTITLE doesn't work or if you have so many users that ps X+ * takes a long time then FILEWHAT keeps the info in a file so that X+ * ftpcount can just print it. X+ */ X+ X+ #define FILEWHAT X+ X+ X+ /* X+ * KERBEROS4 X+ * FTPD X+ * Using the standard MIT KERBEROS 4 code. (If you use *krb* as X+ * in the passwd file then you are probably using Kerberos4.) X+ */ X+ X+ #define KERBEROS4 X+ #define FTPD Xdiff -cbrw wu-ftpd-2.4.2-beta-13-ORIG/src/access.c wu-ftpd-2.4.2-beta-13/src/access.c X*** wu-ftpd-2.4.2-beta-13-ORIG/src/access.c Mon Mar 3 09:39:51 1997 X--- wu-ftpd-2.4.2-beta-13/src/access.c Wed Jun 11 22:05:31 1997 X*************** X*** 71,76 **** X--- 71,80 ---- X #define MAXLINE 80 X static char incline[MAXLINE]; X int pidfd = -1; X+ #ifdef FILEWHAT X+ int whatindex = -1; X+ extern void whatopen(); X+ #endif X X extern int fnmatch(); X X*************** X*** 565,570 **** X--- 569,578 ---- X struct flock arg; X #endif X X+ #ifdef FILEWHAT X+ whatopen( class ); X+ #endif X+ X /* X * if pidfd was not opened previously... X * pidfd must stay open after the chroot(~ftp) X*************** X*** 691,696 **** X--- 699,707 ---- X } X X buf[avail] = procid; X+ #ifdef FILEWHAT X+ whatindex = avail; X+ #endif X X lseek(pidfd, 0, L_SET); X write(pidfd, buf, sizeof(buf)); Xdiff -cbrw wu-ftpd-2.4.2-beta-13-ORIG/src/extensions.h wu-ftpd-2.4.2-beta-13/src/extensions.h X*** wu-ftpd-2.4.2-beta-13-ORIG/src/extensions.h Fri Jan 10 06:14:57 1997 X--- wu-ftpd-2.4.2-beta-13/src/extensions.h Wed Jun 11 22:09:32 1997 X*************** X*** 42,44 **** X--- 42,51 ---- X #define ARG8 entry->arg[8] X #define ARG9 entry->arg[9] X #define ARG entry->arg X+ X+ #ifdef FILEWHAT X+ #define WHATLEN 80 /* How much of the string to record. X+ * Need MAXUSERS * this for the file for each class X+ */ X+ #endif X+ Xdiff -cbrw wu-ftpd-2.4.2-beta-13-ORIG/src/ftpcount.c wu-ftpd-2.4.2-beta-13/src/ftpcount.c X*** wu-ftpd-2.4.2-beta-13-ORIG/src/ftpcount.c Mon Mar 3 09:22:22 1997 X--- wu-ftpd-2.4.2-beta-13/src/ftpcount.c Wed Jun 11 22:15:16 1997 X*************** X*** 212,217 **** X--- 212,223 ---- X #ifndef HAVE_FLOCK X struct flock arg; X #endif X+ #ifdef FILEWHAT X+ FILE *what = NULL; X+ char whatfile[MAXPATHLEN+1]; X+ char whatstr[WHATLEN+1]; X+ int dowhat = 1; X+ #endif X X sprintf(pidfile, _PATH_PIDNAMES, class); X pidfd = open(pidfile, O_RDONLY, 0644); X*************** X*** 219,224 **** X--- 225,238 ---- X return (0); X } X lseek(pidfd, 0, L_SET); X+ #ifdef FILEWHAT X+ sprintf(whatfile, _PATH_WHATNAMES, class); X+ if (!(what = fopen(whatfile, "r"))) { X+ /* Cannot open whatfile */ X+ fprintf(stderr, "Cannot open whatfile %s\n", whatfile); X+ dowhat = 0; X+ } X+ #endif X X count = 0; X X*************** X*** 228,233 **** X--- 242,255 ---- X stat = kill(buf[which], SIGCONT); X if (((stat == -1) && (errno == EPERM)) || !stat) { X if (strcmp(progname,"ftpcount")) { X+ #ifdef FILEWHAT X+ if (dowhat) { X+ fseek(what, WHATLEN * which, SEEK_SET); X+ memset(whatstr, '\0', sizeof(whatstr)); X+ fread(whatstr, sizeof(char), WHATLEN, what); X+ printf(" %s\n", whatstr ); X+ } X+ #else /* ! FILEWHAT */ X #if defined(SVR4) X #ifdef AIX X sprintf(line,"/bin/ps %d",buf[which]); X*************** X*** 246,251 **** X--- 268,274 ---- X fgets(line, 1024, ZeFile); X printf("%s",line); X pclose(ZeFile); X+ #endif /* FILEWHAT */ X } X count++; X } X*************** X*** 258,263 **** X--- 281,291 ---- X fcntl(pidfd, F_SETLK, &arg); X #endif X close(pidfd); X+ X+ #ifdef FILEWHAT X+ if( what ) X+ fclose(what); X+ #endif X X return (count); X } Xdiff -cbrw wu-ftpd-2.4.2-beta-13-ORIG/src/ftpd.c wu-ftpd-2.4.2-beta-13/src/ftpd.c X*** wu-ftpd-2.4.2-beta-13-ORIG/src/ftpd.c Mon Mar 3 09:39:56 1997 X--- wu-ftpd-2.4.2-beta-13/src/ftpd.c Wed Jun 11 23:18:47 1997 X*************** X*** 66,71 **** X--- 66,82 ---- X #include X #endif X X+ #ifdef FILEWHAT X+ #ifdef HAVE_GETRLIMIT X+ #include X+ #include X+ #endif X+ #ifdef SVR4 X+ #include X+ #include X+ #endif /* SVR4 */ X+ #endif /* FILEWHAT */ X+ X #include X #include X #include X*************** X*** 341,347 **** X int pwok = 0; X #endif X X! #ifdef KERBEROS X void init_krb(); X void end_krb(); X char krb_ticket_name[100]; X--- 352,358 ---- X int pwok = 0; X #endif X X! #if defined(KERBEROS) && !defined(KERBEROS4) X void init_krb(); X void end_krb(); X char krb_ticket_name[100]; X*************** X*** 356,361 **** X--- 367,377 ---- X char ls_short[50]; X struct aclmember *entry = NULL; X X+ #ifdef DAEMON X+ /* LMJM: run as a standalone daemon? */ X+ int daemon = 0; X+ #endif X+ X #ifdef __STDC__ X void end_login(void); X void send_data(FILE *, FILE *, off_t); X*************** X*** 415,420 **** X--- 431,437 ---- X setlogmask(LOG_UPTO(LOG_INFO)); X #endif X X+ #ifndef DAEMON X addrlen = sizeof(his_addr); X if (getpeername(0, (struct sockaddr *) &his_addr, &addrlen) < 0) { X syslog(LOG_ERR, "getpeername (%s): %m", argv[0]); X*************** X*** 438,450 **** X--- 455,473 ---- X data_source.sin_port = htons(ntohs(ctrl_addr.sin_port) - 1); X debug = 0; X X+ #endif /* DAEMON */ X+ X /* Save start and extent of argv for setproctitle. */ X Argv = argv; X while (*envp) X envp++; X LastArgv = envp[-1] + strlen(envp[-1]); X X+ #ifndef DAEMON X while ((c = getopt(argc, argv, ":aAvdlLiot:T:u:")) != -1) { X+ #else X+ while ((c = getopt(argc, argv, ":aAvdDlLiot:T:u:")) != -1) { X+ #endif X switch (c) { X X case 'a': X*************** X*** 463,468 **** X--- 486,497 ---- X debug = 1; X break; X X+ #ifdef DAEMON X+ case 'D': X+ daemon = 1; X+ break; X+ #endif X+ X case 'l': X logging = 1; X break; X*************** X*** 692,697 **** X--- 721,757 ---- X #endif X #endif X #endif /* SIG_DEBUG */ X+ X+ #ifdef DAEMON X+ if (daemon) { X+ do_daemon(); X+ } X+ X+ addrlen = sizeof(his_addr); X+ if (getpeername(0, (struct sockaddr *) &his_addr, &addrlen) < 0) { X+ syslog(LOG_ERR, "getpeername (%s): %m", argv[0]); X+ #ifndef DEBUG X+ exit(1); X+ #endif X+ } X+ addrlen = sizeof(ctrl_addr); X+ if (getsockname(0, (struct sockaddr *) &ctrl_addr, &addrlen) < 0) { X+ syslog(LOG_ERR, "getsockname (%s): %m", argv[0]); X+ #ifndef DEBUG X+ exit(1); X+ #endif X+ } X+ #ifdef IPTOS_LOWDELAY X+ tos = IPTOS_LOWDELAY; X+ if (setsockopt(0, IPPROTO_IP, IP_TOS, (char *) &tos, sizeof(int)) < 0) X+ syslog(LOG_WARNING, "setsockopt (IP_TOS): %m"); X+ #endif X+ X+ data_source.sin_port = htons(ntohs(ctrl_addr.sin_port) - 1); X+ debug = 0; X+ #endif /* DAEMON */ X+ X+ X /* Try to handle urgent data inline */ X #ifdef SO_OOBINLINE X if (setsockopt(0, SOL_SOCKET, SO_OOBINLINE, (char *)&on, sizeof(int)) < 0) X*************** X*** 857,862 **** X--- 917,1014 ---- X X static char ttyline[20]; X X+ #ifdef MAPPING_CHDIR X+ /* Keep track of the path the user has chdir'd into and respond with X+ * that to pwd commands. This is to avoid having the absolue disk X+ * path returned, which I want to avoid. X+ */ X+ char mapped_path[ MAXPATHLEN ] = "/"; X+ X+ char * X+ mapping_getwd( path ) X+ char *path; X+ { X+ strcpy( path, mapped_path ); X+ return path; X+ } X+ X+ /* Make these globals rather than local to mapping_chdir to avoid stack overflow */ X+ char pathspace[ MAXPATHLEN ]; X+ char old_mapped_path[ MAXPATHLEN ]; X+ X+ int X+ mapping_chdir( orig_path ) X+ char *orig_path; X+ { X+ int ret; X+ char *sl, *path; X+ X+ strcpy( old_mapped_path, mapped_path ); X+ path = &pathspace[0]; X+ strcpy( path, orig_path ); X+ X+ /* / at start of path, set the start of the mapped_path to / */ X+ if( path[0] == '/' ){ X+ mapped_path[0] = '/'; X+ mapped_path[1] = '\0'; X+ path++; X+ } X+ X+ while( (sl = strchr( path, '/' )) ){ X+ char *dir, *last; X+ dir = path; X+ *sl = '\0'; X+ path = sl + 1; X+ if( *dir ) X+ do_elem( dir ); X+ if( *path == '\0' ) X+ break; X+ } X+ if( *path ) X+ do_elem( path ); X+ X+ if( (ret = chdir( mapped_path )) < 0 ){ X+ strcpy( mapped_path, old_mapped_path ); X+ } X+ X+ return ret; X+ } X+ X+ do_elem( dir ) X+ char *dir; X+ { X+ /* . */ X+ if( dir[0] == '.' && dir[1] == '\0' ){ X+ /* ignore it */ X+ return; X+ } X+ X+ /* .. */ X+ if( dir[0] == '.' && dir[1] == '.' && dir[2] == '\0' ){ X+ char *last; X+ /* lop the last directory off the path */ X+ if( last = strrchr( mapped_path, '/') ){ X+ /* If start of pathname leave the / */ X+ if( last == mapped_path ) X+ last++; X+ *last = '\0'; X+ } X+ return; X+ } X+ X+ /* append the dir part with a leading / unless at root */ X+ if( !(mapped_path[0] == '/' && mapped_path[1] == '\0') ) X+ strcat( mapped_path, "/" ); X+ strcat( mapped_path, dir ); X+ } X+ /* From now on use the mapping version */ X+ X+ #define chdir(d) mapping_chdir(d) X+ #define getwd(d) mapping_getwd(d) X+ #define getcwd(d,u) mapping_getwd(d) X+ X+ #endif /* MAPPING_CHDIR */ X+ X /* Helper function for sgetpwnam(). */ X char * X #ifdef __STDC__ X*************** X*** 899,905 **** X #else X char *sgetsave(); X #endif X! #ifdef KERBEROS X register struct authorization *q; X #endif /* KERBEROS */ X X--- 1051,1057 ---- X #else X char *sgetsave(); X #endif X! #if defined(KERBEROS) && !defined(KERBEROS4) X register struct authorization *q; X #endif /* KERBEROS */ X X*************** X*** 907,913 **** X struct pr_passwd *pr; X #endif X X! #ifdef KERBEROS X init_krb(); X q = getauthuid(p->pw_uid); X end_krb(); X--- 1059,1065 ---- X struct pr_passwd *pr; X #endif X X! #if defined(KERBEROS) && !defined(KERBEROS4) X init_krb(); X q = getauthuid(p->pw_uid); X end_krb(); X*************** X*** 938,944 **** X X save.pw_name = sgetsave(p->pw_name); X X! #ifdef KERBEROS X save.pw_passwd = sgetsave(q->a_password); X #elif defined(SecureWare) X if (pr->uflg.fg_encrypt && pr->ufld.fd_encrypt && *pr->ufld.fd_encrypt) X--- 1090,1096 ---- X X save.pw_name = sgetsave(p->pw_name); X X! #if defined(KERBEROS) && !defined(KERBEROS4) X save.pw_passwd = sgetsave(q->a_password); X #elif defined(SecureWare) X if (pr->uflg.fg_encrypt && pr->ufld.fd_encrypt && *pr->ufld.fd_encrypt) X*************** X*** 1251,1256 **** X--- 1403,1413 ---- X if (use_accessfile) /* see above. _H*/ X acl_setfunctions(); X X+ #ifdef SKEY_CRIMELAB X+ if (!skey_haskey (name)) X+ reply(331, "Password [%s] for %s required.", skey_keyinfo (name), name); X+ else X+ #endif X #ifdef SKEY X pwok = skeyaccess(name, NULL, remotehost, remoteaddr); X reply(331, "%s", skey_challenge(name, pw, pwok)); X*************** X*** 1388,1404 **** X--- 1545,1592 ---- X X if (*passwd == '-') X dolreplies = 0; X+ #ifdef PLUS_PW X+ else if (*passwd == '+') { X+ dolreplies = 0; X+ passwd++; X+ putenv( "NODOTZ=1" ); X+ } X+ #endif /* PLUS_PW */ X else X dolreplies = 1; X /* ******** REGULAR/GUEST USER PASSWORD PROCESSING ********** */ X if (!anonymous) { /* "ftp" is only account allowed no password */ X if (*passwd == '-') X passwd++; X+ #ifdef SKEY_CRIMELAB X+ if (!skey_haskey (the_user)) X+ { X+ int i = skey_passcheck (the_user, passwd); X+ X+ if (i == -1) X+ goto BADPASS; X+ X+ else X+ { X+ if (i < 5) X+ { X+ reply (331, "Warning! Key initialization needed soon. "); X+ reply (331, "(%d logins left)\n", i); X+ } X+ goto GOODPASS; X+ } X+ } X+ #endif /* SKEY_CRIMELAB */ X *guestpw = '\0'; X if (pw == NULL) X salt = "xx"; /* XXX */ X else X salt = pw->pw_passwd; X+ #ifdef KERBEROS4 X+ /* With KERBEROS4 just do this: */ X+ if (pw == NULL || *pw->pw_passwd == '\0' || X+ !krb_pwcheck(pw->pw_name, pw->pw_passwd, passwd)) { X+ #else X #ifdef SECUREOSF X xpasswd = bigcrypt(passwd, salt); X #else X*************** X*** 1420,1425 **** X--- 1608,1618 ---- X if (pw == NULL || *pw->pw_passwd == '\0' || X strcmp(xpasswd, pw->pw_passwd)) { X #endif X+ #endif X+ X+ #ifdef SKEY_CRIMELAB X+ BADPASS: X+ #endif X reply(530, "Login incorrect."); X X #ifdef LOG_FAILED /* 27-Apr-93 EHK/BM */ X*************** X*** 1497,1502 **** X--- 1690,1699 ---- X } X } X X+ #ifdef SKEY_CRIMELAB X+ GOODPASS: X+ #endif X+ X /* if logging is enabled, open logfile before chroot or set group ID */ X if (log_outbound_xfers || log_incoming_xfers) { X xferlog = open(logfile, O_WRONLY | O_APPEND | O_CREAT, 0660); X*************** X*** 3025,3030 **** X--- 3222,3228 ---- X #endif X { X char path[MAXPATHLEN + 1]; X+ #ifndef MAPPING_CHDIR X #ifdef HAVE_GETCWD X extern char *getcwd(); X #else X*************** X*** 3034,3039 **** X--- 3232,3238 ---- X extern char *getwd(); X #endif X #endif X+ #endif /* MAPPING_CHDIR */ X X #ifdef HAVE_GETCWD X if (getcwd(path,MAXPATHLEN) == (char *) NULL) X*************** X*** 3670,3680 **** X #endif X #endif X #endif /* SPT_TYPE != SPT_NONE */ X } X X #endif /* SPT_TYPE != SPT_BUILTIN */ X X! #ifdef KERBEROS X /* thanks to gshapiro@wpi.wpi.edu for the following kerberosities */ X X void X--- 3869,3896 ---- X #endif X #endif X #endif /* SPT_TYPE != SPT_NONE */ X+ #ifdef FILEWHAT X+ { X+ register char *p; X+ register int i; X+ char buf[WHATLEN]; X+ VA_LOCAL_DECL X+ X+ p = buf; X+ X+ /* print the argument string */ X+ VA_START(fmt); X+ (void) vsnprintf(buf, sizeof buf, fmt, ap); X+ VA_END; X+ X+ filewhat(buf); X+ } X+ #endif /* ! FILEWHAT */ X } X X #endif /* SPT_TYPE != SPT_BUILTIN */ X X! #if defined(KERBEROS) && !defined(KERBEROS4) X /* thanks to gshapiro@wpi.wpi.edu for the following kerberosities */ X X void X*************** X*** 3711,3717 **** X { X unlink(krb_ticket_name); X } X! #endif /* KERBEROS */ X X #ifdef ULTRIX_AUTH X static int X--- 3927,3933 ---- X { X unlink(krb_ticket_name); X } X! #endif /* defined(KERBEROS) && !defined(KERBEROS4) */ X X #ifdef ULTRIX_AUTH X static int X*************** X*** 3763,3765 **** X--- 3979,4203 ---- X return -1; X } X #endif /* ULTRIX_AUTH */ X+ X+ #ifdef FILEWHAT X+ extern int whatindex; X+ int what; X+ int dontwhat = 0; X+ X+ void X+ whatopen( class ) X+ char *class; X+ { X+ char whatfile[MAXPATHLEN]; X+ X+ if (!what) { X+ sprintf(whatfile, _PATH_WHATNAMES, class); X+ if (!(what = open(whatfile, O_RDWR|O_CREAT, 0644))) { X+ /* Cannot open whatfile */ X+ syslog(LOG_ERR, "Cannot open whatfile %s", whatfile); X+ dontwhat = 1; X+ } X+ } X+ } X+ X+ /* write to the what file */ X+ filewhat( str ) X+ char *str; X+ { X+ char out[ WHATLEN + 100 ]; /* Add some space for overflows */ X+ char *cr; X+ static int pid = -1; X+ #ifdef SVR4 X+ static int tps = -1; X+ struct tms tms; X+ #else X+ struct rusage ru; X+ #endif X+ unsigned long int usecs = 0, secs = 0; X+ X+ if (dontwhat || !what || whatindex < 0) X+ return; X+ X+ if( pid < 0 ) X+ pid = getpid(); X+ X+ #ifdef SVR4 X+ if( tps < 0 ) X+ tps = CLK_TCK; X+ X+ if( times( &tms ) > 0 ) X+ secs = (tms.tms_utime + tms.tms_stime + tps/2) / tps; /* Round up */ X+ #else X+ if( getrusage( RUSAGE_SELF, &ru ) > 0 ){ X+ usecs = (ru.ru_utime.tv_usec + ru.ru_stime.tv_usec) + X+ (ru.ru_utime.tv_sec + ru.ru_stime.tv_sec) * 1000; X+ secs = (usecs + 500)/1000; /* Round up */ X+ } X+ #endif X+ X+ sprintf( out, "%d %d:%02d %s", pid, secs / 60, secs % 60, str ); X+ if (cr = strchr(out, '\n')) X+ *cr = '\0'; X+ out[ WHATLEN - 1 ] = '\0'; X+ lseek(what, WHATLEN * whatindex, SEEK_SET); X+ write(what, out, WHATLEN); X+ } X+ X+ #endif /* FILEWHAT */ X+ X+ #ifdef DAEMON X+ #include X+ X+ /* I am running as a standalone daemon (not under inetd) */ X+ do_daemon() X+ { X+ struct sockaddr_in server; X+ struct servent *serv; X+ int pgrp; X+ int lsock; X+ int one = 1; X+ int status; X+ int fd; X+ FILE *pidfile; X+ int i; X+ X+ /* Some of this is "borrowed" from inn - lots of it isn't */ X+ X+ /* Fork - so I'm not the owner of the process group any more */ X+ i = fork(); X+ if (i < 0) { X+ syslog(LOG_ERR, "cant fork %m"); X+ exit(1); X+ } X+ /* No need for the parent any more */ X+ if (i > 0) X+ exit(0); X+ X+ #if defined(TIOCNOTTY) X+ /* Disassociate from terminal. */ X+ if ((i = open("/dev/tty", O_RDWR)) >= 0) { X+ if (ioctl(i, TIOCNOTTY, (char *)NULL) < 0) X+ syslog(LOG_ERR, "cant ioctl(TIOCNOTTY) %m"); X+ if (close(i) < 0) X+ syslog(LOG_ERR, "cant close /dev/tty %m"); X+ } X+ #endif /* defined(TIOCNOTTY) */ X+ X+ /* X+ pgrp = setpgrp( 0, getpid() ); X+ */ X+ pgrp = setsid(); X+ if( pgrp < 0 ){ X+ syslog( LOG_ERR, "cannot daemonise: %m" ); X+ exit( 1 ); X+ } X+ X+ if( (pidfile = fopen( _PATH_FTPD_PID, "w" )) ){ X+ fprintf( pidfile, "%d\n", getpid() ); X+ fclose( pidfile ); X+ } X+ else { X+ syslog( LOG_ERR, "Cannot write pidfile: %m" ); X+ } X+ X+ /* Close off all file descriptors and reopen syslog */ X+ { X+ int i, fds; X+ #ifdef HAVE_GETRLIMIT X+ struct rlimit rlp; X+ X+ rlp.rlim_cur = rlp.rlim_max = RLIM_INFINITY; X+ if (getrlimit( RLIMIT_NOFILE, &rlp ) ) X+ return(NULL); X+ fds = rlp.rlim_cur; X+ #else X+ #ifdef HAVE_GETDTABLESIZE X+ if ((fds = getdtablesize()) <= 0) X+ return (NULL); X+ #else X+ #ifdef OPEN_MAX X+ fds=OPEN_MAX; /* need to include limits.h somehow */ X+ #else X+ fds = sizeof(long); /* XXX -- magic */ X+ #endif X+ #endif X+ #endif X+ X+ for( i = 0; i <= fds; i++ ){ X+ close( i ); X+ } X+ #ifdef FACILITY X+ openlog("ftpd", LOG_PID | LOG_NDELAY, FACILITY); X+ #else X+ openlog("ftpd", LOG_PID); X+ #endif X+ /* junk stderr */ X+ (void) freopen(_PATH_DEVNULL, "w", stderr); X+ } X+ X+ /* Create a socket to listen on */ X+ lsock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); X+ if( lsock < 0 ){ X+ syslog( LOG_ERR, "Cannot create socket to listen on: %m" ); X+ exit( 1 ); X+ } X+ if( setsockopt( lsock, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof( one ) ) < 0 ){ X+ syslog( LOG_ERR, "Cannot set SO_REUSEADDR option: %m" ); X+ exit( 1 ); X+ } X+ X+ server.sin_family = AF_INET; X+ server.sin_addr.s_addr = INADDR_ANY; X+ if( !(serv = getservbyname( "ftp", "tcp" )) ){ X+ syslog( LOG_ERR, "Cannot find service ftp: %m" ); X+ exit( 1 ); X+ } X+ server.sin_port = serv->s_port; X+ X+ if( bind( lsock, (struct sockaddr *)&server, sizeof( server ) ) < 0 ){ X+ syslog( LOG_ERR, "Cannot bind socket: %m" ); X+ exit( 1 ); X+ } X+ X+ listen( lsock, MAX_BACKLOG ); X+ while( 1 ){ X+ int pid; X+ int msgsock; X+ X+ msgsock = accept( lsock, 0, 0 ); X+ if( msgsock < 0 ){ X+ syslog( LOG_ERR, "Accept failed: %m" ); X+ sleep( 1 ); X+ continue; X+ } X+ X+ /* Fork off a handler */ X+ pid = fork(); X+ if( pid < 0 ){ X+ syslog( LOG_ERR, "failed to fork: %m" ); X+ sleep( 1 ); X+ continue; X+ } X+ if( pid == 0 ){ X+ /* I am that forked off child */ X+ /* Make sure that stdin/stdout are the new socket */ X+ dup2( msgsock, 0 ); X+ dup2( msgsock, 1 ); X+ /* Only parent needs lsock */ X+ if( lsock != 0 && lsock != 1 ) X+ close( lsock ); X+ return; X+ } X+ X+ /* I am the parent */ X+ close( msgsock ); X+ X+ /* Quick check to see if any of the forked off children have X+ * terminated. */ X+ while( (pid = waitpid( (pid_t)-1, (int *)0, WNOHANG)) > 0 ){ X+ /* A child has finished */ X+ } X+ } X+ } X+ #endif /* DAEMON */ Xdiff -cbrw wu-ftpd-2.4.2-beta-13-ORIG/src/makefiles/Makefile.sol wu-ftpd-2.4.2-beta-13/src/makefiles/Makefile.sol X*** wu-ftpd-2.4.2-beta-13-ORIG/src/makefiles/Makefile.sol Mon Mar 3 09:13:03 1997 X--- wu-ftpd-2.4.2-beta-13/src/makefiles/Makefile.sol Wed Jun 11 23:16:49 1997 X*************** X*** 2,12 **** X # $Id: Makefile.sol,v 1.3 1997/03/03 09:12:59 sob Exp sob $ X # X # X! CC = cc X IFLAGS = -I.. -I../support X LFLAGS = -L../support X! CFLAGS = -g ${IFLAGS} ${LFLAGS} X! LIBES = -lsupport -lsocket -lnsl -lgen X LIBC = /lib/libc.a X LINTFLAGS= X LKERB = -lauth -lckrb -lkrb -ldes X--- 2,24 ---- X # $Id: Makefile.sol,v 1.3 1997/03/03 09:12:59 sob Exp sob $ X # X # X! CC = gcc X! X! # Kerberos4 includes/libraries - comment out these lines if unneeded X! KINC = -I/usr/include/kerberos X! KLIB = -lkrb X! KPW_SRC = krbpw.c X! KPW_OBJ = krbpw.o X! X! # Crimelab_Skey includes/libraries - comment out these lines if unneeded X! SINC = X! SLIB = -L/other_stuff/src/misc/skey/crimelab/src -lskey X! X! # X IFLAGS = -I.. -I../support X LFLAGS = -L../support X! CFLAGS = -g -DDEBUG ${IFLAGS} ${LFLAGS} ${KINC} ${SINC} X! LIBES = -lsupport -lsocket -lnsl -lgen ${SLIB} ${KLIB} X LIBC = /lib/libc.a X LINTFLAGS= X LKERB = -lauth -lckrb -lkrb -ldes X*************** X*** 14,23 **** X X SRCS = ftpd.c ftpcmd.c glob.c logwtmp.c popen.c vers.c access.c extensions.c \ X realpath.c acl.c private.c authenticate.c conversions.c hostacc.c \ X! sigfix.c X OBJS = ftpd.o ftpcmd.o glob.o logwtmp.o popen.o vers.o access.o extensions.o \ X realpath.o acl.o private.o authenticate.o conversions.o hostacc.o \ X! sigfix.o X X all: ftpd ftpcount ftpshut ckconfig X X--- 26,35 ---- X X SRCS = ftpd.c ftpcmd.c glob.c logwtmp.c popen.c vers.c access.c extensions.c \ X realpath.c acl.c private.c authenticate.c conversions.c hostacc.c \ X! sigfix.c $(KPW_SRC) X OBJS = ftpd.o ftpcmd.o glob.o logwtmp.o popen.o vers.o access.o extensions.o \ X realpath.o acl.o private.o authenticate.o conversions.o hostacc.o \ X! sigfix.o $(KPW_OBJ) X X all: ftpd ftpcount ftpshut ckconfig X Xdiff -cbrw wu-ftpd-2.4.2-beta-13-ORIG/src/pathnames.h wu-ftpd-2.4.2-beta-13/src/pathnames.h X*** wu-ftpd-2.4.2-beta-13-ORIG/src/pathnames.h Mon Mar 3 09:39:59 1997 X--- wu-ftpd-2.4.2-beta-13/src/pathnames.h Wed Jun 11 22:54:25 1997 X*************** X*** 52,65 **** X--- 52,74 ---- X #endif X #endif X X+ /* _PATH_FTPD_PIDFILE is only used if DAEMON is defined */ X+ /* _PATH_WHATNAMES is only used if FILEWHAT is defined */ X+ X #ifdef USE_VAR X #ifdef USE_PID X #define _PATH_PIDNAMES "/var/pid/ftp.pids-%s" X+ #define _PATH_FTPD_PID "/var/pid/ftpd.pid" X+ #define _PATH_WHATNAMES "/var/tmp/ftp.whats-%s" X #else X #ifdef USE_TMP X #define _PATH_PIDNAMES "/var/tmp/ftp.pids-%s" X+ #define _PATH_FTPD_PID "/var/tmp/ftpd.pid" X+ #define _PATH_WHATNAMES "/var/tmp/ftp.whats-%s" X #else X #define _PATH_PIDNAMES "/var/run/ftp.pids-%s" X+ #define _PATH_FTPD_PID "/var/run/ftpd.pid" X+ #define _PATH_WHATNAMES "/var/run/ftp.whats-%s" X #endif X #endif X #ifdef USE_LOG END_OF_FILE if test 25035 -ne `wc -c <'wu-2.4.2-upd13-difs'`; then echo shar: \"'wu-2.4.2-upd13-difs'\" unpacked with wrong size! fi # end of 'wu-2.4.2-upd13-difs' fi if test -f 'wu-ftpd-2.4.2-beta-13/src/krbpw.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'wu-ftpd-2.4.2-beta-13/src/krbpw.c'\" else echo shar: Extracting \"'wu-ftpd-2.4.2-beta-13/src/krbpw.c'\" \(8592 characters\) sed "s/^X//" >'wu-ftpd-2.4.2-beta-13/src/krbpw.c' <<'END_OF_FILE' X/* krbpw.c - check the password */ X/* Used by various programs, for each use some program specific #define X * and add an #ifdef block to define these macros. If you are lucky you X * can just -DKRB_PASSWD, to get a Kerberos password checker and, X * and -DKRB_STD_INC to use the standard set of include files. X * X * These are they macros you need to think about: X * KRB_PASSWD use Kerberos password checking, otherwise just uses crypt() X * KRB_REPORT_TRACE(str) define only if you want detailed tracing X * KRB_REPORT_SERIOUS(str) a serious error or a spoofing attempt found X * X * X * To add this into your program look for the places where crypt() is X * used to check the passwd. Replace a test like: X * X if (strcmp (crypt (passwd_read_in, pw->pw_passwd), pw->pw_passwd) != 0) X return FAILED; X * X * by X * X#ifdef KRB_PASSWD X if (!krb_pwcheck (pw->pw_name, pw->pw_passwd, passwd_read_in)) X#else X if (strcmp (crypt (passwd_read_in, pw->pw_passwd), pw->pw_passwd) != 0) X#endif X return FAILED; X * X * X * To compile this you will probably need to add -I/usr/local/include/kerberos X * or something similar (depending where you're kerberos include files are). X * You will also need to link with libkrb.a and probably libdes.a as well. X */ X X/* LINTLIBRARY */ X X#include "config.h" X#ifdef KERBEROS4 X X#ifdef TEST X /* A test mode - generate a standalone program to try out the various X * routines */ X X/* Use the standard include files */ X#define KRB_STD_INC X#define KRB_PASSWD X X#define KRB_REPORT_TRACE(str) fprintf( stderr, "Watch-- %s\n", str ); X#define KRB_REPORT_SERIOUS(str) fprintf( stderr, "FATAL-- %s\n", str ); X#endif /* end of TEST */ X X X#ifdef KRB_STD_INC X /* A catchall - no tracing and use syslog to report serious errors */ X#include X#include X#include X#include X#include X#include X#include X X#endif /* end of KRB_STD_INC */ X X X/* ------------ For use in the ISO Developement Environment ------------ */ X#ifdef ISODE X#include X#include "general.h" X#include "manifest.h" X#ifdef KRB_PASSWD X#include X#include "internet.h" X#include "tailor.h" X#endif X X#define KRB_REPORT_SERIOUS(str) ll_log(compat_log, LLOG_EXCEPTIONS, NULLCP, str) X#endif /* end of ISODE */ X X X/* ------------ For use in the Unix Niftp package ------------ */ X#ifdef UNIXNIFTP X/* Need to compile with -DUNIXNIFTP -DKRB_PASSWD -DKRB_STD_INC */ X X#include "ftp.h" X X#define KRB_REPORT_SERIOUS(str) L_LOG_1(L_MAJOR_COM, 0, "%s\n", (str)) X#endif /* end of UNIXNIFTP */ X X/* ------------ For use in by the ftp daemon ------------ */ X#ifdef FTPD X#include X#include X#include X#include X#include X#include X#include X#include X X#define KRB_REPORT_SERIOUS(str) syslog( LOG_NOTICE, (str)) X#endif X X#ifndef KRB_REPORT_SERIOUS X#define KRB_REPORT_SERIOUS(str) syslog( LOG_NOTICE, (str)) X#endif X X#ifdef KERBEROS4 X#define KERBEROS X#endif X X#ifdef KERBEROS X# ifndef KRB_PASSWD X# define KRB_PASSWD X# endif X#endif X X#ifdef KRB_PASSWD X/* Error code to string */ X#define KRB_ERR_STR(e) ((e) >= 0 ? krb_err_txt[(e)] :"INVALID ERROR RETURN") X#endif /* End of UNIXNIFTP */ X X X Xchar *crypt (); X X/* S. Lacey. and L.McLoughlin Dept. of Computing, Imperial College. X * With substantial modifications by John T Kohl to avoid spoofing. X * X * Takes the username, the password from the password file, and the passwd X * the user is trying to use. X * Returns 1 if the passwd matches otherwise 0. X */ X X#ifndef KRB_PASSWD X/* ARGSUSED */ X#endif Xint krb_pwcheck ( usrname, pwpass, usrpass ) Xchar *usrname; Xchar *pwpass; Xchar *usrpass; X{ X#ifdef KRB_PASSWD X char realm[REALM_SZ]; X int krbval; X unsigned old_alarm; X char obuf[128]; X X /* X * check to see if the passwd is `*krb*' X * if it is, use kerberos. If not then call up crypt(). X */ X X#ifdef KRB_REPORT_TRACE X sprintf (obuf, "krb_pwcheck(%s,%s,SOMESTRING)", usrname, pwpass, usrpass); X KRB_REPORT_TRACE (obuf); X#endif X if (strcmp(pwpass, "*krb*") == 0) { X /* X * use kerberos, first of all find the realm X */ X if (krb_get_lrealm(realm, 1) != KSUCCESS) { X (void) strncpy(realm, KRB_REALM, sizeof(realm)); X } X#ifdef KRB_REPORT_TRACE X sprintf (obuf, "Realm is %s", realm); X KRB_REPORT_TRACE (obuf); X#endif X X /* X * now check the passwd X */ X krbval = krb_get_pw_in_tkt(usrname, "", X realm, "krbtgt", X realm, X DEFAULT_TKT_LIFE, usrpass); X X if( krbval != INTK_OK ){ X sprintf (obuf, "Initial kerberos check for %s failed with %d", usrname, krbval); X KRB_REPORT_SERIOUS( obuf ); X X /* it has failed to match */ X return 0; X } X X#ifdef KRB_REPORT_TRACE X sprintf (obuf, "Initial kerberos check for %s succeeded", usrname); X KRB_REPORT_TRACE (obuf); X#endif X old_alarm = alarm(0); /* Authentic, so don't time out. */ X if (verify_krb_tgt(realm) > 0){ X alarm (old_alarm); X#ifdef KRB_REPORT_TRACE X sprintf (obuf, "Verify succeeded for %s", usrname); X KRB_REPORT_TRACE ( obuf ); X#endif X return 1; /* Success!! */ X } X X /* Oops. He tried to fool us. Tsk, tsk. */ X alarm (old_alarm); X sprintf (obuf, "Attempted hack on kerberos with username %s", usrname); X KRB_REPORT_SERIOUS (obuf); X return 0; X } X#endif X X /* X * use passwd file password X */ X return (strcmp(crypt(usrpass, pwpass), pwpass) == 0); X} X X#ifdef KRB_PASSWD X/* X * Verify the Kerberos ticket-granting ticket just retrieved for the X * user. If the Kerberos server doesn't respond, assume the user is X * trying to fake us out (since we DID just get a TGT from what is X * supposedly our KDC). If the rcmd. service is unknown (i.e., X * the local /etc/srvtab doesn't have it), let her in. X * X * Returns 1 for confirmation, -1 for failure, 0 for uncertainty. X */ Xint verify_krb_tgt (realm) X char *realm; X{ X char hostname[MAXHOSTNAMELEN], phost[BUFSIZ]; X struct hostent *hp; X KTEXT_ST ticket; X AUTH_DAT authdata; X unsigned long addr; X static /*const*/ char rcmd[] = "rcmd"; X char key[8]; X int krbval, retval, have_keys; X char obuf[128]; X X#ifdef ISODE X (void) strcpy (hostname, getlocalhost ()); X#else X if (gethostname (hostname, sizeof(hostname)) == -1) { X KRB_REPORT_SERIOUS( "cannot retrieve local hostname" ); X return -1; X } X#endif X strncpy (phost, krb_get_phost (hostname), sizeof (phost)); X phost[sizeof(phost)-1] = 0; X hp = gethostbyname (hostname); X if (!hp) { X sprintf (obuf, "cannot retrieve local host address: %s", hostname); X KRB_REPORT_SERIOUS (obuf); X return -1; X } X#ifdef BCOPY X bcopy ((char *)hp->h_addr, (char *) &addr, sizeof (addr)); X#else X (void)memcpy ((char *) &addr, (char *)hp->h_addr, sizeof (addr)); X#endif X /* Do we have rcmd. keys? */ X have_keys = read_service_key (rcmd, phost, realm, 0, "/etc/srvtab", key) X ? 0 : 1; X krbval = krb_mk_req (&ticket, rcmd, phost, realm, 0); X if (krbval == KDC_PR_UNKNOWN) { X /* X * Our rcmd. principal isn't known -- just assume valid X * for now? This is one case that the user _could_ fake out. X */ X if (have_keys) X return -1; X else X return 0; X } X else if (krbval != KSUCCESS) { X sprintf (obuf, "Unable to verify Kerberos TGT: %s", KRB_ERR_STR(krbval)); X KRB_REPORT_SERIOUS (obuf); X return -1; X } X /* got ticket, try to use it */ X krbval = krb_rd_req (&ticket, rcmd, phost, addr, &authdata, ""); X#ifdef KRB_REPORT_TRACE X sprintf (obuf, "got result from krb_rd_req of %d", krbval); X KRB_REPORT_TRACE ( obuf ); X#endif X if (krbval != KSUCCESS) { X char *err; X X if (krbval == RD_AP_UNDEC && !have_keys) X retval = 0; X else { X retval = -1; X } X X sprintf (obuf, "can't verify rcmd ticket: %s;%s", X KRB_ERR_STR(krbval), X retval X ? "srvtab found, assuming failure" X : "no srvtab found, assuming success"); X KRB_REPORT_SERIOUS (obuf); X } X else X /* X * The rcmd. ticket has been received _and_ verified. X */ X retval = 1; X X return retval; X} X#endif X X X#ifdef TEST Xextern char *getpass(); X Xmain() X{ X char user[ 100 ]; X char passwd[ 100 ]; X X printf( "Username? " ); fflush( stdout ); X gets( user ); X printf( "Password? " ); fflush( stdout ); X /* OK - so I should do ioctls.... this is quicker to type! X * Can't use getpass() as it only reads 8 chars and kerberos X * passwords can be longer */ X system( "stty -echo" ); X gets( passwd ); X system( "stty echo" ); X printf( "\n" ); X X /* Force a kerberos check of the password */ X if( krb_pwcheck( user, "*krb*", passwd ) ) X printf( "OK\n" ); X else X printf( "FAILED\n" ); X} X#endif X X#endif /* KERBEROS4 */ END_OF_FILE if test 8592 -ne `wc -c <'wu-ftpd-2.4.2-beta-13/src/krbpw.c'`; then echo shar: \"'wu-ftpd-2.4.2-beta-13/src/krbpw.c'\" unpacked with wrong size! fi # end of 'wu-ftpd-2.4.2-beta-13/src/krbpw.c' fi echo shar: End of shell archive. exit 0 .