Ssl upload.yaws与erlang R16B-03.7.el7和yaws 1.98-2.el7一起失败
我需要帮助。我有一个工作网站。上线前的最后一步是更新ssl证书。由于该版本的erlang中存在错误,所以没有发生这种情况。我升级了erlang,然后erlang和yaws驱动程序之间的代码级别不匹配。我没有加载并遵守yaws,我非常高兴能够更新ssl证书。开始推出后,一位用户指出上载功能不起作用。我验证了它仍然可以使用不接受ssl证书的版本。我假设问题出在构建过程中,所以我从CentOS 7的新VM以及该发行版的erlang和Yaws重新开始。同样的问题。似乎我可以上传或新的证书,但不能两者都有。我的上传版本是对std upload.yaws稍加修改的版本。然而,我拿起它试了试。它也失败了。下面是软件级别、故障代码和崩溃数据 任何帮助都将不胜感激 \uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu强 CentOS 3.10.0-123.6.3.el7.x86_64 erlang.x86_64 R16B-03.7.el7@epel yaws.x86_64 1.98-2.el7@epel “强大”网站网站近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日近日UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUSsl upload.yaws与erlang R16B-03.7.el7和yaws 1.98-2.el7一起失败,ssl,file-upload,erlang,yaws,Ssl,File Upload,Erlang,Yaws,我需要帮助。我有一个工作网站。上线前的最后一步是更新ssl证书。由于该版本的erlang中存在错误,所以没有发生这种情况。我升级了erlang,然后erlang和yaws驱动程序之间的代码级别不匹配。我没有加载并遵守yaws,我非常高兴能够更新ssl证书。开始推出后,一位用户指出上载功能不起作用。我验证了它仍然可以使用不接受ssl证书的版本。我假设问题出在构建过程中,所以我从CentOS 7的新VM以及该发行版的erlang和Yaws重新开始。同样的问题。似乎我可以上传或新的证书,但不能两者都有
-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.`
碰撞数据
内部错误,yaws代码崩溃
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}]}]
错误erlang代码引发了未捕获的异常:
文件:/var/lib/yaws/www/dpagepost.yaws:1
类别:错误
例外情况:function_子句
请求:{http_请求,'POST',{abs_路径,“/dpagepost.yaws?action=addf”},{1,1}
堆栈:[{cwpage,addFileChunk,
[{arg,
{ssl,
{sslsocket,
{gen_tcp,#端口,tls_连接},
}},
{{192,168,0,133},54630},
{标题,“保持活动状态”,
“text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8”,
“192.168.0.190”,未定义,未定义,未定义,未定义,
未定义,未定义,“https://192.168.0.190/upload.yaws",
“Mozilla/5.0(X11;Linux x86_64;rv:26.0)Gecko/20100101 Firefox/26.0”,
未定义,
[“\uuuuATUVC=30%7C35;cwhoa\uSID=nonode@nohost-211833414978628805947952202420298501124"],
未定义,未定义,“229”,
“多部分/表单数据;边界=------------------------------------501916758553745487488260262”,
未定义,未定义,未定义,未定义,
[{http_头,10,'Accept-Encoding',未定义,
“gzip,deflate”},
{http_头,11,'Accept-Language',未定义,
“en-US,en;q=0.5”}]},
{http_请求,'POST',
{abs_path,“/dpagepost.yaws?action=addf”},
{1,1}},
{http_请求,'POST',
{abs_path,“/dpagepost.yaws?action=addf”},
{1,1}},
,
“/dpagepost.yaws”,“action=addf”,未定义,
“/var/lib/yaws/www”、“/”、“/var/lib/yaws/www/dpagepost.yaws”,
未定义,未定义,,[],未定义,“/”,未定义},
[{body,“你好,世界”},
{upload,未定义,未定义,true}],
[{file,“cwpage.erl”},{line,239}]},
{cwpage,多部分,2,[{file,“cwpage.erl”},{line,209}]},
{yaws_服务器,交付第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_子句
意味着其中的非子句与给定的参数匹配
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的情况下工作。您显示的代码似乎缺少模块声明之类的内容,这意味着错误报告中的行号是无用的。我建议您将您的问题通过电子邮件发送到Yaws邮件列表,并包含指向代码完整注册表或粘贴箱的链接。谢谢,tkowal。你给我指明了正确的方向。因为这段代码在升级之前就已经运行了,所以它没有恢复文件名的事实必须是由于Yaws或Erlang中的更改。我从Yaws开始,浏览了所有的发行说明。在1.94版中,upload.yaws中引入了一个向后不兼容的修复程序。奇怪的是,没有人更新示例文件。搜索现在查找字段“filename”,而不是atom的“filename”。将此标记为已修复。。。。