2 * rs-serve - (c) 2013 Niklas E. Cathor
4 * This program is distributed in the hope that it will be useful,
5 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7 * GNU Affero General Public License for more details.
9 * You should have received a copy of the GNU Affero General Public License
10 * along with this program. If not, see <http://www.gnu.org/licenses/>.
38 #include <sys/types.h>
39 #include <sys/socket.h>
40 #include <sys/signalfd.h>
43 #include <sys/prctl.h>
47 #include <event2/event.h>
48 #include <event2/buffer.h>
49 #include <event2/util.h>
59 #include <attr/xattr.h>
61 // libssl headers (for SHA1 computation)
63 #include <openssl/sha.h>
68 #include <gssapi/gssapi_krb5.h>
75 #include "common/log.h"
76 #include "common/user.h"
77 #include "common/auth.h"
78 #include "common/json.h"
79 #include "common/attributes.h"
81 #include "handler/auth.h"
82 #include "handler/dispatch.h"
83 #include "handler/storage.h"
84 #include "handler/webfinger.h"
86 extern magic_t magic_cookie;
88 // users with UIDs that don't pass this test don't exist for rs-serve.
89 #define UID_ALLOWED(uid) ( (uid) >= RS_MIN_UID )
91 /* friendly accessors for requests (evhtp_request_t): */
93 // get username (string) from storage request path
94 #define REQUEST_GET_USER(req) (req)->uri->path->match_start
95 // get requested file path (i.e. relative path below user's storage_root)
96 // from storage request path.
97 #define REQUEST_GET_PATH(req) (req)->uri->path->match_end
98 // adds a response header. doesn't copy any values, so only works with
100 #define ADD_RESP_HEADER(req, key, val) \
101 evhtp_headers_add_header(req->headers_out, evhtp_header_new(key, val, 0, 0))
102 // same as ADD_RESP_HEADER, but value is copied (i.e. can be a volatile pointer)
103 #define ADD_RESP_HEADER_CP(req, key, val) \
104 evhtp_headers_add_header(req->headers_out, evhtp_header_new(key, val, 0, 1))
106 #endif /* !RS_SERVE_H */