Roxen.git/
server/
modules/
filesystems/
filesystem.pike
Branch:
Tag:
Non-build tags
All tags
No tags
2005-10-19
2005-10-19 13:33:56 by Henrik Grubbström (Grubba) <grubba@grubba.org>
71a23808347a7f8c215cbe2f94df9256d7794272 (
52
lines) (+
38
/-
14
)
[
Show
|
Annotate
]
Branch:
4.0
Backported chmod fixes from Roxen 4.1.
Rev: server/modules/filesystems/filesystem.pike:1.149
7:
inherit "module"; inherit "socket";
-
constant cvs_version= "$Id: filesystem.pike,v 1.
148
2005/
08
/
25
14
:
01
:
32
grubba Exp $";
+
constant cvs_version= "$Id: filesystem.pike,v 1.
149
2005/
10
/
19
13
:
33
:
56
grubba Exp $";
constant thread_safe=1; #include <module.h>
682:
return(0); }
+
//! @[chmod()] that doesn't throw errors.
+
string safe_chmod(string path, int mask)
+
{
+
return describe_error(catch {
+
chmod(path, mask);
+
return 0;
+
});
+
}
+
mapping make_collection(string coll, RequestID id) { TRACE_ENTER(sprintf("make_collection(%O)", coll), this_object());
734:
int code = mkdir(norm_f); int err_code = errno();
-
privs = 0;
+
TRACE_ENTER(sprintf("%s: Accepted", id->method), 0); if (code) {
-
chmod(norm_f, 0777 & ~(id->misc->umask || 022));
+
string msg = safe_
chmod(norm_f, 0777 & ~(id->misc->umask || 022));
+
privs = 0;
+
if (msg) {
+
TRACE_LEAVE(sprintf("%s: chmod %O failed: %s", id->method, norm_f, msg));
+
} else {
+
TRACE_LEAVE(sprintf("%s: chmod ok", id->method, msg));
+
}
TRACE_LEAVE(sprintf("%s: Success", id->method));
-
TRACE_LEAVE(sprintf("%s: Success", id->method));
+
return Roxen.http_status(201, "Created"); }
-
+
privs = 0;
TRACE_LEAVE(sprintf("%s: Failed", id->method)); return errno_to_status (err_code, 1, id);
941:
code = mkdir(f); int err_code = errno();
-
privs = 0;
+
TRACE_ENTER(sprintf("%s: Accepted", id->method), 0); if (code) {
-
chmod(f, 0777 & ~(id->misc->umask || 022));
+
string msg = safe_
chmod(f, 0777 & ~(id->misc->umask || 022));
+
privs = 0;
+
if (msg) {
+
TRACE_LEAVE(sprintf("%s: chmod %O failed: %s", id->method, f, msg));
+
} else {
TRACE_LEAVE(sprintf("%s: Success", id->method));
-
+
}
TRACE_LEAVE("Success"); if (id->method == "MKCOL") { return Roxen.http_status(201, "Created"); } return Roxen.http_string_answer("Ok"); } else {
-
+
privs = 0;
SIMPLE_TRACE_LEAVE("%s: Failed (errcode:%d)", id->method, errcode); TRACE_LEAVE("Failure"); if (id->method == "MKCOL") {
1044:
} // FIXME: Race-condition.
-
chmod(f, 0666 & ~(id->misc->umask || 022));
+
string msg = safe_
chmod(f, 0666 & ~(id->misc->umask || 022));
privs = 0; putting[id->my_fd] = id->misc->len;
1116:
return Roxen.http_status(403, "Permission denied."); }
-
array
err
=
catch(
chmod(f, id->misc->mode & 0777)
)
;
+
string
msg
=
safe_
chmod(f, id->misc->mode & 0777);
int err_code = errno(); privs = 0;
1128:
cache_set("stat_cache", f, 0); }
-
if(
err
)
+
if(
msg
)
{
-
TRACE_LEAVE("CHMOD: Failure");
+
TRACE_LEAVE(
sprintf(
"CHMOD: Failure
: %s
"
, msg
)
)
;
return errno_to_status (err_code, 0, id); } TRACE_LEAVE("CHMOD: Success");
1587:
int code = mkdir(dest_path); int err_code = errno();
-
privs = 0;
+
if (code) {
-
chmod(dest_path, 0777 & ~(id->misc->umask || 022));
+
string msg = safe_
chmod(dest_path, 0777 & ~(id->misc->umask || 022));
+
privs = 0;
+
if (msg) {
+
TRACE_LEAVE(sprintf("Chmod %O failed: %s", dest_path, msg));
+
} else {
TRACE_LEAVE("Success");
-
+
}
return Roxen.http_status(dest_st?204:201, "Created"); } else { return errno_to_status (err_code, 1, id);