~ubuntu-branches/ubuntu/hardy/lighttpd/hardy-updates

« back to all changes in this revision

Viewing changes to src/mod_webdav.c

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2006-12-08 14:40:42 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20061208144042-3z5kr9pe0kya5lgu
Tags: 1.4.13-6ubuntu1
* Merge from debian unstable, remaining changes:
  - Replace Depends: on perl with Depends: on libterm-readline-perl-perl

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
 *
49
49
 */
50
50
 
51
 
 
 
51
#define WEBDAV_FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH
 
52
#define WEBDAV_DIR_MODE  S_IRWXU | S_IRWXG | S_IRWXO
52
53
 
53
54
/* plugin config for all request/connections */
54
55
 
207
208
                        char *err;
208
209
 
209
210
                        if (SQLITE_OK != sqlite3_open(s->sqlite_db_name->ptr, &(s->sql))) {
210
 
                                log_error_write(srv, __FILE__, __LINE__, "s", "sqlite3_open failed");
 
211
                                log_error_write(srv, __FILE__, __LINE__, "sbs", "sqlite3_open failed for",
 
212
                                                s->sqlite_db_name,
 
213
                                                sqlite3_errmsg(s->sql));
211
214
                                return HANDLER_ERROR;
212
215
                        }
213
216
 
668
671
                return 403;
669
672
        }
670
673
 
671
 
        if (-1 == (ofd = open(dst->path->ptr, O_WRONLY|O_TRUNC|O_CREAT|(overwrite ? 0 : O_EXCL), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH))) {
 
674
        if (-1 == (ofd = open(dst->path->ptr, O_WRONLY|O_TRUNC|O_CREAT|(overwrite ? 0 : O_EXCL), WEBDAV_FILE_MODE))) {
672
675
                /* opening the destination failed for some reason */
673
676
                switch(errno) {
674
677
                case EEXIST:
773
776
                                /* why ? */
774
777
                        } else if (S_ISDIR(st.st_mode)) {
775
778
                                /* a directory */
776
 
                                if (-1 == mkdir(d.path->ptr, 0700) &&
 
779
                                if (-1 == mkdir(d.path->ptr, WEBDAV_DIR_MODE) &&
777
780
                                    errno != EEXIST) {
778
781
                                        /* WTH ? */
779
782
                                } else {
1160
1163
         *
1161
1164
         * X-Litmus: locks: 11 (owner_modify)
1162
1165
         * If: <http://127.0.0.1:1025/dav/litmus/lockme> (<opaquelocktoken:2165478d-0611-49c4-be92-e790d68a38f1>)
1163
 
         * - a tagged check: 
1164
 
         *   if http://127.0.0.1:1025/dav/litmus/lockme is locked with 
 
1166
         * - a tagged check:
 
1167
         *   if http://127.0.0.1:1025/dav/litmus/lockme is locked with
1165
1168
         *   opaquelocktoken:2165478d-0611-49c4-be92-e790d68a38f1, go on
1166
1169
         *
1167
1170
         * X-Litmus: locks: 16 (fail_cond_put)
1172
1175
        if (NULL != (ds = (data_string *)array_get_element(con->request.headers, "If"))) {
1173
1176
                /* Ooh, ooh. A if tag, now the fun begins.
1174
1177
                 *
1175
 
                 * this can only work with a real parser 
 
1178
                 * this can only work with a real parser
1176
1179
                 **/
1177
1180
        } else {
1178
1181
                /* we didn't provided a lock-token -> */
1494
1497
 
1495
1498
                /* let's create the directory */
1496
1499
 
1497
 
                if (-1 == mkdir(con->physical.path->ptr, 0700)) {
 
1500
                if (-1 == mkdir(con->physical.path->ptr, WEBDAV_DIR_MODE)) {
1498
1501
                        switch(errno) {
1499
1502
                        case EPERM:
1500
1503
                                con->http_status = 403;
1652
1655
                                return HANDLER_FINISHED;
1653
1656
                        }
1654
1657
 
1655
 
                        if (-1 == (fd = open(con->physical.path->ptr, O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH))) {
 
1658
                        if (-1 == (fd = open(con->physical.path->ptr, O_WRONLY, WEBDAV_FILE_MODE))) {
1656
1659
                                switch (errno) {
1657
1660
                                case ENOENT:
1658
1661
                                        con->http_status = 404; /* not found */
1676
1679
                        /* take what we have in the request-body and write it to a file */
1677
1680
 
1678
1681
                        /* if the file doesn't exist, create it */
1679
 
                        if (-1 == (fd = open(con->physical.path->ptr, O_WRONLY|O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH))) {
 
1682
                        if (-1 == (fd = open(con->physical.path->ptr, O_WRONLY|O_TRUNC, WEBDAV_FILE_MODE))) {
1680
1683
                                if (errno == ENOENT &&
1681
 
                                    -1 == (fd = open(con->physical.path->ptr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH))) {
 
1684
                                    -1 == (fd = open(con->physical.path->ptr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, WEBDAV_FILE_MODE))) {
1682
1685
                                        /* we can't open the file */
1683
1686
                                        con->http_status = 403;
1684
1687
 
1884
1887
                        /* src is a directory */
1885
1888
 
1886
1889
                        if (-1 == stat(p->physical.path->ptr, &st)) {
1887
 
                                if (-1 == mkdir(p->physical.path->ptr, 0700)) {
 
1890
                                if (-1 == mkdir(p->physical.path->ptr, WEBDAV_DIR_MODE)) {
1888
1891
                                        con->http_status = 403;
1889
1892
                                        return HANDLER_FINISHED;
1890
1893
                                }
1895
1898
                                        return HANDLER_FINISHED;
1896
1899
                                } else {
1897
1900
                                        unlink(p->physical.path->ptr);
1898
 
                                        if (-1 == mkdir(p->physical.path->ptr, 0700)) {
 
1901
                                        if (-1 == mkdir(p->physical.path->ptr, WEBDAV_DIR_MODE)) {
1899
1902
                                                con->http_status = 403;
1900
1903
                                                return HANDLER_FINISHED;
1901
1904
                                        }