📄 ftpcmd.c
字号:
reply(501, "CHMOD: Mode value must be between 0 and 0777"); else if (chmod(yyvsp[-1].s, yyvsp[-3].i) < 0) perror_reply(550, yyvsp[-1].s); else reply(200, "CHMOD command successful."); } if (yyvsp[-1].s != NULL) free(yyvsp[-1].s); } break;case 39:#line 460 "../../inetutils/ftpd/ftpcmd.y"{ reply(200, "Current IDLE time limit is %d seconds; max %d", timeout, maxtimeout); } break;case 40:#line 466 "../../inetutils/ftpd/ftpcmd.y"{ if (yyvsp[-4].i) { if (yyvsp[-1].i < 30 || yyvsp[-1].i > maxtimeout) { reply (501, "Maximum IDLE time must be between 30 and %d seconds", maxtimeout); } else { timeout = yyvsp[-1].i; (void) alarm((unsigned) timeout); reply(200, "Maximum IDLE time set to %d seconds", timeout); } } } break;case 41:#line 482 "../../inetutils/ftpd/ftpcmd.y"{ if (yyvsp[-3].i && yyvsp[-1].s != NULL) store(yyvsp[-1].s, "w", 1); if (yyvsp[-1].s != NULL) free(yyvsp[-1].s); } break;case 42:#line 489 "../../inetutils/ftpd/ftpcmd.y"{ const char *sys_type; /* Official rfc-defined os type. */ char *version = 0; /* A more specific type. */#ifdef HAVE_UNAME struct utsname u; if (uname (&u) == 0) { version = malloc (strlen (u.sysname) + 1 + strlen (u.release) + 1); if (version) sprintf (version, "%s %s", u.sysname, u.release); }#else#ifdef BSD version = "BSD";#endif#endif#ifdef unix sys_type = "UNIX";#else sys_type = "UNKNOWN";#endif if (version) reply(215, "%s Type: L%d Version: %s", sys_type, NBBY, version); else reply(215, "%s Type: L%d", sys_type, NBBY);#ifdef HAVE_UNAME if (version) free (version);#endif } break;case 43:#line 535 "../../inetutils/ftpd/ftpcmd.y"{ if (yyvsp[-3].i && yyvsp[-1].s != NULL) sizecmd(yyvsp[-1].s); if (yyvsp[-1].s != NULL) free(yyvsp[-1].s); } break;case 44:#line 552 "../../inetutils/ftpd/ftpcmd.y"{ if (yyvsp[-3].i && yyvsp[-1].s != NULL) { struct stat stbuf; if (stat(yyvsp[-1].s, &stbuf) < 0) reply(550, "%s: %s", yyvsp[-1].s, strerror(errno)); else if (!S_ISREG(stbuf.st_mode)) { reply(550, "%s: not a plain file.", yyvsp[-1].s); } else { struct tm *t; t = gmtime(&stbuf.st_mtime); reply(213, "%04d%02d%02d%02d%02d%02d", 1900 + t->tm_year, t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); } } if (yyvsp[-1].s != NULL) free(yyvsp[-1].s); } break;case 45:#line 574 "../../inetutils/ftpd/ftpcmd.y"{ reply(221, "Goodbye."); dologout(0); } break;case 46:#line 579 "../../inetutils/ftpd/ftpcmd.y"{ yyerrok; } break;case 47:#line 585 "../../inetutils/ftpd/ftpcmd.y"{ restart_point = (off_t) 0; if (yyvsp[-3].i && yyvsp[-1].s) { if (fromname != NULL) free (fromname); fromname = renamefrom(yyvsp[-1].s); } if (fromname == (char *) 0 && yyvsp[-1].s) free(yyvsp[-1].s); } break;case 48:#line 596 "../../inetutils/ftpd/ftpcmd.y"{ if (fromname != NULL) free (fromname); fromname = (char *) 0; restart_point = yyvsp[-1].i; /* XXX $3 is only "int" */ reply(350, (sizeof(restart_point) > sizeof(long) ? "Restarting at %qd. %s" : "Restarting at %ld. %s"), restart_point, "Send STORE or RETRIEVE to initiate transfer."); } break;case 50:#line 615 "../../inetutils/ftpd/ftpcmd.y"{ yyval.s = (char *)calloc(1, sizeof(char)); } break;case 53:#line 628 "../../inetutils/ftpd/ftpcmd.y"{ char *a, *p; a = (char *)&data_dest.sin_addr; a[0] = yyvsp[-10].i; a[1] = yyvsp[-8].i; a[2] = yyvsp[-6].i; a[3] = yyvsp[-4].i; p = (char *)&data_dest.sin_port; p[0] = yyvsp[-2].i; p[1] = yyvsp[0].i; data_dest.sin_family = AF_INET; } break;case 54:#line 641 "../../inetutils/ftpd/ftpcmd.y"{ yyval.i = FORM_N; } break;case 55:#line 645 "../../inetutils/ftpd/ftpcmd.y"{ yyval.i = FORM_T; } break;case 56:#line 649 "../../inetutils/ftpd/ftpcmd.y"{ yyval.i = FORM_C; } break;case 57:#line 656 "../../inetutils/ftpd/ftpcmd.y"{ cmd_type = TYPE_A; cmd_form = FORM_N; } break;case 58:#line 661 "../../inetutils/ftpd/ftpcmd.y"{ cmd_type = TYPE_A; cmd_form = yyvsp[0].i; } break;case 59:#line 666 "../../inetutils/ftpd/ftpcmd.y"{ cmd_type = TYPE_E; cmd_form = FORM_N; } break;case 60:#line 671 "../../inetutils/ftpd/ftpcmd.y"{ cmd_type = TYPE_E; cmd_form = yyvsp[0].i; } break;case 61:#line 676 "../../inetutils/ftpd/ftpcmd.y"{ cmd_type = TYPE_I; } break;case 62:#line 680 "../../inetutils/ftpd/ftpcmd.y"{ cmd_type = TYPE_L; cmd_bytesz = NBBY; } break;case 63:#line 685 "../../inetutils/ftpd/ftpcmd.y"{ cmd_type = TYPE_L; cmd_bytesz = yyvsp[0].i; } break;case 64:#line 691 "../../inetutils/ftpd/ftpcmd.y"{ cmd_type = TYPE_L; cmd_bytesz = yyvsp[0].i; } break;case 65:#line 699 "../../inetutils/ftpd/ftpcmd.y"{ yyval.i = STRU_F; } break;case 66:#line 703 "../../inetutils/ftpd/ftpcmd.y"{ yyval.i = STRU_R; } break;case 67:#line 707 "../../inetutils/ftpd/ftpcmd.y"{ yyval.i = STRU_P; } break;case 68:#line 714 "../../inetutils/ftpd/ftpcmd.y"{ yyval.i = MODE_S; } break;case 69:#line 718 "../../inetutils/ftpd/ftpcmd.y"{ yyval.i = MODE_B; } break;case 70:#line 722 "../../inetutils/ftpd/ftpcmd.y"{ yyval.i = MODE_C; } break;case 71:#line 729 "../../inetutils/ftpd/ftpcmd.y"{ /* * Problem: this production is used for all pathname * processing, but only gives a 550 error reply. * This is a valid reply in some cases but not in others. */ if (cred.logged_in && yyvsp[0].s && *yyvsp[0].s == '~') { glob_t gl; int flags = GLOB_NOCHECK;#ifdef GLOB_BRACE flags |= GLOB_BRACE;#endif#ifdef GLOB_QUOTE flags |= GLOB_QUOTE;#endif#ifdef GLOB_TILDE flags |= GLOB_TILDE;#endif memset(&gl, 0, sizeof(gl)); if (glob(yyvsp[0].s, flags, NULL, &gl) || gl.gl_pathc == 0) { reply(550, "not found"); yyval.s = NULL; } else { yyval.s = strdup(gl.gl_pathv[0]); } globfree(&gl); free(yyvsp[0].s); } else yyval.s = yyvsp[0].s; } break;case 73:#line 770 "../../inetutils/ftpd/ftpcmd.y"{ int ret, dec, multby, digit; /* * Convert a number that was read as decimal number * to what it would be if it had been read as octal. */ dec = yyvsp[0].i; multby = 1; ret = 0; while (dec) { digit = dec%10; if (digit > 7) { ret = -1; break; } ret += digit * multby; multby *= 8; dec /= 10; } yyval.i = ret; } break;case 74:#line 797 "../../inetutils/ftpd/ftpcmd.y"{ if (cred.logged_in) yyval.i = 1; else { reply(530, "Please login with USER and PASS."); yyval.i = 0; } } break;}#line 705 "/usr/share/bison/bison.simple" yyvsp -= yylen; yyssp -= yylen;#if YYLSP_NEEDED yylsp -= yylen;#endif#if YYDEBUG if (yydebug) { short *yyssp1 = yyss - 1; YYFPRINTF (stderr, "state stack now"); while (yyssp1 != yyssp) YYFPRINTF (stderr, " %d", *++yyssp1); YYFPRINTF (stderr, "\n"); }#endif *++yyvsp = yyval;#if YYLSP_NEEDED *++yylsp = yyloc;#endif /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTBASE] + *yyssp; if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTBASE]; goto yynewstate;/*------------------------------------.| yyerrlab -- here on detecting error |`------------------------------------*/yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs;#ifdef YYERROR_VERBOSE yyn = yypact[yystate]; if (yyn > YYFLAG && yyn < YYLAST) { YYSIZE_T yysize = 0; char *yymsg; int yyx, yycount; yycount = 0; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ for (yyx = yyn < 0 ? -yyn : 0; yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) if (yycheck[yyx + yyn] == yyx) yysize += yystrlen (yytname[yyx]) + 15, yycount++; yysize += yystrlen ("parse error, unexpected ") + 1; yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); yymsg = (char *) YYSTACK_ALLOC (yysize); if (yymsg != 0) { char *yyp = yystpcpy (yymsg, "parse error, unexpected "); yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); if (yycount < 5) { yycount = 0; for (yyx = yyn < 0 ? -yyn : 0; yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) if (yycheck[yyx + yyn] == yyx) { const char *yyq = ! yycount ? ", expecting " : " or "; yyp = yystpcpy (yyp, yyq); yyp = yystpcpy (yyp, yytname[yyx]); yycount++; } } yyerror (yymsg); YYSTACK_FREE (yymsg); } else yyerror ("parse error; also virtual memory exhausted"); } else#endif /* defined (YYERROR_VERBOSE) */ yyerror ("parse error"); } goto yyerrlab1;/*--------------------------------------------------.| yyerrlab1 -- error raised explicitly by an action |`--------------------------------------------------*/yyerrlab1: if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ /* return failure if at end of input */ if (yychar == YYEOF) YYABORT; YYDPRINTF ((stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1])); yychar = YYEMPTY; } /* Else will try to reuse lookahead token after shifting the error token. */ yyerrstatus = 3; /* Each real token shifted decrements this */ goto yyerrhandle;/*-------------------------------------------------------------------.| yyerrdefault -- current state does not do anything special for the || error token. |`-------------------------------------------------------------------*/yyerrdefault:#if 0 /* This is wrong; only states that explicitly want error tokens should shift them. */ /* If its default is to accept any token, ok. Otherwise pop it. */ yyn = yydefact[yystate]; if (yyn) goto yydefault;#endif/*---------------------------------------------------------------.| yyerrpop -- pop the current state because it cannot handle the || error token |
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -