140081Sbostic #ifndef lint 2*40084Sbostic char yysccsid[] = "@(#)yaccpar 1.3 (Berkeley) 01/21/90"; 340081Sbostic #endif 440081Sbostic #define A 257 540081Sbostic #define B 258 640081Sbostic #define C 259 740081Sbostic #define E 260 840081Sbostic #define F 261 940081Sbostic #define I 262 1040081Sbostic #define L 263 1140081Sbostic #define N 264 1240081Sbostic #define P 265 1340081Sbostic #define R 266 1440081Sbostic #define S 267 1540081Sbostic #define T 268 1640081Sbostic #define SP 269 1740081Sbostic #define CRLF 270 1840081Sbostic #define COMMA 271 1940081Sbostic #define STRING 272 2040081Sbostic #define NUMBER 273 2140081Sbostic #define USER 274 2240081Sbostic #define PASS 275 2340081Sbostic #define ACCT 276 2440081Sbostic #define REIN 277 2540081Sbostic #define QUIT 278 2640081Sbostic #define PORT 279 2740081Sbostic #define PASV 280 2840081Sbostic #define TYPE 281 2940081Sbostic #define STRU 282 3040081Sbostic #define MODE 283 3140081Sbostic #define RETR 284 3240081Sbostic #define STOR 285 3340081Sbostic #define APPE 286 3440081Sbostic #define MLFL 287 3540081Sbostic #define MAIL 288 3640081Sbostic #define MSND 289 3740081Sbostic #define MSOM 290 3840081Sbostic #define MSAM 291 3940081Sbostic #define MRSQ 292 4040081Sbostic #define MRCP 293 4140081Sbostic #define ALLO 294 4240081Sbostic #define REST 295 4340081Sbostic #define RNFR 296 4440081Sbostic #define RNTO 297 4540081Sbostic #define ABOR 298 4640081Sbostic #define DELE 299 4740081Sbostic #define CWD 300 4840081Sbostic #define LIST 301 4940081Sbostic #define NLST 302 5040081Sbostic #define SITE 303 5140081Sbostic #define STAT 304 5240081Sbostic #define HELP 305 5340081Sbostic #define NOOP 306 5440081Sbostic #define MKD 307 5540081Sbostic #define RMD 308 5640081Sbostic #define PWD 309 5740081Sbostic #define CDUP 310 5840081Sbostic #define STOU 311 5940081Sbostic #define SMNT 312 6040081Sbostic #define SYST 313 6140081Sbostic #define SIZE 314 6240081Sbostic #define MDTM 315 6340081Sbostic #define UMASK 316 6440081Sbostic #define IDLE 317 6540081Sbostic #define CHMOD 318 6640081Sbostic #define LEXERR 319 6740081Sbostic #define YYERRCODE 256 6840081Sbostic #line 26 "ftp.y" 6940081Sbostic 7040081Sbostic #ifndef lint 7140081Sbostic static char sccsid[] = "@(#)ftpcmd.y 5.20.1.1 (Berkeley) 3/2/89"; 7240081Sbostic #endif /* not lint */ 7340081Sbostic 7440081Sbostic #include <sys/param.h> 7540081Sbostic #include <sys/socket.h> 7640081Sbostic 7740081Sbostic #include <netinet/in.h> 7840081Sbostic 7940081Sbostic #include <arpa/ftp.h> 8040081Sbostic 8140081Sbostic #include <stdio.h> 8240081Sbostic #include <signal.h> 8340081Sbostic #include <ctype.h> 8440081Sbostic #include <pwd.h> 8540081Sbostic #include <setjmp.h> 8640081Sbostic #include <syslog.h> 8740081Sbostic #include <sys/stat.h> 8840081Sbostic #include <time.h> 8940081Sbostic 9040081Sbostic extern struct sockaddr_in data_dest; 9140081Sbostic extern int logged_in; 9240081Sbostic extern struct passwd *pw; 9340081Sbostic extern int guest; 9440081Sbostic extern int logging; 9540081Sbostic extern int type; 9640081Sbostic extern int form; 9740081Sbostic extern int debug; 9840081Sbostic extern int timeout; 9940081Sbostic extern int maxtimeout; 10040081Sbostic extern int pdata; 10140081Sbostic extern char hostname[], remotehost[]; 10240081Sbostic extern char proctitle[]; 10340081Sbostic extern char *globerr; 10440081Sbostic extern int usedefault; 10540081Sbostic extern int transflag; 10640081Sbostic extern char tmpline[]; 10740081Sbostic char **glob(); 10840081Sbostic 10940081Sbostic static int cmd_type; 11040081Sbostic static int cmd_form; 11140081Sbostic static int cmd_bytesz; 11240081Sbostic char cbuf[512]; 11340081Sbostic char *fromname; 11440081Sbostic 11540081Sbostic char *index(); 11640081Sbostic #line 116 "ftp.tab.c" 117*40084Sbostic short yylhs[] = { -1, 11840081Sbostic 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 11940081Sbostic 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12040081Sbostic 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12140081Sbostic 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12240081Sbostic 1, 1, 1, 1, 1, 1, 2, 3, 4, 4, 12340081Sbostic 12, 5, 13, 13, 13, 6, 6, 6, 6, 6, 12440081Sbostic 6, 6, 6, 7, 7, 7, 8, 8, 8, 10, 12540081Sbostic 14, 11, 9, 12640081Sbostic }; 127*40084Sbostic short yylen[] = { 2, 12840081Sbostic 0, 2, 2, 4, 4, 4, 2, 4, 4, 4, 12940081Sbostic 4, 8, 5, 5, 5, 3, 5, 3, 5, 5, 13040081Sbostic 2, 5, 4, 2, 3, 5, 2, 4, 2, 5, 13140081Sbostic 5, 3, 3, 4, 6, 5, 7, 9, 4, 6, 13240081Sbostic 5, 2, 5, 5, 2, 2, 5, 1, 0, 1, 13340081Sbostic 1, 11, 1, 1, 1, 1, 3, 1, 3, 1, 13440081Sbostic 1, 3, 2, 1, 1, 1, 1, 1, 1, 1, 13540081Sbostic 1, 1, 0, 13640081Sbostic }; 137*40084Sbostic short yydefred[] = { 1, 13840081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13940081Sbostic 73, 73, 73, 0, 73, 0, 0, 73, 73, 73, 14040081Sbostic 73, 0, 0, 0, 0, 73, 73, 73, 73, 73, 14140081Sbostic 0, 73, 73, 2, 3, 46, 0, 0, 45, 0, 14240081Sbostic 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14340081Sbostic 24, 0, 0, 0, 0, 0, 21, 0, 0, 27, 14440081Sbostic 29, 0, 0, 0, 0, 0, 42, 0, 0, 48, 14540081Sbostic 0, 50, 0, 0, 0, 0, 0, 60, 0, 0, 14640081Sbostic 64, 66, 65, 0, 68, 69, 67, 0, 0, 0, 14740081Sbostic 0, 0, 0, 71, 0, 70, 0, 0, 25, 0, 14840081Sbostic 18, 0, 16, 0, 73, 0, 73, 0, 0, 0, 14940081Sbostic 0, 32, 33, 0, 0, 0, 4, 5, 0, 6, 15040081Sbostic 0, 0, 0, 51, 63, 8, 9, 10, 0, 0, 15140081Sbostic 0, 0, 11, 0, 23, 0, 0, 0, 0, 0, 15240081Sbostic 34, 0, 0, 39, 0, 0, 28, 0, 0, 0, 15340081Sbostic 0, 0, 0, 55, 53, 54, 57, 59, 62, 13, 15440081Sbostic 14, 15, 0, 47, 22, 26, 19, 17, 0, 0, 15540081Sbostic 36, 0, 0, 20, 30, 31, 41, 43, 44, 0, 15640081Sbostic 0, 35, 72, 0, 40, 0, 0, 0, 37, 0, 15740081Sbostic 0, 12, 0, 0, 38, 0, 0, 0, 52, 15840081Sbostic }; 159*40084Sbostic short yydgoto[] = { 1, 16040081Sbostic 34, 35, 71, 73, 75, 80, 84, 88, 45, 95, 16140081Sbostic 184, 125, 157, 96, 16240081Sbostic }; 163*40084Sbostic short yysindex[] = { 0, 16440081Sbostic -224, -247, -239, -236, -232, -222, -204, -200, -181, -177, 16540081Sbostic 0, 0, 0, -166, 0, -161, -199, 0, 0, 0, 16640081Sbostic 0, -160, -159, -264, -158, 0, 0, 0, 0, 0, 16740081Sbostic -157, 0, 0, 0, 0, 0, -167, -162, 0, -156, 16840081Sbostic 0, -250, -198, -165, -155, -154, -153, -151, -150, -152, 16940081Sbostic 0, -145, -252, -229, -217, -302, 0, -144, -146, 0, 17040081Sbostic 0, -142, -141, -140, -139, -137, 0, -136, -135, 0, 17140081Sbostic -134, 0, -133, -132, -130, -131, -128, 0, -249, -127, 17240081Sbostic 0, 0, 0, -126, 0, 0, 0, -125, -152, -152, 17340081Sbostic -152, -205, -152, 0, -124, 0, -152, -152, 0, -152, 17440081Sbostic 0, -143, 0, -173, 0, -171, 0, -152, -123, -152, 17540081Sbostic -152, 0, 0, -152, -152, -152, 0, 0, -138, 0, 17640081Sbostic -164, -164, -122, 0, 0, 0, 0, 0, -121, -120, 17740081Sbostic -118, -148, 0, -117, 0, -116, -115, -114, -113, -112, 17840081Sbostic 0, -163, -111, 0, -110, -109, 0, -107, -106, -105, 17940081Sbostic -104, -103, -129, 0, 0, 0, 0, 0, 0, 0, 18040081Sbostic 0, 0, -101, 0, 0, 0, 0, 0, -100, -102, 18140081Sbostic 0, -98, -102, 0, 0, 0, 0, 0, 0, -99, 18240081Sbostic -97, 0, 0, -95, 0, -96, -94, -92, 0, -152, 18340081Sbostic -93, 0, -91, -90, 0, -88, -87, -86, 0, 18440081Sbostic }; 185*40084Sbostic short yyrindex[] = { 0, 18640081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18740081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18840081Sbostic 0, 0, -83, 0, 0, 0, 0, 0, 0, 0, 18940081Sbostic 0, 0, 0, 0, 0, 0, 0, -82, 0, 0, 19040081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19140081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19240081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19340081Sbostic 0, 0, 0, 0, 0, -81, -80, 0, -158, 0, 19440081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19540081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19640081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19740081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19840081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19940081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20040081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20140081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20240081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20340081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20440081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20540081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 0, 20640081Sbostic }; 207*40084Sbostic short yygindex[] = { 0, 20840081Sbostic 0, 0, 0, 0, 0, 0, 0, 0, 16, -89, 20940081Sbostic -25, 35, 47, 0, 21040081Sbostic }; 211*40084Sbostic #define YYTABLESIZE 190 212*40084Sbostic short yytable[] = { 129, 21340081Sbostic 130, 131, 104, 134, 59, 60, 76, 136, 137, 77, 21440081Sbostic 138, 78, 79, 105, 106, 107, 98, 99, 146, 123, 21540081Sbostic 148, 149, 36, 124, 150, 151, 152, 46, 47, 37, 21640081Sbostic 49, 2, 38, 52, 53, 54, 55, 39, 58, 100, 21740081Sbostic 101, 62, 63, 64, 65, 66, 40, 68, 69, 3, 21840081Sbostic 4, 102, 103, 5, 6, 7, 8, 9, 10, 11, 21940081Sbostic 12, 13, 81, 132, 133, 41, 82, 83, 42, 14, 22040081Sbostic 51, 15, 16, 17, 18, 19, 20, 21, 22, 23, 22140081Sbostic 24, 25, 26, 27, 28, 29, 30, 43, 31, 32, 22240081Sbostic 33, 44, 85, 86, 154, 140, 141, 143, 144, 155, 22340081Sbostic 193, 87, 48, 156, 70, 170, 171, 50, 56, 72, 22440081Sbostic 57, 61, 67, 89, 90, 91, 74, 163, 93, 94, 22540081Sbostic 142, 92, 145, 97, 108, 109, 110, 111, 139, 112, 22640081Sbostic 113, 114, 115, 116, 153, 117, 118, 121, 119, 120, 22740081Sbostic 122, 180, 126, 127, 128, 135, 147, 186, 160, 161, 22840081Sbostic 124, 162, 164, 165, 166, 167, 168, 159, 173, 169, 22940081Sbostic 174, 172, 175, 176, 177, 178, 179, 181, 158, 182, 23040081Sbostic 183, 185, 190, 187, 189, 188, 191, 192, 195, 194, 23140081Sbostic 196, 0, 0, 198, 197, 73, 199, 49, 56, 58, 23240081Sbostic }; 233*40084Sbostic short yycheck[] = { 89, 23440081Sbostic 90, 91, 305, 93, 269, 270, 257, 97, 98, 260, 23540081Sbostic 100, 262, 263, 316, 317, 318, 269, 270, 108, 269, 23640081Sbostic 110, 111, 270, 273, 114, 115, 116, 12, 13, 269, 23740081Sbostic 15, 256, 269, 18, 19, 20, 21, 270, 23, 269, 23840081Sbostic 270, 26, 27, 28, 29, 30, 269, 32, 33, 274, 23940081Sbostic 275, 269, 270, 278, 279, 280, 281, 282, 283, 284, 24040081Sbostic 285, 286, 261, 269, 270, 270, 265, 266, 269, 294, 24140081Sbostic 270, 296, 297, 298, 299, 300, 301, 302, 303, 304, 24240081Sbostic 305, 306, 307, 308, 309, 310, 311, 269, 313, 314, 24340081Sbostic 315, 269, 258, 259, 259, 269, 270, 269, 270, 264, 24440081Sbostic 190, 267, 269, 268, 272, 269, 270, 269, 269, 272, 24540081Sbostic 270, 270, 270, 269, 269, 269, 273, 266, 269, 272, 24640081Sbostic 105, 273, 107, 269, 269, 272, 269, 269, 272, 270, 24740081Sbostic 270, 269, 269, 269, 273, 270, 270, 269, 271, 270, 24840081Sbostic 269, 271, 270, 270, 270, 270, 270, 173, 270, 270, 24940081Sbostic 273, 270, 270, 270, 270, 270, 270, 123, 269, 272, 25040081Sbostic 270, 273, 270, 270, 270, 270, 270, 269, 122, 270, 25140081Sbostic 273, 270, 269, 273, 270, 273, 271, 270, 270, 273, 25240081Sbostic 271, -1, -1, 271, 273, 269, 273, 270, 270, 270, 25340081Sbostic }; 25440081Sbostic #define YYFINAL 1 25540081Sbostic #ifndef YYDEBUG 25640081Sbostic #define YYDEBUG 0 25740081Sbostic #endif 25840081Sbostic #define YYMAXTOKEN 319 25940081Sbostic #if YYDEBUG 260*40084Sbostic char *yyname[] = { 26140081Sbostic "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 26240081Sbostic 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 26340081Sbostic 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 26440081Sbostic 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 26540081Sbostic 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 26640081Sbostic 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 26740081Sbostic 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"A","B","C","E","F","I","L","N", 26840081Sbostic "P","R","S","T","SP","CRLF","COMMA","STRING","NUMBER","USER","PASS","ACCT", 26940081Sbostic "REIN","QUIT","PORT","PASV","TYPE","STRU","MODE","RETR","STOR","APPE","MLFL", 27040081Sbostic "MAIL","MSND","MSOM","MSAM","MRSQ","MRCP","ALLO","REST","RNFR","RNTO","ABOR", 27140081Sbostic "DELE","CWD","LIST","NLST","SITE","STAT","HELP","NOOP","MKD","RMD","PWD","CDUP", 27240081Sbostic "STOU","SMNT","SYST","SIZE","MDTM","UMASK","IDLE","CHMOD","LEXERR", 27340081Sbostic }; 274*40084Sbostic char *yyrule[] = { 27540081Sbostic "$accept : cmd_list", 27640081Sbostic "cmd_list :", 27740081Sbostic "cmd_list : cmd_list cmd", 27840081Sbostic "cmd_list : cmd_list rcmd", 27940081Sbostic "cmd : USER SP username CRLF", 28040081Sbostic "cmd : PASS SP password CRLF", 28140081Sbostic "cmd : PORT SP host_port CRLF", 28240081Sbostic "cmd : PASV CRLF", 28340081Sbostic "cmd : TYPE SP type_code CRLF", 28440081Sbostic "cmd : STRU SP struct_code CRLF", 28540081Sbostic "cmd : MODE SP mode_code CRLF", 28640081Sbostic "cmd : ALLO SP NUMBER CRLF", 28740081Sbostic "cmd : ALLO SP NUMBER SP R SP NUMBER CRLF", 28840081Sbostic "cmd : RETR check_login SP pathname CRLF", 28940081Sbostic "cmd : STOR check_login SP pathname CRLF", 29040081Sbostic "cmd : APPE check_login SP pathname CRLF", 29140081Sbostic "cmd : NLST check_login CRLF", 29240081Sbostic "cmd : NLST check_login SP STRING CRLF", 29340081Sbostic "cmd : LIST check_login CRLF", 29440081Sbostic "cmd : LIST check_login SP pathname CRLF", 29540081Sbostic "cmd : STAT check_login SP pathname CRLF", 29640081Sbostic "cmd : STAT CRLF", 29740081Sbostic "cmd : DELE check_login SP pathname CRLF", 29840081Sbostic "cmd : RNTO SP pathname CRLF", 29940081Sbostic "cmd : ABOR CRLF", 30040081Sbostic "cmd : CWD check_login CRLF", 30140081Sbostic "cmd : CWD check_login SP pathname CRLF", 30240081Sbostic "cmd : HELP CRLF", 30340081Sbostic "cmd : HELP SP STRING CRLF", 30440081Sbostic "cmd : NOOP CRLF", 30540081Sbostic "cmd : MKD check_login SP pathname CRLF", 30640081Sbostic "cmd : RMD check_login SP pathname CRLF", 30740081Sbostic "cmd : PWD check_login CRLF", 30840081Sbostic "cmd : CDUP check_login CRLF", 30940081Sbostic "cmd : SITE SP HELP CRLF", 31040081Sbostic "cmd : SITE SP HELP SP STRING CRLF", 31140081Sbostic "cmd : SITE SP UMASK check_login CRLF", 31240081Sbostic "cmd : SITE SP UMASK check_login SP octal_number CRLF", 31340081Sbostic "cmd : SITE SP CHMOD check_login SP octal_number SP pathname CRLF", 31440081Sbostic "cmd : SITE SP IDLE CRLF", 31540081Sbostic "cmd : SITE SP IDLE SP NUMBER CRLF", 31640081Sbostic "cmd : STOU check_login SP pathname CRLF", 31740081Sbostic "cmd : SYST CRLF", 31840081Sbostic "cmd : SIZE check_login SP pathname CRLF", 31940081Sbostic "cmd : MDTM check_login SP pathname CRLF", 32040081Sbostic "cmd : QUIT CRLF", 32140081Sbostic "cmd : error CRLF", 32240081Sbostic "rcmd : RNFR check_login SP pathname CRLF", 32340081Sbostic "username : STRING", 32440081Sbostic "password :", 32540081Sbostic "password : STRING", 32640081Sbostic "byte_size : NUMBER", 32740081Sbostic "host_port : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER", 32840081Sbostic "form_code : N", 32940081Sbostic "form_code : T", 33040081Sbostic "form_code : C", 33140081Sbostic "type_code : A", 33240081Sbostic "type_code : A SP form_code", 33340081Sbostic "type_code : E", 33440081Sbostic "type_code : E SP form_code", 33540081Sbostic "type_code : I", 33640081Sbostic "type_code : L", 33740081Sbostic "type_code : L SP byte_size", 33840081Sbostic "type_code : L byte_size", 33940081Sbostic "struct_code : F", 34040081Sbostic "struct_code : R", 34140081Sbostic "struct_code : P", 34240081Sbostic "mode_code : S", 34340081Sbostic "mode_code : B", 34440081Sbostic "mode_code : C", 34540081Sbostic "pathname : pathstring", 34640081Sbostic "pathstring : STRING", 34740081Sbostic "octal_number : NUMBER", 34840081Sbostic "check_login :", 34940081Sbostic }; 35040081Sbostic #endif 35140081Sbostic #ifndef YYSTYPE 35240081Sbostic typedef int YYSTYPE; 35340081Sbostic #endif 35440081Sbostic #define yyclearin (yychar=(-1)) 35540081Sbostic #define yyerrok (yyerrflag=0) 35640081Sbostic #ifndef YYSTACKSIZE 35740081Sbostic #ifdef YYMAXDEPTH 35840081Sbostic #define YYSTACKSIZE YYMAXDEPTH 35940081Sbostic #else 36040081Sbostic #define YYSTACKSIZE 300 36140081Sbostic #endif 36240081Sbostic #endif 36340081Sbostic int yydebug; 36440081Sbostic int yynerrs; 36540081Sbostic int yyerrflag; 36640081Sbostic int yychar; 36740081Sbostic short *yyssp; 36840081Sbostic YYSTYPE *yyvsp; 36940081Sbostic YYSTYPE yyval; 37040081Sbostic YYSTYPE yylval; 37140081Sbostic #define yystacksize YYSTACKSIZE 37240081Sbostic short yyss[YYSTACKSIZE]; 37340081Sbostic YYSTYPE yyvs[YYSTACKSIZE]; 37440081Sbostic #line 658 "ftp.y" 37540081Sbostic 37640081Sbostic extern jmp_buf errcatch; 37740081Sbostic 37840081Sbostic #define CMD 0 /* beginning of command */ 37940081Sbostic #define ARGS 1 /* expect miscellaneous arguments */ 38040081Sbostic #define STR1 2 /* expect SP followed by STRING */ 38140081Sbostic #define STR2 3 /* expect STRING */ 38240081Sbostic #define OSTR 4 /* optional SP then STRING */ 38340081Sbostic #define ZSTR1 5 /* SP then optional STRING */ 38440081Sbostic #define ZSTR2 6 /* optional STRING after SP */ 38540081Sbostic #define SITECMD 7 /* SITE command */ 38640081Sbostic #define NSTR 8 /* Number followed by a string */ 38740081Sbostic 38840081Sbostic struct tab { 38940081Sbostic char *name; 39040081Sbostic short token; 39140081Sbostic short state; 39240081Sbostic short implemented; /* 1 if command is implemented */ 39340081Sbostic char *help; 39440081Sbostic }; 39540081Sbostic 39640081Sbostic struct tab cmdtab[] = { /* In order defined in RFC 765 */ 39740081Sbostic { "USER", USER, STR1, 1, "<sp> username" }, 39840081Sbostic { "PASS", PASS, ZSTR1, 1, "<sp> password" }, 39940081Sbostic { "ACCT", ACCT, STR1, 0, "(specify account)" }, 40040081Sbostic { "SMNT", SMNT, ARGS, 0, "(structure mount)" }, 40140081Sbostic { "REIN", REIN, ARGS, 0, "(reinitialize server state)" }, 40240081Sbostic { "QUIT", QUIT, ARGS, 1, "(terminate service)", }, 40340081Sbostic { "PORT", PORT, ARGS, 1, "<sp> b0, b1, b2, b3, b4" }, 40440081Sbostic { "PASV", PASV, ARGS, 1, "(set server in passive mode)" }, 40540081Sbostic { "TYPE", TYPE, ARGS, 1, "<sp> [ A | E | I | L ]" }, 40640081Sbostic { "STRU", STRU, ARGS, 1, "(specify file structure)" }, 40740081Sbostic { "MODE", MODE, ARGS, 1, "(specify transfer mode)" }, 40840081Sbostic { "RETR", RETR, STR1, 1, "<sp> file-name" }, 40940081Sbostic { "STOR", STOR, STR1, 1, "<sp> file-name" }, 41040081Sbostic { "APPE", APPE, STR1, 1, "<sp> file-name" }, 41140081Sbostic { "MLFL", MLFL, OSTR, 0, "(mail file)" }, 41240081Sbostic { "MAIL", MAIL, OSTR, 0, "(mail to user)" }, 41340081Sbostic { "MSND", MSND, OSTR, 0, "(mail send to terminal)" }, 41440081Sbostic { "MSOM", MSOM, OSTR, 0, "(mail send to terminal or mailbox)" }, 41540081Sbostic { "MSAM", MSAM, OSTR, 0, "(mail send to terminal and mailbox)" }, 41640081Sbostic { "MRSQ", MRSQ, OSTR, 0, "(mail recipient scheme question)" }, 41740081Sbostic { "MRCP", MRCP, STR1, 0, "(mail recipient)" }, 41840081Sbostic { "ALLO", ALLO, ARGS, 1, "allocate storage (vacuously)" }, 41940081Sbostic { "REST", REST, ARGS, 0, "(restart command)" }, 42040081Sbostic { "RNFR", RNFR, STR1, 1, "<sp> file-name" }, 42140081Sbostic { "RNTO", RNTO, STR1, 1, "<sp> file-name" }, 42240081Sbostic { "ABOR", ABOR, ARGS, 1, "(abort operation)" }, 42340081Sbostic { "DELE", DELE, STR1, 1, "<sp> file-name" }, 42440081Sbostic { "CWD", CWD, OSTR, 1, "[ <sp> directory-name ]" }, 42540081Sbostic { "XCWD", CWD, OSTR, 1, "[ <sp> directory-name ]" }, 42640081Sbostic { "LIST", LIST, OSTR, 1, "[ <sp> path-name ]" }, 42740081Sbostic { "NLST", NLST, OSTR, 1, "[ <sp> path-name ]" }, 42840081Sbostic { "SITE", SITE, SITECMD, 1, "site-cmd [ <sp> arguments ]" }, 42940081Sbostic { "SYST", SYST, ARGS, 1, "(get type of operating system)" }, 43040081Sbostic { "STAT", STAT, OSTR, 1, "[ <sp> path-name ]" }, 43140081Sbostic { "HELP", HELP, OSTR, 1, "[ <sp> <string> ]" }, 43240081Sbostic { "NOOP", NOOP, ARGS, 1, "" }, 43340081Sbostic { "MKD", MKD, STR1, 1, "<sp> path-name" }, 43440081Sbostic { "XMKD", MKD, STR1, 1, "<sp> path-name" }, 43540081Sbostic { "RMD", RMD, STR1, 1, "<sp> path-name" }, 43640081Sbostic { "XRMD", RMD, STR1, 1, "<sp> path-name" }, 43740081Sbostic { "PWD", PWD, ARGS, 1, "(return current directory)" }, 43840081Sbostic { "XPWD", PWD, ARGS, 1, "(return current directory)" }, 43940081Sbostic { "CDUP", CDUP, ARGS, 1, "(change to parent directory)" }, 44040081Sbostic { "XCUP", CDUP, ARGS, 1, "(change to parent directory)" }, 44140081Sbostic { "STOU", STOU, STR1, 1, "<sp> file-name" }, 44240081Sbostic { "SIZE", SIZE, OSTR, 1, "<sp> path-name" }, 44340081Sbostic { "MDTM", MDTM, OSTR, 1, "<sp> path-name" }, 44440081Sbostic { NULL, 0, 0, 0, 0 } 44540081Sbostic }; 44640081Sbostic 44740081Sbostic struct tab sitetab[] = { 44840081Sbostic { "UMASK", UMASK, ARGS, 1, "[ <sp> umask ]" }, 44940081Sbostic { "IDLE", IDLE, ARGS, 1, "[ <sp> maximum-idle-time ]" }, 45040081Sbostic { "CHMOD", CHMOD, NSTR, 1, "<sp> mode <sp> file-name" }, 45140081Sbostic { "HELP", HELP, OSTR, 1, "[ <sp> <string> ]" }, 45240081Sbostic { NULL, 0, 0, 0, 0 } 45340081Sbostic }; 45440081Sbostic 45540081Sbostic struct tab * 45640081Sbostic lookup(p, cmd) 45740081Sbostic register struct tab *p; 45840081Sbostic char *cmd; 45940081Sbostic { 46040081Sbostic 46140081Sbostic for (; p->name != NULL; p++) 46240081Sbostic if (strcmp(cmd, p->name) == 0) 46340081Sbostic return (p); 46440081Sbostic return (0); 46540081Sbostic } 46640081Sbostic 46740081Sbostic #include <arpa/telnet.h> 46840081Sbostic 46940081Sbostic /* 47040081Sbostic * getline - a hacked up version of fgets to ignore TELNET escape codes. 47140081Sbostic */ 47240081Sbostic char * 47340081Sbostic getline(s, n, iop) 47440081Sbostic char *s; 47540081Sbostic register FILE *iop; 47640081Sbostic { 47740081Sbostic register c; 47840081Sbostic register char *cs; 47940081Sbostic 48040081Sbostic cs = s; 48140081Sbostic /* tmpline may contain saved command from urgent mode interruption */ 48240081Sbostic for (c = 0; tmpline[c] != '\0' && --n > 0; ++c) { 48340081Sbostic *cs++ = tmpline[c]; 48440081Sbostic if (tmpline[c] == '\n') { 48540081Sbostic *cs++ = '\0'; 48640081Sbostic if (debug) 48740081Sbostic syslog(LOG_DEBUG, "command: %s", s); 48840081Sbostic tmpline[0] = '\0'; 48940081Sbostic return(s); 49040081Sbostic } 49140081Sbostic if (c == 0) 49240081Sbostic tmpline[0] = '\0'; 49340081Sbostic } 49440081Sbostic while ((c = getc(iop)) != EOF) { 49540081Sbostic c &= 0377; 49640081Sbostic if (c == IAC) { 49740081Sbostic if ((c = getc(iop)) != EOF) { 49840081Sbostic c &= 0377; 49940081Sbostic switch (c) { 50040081Sbostic case WILL: 50140081Sbostic case WONT: 50240081Sbostic c = getc(iop); 50340081Sbostic printf("%c%c%c", IAC, DONT, 0377&c); 50440081Sbostic (void) fflush(stdout); 50540081Sbostic continue; 50640081Sbostic case DO: 50740081Sbostic case DONT: 50840081Sbostic c = getc(iop); 50940081Sbostic printf("%c%c%c", IAC, WONT, 0377&c); 51040081Sbostic (void) fflush(stdout); 51140081Sbostic continue; 51240081Sbostic case IAC: 51340081Sbostic break; 51440081Sbostic default: 51540081Sbostic continue; /* ignore command */ 51640081Sbostic } 51740081Sbostic } 51840081Sbostic } 51940081Sbostic *cs++ = c; 52040081Sbostic if (--n <= 0 || c == '\n') 52140081Sbostic break; 52240081Sbostic } 52340081Sbostic if (c == EOF && cs == s) 52440081Sbostic return (NULL); 52540081Sbostic *cs++ = '\0'; 52640081Sbostic if (debug) 52740081Sbostic syslog(LOG_DEBUG, "command: %s", s); 52840081Sbostic return (s); 52940081Sbostic } 53040081Sbostic 53140081Sbostic static int 53240081Sbostic toolong() 53340081Sbostic { 53440081Sbostic time_t now; 53540081Sbostic extern char *ctime(); 53640081Sbostic extern time_t time(); 53740081Sbostic 53840081Sbostic reply(421, 53940081Sbostic "Timeout (%d seconds): closing control connection.", timeout); 54040081Sbostic (void) time(&now); 54140081Sbostic if (logging) { 54240081Sbostic syslog(LOG_INFO, 54340081Sbostic "User %s timed out after %d seconds at %s", 54440081Sbostic (pw ? pw -> pw_name : "unknown"), timeout, ctime(&now)); 54540081Sbostic } 54640081Sbostic dologout(1); 54740081Sbostic } 54840081Sbostic 54940081Sbostic yylex() 55040081Sbostic { 55140081Sbostic static int cpos, state; 55240081Sbostic register char *cp, *cp2; 55340081Sbostic register struct tab *p; 55440081Sbostic int n; 55540081Sbostic char c, *strpbrk(); 55640081Sbostic char *copy(); 55740081Sbostic 55840081Sbostic for (;;) { 55940081Sbostic switch (state) { 56040081Sbostic 56140081Sbostic case CMD: 56240081Sbostic (void) signal(SIGALRM, toolong); 56340081Sbostic (void) alarm((unsigned) timeout); 56440081Sbostic if (getline(cbuf, sizeof(cbuf)-1, stdin) == NULL) { 56540081Sbostic reply(221, "You could at least say goodbye."); 56640081Sbostic dologout(0); 56740081Sbostic } 56840081Sbostic (void) alarm(0); 56940081Sbostic #ifdef SETPROCTITLE 57040081Sbostic if (strncasecmp(cbuf, "PASS", 4) != NULL) 57140081Sbostic setproctitle("%s: %s", proctitle, cbuf); 57240081Sbostic #endif /* SETPROCTITLE */ 57340081Sbostic if ((cp = index(cbuf, '\r'))) { 57440081Sbostic *cp++ = '\n'; 57540081Sbostic *cp = '\0'; 57640081Sbostic } 57740081Sbostic if ((cp = strpbrk(cbuf, " \n"))) 57840081Sbostic cpos = cp - cbuf; 57940081Sbostic if (cpos == 0) 58040081Sbostic cpos = 4; 58140081Sbostic c = cbuf[cpos]; 58240081Sbostic cbuf[cpos] = '\0'; 58340081Sbostic upper(cbuf); 58440081Sbostic p = lookup(cmdtab, cbuf); 58540081Sbostic cbuf[cpos] = c; 58640081Sbostic if (p != 0) { 58740081Sbostic if (p->implemented == 0) { 58840081Sbostic nack(p->name); 58940081Sbostic longjmp(errcatch,0); 59040081Sbostic /* NOTREACHED */ 59140081Sbostic } 59240081Sbostic state = p->state; 59340081Sbostic *(char **)&yylval = p->name; 59440081Sbostic return (p->token); 59540081Sbostic } 59640081Sbostic break; 59740081Sbostic 59840081Sbostic case SITECMD: 59940081Sbostic if (cbuf[cpos] == ' ') { 60040081Sbostic cpos++; 60140081Sbostic return (SP); 60240081Sbostic } 60340081Sbostic cp = &cbuf[cpos]; 60440081Sbostic if ((cp2 = strpbrk(cp, " \n"))) 60540081Sbostic cpos = cp2 - cbuf; 60640081Sbostic c = cbuf[cpos]; 60740081Sbostic cbuf[cpos] = '\0'; 60840081Sbostic upper(cp); 60940081Sbostic p = lookup(sitetab, cp); 61040081Sbostic cbuf[cpos] = c; 61140081Sbostic if (p != 0) { 61240081Sbostic if (p->implemented == 0) { 61340081Sbostic state = CMD; 61440081Sbostic nack(p->name); 61540081Sbostic longjmp(errcatch,0); 61640081Sbostic /* NOTREACHED */ 61740081Sbostic } 61840081Sbostic state = p->state; 61940081Sbostic *(char **)&yylval = p->name; 62040081Sbostic return (p->token); 62140081Sbostic } 62240081Sbostic state = CMD; 62340081Sbostic break; 62440081Sbostic 62540081Sbostic case OSTR: 62640081Sbostic if (cbuf[cpos] == '\n') { 62740081Sbostic state = CMD; 62840081Sbostic return (CRLF); 62940081Sbostic } 63040081Sbostic /* FALLTHROUGH */ 63140081Sbostic 63240081Sbostic case STR1: 63340081Sbostic case ZSTR1: 63440081Sbostic dostr1: 63540081Sbostic if (cbuf[cpos] == ' ') { 63640081Sbostic cpos++; 63740081Sbostic state = state == OSTR ? STR2 : ++state; 63840081Sbostic return (SP); 63940081Sbostic } 64040081Sbostic break; 64140081Sbostic 64240081Sbostic case ZSTR2: 64340081Sbostic if (cbuf[cpos] == '\n') { 64440081Sbostic state = CMD; 64540081Sbostic return (CRLF); 64640081Sbostic } 64740081Sbostic /* FALLTHROUGH */ 64840081Sbostic 64940081Sbostic case STR2: 65040081Sbostic cp = &cbuf[cpos]; 65140081Sbostic n = strlen(cp); 65240081Sbostic cpos += n - 1; 65340081Sbostic /* 65440081Sbostic * Make sure the string is nonempty and \n terminated. 65540081Sbostic */ 65640081Sbostic if (n > 1 && cbuf[cpos] == '\n') { 65740081Sbostic cbuf[cpos] = '\0'; 65840081Sbostic *(char **)&yylval = copy(cp); 65940081Sbostic cbuf[cpos] = '\n'; 66040081Sbostic state = ARGS; 66140081Sbostic return (STRING); 66240081Sbostic } 66340081Sbostic break; 66440081Sbostic 66540081Sbostic case NSTR: 66640081Sbostic if (cbuf[cpos] == ' ') { 66740081Sbostic cpos++; 66840081Sbostic return (SP); 66940081Sbostic } 67040081Sbostic if (isdigit(cbuf[cpos])) { 67140081Sbostic cp = &cbuf[cpos]; 67240081Sbostic while (isdigit(cbuf[++cpos])) 67340081Sbostic ; 67440081Sbostic c = cbuf[cpos]; 67540081Sbostic cbuf[cpos] = '\0'; 67640081Sbostic yylval = atoi(cp); 67740081Sbostic cbuf[cpos] = c; 67840081Sbostic state = STR1; 67940081Sbostic return (NUMBER); 68040081Sbostic } 68140081Sbostic state = STR1; 68240081Sbostic goto dostr1; 68340081Sbostic 68440081Sbostic case ARGS: 68540081Sbostic if (isdigit(cbuf[cpos])) { 68640081Sbostic cp = &cbuf[cpos]; 68740081Sbostic while (isdigit(cbuf[++cpos])) 68840081Sbostic ; 68940081Sbostic c = cbuf[cpos]; 69040081Sbostic cbuf[cpos] = '\0'; 69140081Sbostic yylval = atoi(cp); 69240081Sbostic cbuf[cpos] = c; 69340081Sbostic return (NUMBER); 69440081Sbostic } 69540081Sbostic switch (cbuf[cpos++]) { 69640081Sbostic 69740081Sbostic case '\n': 69840081Sbostic state = CMD; 69940081Sbostic return (CRLF); 70040081Sbostic 70140081Sbostic case ' ': 70240081Sbostic return (SP); 70340081Sbostic 70440081Sbostic case ',': 70540081Sbostic return (COMMA); 70640081Sbostic 70740081Sbostic case 'A': 70840081Sbostic case 'a': 70940081Sbostic return (A); 71040081Sbostic 71140081Sbostic case 'B': 71240081Sbostic case 'b': 71340081Sbostic return (B); 71440081Sbostic 71540081Sbostic case 'C': 71640081Sbostic case 'c': 71740081Sbostic return (C); 71840081Sbostic 71940081Sbostic case 'E': 72040081Sbostic case 'e': 72140081Sbostic return (E); 72240081Sbostic 72340081Sbostic case 'F': 72440081Sbostic case 'f': 72540081Sbostic return (F); 72640081Sbostic 72740081Sbostic case 'I': 72840081Sbostic case 'i': 72940081Sbostic return (I); 73040081Sbostic 73140081Sbostic case 'L': 73240081Sbostic case 'l': 73340081Sbostic return (L); 73440081Sbostic 73540081Sbostic case 'N': 73640081Sbostic case 'n': 73740081Sbostic return (N); 73840081Sbostic 73940081Sbostic case 'P': 74040081Sbostic case 'p': 74140081Sbostic return (P); 74240081Sbostic 74340081Sbostic case 'R': 74440081Sbostic case 'r': 74540081Sbostic return (R); 74640081Sbostic 74740081Sbostic case 'S': 74840081Sbostic case 's': 74940081Sbostic return (S); 75040081Sbostic 75140081Sbostic case 'T': 75240081Sbostic case 't': 75340081Sbostic return (T); 75440081Sbostic 75540081Sbostic } 75640081Sbostic break; 75740081Sbostic 75840081Sbostic default: 75940081Sbostic fatal("Unknown state in scanner."); 76040081Sbostic } 76140081Sbostic yyerror((char *) 0); 76240081Sbostic state = CMD; 76340081Sbostic longjmp(errcatch,0); 76440081Sbostic } 76540081Sbostic } 76640081Sbostic 76740081Sbostic upper(s) 76840081Sbostic register char *s; 76940081Sbostic { 77040081Sbostic while (*s != '\0') { 77140081Sbostic if (islower(*s)) 77240081Sbostic *s = toupper(*s); 77340081Sbostic s++; 77440081Sbostic } 77540081Sbostic } 77640081Sbostic 77740081Sbostic char * 77840081Sbostic copy(s) 77940081Sbostic char *s; 78040081Sbostic { 78140081Sbostic char *p; 78240081Sbostic extern char *malloc(), *strcpy(); 78340081Sbostic 78440081Sbostic p = malloc((unsigned) strlen(s) + 1); 78540081Sbostic if (p == NULL) 78640081Sbostic fatal("Ran out of memory."); 78740081Sbostic (void) strcpy(p, s); 78840081Sbostic return (p); 78940081Sbostic } 79040081Sbostic 79140081Sbostic help(ctab, s) 79240081Sbostic struct tab *ctab; 79340081Sbostic char *s; 79440081Sbostic { 79540081Sbostic register struct tab *c; 79640081Sbostic register int width, NCMDS; 79740081Sbostic char *type; 79840081Sbostic 79940081Sbostic if (ctab == sitetab) 80040081Sbostic type = "SITE "; 80140081Sbostic else 80240081Sbostic type = ""; 80340081Sbostic width = 0, NCMDS = 0; 80440081Sbostic for (c = ctab; c->name != NULL; c++) { 80540081Sbostic int len = strlen(c->name); 80640081Sbostic 80740081Sbostic if (len > width) 80840081Sbostic width = len; 80940081Sbostic NCMDS++; 81040081Sbostic } 81140081Sbostic width = (width + 8) &~ 7; 81240081Sbostic if (s == 0) { 81340081Sbostic register int i, j, w; 81440081Sbostic int columns, lines; 81540081Sbostic 81640081Sbostic lreply(214, "The following %scommands are recognized %s.", 81740081Sbostic type, "(* =>'s unimplemented)"); 81840081Sbostic columns = 76 / width; 81940081Sbostic if (columns == 0) 82040081Sbostic columns = 1; 82140081Sbostic lines = (NCMDS + columns - 1) / columns; 82240081Sbostic for (i = 0; i < lines; i++) { 82340081Sbostic printf(" "); 82440081Sbostic for (j = 0; j < columns; j++) { 82540081Sbostic c = ctab + j * lines + i; 82640081Sbostic printf("%s%c", c->name, 82740081Sbostic c->implemented ? ' ' : '*'); 82840081Sbostic if (c + lines >= &ctab[NCMDS]) 82940081Sbostic break; 83040081Sbostic w = strlen(c->name) + 1; 83140081Sbostic while (w < width) { 83240081Sbostic putchar(' '); 83340081Sbostic w++; 83440081Sbostic } 83540081Sbostic } 83640081Sbostic printf("\r\n"); 83740081Sbostic } 83840081Sbostic (void) fflush(stdout); 83940081Sbostic reply(214, "Direct comments to ftp-bugs@%s.", hostname); 84040081Sbostic return; 84140081Sbostic } 84240081Sbostic upper(s); 84340081Sbostic c = lookup(ctab, s); 84440081Sbostic if (c == (struct tab *)0) { 84540081Sbostic reply(502, "Unknown command %s.", s); 84640081Sbostic return; 84740081Sbostic } 84840081Sbostic if (c->implemented) 84940081Sbostic reply(214, "Syntax: %s%s %s", type, c->name, c->help); 85040081Sbostic else 85140081Sbostic reply(214, "%s%-*s\t%s; unimplemented.", type, width, 85240081Sbostic c->name, c->help); 85340081Sbostic } 85440081Sbostic 85540081Sbostic sizecmd(filename) 85640081Sbostic char *filename; 85740081Sbostic { 85840081Sbostic switch (type) { 85940081Sbostic case TYPE_L: 86040081Sbostic case TYPE_I: { 86140081Sbostic struct stat stbuf; 86240081Sbostic if (stat(filename, &stbuf) < 0 || 86340081Sbostic (stbuf.st_mode&S_IFMT) != S_IFREG) 86440081Sbostic reply(550, "%s: not a plain file.", filename); 86540081Sbostic else 86640081Sbostic reply(213, "%lu", stbuf.st_size); 86740081Sbostic break;} 86840081Sbostic case TYPE_A: { 86940081Sbostic FILE *fin; 87040081Sbostic register int c, count; 87140081Sbostic struct stat stbuf; 87240081Sbostic fin = fopen(filename, "r"); 87340081Sbostic if (fin == NULL) { 87440081Sbostic perror_reply(550, filename); 87540081Sbostic return; 87640081Sbostic } 87740081Sbostic if (fstat(fileno(fin), &stbuf) < 0 || 87840081Sbostic (stbuf.st_mode&S_IFMT) != S_IFREG) { 87940081Sbostic reply(550, "%s: not a plain file.", filename); 88040081Sbostic (void) fclose(fin); 88140081Sbostic return; 88240081Sbostic } 88340081Sbostic 88440081Sbostic count = 0; 88540081Sbostic while((c=getc(fin)) != EOF) { 88640081Sbostic if (c == '\n') /* will get expanded to \r\n */ 88740081Sbostic count++; 88840081Sbostic count++; 88940081Sbostic } 89040081Sbostic (void) fclose(fin); 89140081Sbostic 89240081Sbostic reply(213, "%ld", count); 89340081Sbostic break;} 89440081Sbostic default: 89540081Sbostic reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]); 89640081Sbostic } 89740081Sbostic } 898*40084Sbostic #line 898 "ftp.tab.c" 899*40084Sbostic #define YYABORT goto yyabort 90040081Sbostic #define YYACCEPT goto yyaccept 90140081Sbostic #define YYERROR goto yyerrlab 90240081Sbostic int 90340081Sbostic yyparse() 90440081Sbostic { 90540081Sbostic register int yym, yyn, yystate; 90640081Sbostic #if YYDEBUG 90740081Sbostic register char *yys; 90840081Sbostic extern char *getenv(); 90940081Sbostic 91040081Sbostic if (yys = getenv("YYDEBUG")) 91140081Sbostic { 91240081Sbostic yyn = *yys; 91340081Sbostic if (yyn == '0') 91440081Sbostic yydebug = 0; 91540081Sbostic else if (yyn >= '1' && yyn <= '9') 91640081Sbostic yydebug = yyn - '0'; 91740081Sbostic } 91840081Sbostic #endif 91940081Sbostic 92040081Sbostic yynerrs = 0; 92140081Sbostic yyerrflag = 0; 92240081Sbostic yychar = (-1); 92340081Sbostic 92440081Sbostic yyssp = yyss; 92540081Sbostic yyvsp = yyvs; 92640081Sbostic *yyssp = yystate = 0; 92740081Sbostic 92840081Sbostic yyloop: 92940081Sbostic if (yyn = yydefred[yystate]) goto yyreduce; 93040081Sbostic if (yychar < 0) 93140081Sbostic { 93240081Sbostic if ((yychar = yylex()) < 0) yychar = 0; 93340081Sbostic #if YYDEBUG 93440081Sbostic if (yydebug) 93540081Sbostic { 93640081Sbostic yys = 0; 93740081Sbostic if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; 93840081Sbostic if (!yys) yys = "illegal-symbol"; 93940081Sbostic printf("yydebug: state %d, reading %d (%s)\n", yystate, 94040081Sbostic yychar, yys); 94140081Sbostic } 94240081Sbostic #endif 94340081Sbostic } 94440081Sbostic if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && 94540081Sbostic yyn <= YYTABLESIZE && yycheck[yyn] == yychar) 94640081Sbostic { 94740081Sbostic #if YYDEBUG 94840081Sbostic if (yydebug) 94940081Sbostic printf("yydebug: state %d, shifting to state %d\n", 95040081Sbostic yystate, yytable[yyn]); 95140081Sbostic #endif 95240081Sbostic if (yyssp >= yyss + yystacksize - 1) 95340081Sbostic { 95440081Sbostic goto yyoverflow; 95540081Sbostic } 95640081Sbostic *++yyssp = yystate = yytable[yyn]; 95740081Sbostic *++yyvsp = yylval; 95840081Sbostic yychar = (-1); 95940081Sbostic if (yyerrflag > 0) --yyerrflag; 96040081Sbostic goto yyloop; 96140081Sbostic } 96240081Sbostic if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && 96340081Sbostic yyn <= YYTABLESIZE && yycheck[yyn] == yychar) 96440081Sbostic { 96540081Sbostic yyn = yytable[yyn]; 96640081Sbostic goto yyreduce; 96740081Sbostic } 96840081Sbostic if (yyerrflag) goto yyinrecovery; 969*40084Sbostic #ifdef lint 970*40084Sbostic goto yynewerror; 971*40084Sbostic #endif 97240081Sbostic yynewerror: 97340081Sbostic yyerror("syntax error"); 974*40084Sbostic #ifdef lint 975*40084Sbostic goto yyerrlab; 976*40084Sbostic #endif 97740081Sbostic yyerrlab: 97840081Sbostic ++yynerrs; 97940081Sbostic yyinrecovery: 98040081Sbostic if (yyerrflag < 3) 98140081Sbostic { 98240081Sbostic yyerrflag = 3; 98340081Sbostic for (;;) 98440081Sbostic { 98540081Sbostic if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && 98640081Sbostic yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) 98740081Sbostic { 98840081Sbostic #if YYDEBUG 98940081Sbostic if (yydebug) 99040081Sbostic printf("yydebug: state %d, error recovery shifting\ 99140081Sbostic to state %d\n", *yyssp, yytable[yyn]); 99240081Sbostic #endif 99340081Sbostic if (yyssp >= yyss + yystacksize - 1) 99440081Sbostic { 99540081Sbostic goto yyoverflow; 99640081Sbostic } 99740081Sbostic *++yyssp = yystate = yytable[yyn]; 99840081Sbostic *++yyvsp = yylval; 99940081Sbostic goto yyloop; 100040081Sbostic } 100140081Sbostic else 100240081Sbostic { 100340081Sbostic #if YYDEBUG 100440081Sbostic if (yydebug) 100540081Sbostic printf("yydebug: error recovery discarding state %d\n", 100640081Sbostic *yyssp); 100740081Sbostic #endif 100840081Sbostic if (yyssp <= yyss) goto yyabort; 100940081Sbostic --yyssp; 101040081Sbostic --yyvsp; 101140081Sbostic } 101240081Sbostic } 101340081Sbostic } 101440081Sbostic else 101540081Sbostic { 101640081Sbostic if (yychar == 0) goto yyabort; 101740081Sbostic #if YYDEBUG 101840081Sbostic if (yydebug) 101940081Sbostic { 102040081Sbostic yys = 0; 102140081Sbostic if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; 102240081Sbostic if (!yys) yys = "illegal-symbol"; 102340081Sbostic printf("yydebug: state %d, error recovery discards token %d (%s)\n", 102440081Sbostic yystate, yychar, yys); 102540081Sbostic } 102640081Sbostic #endif 102740081Sbostic yychar = (-1); 102840081Sbostic goto yyloop; 102940081Sbostic } 103040081Sbostic yyreduce: 103140081Sbostic #if YYDEBUG 103240081Sbostic if (yydebug) 103340081Sbostic printf("yydebug: state %d, reducing by rule %d (%s)\n", 103440081Sbostic yystate, yyn, yyrule[yyn]); 103540081Sbostic #endif 103640081Sbostic yym = yylen[yyn]; 103740081Sbostic yyval = yyvsp[1-yym]; 103840081Sbostic switch (yyn) 103940081Sbostic { 104040081Sbostic case 2: 104140081Sbostic #line 99 "ftp.y" 104240081Sbostic { 104340081Sbostic fromname = (char *) 0; 104440081Sbostic } 104540081Sbostic break; 104640081Sbostic case 4: 104740081Sbostic #line 106 "ftp.y" 104840081Sbostic { 104940081Sbostic user((char *) yyvsp[-1]); 105040081Sbostic free((char *) yyvsp[-1]); 105140081Sbostic } 105240081Sbostic break; 105340081Sbostic case 5: 105440081Sbostic #line 111 "ftp.y" 105540081Sbostic { 105640081Sbostic pass((char *) yyvsp[-1]); 105740081Sbostic free((char *) yyvsp[-1]); 105840081Sbostic } 105940081Sbostic break; 106040081Sbostic case 6: 106140081Sbostic #line 116 "ftp.y" 106240081Sbostic { 106340081Sbostic usedefault = 0; 106440081Sbostic if (pdata >= 0) { 106540081Sbostic (void) close(pdata); 106640081Sbostic pdata = -1; 106740081Sbostic } 106840081Sbostic reply(200, "PORT command successful."); 106940081Sbostic } 107040081Sbostic break; 107140081Sbostic case 7: 107240081Sbostic #line 125 "ftp.y" 107340081Sbostic { 107440081Sbostic passive(); 107540081Sbostic } 107640081Sbostic break; 107740081Sbostic case 8: 107840081Sbostic #line 129 "ftp.y" 107940081Sbostic { 108040081Sbostic switch (cmd_type) { 108140081Sbostic 108240081Sbostic case TYPE_A: 108340081Sbostic if (cmd_form == FORM_N) { 108440081Sbostic reply(200, "Type set to A."); 108540081Sbostic type = cmd_type; 108640081Sbostic form = cmd_form; 108740081Sbostic } else 108840081Sbostic reply(504, "Form must be N."); 108940081Sbostic break; 109040081Sbostic 109140081Sbostic case TYPE_E: 109240081Sbostic reply(504, "Type E not implemented."); 109340081Sbostic break; 109440081Sbostic 109540081Sbostic case TYPE_I: 109640081Sbostic reply(200, "Type set to I."); 109740081Sbostic type = cmd_type; 109840081Sbostic break; 109940081Sbostic 110040081Sbostic case TYPE_L: 110140081Sbostic #if NBBY == 8 110240081Sbostic if (cmd_bytesz == 8) { 110340081Sbostic reply(200, 110440081Sbostic "Type set to L (byte size 8)."); 110540081Sbostic type = cmd_type; 110640081Sbostic } else 110740081Sbostic reply(504, "Byte size must be 8."); 110840081Sbostic #else /* NBBY == 8 */ 110940081Sbostic UNIMPLEMENTED for NBBY != 8 111040081Sbostic #endif /* NBBY == 8 */ 111140081Sbostic } 111240081Sbostic } 111340081Sbostic break; 111440081Sbostic case 9: 111540081Sbostic #line 164 "ftp.y" 111640081Sbostic { 111740081Sbostic switch (yyvsp[-1]) { 111840081Sbostic 111940081Sbostic case STRU_F: 112040081Sbostic reply(200, "STRU F ok."); 112140081Sbostic break; 112240081Sbostic 112340081Sbostic default: 112440081Sbostic reply(504, "Unimplemented STRU type."); 112540081Sbostic } 112640081Sbostic } 112740081Sbostic break; 112840081Sbostic case 10: 112940081Sbostic #line 176 "ftp.y" 113040081Sbostic { 113140081Sbostic switch (yyvsp[-1]) { 113240081Sbostic 113340081Sbostic case MODE_S: 113440081Sbostic reply(200, "MODE S ok."); 113540081Sbostic break; 113640081Sbostic 113740081Sbostic default: 113840081Sbostic reply(502, "Unimplemented MODE type."); 113940081Sbostic } 114040081Sbostic } 114140081Sbostic break; 114240081Sbostic case 11: 114340081Sbostic #line 188 "ftp.y" 114440081Sbostic { 114540081Sbostic reply(202, "ALLO command ignored."); 114640081Sbostic } 114740081Sbostic break; 114840081Sbostic case 12: 114940081Sbostic #line 192 "ftp.y" 115040081Sbostic { 115140081Sbostic reply(202, "ALLO command ignored."); 115240081Sbostic } 115340081Sbostic break; 115440081Sbostic case 13: 115540081Sbostic #line 196 "ftp.y" 115640081Sbostic { 115740081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL) 115840081Sbostic retrieve((char *) 0, (char *) yyvsp[-1]); 115940081Sbostic if (yyvsp[-1] != NULL) 116040081Sbostic free((char *) yyvsp[-1]); 116140081Sbostic } 116240081Sbostic break; 116340081Sbostic case 14: 116440081Sbostic #line 203 "ftp.y" 116540081Sbostic { 116640081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL) 116740081Sbostic store((char *) yyvsp[-1], "w", 0); 116840081Sbostic if (yyvsp[-1] != NULL) 116940081Sbostic free((char *) yyvsp[-1]); 117040081Sbostic } 117140081Sbostic break; 117240081Sbostic case 15: 117340081Sbostic #line 210 "ftp.y" 117440081Sbostic { 117540081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL) 117640081Sbostic store((char *) yyvsp[-1], "a", 0); 117740081Sbostic if (yyvsp[-1] != NULL) 117840081Sbostic free((char *) yyvsp[-1]); 117940081Sbostic } 118040081Sbostic break; 118140081Sbostic case 16: 118240081Sbostic #line 217 "ftp.y" 118340081Sbostic { 118440081Sbostic if (yyvsp[-1]) 118540081Sbostic send_file_list("."); 118640081Sbostic } 118740081Sbostic break; 118840081Sbostic case 17: 118940081Sbostic #line 222 "ftp.y" 119040081Sbostic { 119140081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL) 119240081Sbostic send_file_list((char *) yyvsp[-1]); 119340081Sbostic if (yyvsp[-1] != NULL) 119440081Sbostic free((char *) yyvsp[-1]); 119540081Sbostic } 119640081Sbostic break; 119740081Sbostic case 18: 119840081Sbostic #line 229 "ftp.y" 119940081Sbostic { 120040081Sbostic if (yyvsp[-1]) 120140081Sbostic retrieve("/bin/ls -lgA", ""); 120240081Sbostic } 120340081Sbostic break; 120440081Sbostic case 19: 120540081Sbostic #line 234 "ftp.y" 120640081Sbostic { 120740081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL) 120840081Sbostic retrieve("/bin/ls -lgA %s", (char *) yyvsp[-1]); 120940081Sbostic if (yyvsp[-1] != NULL) 121040081Sbostic free((char *) yyvsp[-1]); 121140081Sbostic } 121240081Sbostic break; 121340081Sbostic case 20: 121440081Sbostic #line 241 "ftp.y" 121540081Sbostic { 121640081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL) 121740081Sbostic statfilecmd((char *) yyvsp[-1]); 121840081Sbostic if (yyvsp[-1] != NULL) 121940081Sbostic free((char *) yyvsp[-1]); 122040081Sbostic } 122140081Sbostic break; 122240081Sbostic case 21: 122340081Sbostic #line 248 "ftp.y" 122440081Sbostic { 122540081Sbostic statcmd(); 122640081Sbostic } 122740081Sbostic break; 122840081Sbostic case 22: 122940081Sbostic #line 252 "ftp.y" 123040081Sbostic { 123140081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL) 123240081Sbostic delete((char *) yyvsp[-1]); 123340081Sbostic if (yyvsp[-1] != NULL) 123440081Sbostic free((char *) yyvsp[-1]); 123540081Sbostic } 123640081Sbostic break; 123740081Sbostic case 23: 123840081Sbostic #line 259 "ftp.y" 123940081Sbostic { 124040081Sbostic if (fromname) { 124140081Sbostic renamecmd(fromname, (char *) yyvsp[-1]); 124240081Sbostic free(fromname); 124340081Sbostic fromname = (char *) 0; 124440081Sbostic } else { 124540081Sbostic reply(503, "Bad sequence of commands."); 124640081Sbostic } 124740081Sbostic free((char *) yyvsp[-1]); 124840081Sbostic } 124940081Sbostic break; 125040081Sbostic case 24: 125140081Sbostic #line 270 "ftp.y" 125240081Sbostic { 125340081Sbostic reply(225, "ABOR command successful."); 125440081Sbostic } 125540081Sbostic break; 125640081Sbostic case 25: 125740081Sbostic #line 274 "ftp.y" 125840081Sbostic { 125940081Sbostic if (yyvsp[-1]) 126040081Sbostic cwd(pw->pw_dir); 126140081Sbostic } 126240081Sbostic break; 126340081Sbostic case 26: 126440081Sbostic #line 279 "ftp.y" 126540081Sbostic { 126640081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL) 126740081Sbostic cwd((char *) yyvsp[-1]); 126840081Sbostic if (yyvsp[-1] != NULL) 126940081Sbostic free((char *) yyvsp[-1]); 127040081Sbostic } 127140081Sbostic break; 127240081Sbostic case 27: 127340081Sbostic #line 286 "ftp.y" 127440081Sbostic { 127540081Sbostic help(cmdtab, (char *) 0); 127640081Sbostic } 127740081Sbostic break; 127840081Sbostic case 28: 127940081Sbostic #line 290 "ftp.y" 128040081Sbostic { 128140081Sbostic register char *cp = (char *)yyvsp[-1]; 128240081Sbostic 128340081Sbostic if (strncasecmp(cp, "SITE", 4) == 0) { 128440081Sbostic cp = (char *)yyvsp[-1] + 4; 128540081Sbostic if (*cp == ' ') 128640081Sbostic cp++; 128740081Sbostic if (*cp) 128840081Sbostic help(sitetab, cp); 128940081Sbostic else 129040081Sbostic help(sitetab, (char *) 0); 129140081Sbostic } else 129240081Sbostic help(cmdtab, (char *) yyvsp[-1]); 129340081Sbostic } 129440081Sbostic break; 129540081Sbostic case 29: 129640081Sbostic #line 305 "ftp.y" 129740081Sbostic { 129840081Sbostic reply(200, "NOOP command successful."); 129940081Sbostic } 130040081Sbostic break; 130140081Sbostic case 30: 130240081Sbostic #line 309 "ftp.y" 130340081Sbostic { 130440081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL) 130540081Sbostic makedir((char *) yyvsp[-1]); 130640081Sbostic if (yyvsp[-1] != NULL) 130740081Sbostic free((char *) yyvsp[-1]); 130840081Sbostic } 130940081Sbostic break; 131040081Sbostic case 31: 131140081Sbostic #line 316 "ftp.y" 131240081Sbostic { 131340081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL) 131440081Sbostic removedir((char *) yyvsp[-1]); 131540081Sbostic if (yyvsp[-1] != NULL) 131640081Sbostic free((char *) yyvsp[-1]); 131740081Sbostic } 131840081Sbostic break; 131940081Sbostic case 32: 132040081Sbostic #line 323 "ftp.y" 132140081Sbostic { 132240081Sbostic if (yyvsp[-1]) 132340081Sbostic pwd(); 132440081Sbostic } 132540081Sbostic break; 132640081Sbostic case 33: 132740081Sbostic #line 328 "ftp.y" 132840081Sbostic { 132940081Sbostic if (yyvsp[-1]) 133040081Sbostic cwd(".."); 133140081Sbostic } 133240081Sbostic break; 133340081Sbostic case 34: 133440081Sbostic #line 333 "ftp.y" 133540081Sbostic { 133640081Sbostic help(sitetab, (char *) 0); 133740081Sbostic } 133840081Sbostic break; 133940081Sbostic case 35: 134040081Sbostic #line 337 "ftp.y" 134140081Sbostic { 134240081Sbostic help(sitetab, (char *) yyvsp[-1]); 134340081Sbostic } 134440081Sbostic break; 134540081Sbostic case 36: 134640081Sbostic #line 341 "ftp.y" 134740081Sbostic { 134840081Sbostic int oldmask; 134940081Sbostic 135040081Sbostic if (yyvsp[-1]) { 135140081Sbostic oldmask = umask(0); 135240081Sbostic (void) umask(oldmask); 135340081Sbostic reply(200, "Current UMASK is %03o", oldmask); 135440081Sbostic } 135540081Sbostic } 135640081Sbostic break; 135740081Sbostic case 37: 135840081Sbostic #line 351 "ftp.y" 135940081Sbostic { 136040081Sbostic int oldmask; 136140081Sbostic 136240081Sbostic if (yyvsp[-3]) { 136340081Sbostic if ((yyvsp[-1] == -1) || (yyvsp[-1] > 0777)) { 136440081Sbostic reply(501, "Bad UMASK value"); 136540081Sbostic } else { 136640081Sbostic oldmask = umask(yyvsp[-1]); 136740081Sbostic reply(200, 136840081Sbostic "UMASK set to %03o (was %03o)", 136940081Sbostic yyvsp[-1], oldmask); 137040081Sbostic } 137140081Sbostic } 137240081Sbostic } 137340081Sbostic break; 137440081Sbostic case 38: 137540081Sbostic #line 366 "ftp.y" 137640081Sbostic { 137740081Sbostic if (yyvsp[-5] && (yyvsp[-1] != NULL)) { 137840081Sbostic if (yyvsp[-3] > 0777) 137940081Sbostic reply(501, 138040081Sbostic "CHMOD: Mode value must be between 0 and 0777"); 138140081Sbostic else if (chmod((char *) yyvsp[-1], yyvsp[-3]) < 0) 138240081Sbostic perror_reply(550, (char *) yyvsp[-1]); 138340081Sbostic else 138440081Sbostic reply(200, "CHMOD command successful."); 138540081Sbostic } 138640081Sbostic if (yyvsp[-1] != NULL) 138740081Sbostic free((char *) yyvsp[-1]); 138840081Sbostic } 138940081Sbostic break; 139040081Sbostic case 39: 139140081Sbostic #line 380 "ftp.y" 139240081Sbostic { 139340081Sbostic reply(200, 139440081Sbostic "Current IDLE time limit is %d seconds; max %d", 139540081Sbostic timeout, maxtimeout); 139640081Sbostic } 139740081Sbostic break; 139840081Sbostic case 40: 139940081Sbostic #line 386 "ftp.y" 140040081Sbostic { 140140081Sbostic if (yyvsp[-1] < 30 || yyvsp[-1] > maxtimeout) { 140240081Sbostic reply(501, 140340081Sbostic "Maximum IDLE time must be between 30 and %d seconds", 140440081Sbostic maxtimeout); 140540081Sbostic } else { 140640081Sbostic timeout = yyvsp[-1]; 140740081Sbostic (void) alarm((unsigned) timeout); 140840081Sbostic reply(200, 140940081Sbostic "Maximum IDLE time set to %d seconds", 141040081Sbostic timeout); 141140081Sbostic } 141240081Sbostic } 141340081Sbostic break; 141440081Sbostic case 41: 141540081Sbostic #line 400 "ftp.y" 141640081Sbostic { 141740081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL) 141840081Sbostic store((char *) yyvsp[-1], "w", 1); 141940081Sbostic if (yyvsp[-1] != NULL) 142040081Sbostic free((char *) yyvsp[-1]); 142140081Sbostic } 142240081Sbostic break; 142340081Sbostic case 42: 142440081Sbostic #line 407 "ftp.y" 142540081Sbostic { 142640081Sbostic #ifdef unix 142740081Sbostic #ifdef BSD 142840081Sbostic reply(215, "UNIX Type: L%d Version: BSD-%d", 142940081Sbostic NBBY, BSD); 143040081Sbostic #else /* BSD */ 143140081Sbostic reply(215, "UNIX Type: L%d", NBBY); 143240081Sbostic #endif /* BSD */ 143340081Sbostic #else /* unix */ 143440081Sbostic reply(215, "UNKNOWN Type: L%d", NBBY); 143540081Sbostic #endif /* unix */ 143640081Sbostic } 143740081Sbostic break; 143840081Sbostic case 43: 143940081Sbostic #line 428 "ftp.y" 144040081Sbostic { 144140081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL) 144240081Sbostic sizecmd((char *) yyvsp[-1]); 144340081Sbostic if (yyvsp[-1] != NULL) 144440081Sbostic free((char *) yyvsp[-1]); 144540081Sbostic } 144640081Sbostic break; 144740081Sbostic case 44: 144840081Sbostic #line 445 "ftp.y" 144940081Sbostic { 145040081Sbostic if (yyvsp[-3] && yyvsp[-1] != NULL) { 145140081Sbostic struct stat stbuf; 145240081Sbostic if (stat((char *) yyvsp[-1], &stbuf) < 0) 145340081Sbostic perror_reply(550, "%s", (char *) yyvsp[-1]); 145440081Sbostic else if ((stbuf.st_mode&S_IFMT) != S_IFREG) { 145540081Sbostic reply(550, "%s: not a plain file.", 145640081Sbostic (char *) yyvsp[-1]); 145740081Sbostic } else { 145840081Sbostic register struct tm *t; 145940081Sbostic struct tm *gmtime(); 146040081Sbostic t = gmtime(&stbuf.st_mtime); 146140081Sbostic reply(213, 146240081Sbostic "19%02d%02d%02d%02d%02d%02d", 146340081Sbostic t->tm_year, t->tm_mon+1, t->tm_mday, 146440081Sbostic t->tm_hour, t->tm_min, t->tm_sec); 146540081Sbostic } 146640081Sbostic } 146740081Sbostic if (yyvsp[-1] != NULL) 146840081Sbostic free((char *) yyvsp[-1]); 146940081Sbostic } 147040081Sbostic break; 147140081Sbostic case 45: 147240081Sbostic #line 467 "ftp.y" 147340081Sbostic { 147440081Sbostic reply(221, "Goodbye."); 147540081Sbostic dologout(0); 147640081Sbostic } 147740081Sbostic break; 147840081Sbostic case 46: 147940081Sbostic #line 472 "ftp.y" 148040081Sbostic { 148140081Sbostic yyerrok; 148240081Sbostic } 148340081Sbostic break; 148440081Sbostic case 47: 148540081Sbostic #line 477 "ftp.y" 148640081Sbostic { 148740081Sbostic char *renamefrom(); 148840081Sbostic 148940081Sbostic if (yyvsp[-3] && yyvsp[-1]) { 149040081Sbostic fromname = renamefrom((char *) yyvsp[-1]); 149140081Sbostic if (fromname == (char *) 0 && yyvsp[-1]) { 149240081Sbostic free((char *) yyvsp[-1]); 149340081Sbostic } 149440081Sbostic } 149540081Sbostic } 149640081Sbostic break; 149740081Sbostic case 49: 149840081Sbostic #line 493 "ftp.y" 149940081Sbostic { 150040081Sbostic *(char **)&(yyval ) = ""; 150140081Sbostic } 150240081Sbostic break; 150340081Sbostic case 52: 150440081Sbostic #line 504 "ftp.y" 150540081Sbostic { 150640081Sbostic register char *a, *p; 150740081Sbostic 150840081Sbostic a = (char *)&data_dest.sin_addr; 150940081Sbostic a[0] = yyvsp[-10]; a[1] = yyvsp[-8]; a[2] = yyvsp[-6]; a[3] = yyvsp[-4]; 151040081Sbostic p = (char *)&data_dest.sin_port; 151140081Sbostic p[0] = yyvsp[-2]; p[1] = yyvsp[0]; 151240081Sbostic data_dest.sin_family = AF_INET; 151340081Sbostic } 151440081Sbostic break; 151540081Sbostic case 53: 151640081Sbostic #line 516 "ftp.y" 151740081Sbostic { 151840081Sbostic yyval = FORM_N; 151940081Sbostic } 152040081Sbostic break; 152140081Sbostic case 54: 152240081Sbostic #line 520 "ftp.y" 152340081Sbostic { 152440081Sbostic yyval = FORM_T; 152540081Sbostic } 152640081Sbostic break; 152740081Sbostic case 55: 152840081Sbostic #line 524 "ftp.y" 152940081Sbostic { 153040081Sbostic yyval = FORM_C; 153140081Sbostic } 153240081Sbostic break; 153340081Sbostic case 56: 153440081Sbostic #line 530 "ftp.y" 153540081Sbostic { 153640081Sbostic cmd_type = TYPE_A; 153740081Sbostic cmd_form = FORM_N; 153840081Sbostic } 153940081Sbostic break; 154040081Sbostic case 57: 154140081Sbostic #line 535 "ftp.y" 154240081Sbostic { 154340081Sbostic cmd_type = TYPE_A; 154440081Sbostic cmd_form = yyvsp[0]; 154540081Sbostic } 154640081Sbostic break; 154740081Sbostic case 58: 154840081Sbostic #line 540 "ftp.y" 154940081Sbostic { 155040081Sbostic cmd_type = TYPE_E; 155140081Sbostic cmd_form = FORM_N; 155240081Sbostic } 155340081Sbostic break; 155440081Sbostic case 59: 155540081Sbostic #line 545 "ftp.y" 155640081Sbostic { 155740081Sbostic cmd_type = TYPE_E; 155840081Sbostic cmd_form = yyvsp[0]; 155940081Sbostic } 156040081Sbostic break; 156140081Sbostic case 60: 156240081Sbostic #line 550 "ftp.y" 156340081Sbostic { 156440081Sbostic cmd_type = TYPE_I; 156540081Sbostic } 156640081Sbostic break; 156740081Sbostic case 61: 156840081Sbostic #line 554 "ftp.y" 156940081Sbostic { 157040081Sbostic cmd_type = TYPE_L; 157140081Sbostic cmd_bytesz = NBBY; 157240081Sbostic } 157340081Sbostic break; 157440081Sbostic case 62: 157540081Sbostic #line 559 "ftp.y" 157640081Sbostic { 157740081Sbostic cmd_type = TYPE_L; 157840081Sbostic cmd_bytesz = yyvsp[0]; 157940081Sbostic } 158040081Sbostic break; 158140081Sbostic case 63: 158240081Sbostic #line 565 "ftp.y" 158340081Sbostic { 158440081Sbostic cmd_type = TYPE_L; 158540081Sbostic cmd_bytesz = yyvsp[0]; 158640081Sbostic } 158740081Sbostic break; 158840081Sbostic case 64: 158940081Sbostic #line 572 "ftp.y" 159040081Sbostic { 159140081Sbostic yyval = STRU_F; 159240081Sbostic } 159340081Sbostic break; 159440081Sbostic case 65: 159540081Sbostic #line 576 "ftp.y" 159640081Sbostic { 159740081Sbostic yyval = STRU_R; 159840081Sbostic } 159940081Sbostic break; 160040081Sbostic case 66: 160140081Sbostic #line 580 "ftp.y" 160240081Sbostic { 160340081Sbostic yyval = STRU_P; 160440081Sbostic } 160540081Sbostic break; 160640081Sbostic case 67: 160740081Sbostic #line 586 "ftp.y" 160840081Sbostic { 160940081Sbostic yyval = MODE_S; 161040081Sbostic } 161140081Sbostic break; 161240081Sbostic case 68: 161340081Sbostic #line 590 "ftp.y" 161440081Sbostic { 161540081Sbostic yyval = MODE_B; 161640081Sbostic } 161740081Sbostic break; 161840081Sbostic case 69: 161940081Sbostic #line 594 "ftp.y" 162040081Sbostic { 162140081Sbostic yyval = MODE_C; 162240081Sbostic } 162340081Sbostic break; 162440081Sbostic case 70: 162540081Sbostic #line 600 "ftp.y" 162640081Sbostic { 162740081Sbostic /* 1628*40084Sbostic * Problem: this production is used for all pathname 1629*40084Sbostic * processing, but only gives a 550 error reply. 1630*40084Sbostic * This is a valid reply in some cases but not in others. 1631*40084Sbostic */ 163240081Sbostic if (logged_in && yyvsp[0] && strncmp((char *) yyvsp[0], "~", 1) == 0) { 163340081Sbostic *(char **)&(yyval ) = *glob((char *) yyvsp[0]); 163440081Sbostic if (globerr != NULL) { 163540081Sbostic reply(550, globerr); 163640081Sbostic yyval = NULL; 163740081Sbostic } 163840081Sbostic free((char *) yyvsp[0]); 163940081Sbostic } else 164040081Sbostic yyval = yyvsp[0]; 164140081Sbostic } 164240081Sbostic break; 164340081Sbostic case 72: 164440081Sbostic #line 622 "ftp.y" 164540081Sbostic { 164640081Sbostic register int ret, dec, multby, digit; 164740081Sbostic 164840081Sbostic /* 1649*40084Sbostic * Convert a number that was read as decimal number 1650*40084Sbostic * to what it would be if it had been read as octal. 1651*40084Sbostic */ 165240081Sbostic dec = yyvsp[0]; 165340081Sbostic multby = 1; 165440081Sbostic ret = 0; 165540081Sbostic while (dec) { 165640081Sbostic digit = dec%10; 165740081Sbostic if (digit > 7) { 165840081Sbostic ret = -1; 165940081Sbostic break; 166040081Sbostic } 166140081Sbostic ret += digit * multby; 166240081Sbostic multby *= 8; 166340081Sbostic dec /= 10; 166440081Sbostic } 166540081Sbostic yyval = ret; 166640081Sbostic } 166740081Sbostic break; 166840081Sbostic case 73: 166940081Sbostic #line 647 "ftp.y" 167040081Sbostic { 167140081Sbostic if (logged_in) 167240081Sbostic yyval = 1; 167340081Sbostic else { 167440081Sbostic reply(530, "Please login with USER and PASS."); 167540081Sbostic yyval = 0; 167640081Sbostic } 167740081Sbostic } 167840081Sbostic break; 1679*40084Sbostic #line 1679 "ftp.tab.c" 168040081Sbostic } 168140081Sbostic yyssp -= yym; 168240081Sbostic yystate = *yyssp; 168340081Sbostic yyvsp -= yym; 168440081Sbostic yym = yylhs[yyn]; 168540081Sbostic if (yystate == 0 && yym == 0) 168640081Sbostic { 168740081Sbostic #ifdef YYDEBUG 168840081Sbostic if (yydebug) 168940081Sbostic printf("yydebug: after reduction, shifting from state 0 to\ 169040081Sbostic state %d\n", YYFINAL); 169140081Sbostic #endif 169240081Sbostic yystate = YYFINAL; 169340081Sbostic *++yyssp = YYFINAL; 169440081Sbostic *++yyvsp = yyval; 169540081Sbostic if (yychar < 0) 169640081Sbostic { 169740081Sbostic if ((yychar = yylex()) < 0) yychar = 0; 169840081Sbostic #if YYDEBUG 169940081Sbostic if (yydebug) 170040081Sbostic { 170140081Sbostic yys = 0; 170240081Sbostic if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; 170340081Sbostic if (!yys) yys = "illegal-symbol"; 170440081Sbostic printf("yydebug: state %d, reading %d (%s)\n", 170540081Sbostic YYFINAL, yychar, yys); 170640081Sbostic } 170740081Sbostic #endif 170840081Sbostic } 170940081Sbostic if (yychar == 0) goto yyaccept; 171040081Sbostic goto yyloop; 171140081Sbostic } 171240081Sbostic if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && 171340081Sbostic yyn <= YYTABLESIZE && yycheck[yyn] == yystate) 171440081Sbostic yystate = yytable[yyn]; 171540081Sbostic else 171640081Sbostic yystate = yydgoto[yym]; 171740081Sbostic #ifdef YYDEBUG 171840081Sbostic if (yydebug) 171940081Sbostic printf("yydebug: after reduction, shifting from state %d \ 172040081Sbostic to state %d\n", *yyssp, yystate); 172140081Sbostic #endif 172240081Sbostic if (yyssp >= yyss + yystacksize - 1) 172340081Sbostic { 172440081Sbostic goto yyoverflow; 172540081Sbostic } 172640081Sbostic *++yyssp = yystate; 172740081Sbostic *++yyvsp = yyval; 172840081Sbostic goto yyloop; 172940081Sbostic yyoverflow: 173040081Sbostic yyerror("yacc stack overflow"); 173140081Sbostic yyabort: 173240081Sbostic return (1); 173340081Sbostic yyaccept: 173440081Sbostic return (0); 173540081Sbostic } 1736