change files changed time to created time

0

I have an apache web server which serves files over webdav (Ubuntu 18.04.5, Apache 2.4.29 with mod_dav enabled)

I modifed the permissions with chmod on all files and now the webserver returns the wrong creation date (changed instead of created)

<lp1:creationdate>2020-11-12T07:02:01Z</lp1:creationdate>
<lp1:getlastmodified>Mon, 12 Oct 2020 05:50:52 GMT</lp1:getlastmodified>

This has to be a bug in apaches webdav module. The bad thing is that, because I use the webdav server for my clients to perform backups. And now if a client tries to restore a backup, all backups have the same timestamp and he can't tell which is the right one to choose.

As a quick fix, how do I change a files ctime value to crtime (or mtime)

here are some debug infos to confirm that this happens.

LC_ALL=C stat ./backup.zip
  File: ./backup.zip
  Size: 20234077        Blocks: 39520      IO Block: 4096   regular file
Device: 6620b6e1h/1713420001d   Inode: 61214357    Links: 1
Access: (0770/-rwxrwx---)  Uid: (10001/user)   Gid: ( 1008/group)
Access: 2020-11-11 23:46:05.827618160 +0100
Modify: 2020-10-12 07:50:52.910941633 +0200
Change: 2020-11-12 08:02:01.492212852 +0100
 Birth: -

stat -c %i ./backup.zip
61214357

debugfs -R 'stat <61214357>' /dev/ploop26158p1
Inode: 61214357   Type: regular    Mode:  0770   Flags: 0x80000
Generation: 585915609    Version: 0x00000000:00000001
User: 10001   Group:  1008   Size: 20234077
File ACL: 0
Links: 1   Blockcount: 39520
Fragment:  Address: 0    Number: 0    Size: 0
 ctime: 0x5facdde9:755a49d0 -- Thu Nov 12 08:02:01 2020
 atime: 0x5fac69ad:c551cdc0 -- Wed Nov 11 23:46:05 2020
 mtime: 0x5f83eebc:d92f7704 -- Mon Oct 12 07:50:52 2020
crtime: 0x5f83eeab:bd410660 -- Mon Oct 12 07:50:35 2020
Size of extra inode fields: 28
EXTENTS:
(0-511):287372288-287372799, (512-1023):287354880-287355391, (1024-4095):287360000-287363071, (4096-4939):287350784-287351627
curl -u user:pass -i -X PROPFIND https://domain.tld/ --upload-file - -H "Depth: 1" <<end
<?xml version="1.0" encoding="utf-8" ?><propfind xmlns="DAV:"><allprop/></propfind>
end
HTTP/1.1 100 Continue

HTTP/1.1 207 Multi-Status
Date: Thu, 12 Nov 2020 07:23:27 GMT
Server: Apache
X-Powered-By: PleskLin
Content-Length: 1641
Content-Type: text/xml; charset="utf-8"

<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:ns0="DAV:">
<D:response xmlns:lp2="http://apache.org/dav/props/" xmlns:lp1="DAV:">
<D:href>/</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype><D:collection/></lp1:resourcetype>
<lp1:creationdate>2020-11-12T07:02:01Z</lp1:creationdate>
<lp1:getlastmodified>Mon, 12 Oct 2020 05:50:52 GMT</lp1:getlastmodified>
<lp1:getetag>"1000-5b172e19a0d5d"</lp1:getetag>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
<D:response xmlns:lp2="http://apache.org/dav/props/" xmlns:lp1="DAV:">
<D:href>/backup.zip</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype/>
<lp1:creationdate>2020-11-12T07:02:01Z</lp1:creationdate>
<lp1:getcontentlength>20234077</lp1:getcontentlength>
<lp1:getlastmodified>Mon, 12 Oct 2020 05:50:52 GMT</lp1:getlastmodified>
<lp1:getetag>"134bf5d-5b172e19a0d5d"</lp1:getetag>
<lp2:executable>T</lp2:executable>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>application/zip</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
apache2
files
webdav

1 Answer

0

I think you are gonna have to pick your poison: on this question you have multiple answers, none of them pretty

answered on Server Fault Nov 12, 2020 by NublaII

User contributions licensed under CC BY-SA 3.0