gpt4 book ai didi

ssl - upload.yaws 因 erlang R16B-03.7.el7 和 yaws 1.98-2.el7 而失败

转载 作者:太空宇宙 更新时间:2023-11-03 14:58:50 25 4
gpt4 key购买 nike

我需要帮助。我有一个工作网站。上线前的最后一步是更新 ssl 证书。由于那个版本的 erlang 中的错误,这并没有发生。我升级了 erlang,然后 erlang 和 yaws 驱动程序之间的代码级别不匹配。我下载并遵守了 yaws,令我非常高兴的是我能够更新 ssl 证书。开始推出后,一位用户指出上传功能无法使用。我确认它仍然适用于不接受 ssl 证书的版本。我认为问题出在构建过程中,所以我重新开始使用 CentOS 7 的新虚拟机以及该发行版中的 erlang 和 Yaws。同样的问题。看来我可以上传证书或新证书,但不能同时拥有两者。我的上传版本是 std upload.yaws 的略微修改版本。但是,我拿起它并尝试了它。它也失败了。以下是软件级别、失败代码和崩溃数据。

任何帮助将不胜感激。

________代码 __________________________________________________________________CentOS 3.10.0-123.6.3.el7.x86_64erlang.x86_64 R16B-03.7.el7 @epelyaws.x86_64 1.98-2.el7 @epel

_CODE____________________________________________________________________________________________________________________________

 -record(upload, { % represents state for a partially processed upload
fd,
filename,
last}).

-define(DIR, "/var/lib/yaws/www/cwfiles/").

showup(List) -> % Adds the rows of files from the DB
[{tr,[],[
{th,[], "File Name"}
]},
map(fun(Y) -> {TFid,FName} = Y, [
{tr,[],[
{td,[], [{input, [{type,text},{name,"Filename"},{value,FName}]}]},
{td,[], [{a,[{href,["dpagepost.yaws?action=delf& fid=",integer_to_list(TFid),"&fname=",[FName]]}],"Delete File"}]}
]}
] end, List)].

upload(A) -> upload(A,[]).
upload(A, Comment) ->
Css = css_head(A,on,57),
Body = case getadmen(A) of
true ->
Ref=dbconnect(),
{selected,_,LFil} = odbc:sql_query(Ref,"select fid,filename from files"),
odbc:disconnect(Ref),
{ehtml, [
{h2, [], "Update Files (Upload/Delete)"},
{hr},
{h3,[], [Comment]},
{hr},
{table, [], [
showup(LFil) % Do rows from DB
]}, %end table
{hr},
{form, [{enctype, "multipart/form-data"},{action," /dpagepost.yaws?action=addf"},{method,post}],[
{input, [{type,file},{name,"fname"},{width,"50"},{value,"Upload"}]},
{input, [{type,submit},{value,"Upload"}]}
]}
]};
_ ->
{ehtml, [
{h2, [], "Unvalid Action. Please insure you are Admin Enabled"},
{hr}
]}
end,
[Css, Body, bot(), break].


%%% Process POST data from client, state=#upload
%%% returns Ehtml | {get_more, Continuation, NewState}
uploadpost(A) ->
CAdmen = getadmen(A),
case {yaws_api:queryvar(A,"action"),CAdmen} of
{{ok, Action},true} -> Action;
_ -> Action = ""
end,
case Action of
"addf" ->
State = case A#arg.state of
undefined -> #upload{};
_ -> A#arg.state
end,
multipart(A, State);
"delf" ->
case {yaws_api:queryvar(A, "fid"),yaws_api:queryvar(A, "fname"),CAdmen} of
{{ok,LFid},{ok,LFname},true} ->
{NFid,_} = string:to_integer(LFid),
Fname = string:strip(LFname),
SQL = "delete from files where fid=?",
Ref=dbconnect(),
odbc:param_query(Ref,SQL,[{sql_integer, [NFid]}]),
odbc:disconnect(Ref),
case file:delete(concat(?DIR,Fname)) of
ok ->
upload(A,"File Delete sucessfull.");
_ -> upload(A,"File Delete Failed.")
end;
_ -> upload(A,"You performed an invalid Action.")
end;
_ -> upload(A,"You performed an invalid Action.")
end.

err() -> "error".


multipart(A, State) ->
Admen = getadmen(A),
Parse = yaws_api:parse_multipart_post(A),
case {Parse,Admen} of
{{cont, Cont, Res},true} ->
case addFileChunk(A, Res, State) of
{done, Result} ->
upload(A,Result);
{cont, NewState} ->
{get_more, Cont, NewState}
end;
{{result, Res},true} ->
case addFileChunk(A, Res, State#upload{last=true}) of
{done, Result} ->
upload(A,Result);
{cont, _} ->
upload(A,"Upload failed")
end;
_ ->
upload(A,"Upload failed")
end.

addFileChunk(A, [{part_body, Data}|Res], State) ->
addFileChunk(A, [{body, Data}|Res], State);
addFileChunk(_A, [], State) when State#upload.last==true,State#upload.filename /= undefined,State#upload.fd /= undefined ->
file:close(State#upload.fd),
SQL = "insert into files (filename) values ( ?)",
Ref=dbconnect(),
odbc:param_query(Ref,SQL,[{{sql_varchar, 50}, [State#upload.filename]}]),
odbc:disconnect(Ref),
{done,"Upload Completed Sucessfully."};
addFileChunk(_A, [], State) when State#upload.last==true ->
{done, err()};
addFileChunk(_A, [], State) ->
{cont, State};
addFileChunk(A, [{head, {_Name, Opts}}|Res], State ) ->
case lists:keysearch(filename, 1, Opts) of
{value, {_, Fname0}} ->
Fname = yaws_api:sanitize_file_name(filename:basename(Fname0)),
%file:make_dir(?DIR),
case file:open([?DIR, Fname] ,[write]) of
{ok, Fd} ->
S2 = State#upload{filename = Fname,fd = Fd},
addFileChunk(A, Res, S2);
_ ->
{done, err()}
end;
false -> addFileChunk(A,Res,State)
end;
addFileChunk(A, [{body, Data}|Res], State) when State#upload.filename /= undefined ->
case file:write(State#upload.fd, Data) of
ok ->
addFileChunk(A, Res, State);
_ ->
{done, err()}
end.`

_________崩溃数据________________ 内部错误,雅司代码崩溃

ERROR erlang code threw an uncaught exception:
File: /var/lib/yaws/www/dpagepost.yaws:1
Class: error
Exception: function_clause
Req: {http_request,'POST',{abs_path,"/dpagepost.yaws?action=addf"},{1,1}}
Stack: [{cwpage,addFileChunk,
[{arg,
{ssl,
{sslsocket,
{gen_tcp,#Port<0.1480>,tls_connection},
<0.73.0>}},
{{192,168,0,133},54630},
{headers,"keep-alive",
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"192.168.0.190",undefined,undefined,undefined,undefined,
undefined,undefined,"https://192.168.0.190/upload.yaws",
"Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0",
undefined,
["__atuvc=30%7C35; cwhoa_sid=nonode@nohost-211833414978628805947952202420298501124"],
undefined,undefined,"229",
"multipart/form-data; boundary=---------------------------501916758553745487488260262",
undefined,undefined,undefined,undefined,
[{http_header,10,'Accept-Encoding',undefined,
"gzip, deflate"},
{http_header,11,'Accept-Language',undefined,
"en-US,en;q=0.5"}]},
{http_request,'POST',
{abs_path,"/dpagepost.yaws?action=addf"},
{1,1}},
{http_request,'POST',
{abs_path,"/dpagepost.yaws?action=addf"},
{1,1}},
<<"-----------------------------501916758553745487488260262\r\nContent-Disposition: form-data; name=\"fname\"; filename=\"Hello.txt\"\r\nContent-Type: text/plain\r\n\r\nHello, World\n\r\n-----------------------------501916758553745487488260262--\r\n">>,
"/dpagepost.yaws","action=addf",undefined,
"/var/lib/yaws/www","/","/var/lib/yaws/www/dpagepost.yaws",
undefined,undefined,<0.72.0>,[],undefined,"/",undefined},
[{body,"Hello, World\n"}],
{upload,undefined,undefined,true}],
[{file,"cwpage.erl"},{line,239}]},
{cwpage,multipart,2,[{file,"cwpage.erl"},{line,209}]},
{yaws_server,deliver_dyn_part,8,
[{file,"yaws_server.erl"},{line,2801}]},
{yaws_server,aloop,4,[{file,"yaws_server.erl"},{line,1215}]},
{yaws_server,acceptor0,2,[{file,"yaws_server.erl"},{line,1052}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]

最佳答案

很抱歉只回答了部分问题,但这对于评论来说太长了。

错误 function_clause 意味着没有子句匹配给定的参数。

addFileChunk(A, [{part_body, Data}|Res], State) -> ...
addFileChunk(_A, [], State) when State#upload.last==true,State#upload.filename /= undefined,State#upload.fd /= undefined -> ...
addFileChunk(_A, [], State) when State#upload.last==true -> ...
addFileChunk(_A, [], State) -> ...
addFileChunk(A, [{head, {_Name, Opts}}|Res], State ) -> ...
addFileChunk(A, [{body, Data}|Res], State) when State#upload.filename /= undefined -> ...

第一个参数未使用或匹配所有内容,所以让我们看看其他两个。

[{body,"Hello, World\n"}],
{upload,undefined,undefined,true}

如果 upload 记录中有文件名,它可以匹配最后一个子句。所以在 uploadpost/1 中:

case Action of    
"addf" ->
State = case A#arg.state of
undefined -> #upload{};
_ -> A#arg.state
end,

例如,您可以从 arg.clidata 中提取文件名并将其添加到 upload 状态。这应该可以解决问题,但我不知道为什么它在没有 SSL 的情况下也能正常工作。

关于ssl - upload.yaws 因 erlang R16B-03.7.el7 和 yaws 1.98-2.el7 而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25575367/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com