Go: x/net/webdav: λŠμ–΄μ§„ λ§ν¬μ—μ„œ μ‹€νŒ¨

에 λ§Œλ“  2016λ…„ 06μ›” 27일  Β·  3μ½”λ©˜νŠΈ  Β·  좜처: golang/go

깨진 링크가 ν¬ν•¨λœ 디렉토리λ₯Ό λ‚˜μ—΄ν•˜λ €κ³  ν•˜λ©΄ 정보가 μ—†λŠ” 였λ₯˜κ°€ λ°œμƒν•©λ‹ˆλ‹€.

$ cadaver webdav://localhost:5555/api/v1/content                                                                                                                                         
dav:/api/v1/content/> ls etc
Listing collection `/api/v1/content/etc/': failed:
XML parse error at line 1: junk after document element

이것은 webdav μ„œλ²„μ—μ„œ 얻은 κ²ƒμž…λ‹ˆλ‹€.

2016/06/27 14:52:42 http: multiple response.WriteHeader calls

이 였λ₯˜λŠ” 깨진 링크 νŒŒμΌμ— λŒ€ν•΄ statλ₯Ό ν˜ΈμΆœν•˜λŠ” file.go [1]μ—μ„œ λ°œμƒν•˜μ§€λ§Œ webdav.go walkFn [2]μ—μ„œ μ²˜λ¦¬λ˜μ–΄μ•Ό ν•œλ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€.

λ‚˜λŠ” 무엇을 인쇄/λ°˜ν™˜ν•΄μ•Ό 할지 확신이 μ„œμ§€ μ•Šμ§€λ§Œ 이 링크가 μ–΄λ–»κ²Œλ“  λŠμ–΄μ§„ κ²ƒμœΌλ‘œ ν‘œμ‹œλœ 전체 디렉토리 λͺ©λ‘(예: webdavλŠ” λ‚΄ 생각에 이것에 λŒ€ν•΄ λΆ€μˆ΄μ„œλŠ” μ•ˆ 됨)을 얻을 κ²ƒμœΌλ‘œ μ˜ˆμƒν•©λ‹ˆλ‹€.

[1] https://github.com/golang/net/blob/master/webdav/file.go#L779
[2] https://github.com/golang/net/blob/master/webdav/webdav.go#L527

/cc @simon3z

κ°€μž₯ μœ μš©ν•œ λŒ“κΈ€

이 λ¬Έμ œκ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€. https://github.com/golang/net/blob/master/webdav/webdav.go#L557 μ—μ„œ 였λ₯˜κ°€ λ°œμƒν•˜λ©΄ nil을 λ°˜ν™˜ν•˜μ—¬ λ‘œμ»¬μ—μ„œ μˆ˜μ •ν–ˆμŠ΅λ‹ˆλ‹€

λ‚˜λŠ” Apache κ΅¬ν˜„μœΌλ‘œ λ™μΌν•œ μ‚¬μš© 사둀λ₯Ό ν…ŒμŠ€νŠΈν–ˆμœΌλ©° 깨진 심볼릭 링크의 경우 μžλ™μœΌλ‘œ μ‚­μ œλ©λ‹ˆλ‹€.

μΆ©λΆ„νžˆ 쒋은 ν•΄κ²°μ±…μΈμ§€λŠ” λͺ¨λ₯΄κ² μ§€λ§Œ 였늘의 행동도 틀리닀.
λ‹€μŒμ€ 잘λͺ»λœ μ‘λ‹΅μ˜ wireshark μΆ”μ μž…λ‹ˆλ‹€.

Host: 10.21.59.204
Depth: 1
Content-Type: application/xml
Apply-To-Redirect-Ref: T
Accept-Encoding: gzip, deflate
User-Agent: gvfs/1.28.2
Accept-Language: en-us, en;q=0.9
Connection: Keep-Alive
Content-Length: 235

<?xml version="1.0" encoding="utf-8" ?>
 <D:propfind xmlns:D="DAV:">
  <D:prop>
<D:creationdate/>
<D:displayname/>
<D:getcontentlength/>
<D:getcontenttype/>
<D:getetag/>
<D:getlastmodified/>
<D:resourcetype/>
  </D:prop>
 </D:propfind>HTTP/1.1 207 status code 207
Content-Type: text/xml; charset=utf-8
Date: Wed, 15 Mar 2017 09:00:40 GMT
Content-Length: 610

<?xml version="1.0" encoding="UTF-8"?><D:multistatus xmlns:D="DAV:"><D:response><D:href>/dav</D:href><D:propstat><D:prop><D:displayname></D:displayname><D:getlastmodified>Wed, 15 Mar 2017 08:59:55 GMT</D:getlastmodified><D:resourcetype><D:collection xmlns:D="DAV:"/></D:resourcetype></D:prop><D:status>HTTP/1.1 200 OK</D:status></D:propstat><D:propstat><D:prop><D:creationdate></D:creationdate><D:getcontentlength></D:getcontentlength><D:getcontenttype></D:getcontenttype><D:getetag></D:getetag></D:prop><D:status>HTTP/1.1 404 Not Found</D:status></D:propstat></D:response></D:multistatus>Internal Server Error

Webdav μ‚¬μ–‘μ—μ„œλŠ” λ‹€μŒκ³Ό 같이 λ§ν•©λ‹ˆλ‹€.

allprop 및 propname의 경우 principal에
νŠΉμ • μž¬μ‚°μ΄ μ‘΄μž¬ν•˜λŠ”μ§€ μ—¬λΆ€λ₯Ό μ•Œ ꢌ리
μ‘λ‹΅μ—μ„œ 쑰용히 μ œμ™Έλ˜μ–΄μ•Ό ν•©λ‹ˆλ‹€.

이것이 우리의 μ‚¬μš© 사둀에 μ μš©λ˜λŠ”μ§€ λͺ¨λ₯΄κ² μŠ΅λ‹ˆλ‹€

λͺ¨λ“  3 λŒ“κΈ€

이 λ¬Έμ œκ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€. https://github.com/golang/net/blob/master/webdav/webdav.go#L557 μ—μ„œ 였λ₯˜κ°€ λ°œμƒν•˜λ©΄ nil을 λ°˜ν™˜ν•˜μ—¬ λ‘œμ»¬μ—μ„œ μˆ˜μ •ν–ˆμŠ΅λ‹ˆλ‹€

λ‚˜λŠ” Apache κ΅¬ν˜„μœΌλ‘œ λ™μΌν•œ μ‚¬μš© 사둀λ₯Ό ν…ŒμŠ€νŠΈν–ˆμœΌλ©° 깨진 심볼릭 링크의 경우 μžλ™μœΌλ‘œ μ‚­μ œλ©λ‹ˆλ‹€.

μΆ©λΆ„νžˆ 쒋은 ν•΄κ²°μ±…μΈμ§€λŠ” λͺ¨λ₯΄κ² μ§€λ§Œ 였늘의 행동도 틀리닀.
λ‹€μŒμ€ 잘λͺ»λœ μ‘λ‹΅μ˜ wireshark μΆ”μ μž…λ‹ˆλ‹€.

Host: 10.21.59.204
Depth: 1
Content-Type: application/xml
Apply-To-Redirect-Ref: T
Accept-Encoding: gzip, deflate
User-Agent: gvfs/1.28.2
Accept-Language: en-us, en;q=0.9
Connection: Keep-Alive
Content-Length: 235

<?xml version="1.0" encoding="utf-8" ?>
 <D:propfind xmlns:D="DAV:">
  <D:prop>
<D:creationdate/>
<D:displayname/>
<D:getcontentlength/>
<D:getcontenttype/>
<D:getetag/>
<D:getlastmodified/>
<D:resourcetype/>
  </D:prop>
 </D:propfind>HTTP/1.1 207 status code 207
Content-Type: text/xml; charset=utf-8
Date: Wed, 15 Mar 2017 09:00:40 GMT
Content-Length: 610

<?xml version="1.0" encoding="UTF-8"?><D:multistatus xmlns:D="DAV:"><D:response><D:href>/dav</D:href><D:propstat><D:prop><D:displayname></D:displayname><D:getlastmodified>Wed, 15 Mar 2017 08:59:55 GMT</D:getlastmodified><D:resourcetype><D:collection xmlns:D="DAV:"/></D:resourcetype></D:prop><D:status>HTTP/1.1 200 OK</D:status></D:propstat><D:propstat><D:prop><D:creationdate></D:creationdate><D:getcontentlength></D:getcontentlength><D:getcontenttype></D:getcontenttype><D:getetag></D:getetag></D:prop><D:status>HTTP/1.1 404 Not Found</D:status></D:propstat></D:response></D:multistatus>Internal Server Error

Webdav μ‚¬μ–‘μ—μ„œλŠ” λ‹€μŒκ³Ό 같이 λ§ν•©λ‹ˆλ‹€.

allprop 및 propname의 경우 principal에
νŠΉμ • μž¬μ‚°μ΄ μ‘΄μž¬ν•˜λŠ”μ§€ μ—¬λΆ€λ₯Ό μ•Œ ꢌ리
μ‘λ‹΅μ—μ„œ 쑰용히 μ œμ™Έλ˜μ–΄μ•Ό ν•©λ‹ˆλ‹€.

이것이 우리의 μ‚¬μš© 사둀에 μ μš©λ˜λŠ”μ§€ λͺ¨λ₯΄κ² μŠ΅λ‹ˆλ‹€

깨진 링크에 μ•‘μ„ΈμŠ€ν•˜λŠ” 경우 4XX μƒνƒœ μ½”λ“œκ°€ λ°˜ν™˜λ˜μ–΄μ•Ό ν•œλ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€. 특히 κΆŒν•œ λŒ€μƒ 외뢀에 μ—°κ²°λœ 링크의 경우 403 Forbidden , 링크된 링크의 경우 404 Not Found μž…λ‹ˆλ‹€. μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” λŒ€μƒμ—κ²Œ.

ν˜„μž¬ 였λ₯˜μ— μ˜ν•΄ λ°˜ν™˜ FileSystem.OpenFile λ˜λŠ” File.Stat 에 전솑 http.StatusInternalServerError 와 원인을 "HTTP : golang.org/x/net/webdav.(*Handlerμ—μ„œ λΆˆν•„μš”ν•œ response.WriteHeader 호좜) .ServeHTTP(webdav.go:74)"

https://golang.org/cl/249797 μ—μ„œ 이 문제λ₯Ό μ–ΈκΈ‰: webdav: ignore os.PathError in PROPFIND

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰