leo-project / leofs

The LeoFS Storage System
https://leo-project.net/leofs/
Apache License 2.0
1.56k stars 155 forks source link

can't upload file name with space or other character got 403 forbidden #229

Closed adhioutlined closed 10 years ago

adhioutlined commented 10 years ago

got error like this :

[E] gateway_0@192.168.24.80 2014-08-27 14:01:49.698143 +0700    1409122909  leo_s3_auth:authenticate_3/1    403 <<"n4ViUKIw2GWWkU2D7HixyAhZPAk=">>
[E] gateway_0@192.168.24.80 2014-08-27 14:01:49.698951 +0700    1409122909  null:null   0   ** Cowboy handler leo_gateway_s3_api terminating in handle/2
   for the reason error:{badmatch,{ok,{http_req,{sslsocket,{gen_tcp,#Port<0.2012>,tls_connection},<0.1967.0>},ranch_ssl,keepalive,<0.1968.0>,<<"PUT">>,'HTTP/1.1',{{192,168,24,21},53246},<<"asdf.tomica.jcamp.net">>,undefined,443,<<"/dgh/Forever%20And%20Always.mp3">>,undefined,<<>>,[],[],[{<<"host">>,<<"asdf.tomica.jcamp.net">>},{<<"date">>,<<"Wed, 27 Aug 2014 07:01:49 GMT">>},{<<"authorization">>,<<"AWS 18dda8aed33612bc303c:Dz1vYFZaoYiheACMUuyM7YjYx6A=">>},{<<"connection">>,<<"Keep-Alive">>},{<<"user-agent">>,<<"DragonDisk 1.05 ( http://www.dragondisk.com )">>},{<<"content-type">>,<<"audio/mpeg">>},{<<"expect">>,<<"100-continue">>},{<<"content-length">>,<<"5509549">>}],[{<<"connection">>,[<<"keep-alive">>]}],undefined,[],waiting,undefined,<<>>,false,done,[],<<>>,undefined}}}
** Handler state was [{1,64},true,{http_options,leo_gateway_s3_api,8080,8443,"./etc/server_cert.pem","./etc/server_key.pem",128,4096,inner,16,1073741824,524288000,1048576,"./cache/data","./cache/journal",300,1048576,[],[],1000,5242880000,5242880,5242880,5767168}]
** Request was [{socket,{sslsocket,{gen_tcp,#Port<0.2012>,tls_connection},<0.1967.0>}},{transport,ranch_ssl},{connection,keepalive},{pid,<0.1968.0>},{method,<<"PUT">>},{version,'HTTP/1.1'},{peer,{{192,168,24,21},53246}},{host,<<"asdf.tomica.jcamp.net">>},{host_info,undefined},{port,443},{path,<<"/dgh/Forever%20And%20Always.mp3">>},{path_info,undefined},{qs,<<>>},{qs_vals,undefined},{bindings,[]},{headers,[{<<"host">>,<<"asdf.tomica.jcamp.net">>},{<<"date">>,<<"Wed, 27 Aug 2014 07:01:49 GMT">>},{<<"authorization">>,<<"AWS 18dda8aed33612bc303c:Dz1vYFZaoYiheACMUuyM7YjYx6A=">>},{<<"connection">>,<<"Keep-Alive">>},{<<"user-agent">>,<<"DragonDisk 1.05 ( http://www.dragondisk.com )">>},{<<"content-type">>,<<"audio/mpeg">>},{<<"expect">>,<<"100-continue">>},{<<"content-length">>,<<"5509549">>}]},{p_headers,[{<<"connection">>,[<<"keep-alive">>]}]},{cookies,undefined},{meta,[]},{body_state,waiting},{multipart,undefined},{buffer,<<>>},{resp_compress,false},{resp_state,waiting},{resp_headers,[]},{resp_body,<<>>},{onresponse,undefined}]
** Stacktrace: [{leo_gateway_s3_api,handle_2,6,[{file,"src/leo_gateway_s3_api.erl"},{line,452}]},{cowboy_handler,handler_handle,4,[{file,"src/cowboy_handler.erl"},{line,119}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,523}]}]

while upload file name with space using dragon disk , its normal when I just upload file using name like "leofs.mp3"

and this error while upload long name folder

[E] gateway_0@192.168.24.80 2014-08-27 14:03:49.437297 +0700    1409123029  leo_s3_auth:authenticate_3/1    403 <<"ZDg4M8anYsDiH8KrYUsRwJZomug=">>
[E] gateway_0@192.168.24.80 2014-08-27 14:03:49.438362 +0700    1409123029  null:null   0   ** Cowboy handler leo_gateway_s3_api terminating in handle/2
   for the reason error:{badmatch,{ok,{http_req,{sslsocket,{gen_tcp,#Port<0.2032>,tls_connection},<0.3375.0>},ranch_ssl,keepalive,<0.3376.0>,<<"PUT">>,'HTTP/1.1',{{192,168,24,21},53304},<<"asdf.tomica.jcamp.net">>,undefined,443,<<"/%5B2012.04.12%5D%20Dunia%20Batas/01.%20Berdua%20Saja.mp3">>,undefined,<<>>,[],[],[{<<"host">>,<<"asdf.tomica.jcamp.net">>},{<<"date">>,<<"Wed, 27 Aug 2014 07:03:49 GMT">>},{<<"authorization">>,<<"AWS 18dda8aed33612bc303c:KfDMZmz93E+8QY/XPyzi9IHoYto=">>},{<<"connection">>,<<"Keep-Alive">>},{<<"user-agent">>,<<"DragonDisk 1.05 ( http://www.dragondisk.com )">>},{<<"content-type">>,<<"audio/mpeg">>},{<<"expect">>,<<"100-continue">>},{<<"content-length">>,<<"11229093">>}],[{<<"connection">>,[<<"keep-alive">>]}],undefined,[],waiting,undefined,<<>>,false,done,[],<<>>,undefined}}}
** Handler state was [{1,64},true,{http_options,leo_gateway_s3_api,8080,8443,"./etc/server_cert.pem","./etc/server_key.pem",128,4096,inner,16,1073741824,524288000,1048576,"./cache/data","./cache/journal",300,1048576,[],[],1000,5242880000,5242880,5242880,5767168}]
** Request was [{socket,{sslsocket,{gen_tcp,#Port<0.2032>,tls_connection},<0.3375.0>}},{transport,ranch_ssl},{connection,keepalive},{pid,<0.3376.0>},{method,<<"PUT">>},{version,'HTTP/1.1'},{peer,{{192,168,24,21},53304}},{host,<<"asdf.tomica.jcamp.net">>},{host_info,undefined},{port,443},{path,<<"/%5B2012.04.12%5D%20Dunia%20Batas/01.%20Berdua%20Saja.mp3">>},{path_info,undefined},{qs,<<>>},{qs_vals,undefined},{bindings,[]},{headers,[{<<"host">>,<<"asdf.tomica.jcamp.net">>},{<<"date">>,<<"Wed, 27 Aug 2014 07:03:49 GMT">>},{<<"authorization">>,<<"AWS 18dda8aed33612bc303c:KfDMZmz93E+8QY/XPyzi9IHoYto=">>},{<<"connection">>,<<"Keep-Alive">>},{<<"user-agent">>,<<"DragonDisk 1.05 ( http://www.dragondisk.com )">>},{<<"content-type">>,<<"audio/mpeg">>},{<<"expect">>,<<"100-continue">>},{<<"content-length">>,<<"11229093">>}]},{p_headers,[{<<"connection">>,[<<"keep-alive">>]}]},{cookies,undefined},{meta,[]},{body_state,waiting},{multipart,undefined},{buffer,<<>>},{resp_compress,false},{resp_state,waiting},{resp_headers,[]},{resp_body,<<>>},{onresponse,undefined}]
** Stacktrace: [{leo_gateway_s3_api,handle_2,6,[{file,"src/leo_gateway_s3_api.erl"},{line,452}]},{cowboy_handler,handler_handle,4,[{file,"src/cowboy_handler.erl"},{line,119}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,523}]}]

this is my cluster info

sc@tomica:/mnt/xfs/leofs$ ./leofs-adm status
[System config]
                System version : 1.1.1
                    Cluster Id : srg_1
                         DC Id : semarang
                Total replicas : 2
           # of successes of R : 1
           # of successes of W : 1
           # of successes of D : 1
 # of DC-awareness replicas    : 0
                     ring size : 2^128
             Current ring hash : 2c9679bc
                Prev ring hash : 4fd56fa0
[Multi DC replication settings]
         max # of joinable DCs : 4
            # of replicas a DC : 2

[Node(s) state]
-------+------------------------------+--------------+----------------+----------------+----------------------------
 type  |             node             |    state     |  current ring  |   prev ring    |          updated at
-------+------------------------------+--------------+----------------+----------------+----------------------------
  S    | storage_0@192.168.24.80      | running      | 2c9679bc       | 4fd56fa0       | 2014-08-27 13:36:42 +0700
  S    | storage_2@192.168.24.82      | running      | 2c9679bc       | 4fd56fa0       | 2014-08-27 13:45:21 +0700
  S    | storage_3@192.168.24.83      | running      | 2c9679bc       | 4fd56fa0       | 2014-08-27 13:36:43 +0700
  G    | gateway_0@192.168.24.80      | running      | 2c9679bc       | 4fd56fa0       | 2014-08-27 14:00:55 +0700

sc@tomica:/mnt/xfs/leofs$ ./leofs-adm cluster-status
cluster id |   dc id    |    status    | # of storages  |          updated at
-----------+------------+--------------+----------------+-----------------------------
jogja_1    | jogja      | running      |              3 | 2014-08-27 13:46:38 +0700

sc@hotwheels:/mnt/xfs/leofs$ ./leofs-adm status
[System config]
                System version : 1.1.1
                    Cluster Id : jogja_1
                         DC Id : jogja
                Total replicas : 2
           # of successes of R : 1
           # of successes of W : 1
           # of successes of D : 1
 # of DC-awareness replicas    : 0
                     ring size : 2^128
             Current ring hash : 49697f91
                Prev ring hash : a4aee014
[Multi DC replication settings]
         max # of joinable DCs : 4
            # of replicas a DC : 2

[Node(s) state]
-------+---------------------------------+--------------+----------------+----------------+----------------------------
 type  |              node               |    state     |  current ring  |   prev ring    |          updated at
-------+---------------------------------+--------------+----------------+----------------+----------------------------
  S    | storage_jog_5@192.168.2.40      | running      | 49697f91       | a4aee014       | 2014-08-27 13:31:26 +0700
  S    | storage_jog_6@192.168.2.41      | running      | 49697f91       | a4aee014       | 2014-08-27 13:31:25 +0700
  S    | storage_jog_7@192.168.2.42      | running      | 49697f91       | a4aee014       | 2014-08-27 13:46:38 +0700
  G    | gateway_jog_0@192.168.2.40      | running      | 49697f91       | a4aee014       | 2014-08-27 13:31:28 +0700

sc@hotwheels:/mnt/xfs/leofs$ ./leofs-adm cluster-status
cluster id |   dc id    |    status    | # of storages  |          updated at
-----------+------------+--------------+----------------+-----------------------------
srg_1      | semarang   | running      |              3 | 2014-08-27 13:45:34 +0700
yosukehara commented 10 years ago

Thank you for your report. I've checked this issue and reproduced it. So I'll fix it soon. In addition, we'll add new test cases in leofs_client_test.

mocchira commented 10 years ago

notes this issue only happen in LeoFSv1.1.1.

yosukehara commented 10 years ago

After we fixed #219 , this issue happen.

adhioutlined commented 10 years ago

sorry how to change on existing system ? did I have to git clone, make deps, edit the deps/leo_commons/src/leo_http.erl and make & make release ?

yosukehara commented 10 years ago

You can succeed in building latest LeoFS with using git_checkout .

$ rm deps/leo_commons
$ rm deps/leo_gateway
$ ./rebar get-deps
$ sh ./git_checkout develop
$ make
adhioutlined commented 10 years ago

still got error when create folder using "[ ]" , this error on leo_gateway when I create folder "test [folder]"

[E] gateway_0@192.168.24.80 2014-08-29 07:14:17.9816 +0700  1409271257  leo_s3_auth:authenticate_3/1    403 <<"h8i5pSZxne5iWTddopxczPMuNAQ=">>
[E] gateway_0@192.168.24.80 2014-08-29 07:14:17.11263 +0700 1409271257  null:null   0   ** Cowboy handler leo_gateway_s3_api terminating in handle/2
   for the reason error:{badmatch,{ok,{http_req,{sslsocket,{gen_tcp,#Port<0.2096>,tls_connection},<0.5904.0>},ranch_ssl,keepalive,<0.5905.0>,<<"PUT">>,'HTTP/1.1',{{192,168,24,21},56557},<<"kalala.tomica.jcamp.net">>,undefined,443,<<"/kd%20ksd/test%20%5Bfolder%5D/">>,undefined,<<>>,[],[],[{<<"host">>,<<"kalala.tomica.jcamp.net">>},{<<"date">>,<<"Mon, 01 Sep 2014 06:55:52 GMT">>},{<<"authorization">>,<<"AWS c489f9da4beac12fbcae:lNamjNEe452Us6a7fLOYVD6uHbU=">>},{<<"connection">>,<<"Keep-Alive">>},{<<"user-agent">>,<<"DragonDisk 1.05 ( http://www.dragondisk.com )">>},{<<"content-length">>,<<"0">>}],[{<<"connection">>,[<<"keep-alive">>]}],undefined,[],waiting,undefined,<<>>,false,done,[],<<>>,undefined}}}
** Handler state was [{1,64},true,{http_options,leo_gateway_s3_api,8080,8443,"./etc/server_cert.pem","./etc/server_key.pem",128,4096,inner,16,1073741824,524288000,1048576,"./cache/data","./cache/journal",300,1048576,[],[],1000,5242880000,5242880,5242880,5767168}]
** Request was [{socket,{sslsocket,{gen_tcp,#Port<0.2096>,tls_connection},<0.5904.0>}},{transport,ranch_ssl},{connection,keepalive},{pid,<0.5905.0>},{method,<<"PUT">>},{version,'HTTP/1.1'},{peer,{{192,168,24,21},56557}},{host,<<"kalala.tomica.jcamp.net">>},{host_info,undefined},{port,443},{path,<<"/kd%20ksd/test%20%5Bfolder%5D/">>},{path_info,undefined},{qs,<<>>},{qs_vals,undefined},{bindings,[]},{headers,[{<<"host">>,<<"kalala.tomica.jcamp.net">>},{<<"date">>,<<"Mon, 01 Sep 2014 06:55:52 GMT">>},{<<"authorization">>,<<"AWS c489f9da4beac12fbcae:lNamjNEe452Us6a7fLOYVD6uHbU=">>},{<<"connection">>,<<"Keep-Alive">>},{<<"user-agent">>,<<"DragonDisk 1.05 ( http://www.dragondisk.com )">>},{<<"content-length">>,<<"0">>}]},{p_headers,[{<<"connection">>,[<<"keep-alive">>]}]},{cookies,undefined},{meta,[]},{body_state,waiting},{multipart,undefined},{buffer,<<>>},{resp_compress,false},{resp_state,waiting},{resp_headers,[]},{resp_body,<<>>},{onresponse,undefined}]
** Stacktrace: [{leo_gateway_s3_api,handle_2,6,[{file,"src/leo_gateway_s3_api.erl"},{line,452}]},{cowboy_handler,handler_handle,4,[{file,"src/cowboy_handler.erl"},{line,119}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,523}]}]
yosukehara commented 10 years ago

I've fixed the above issue as follows: https://github.com/leo-project/leo_gateway/commit/57812806cd7a30b28c4e3c1d60f5e0a764ca4732

So you're able to check with the latest develop branch. Thank you for your report.