seafile-server: downgrade libevhtp and add openwrt patches

This commit is contained in:
blshkv 2019-06-16 00:54:42 +08:00
parent 36d37d11ae
commit 5592188cc0
No known key found for this signature in database
GPG key ID: 273E3E90D1A6294F
20 changed files with 941 additions and 1 deletions

View file

@ -0,0 +1 @@
DIST libevhtp-haiwen-20140819.zip 458401 BLAKE2B ee8e33a985db5f20880dcb6f2fc64f98266b9b524ac5bb97ed64e2aa4f2f24904a926bbf458ce13c5a4d51e1702c7e1d5bb81d8d5cc27989c5c4fba54a5a7252 SHA512 bd0e3ee37fdb0b1efed8a76c38aa292be4c55b870554fa5ca73f2b26c305533a21b2be1f81339608b27a14a9bcb502b0417c478cd819bb63ec205b2c2b413911

View file

@ -0,0 +1,49 @@
diff -rupN libevhtp-1.2.9.orig/htparse/htparse.c libevhtp-1.2.9/htparse/htparse.c
--- libevhtp-1.2.9.orig/htparse/htparse.c 2014-03-23 12:50:50.000000000 +0100
+++ libevhtp-1.2.9/htparse/htparse.c 2014-12-09 01:12:22.242001241 +0100
@@ -197,6 +197,7 @@ static const char * method_strmap[] = {
#define _MIN_READ(a, b) ((a) < (b) ? (a) : (b))
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define _str3_cmp(m, c0, c1, c2, c3) \
*(uint32_t *)m == ((c3 << 24) | (c2 << 16) | (c1 << 8) | c0)
@@ -226,6 +227,37 @@ static const char * method_strmap[] = {
*(uint32_t *)m == ((c3 << 24) | (c2 << 16) | (c1 << 8) | c0) \
&& ((uint32_t *)m)[1] == ((c7 << 24) | (c6 << 16) | (c5 << 8) | c4) \
&& m[8] == c8
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#define _str3_cmp(m, c0, c1, c2, c3) \
+ *(uint32_t *)m == ((c0 << 24) | (c1 << 16) | (c2 << 8) | c3)
+
+#define _str3Ocmp(m, c0, c1, c2, c3) \
+ *(uint32_t *)m == ((c0 << 24) | (c1 << 16) | (c2 << 8) | c3)
+
+#define _str4cmp(m, c0, c1, c2, c3) \
+ *(uint32_t *)m == ((c0 << 24) | (c1 << 16) | (c2 << 8) | c3)
+
+#define _str5cmp(m, c0, c1, c2, c3, c4) \
+ *(uint32_t *)m == ((c0 << 24) | (c1 << 16) | (c2 << 8) | c3) \
+ && m[4] == c4
+
+#define _str6cmp(m, c0, c1, c2, c3, c4, c5) \
+ *(uint32_t *)m == ((c0 << 24) | (c1 << 16) | (c2 << 8) | c3) \
+ && (((uint32_t *)m)[1] & 0xffff0000) == ((c4 << 24) | c5 << 16)
+
+#define _str7_cmp(m, c0, c1, c2, c3, c4, c5, c6, c7) \
+ *(uint32_t *)m == ((c0 << 24) | (c1 << 16) | (c2 << 8) | c3) \
+ && ((uint32_t *)m)[1] == ((c4 << 24) | (c5 << 16) | (c6 << 8) | c7)
+
+#define _str8cmp(m, c0, c1, c2, c3, c4, c5, c6, c7) \
+ *(uint32_t *)m == ((c0 << 24) | (c1 << 16) | (c2 << 8) | c3) \
+ && ((uint32_t *)m)[1] == ((c4 << 24) | (c5 << 16) | (c6 << 8) | c7)
+
+#define _str9cmp(m, c0, c1, c2, c3, c4, c5, c6, c7, c8) \
+ *(uint32_t *)m == ((c0 << 24) | (c1 << 16) | (c2 << 8) | c3) \
+ && ((uint32_t *)m)[1] == ((c4 << 24) | (c5 << 16) | (c6 << 8) | c7) \
+ && m[8] == c8
+#endif
#define __HTPARSE_GENHOOK(__n) \
static inline int hook_ ## __n ## _run(htparser * p, htparse_hooks * hooks) { \

View file

@ -0,0 +1,132 @@
--- a/evhtp.c
+++ b/evhtp.c
@@ -1686,16 +1686,15 @@ _evhtp_ssl_thread_lock(int mode, int typ
#endif
static void
_evhtp_ssl_delete_scache_ent(evhtp_ssl_ctx_t * ctx, evhtp_ssl_sess_t * sess) {
- evhtp_t * htp;
- evhtp_ssl_cfg_t * cfg;
- unsigned char * sid;
- unsigned int slen;
+ evhtp_t * htp;
+ evhtp_ssl_cfg_t * cfg;
+ evhtp_ssl_data_t * sid;
+ unsigned int slen;
htp = (evhtp_t *)SSL_CTX_get_app_data(ctx);
cfg = htp->ssl_cfg;
- sid = sess->session_id;
- slen = sess->session_id_length;
+ sid = (evhtp_ssl_data_t *)SSL_SESSION_get_id(sess, &slen);
if (cfg->scache_del) {
(cfg->scache_del)(htp, sid, slen);
@@ -1706,14 +1705,17 @@ static int
_evhtp_ssl_add_scache_ent(evhtp_ssl_t * ssl, evhtp_ssl_sess_t * sess) {
evhtp_connection_t * connection;
evhtp_ssl_cfg_t * cfg;
- unsigned char * sid;
+ evhtp_ssl_data_t * sid;
int slen;
connection = (evhtp_connection_t *)SSL_get_app_data(ssl);
- cfg = connection->htp->ssl_cfg;
+ if (connection->htp == NULL)
+ {
+ return 0; /* We cannot get the ssl_cfg */
+ }
- sid = sess->session_id;
- slen = sess->session_id_length;
+ cfg = connection->htp->ssl_cfg;
+ sid = (evhtp_ssl_data_t *)SSL_SESSION_get_id(sess, &slen);
SSL_set_timeout(sess, cfg->scache_timeout);
@@ -1725,7 +1727,7 @@ _evhtp_ssl_add_scache_ent(evhtp_ssl_t *
}
static evhtp_ssl_sess_t *
-_evhtp_ssl_get_scache_ent(evhtp_ssl_t * ssl, unsigned char * sid, int sid_len, int * copy) {
+_evhtp_ssl_get_scache_ent(evhtp_ssl_t * ssl, evhtp_ssl_data_t * sid, int sid_len, int * copy) {
evhtp_connection_t * connection;
evhtp_ssl_cfg_t * cfg;
evhtp_ssl_sess_t * sess;
@@ -1767,12 +1769,12 @@ _evhtp_ssl_servername(evhtp_ssl_t * ssl,
connection->vhost_via_sni = 1;
SSL_set_SSL_CTX(ssl, evhtp_vhost->ssl_ctx);
- SSL_set_options(ssl, SSL_CTX_get_options(ssl->ctx));
+ SSL_set_options(ssl, SSL_CTX_get_options(SSL_get_SSL_CTX(ssl)));
if ((SSL_get_verify_mode(ssl) == SSL_VERIFY_NONE) ||
(SSL_num_renegotiations(ssl) == 0)) {
- SSL_set_verify(ssl, SSL_CTX_get_verify_mode(ssl->ctx),
- SSL_CTX_get_verify_callback(ssl->ctx));
+ SSL_set_verify(ssl, SSL_CTX_get_verify_mode(SSL_get_SSL_CTX(ssl)),
+ SSL_CTX_get_verify_callback(SSL_get_SSL_CTX(ssl)));
}
return SSL_TLSEXT_ERR_OK;
@@ -3017,15 +3019,21 @@ evhtp_ssl_init(evhtp_t * htp, evhtp_ssl_
return -1;
}
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
SSL_library_init();
SSL_load_error_strings();
+#endif
RAND_poll();
STACK_OF(SSL_COMP) * comp_methods = SSL_COMP_get_compression_methods();
sk_SSL_COMP_zero(comp_methods);
htp->ssl_cfg = cfg;
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
htp->ssl_ctx = SSL_CTX_new(SSLv23_server_method());
+#else
+ htp->ssl_ctx = SSL_CTX_new(TLS_server_method());
+#endif
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
SSL_CTX_set_options(htp->ssl_ctx, SSL_MODE_RELEASE_BUFFERS);
@@ -3062,7 +3070,11 @@ evhtp_ssl_init(evhtp_t * htp, evhtp_ssl_
SSL_CTX_set_verify(htp->ssl_ctx, cfg->verify_peer, cfg->x509_verify_cb);
if (cfg->x509_chk_issued_cb != NULL) {
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
htp->ssl_ctx->cert_store->check_issued = cfg->x509_chk_issued_cb;
+#else
+ X509_STORE_set_check_issued(SSL_CTX_get_cert_store(htp->ssl_ctx), cfg->x509_chk_issued_cb);
+#endif
}
if (cfg->verify_depth) {
--- a/evhtp.h
+++ b/evhtp.h
@@ -34,6 +34,11 @@ typedef SSL evhtp_
typedef SSL_CTX evhtp_ssl_ctx_t;
typedef X509 evhtp_x509_t;
typedef X509_STORE_CTX evhtp_x509_store_ctx_t;
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+typedef unsigned char evhtp_ssl_data_t;
+#else
+typedef const unsigned char evhtp_ssl_data_t;
+#endif
#else
typedef void evhtp_ssl_sess_t;
typedef void evhtp_ssl_t;
@@ -154,9 +159,9 @@ typedef int (*evhtp_headers_iterator)(ev
typedef int (*evhtp_ssl_verify_cb)(int pre_verify, evhtp_x509_store_ctx_t * ctx);
typedef int (*evhtp_ssl_chk_issued_cb)(evhtp_x509_store_ctx_t * ctx, evhtp_x509_t * x, evhtp_x509_t * issuer);
-typedef int (*evhtp_ssl_scache_add)(evhtp_connection_t * connection, unsigned char * sid, int sid_len, evhtp_ssl_sess_t * sess);
-typedef void (*evhtp_ssl_scache_del)(evhtp_t * htp, unsigned char * sid, int sid_len);
-typedef evhtp_ssl_sess_t * (*evhtp_ssl_scache_get)(evhtp_connection_t * connection, unsigned char * sid, int sid_len);
+typedef int (*evhtp_ssl_scache_add)(evhtp_connection_t * connection, evhtp_ssl_data_t * sid, int sid_len, evhtp_ssl_sess_t * sess);
+typedef void (*evhtp_ssl_scache_del)(evhtp_t * htp, evhtp_ssl_data_t * sid, int sid_len);
+typedef evhtp_ssl_sess_t * (*evhtp_ssl_scache_get)(evhtp_connection_t * connection, evhtp_ssl_data_t * sid, int sid_len);
typedef void * (*evhtp_ssl_scache_init)(evhtp_t *);
#define EVHTP_VERSION "1.1.6"

View file

@ -0,0 +1,65 @@
From d24ad5d0542c14dce3790bb6d08589ae4019caa9 Mon Sep 17 00:00:00 2001
From: Moritz Lipp <mlq@pwmt.org>
Date: Tue, 23 Jul 2013 21:42:36 +0200
Subject: [PATCH 1/2] Include signal.h for SIGTERM declaration
---
test_proxy.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/test_proxy.c b/test_proxy.c
index 2b391613..4adafdeb 100644
--- a/test_proxy.c
+++ b/test_proxy.c
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
+#include <signal.h>
#include <errno.h>
#include <evhtp.h>
From bb238f6f802707eb147129de481a8c55c32b06b8 Mon Sep 17 00:00:00 2001
From: Moritz Lipp <mlq@pwmt.org>
Date: Tue, 23 Jul 2013 21:44:50 +0200
Subject: [PATCH 2/2] Resolve memory leaks in evhtp.c
This patch resolves memory leaks of the variable key_s in
_evhtp_request_parser_header_key by adding proper calls to free the previously
allocated memory upon failure and return. In addition it checks if the initial
allocation of the memory succeeded and acts accordingly.
---
evhtp.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/evhtp.c b/evhtp.c
index 2cde1da0..ca10a6c0 100644
--- a/evhtp.c
+++ b/evhtp.c
@@ -902,16 +902,24 @@ _evhtp_request_parser_header_key(htparser * p, const char * data, size_t len) {
char * key_s; /* = strndup(data, len); */
evhtp_header_t * hdr;
- key_s = malloc(len + 1);
+ key_s = malloc(len + 1);
+ if (key_s == NULL) {
+ return -1;
+ }
+
key_s[len] = '\0';
memcpy(key_s, data, len);
if ((hdr = evhtp_header_key_add(c->request->headers_in, key_s, 0)) == NULL) {
c->request->status = EVHTP_RES_FATAL;
+ free(key_s);
return -1;
}
hdr->k_heaped = 1;
+
+ free(key_s);
+
return 0;
}

View file

@ -0,0 +1,46 @@
# Copyright 1999-2019 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
EAPI=7
inherit cmake-utils
HASH_COMMIT=18c649203f009ef1d77d6f8301eba09af3777adf
DESCRIPTION="Create extremely-fast and secure embedded HTTP servers with ease"
HOMEPAGE="https://github.com/criticalstack/libevhtp"
SRC_URI="https://github.com/haiwen/libevhtp/archive/${HASH_COMMIT}.zip -> ${P}.zip"
LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="+oniguruma"
RDEPEND="oniguruma? ( dev-libs/oniguruma )"
DEPEND="${RDEPEND}"
S="${WORKDIR}/libevhtp-${HASH_COMMIT}"
src_prepare() {
# eapply "${FILESDIR}/010-strcmp-endianness-fix.patch"
# eapply "${FILESDIR}/020-openssl-1.1-compatibility.patch"
eapply "${FILESDIR}/pull-1.patch"
sed -i -e "s|lib/pkgconfig|$(get_libdir)/pkgconfig|" \
-e "s|lib/cmake|$(get_libdir)/cmake|" \
-e "s|DESTINATION \"lib|DESTINATION \"$(get_libdir)|" \
"${S}/CMakeLists.txt"
cmake-utils_src_prepare
eapply_user
}
src_configure() {
local mycmakeargs=(
# #libevent issue
# -DEVHTP_DISABLE_MEMFUNCTIONS=ON
# #https://manual.seafile.com/build_seafile/server.html
-DEVHTP_DISABLE_SSL=ON
-DEVHTP_BUILD_SHARED=OFF
#must be OFF for seafile
# $(usex oniguruma -DEVHTP_DISABLE_REGEX=OFF)
)
cmake-utils_src_configure
}

View file

@ -0,0 +1,73 @@
--- a/scripts/seaf-fsck.sh
+++ b/scripts/seaf-fsck.sh
@@ -7,7 +7,7 @@ INSTALLPATH=$(dirname "${SCRIPT}")
TOPDIR=$(dirname "${INSTALLPATH}")
default_ccnet_conf_dir=${TOPDIR}/ccnet
default_conf_dir=${TOPDIR}/conf
-seaf_fsck=${INSTALLPATH}/seafile/bin/seaf-fsck
+seaf_fsck=/usr/bin/seaf-fsck
export PATH=${INSTALLPATH}/seafile/bin:$PATH
export SEAFILE_LD_LIBRARY_PATH=${INSTALLPATH}/seafile/lib/:${INSTALLPATH}/seafile/lib64:${LD_LIBRARY_PATH}
--- a/scripts/seaf-gc.sh
+++ b/scripts/seaf-gc.sh
@@ -7,7 +7,7 @@ INSTALLPATH=$(dirname "${SCRIPT}")
TOPDIR=$(dirname "${INSTALLPATH}")
default_ccnet_conf_dir=${TOPDIR}/ccnet
default_conf_dir=${TOPDIR}/conf
-seaf_gc=${INSTALLPATH}/seafile/bin/seafserv-gc
+seaf_gc=/usr/bin/seafserv-gc
seaf_gc_opts=""
export PATH=${INSTALLPATH}/seafile/bin:$PATH
--- a/scripts/setup-seafile-mysql.sh
+++ b/scripts/setup-seafile-mysql.sh
@@ -40,15 +40,10 @@ function check_python_executable() {
function check_python_module () {
module=$1
name=$2
- hint=$3
printf " Checking python module: ${name} ... "
if ! $PYTHON -c "import ${module}" 2>/dev/null 1>&2; then
echo
printf "\033[33m ${name} \033[m is not installed, Please install it first.\n"
- if [[ "${hint}" != "" ]]; then
- printf "${hint}"
- echo
- fi
err_and_quit;
fi
echo -e "Done."
@@ -70,14 +65,10 @@ function check_python () {
if [[ $PYTHON == "python2.6" ]]; then
py26="2.6"
fi
- hint="\nOn Debian/Ubntu: apt-get install python-setuptools\nOn CentOS/RHEL: yum install python${py26}-distribute"
- check_python_module pkg_resources setuptools "${hint}"
-
- hint="\nOn Debian/Ubntu: apt-get install python-imaging\nOn CentOS/RHEL: yum install python${py26}-imaging"
- check_python_module PIL python-imaging "${hint}"
- hint='\nOn Debian/Ubuntu:\n\nsudo apt-get install python-mysqldb\n\nOn CentOS/RHEL:\n\nsudo yum install MySQL-python'
- check_python_module MySQLdb python-mysqldb "${hint}"
+ check_python_module pkg_resources setuptools
+ check_python_module PIL python-imaging
+ check_python_module MySQLdb python-mysqldb
fi
echo
}
@@ -85,5 +76,6 @@ function check_python () {
check_python;
export PYTHON=$PYTHON
+export PYTHONPATH="/usr/share/seafile/seafile-server/seahub/thirdpart:$PYTHONPATH"
exec $PYTHON "$python_script" "$@"
--- a/scripts/sqlite2mysql.sh
+++ b/scripts/sqlite2mysql.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#
# This shell script and corresponding sqlite2mysql.py are used to
# migrate Seafile data from SQLite to MySQL.

View file

@ -0,0 +1,23 @@
--- a/controller/seafile-controller.c
+++ b/controller/seafile-controller.c
@@ -21,7 +21,7 @@
SeafileController *ctl;
-static char *controller_pidfile = NULL;
+static char *controller_pidfile = "/var/run/seafile/seafile-controller.pid";
char *bin_dir = NULL;
char *installpath = NULL;
@@ -591,9 +591,9 @@ stop_ccnet_server ()
static void
init_pidfile_path (SeafileController *ctl)
{
- char *pid_dir = g_build_filename (topdir, "pids", NULL);
+ char *pid_dir = g_path_get_dirname (controller_pidfile);
if (!g_file_test(pid_dir, G_FILE_TEST_EXISTS)) {
- if (g_mkdir(pid_dir, 0777) < 0) {
+ if (g_mkdir(pid_dir, 0755) < 0) {
seaf_warning("failed to create pid dir %s: %s", pid_dir, strerror(errno));
controller_exit(1);
}

View file

@ -0,0 +1,60 @@
--- a/tools/seafile-admin
+++ b/tools/seafile-admin
@@ -449,9 +449,12 @@ workers = 3
# Logging
runtime_dir = os.path.dirname(__file__)
-pidfile = os.path.join(runtime_dir, 'seahub.pid')
+pidfile = '/var/run/seafile/seahub.pid'
errorlog = os.path.join(runtime_dir, 'error.log')
accesslog = os.path.join(runtime_dir, 'access.log')
+
+# for file upload, we need a longer timeout value (default is only 30s, too short)
+timeout = 1200
'''
try:
@@ -526,6 +529,7 @@ def check_django_version():
def check_python_module(import_name, package_name=None, silent=False):
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "seahub.settings")
package_name = package_name or import_name
if not silent:
info('checking %s' % package_name)
@@ -785,7 +789,7 @@ def check_layout(args):
conf[CONF_SEAFILE_DIR] = seafile_data_dir
conf[CONF_SEAHUB_DIR] = seahub_dir
conf[CONF_SEAHUB_CONF] = seahub_conf
- conf[CONF_SEAHUB_PIDFILE] = os.path.join(runtime_dir, 'seahub.pid')
+ conf[CONF_SEAHUB_PIDFILE] = '/var/run/seafile/seahub.pid'
conf[CONF_SEAHUB_OUTLOG] = os.path.join(runtime_dir, 'access.log')
conf[CONF_SEAHUB_ERRLOG] = os.path.join(runtime_dir, 'error.log')
@@ -836,10 +840,13 @@ def setup_seafile(args):
print '-----------------------------------------------------------------'
print '-----------------------------------------------------------------'
print
- print 'To start/stop seafile server:'
+ print 'To start, stop or restart seafile:'
+ print
+ print highlight(' # /etc/init.d/seafile { start | stop | restart }')
print
- print highlight(' $ cd %s' % cwd)
- print highlight(' $ %s { start | stop }' % SCRIPT_NAME)
+ print 'To start, stop or restart seahub:'
+ print
+ print highlight(' # /etc/init.d/seahub { start | stop | restart }')
print
print 'If you have any problem, refer to\n'
print
@@ -903,8 +910,7 @@ def start_seafile(args):
def stop_seafile(dummy):
info('Stopping seafile server')
pkill('seafile-controller')
- runtime_dir = os.path.join(cwd, 'seafile-server', 'runtime')
- pidfile = os.path.join(runtime_dir, 'seahub.pid')
+ pidfile = '/var/run/seafile/seahub.pid'
try:
with open(pidfile, 'r') as fp:
pid = fp.read().strip('\n ')

View file

@ -0,0 +1,42 @@
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,3 +1,5 @@
+include $(TOPDIR)/rules.mk
+
pcfiles = libseafile.pc
pkgconfig_DATA = $(pcfiles)
pkgconfigdir = $(libdir)/pkgconfig
@@ -33,7 +35,7 @@ seafile_HEADERS = seafile-object.h
seafile-object.h: ${seafile_object_define}
rm -f $@
- valac --pkg posix ${seafile_object_define} -C -H seafile-object.h
+ "$(STAGING_DIR_HOSTPKG)/bin/valac" --pkg posix ${seafile_object_define} -C -H seafile-object.h
DISTCLEANFILES = ${searpc_gen}
@@ -56,7 +58,7 @@ rpc_table.stamp: ${top_srcdir}/lib/rpc_table.py
@rm -f rpc_table.tmp
@touch rpc_table.tmp
@echo "[libsearpc]: generating rpc header files"
- @PYTHON@ `which searpc-codegen.py` ${top_srcdir}/lib/rpc_table.py
+ @PYTHON@ "$(STAGING_DIR)/usr/bin/searpc-codegen.py" ${top_srcdir}/lib/rpc_table.py
@echo "[libsearpc]: done"
@mv -f rpc_table.tmp $@
@@ -66,7 +68,7 @@ vala.stamp: ${seafile_object_define}
rm -f ${seafile_object_gen}
@rm -f vala.tmp
@touch vala.tmp
- valac -C --pkg posix $^
+ "$(STAGING_DIR_HOSTPKG)/bin/valac" -C --pkg posix $^
@mv -f vala.tmp $@
${seafile_object_gen}: vala.stamp
@@ -82,5 +84,5 @@ install-data-local:
if MACOS
sed -i '' -e "s|(DESTDIR)|${DESTDIR}|g" $(pcfiles)
else
- ${SED} -i "s|(DESTDIR)|${DESTDIR}|g" $(pcfiles)
+ ${SED} "s|(DESTDIR)|${DESTDIR}|g" $(pcfiles)
endif

View file

@ -0,0 +1,38 @@
--- a/lib/repo.vala
+++ b/lib/repo.vala
@@ -34,7 +34,7 @@ public class Repo : Object {
// data format version
public int version { get; set; }
- public int last_modify { get; set; }
+ public int64 last_modify { get; set; }
public int64 size { get; set; }
public int64 file_count { get; set; }
public string last_modifier { get; set; }
@@ -45,7 +45,7 @@ public class Repo : Object {
public string repo_id { get; set; }
public string repo_name { get; set; }
public string repo_desc { get; set; }
- public int last_modified { get; set; }
+ public int64 last_modified { get; set; }
// Section 2: Encryption related
// Members in this section should be set for every Repo object
@@ -68,7 +68,7 @@ public class Repo : Object {
get { return _relay_id; }
set { _relay_id = value; }
}
- public int last_sync_time { get; set; }
+ public int64 last_sync_time { get; set; }
public bool auto_sync { get; set; }
public bool worktree_invalid { get; set; }
@@ -162,7 +162,7 @@ public class DeletedEntry : Object {
public string obj_name { get; set; }
public string basedir { get; set; }
public int mode { get; set; }
- public int delete_time { get; set; }
+ public int64 delete_time { get; set; }
public int64 file_size { get; set; }
public string scan_stat { get; set; }
}

View file

@ -0,0 +1,20 @@
--- a/scripts/seaf-fuse.sh
+++ b/scripts/seaf-fuse.sh
@@ -7,7 +7,7 @@ INSTALLPATH=$(dirname "${SCRIPT}")
TOPDIR=$(dirname "${INSTALLPATH}")
default_ccnet_conf_dir=${TOPDIR}/ccnet
default_conf_dir=${TOPDIR}/conf
-seaf_fuse=${INSTALLPATH}/seafile/bin/seaf-fuse
+seaf_fuse=/usr/bin/seaf-fuse
export PATH=${INSTALLPATH}/seafile/bin:$PATH
export SEAFILE_LD_LIBRARY_PATH=${INSTALLPATH}/seafile/lib/:${INSTALLPATH}/seafile/lib64:${LD_LIBRARY_PATH}
@@ -68,7 +68,7 @@ function validate_already_running () {
}
function warning_if_seafile_not_running () {
- if ! pgrep -f "seafile-controller -c ${default_ccnet_conf_dir}" 2>/dev/null 1>&2; then
+ if ! pgrep -f "seafile-controller -F ${default_conf_dir}" 2>/dev/null 1>&2; then
echo
echo "Warning: seafile-controller not running. Have you run \"./seafile.sh start\" ?"
echo

View file

@ -0,0 +1,35 @@
From 13f95a28ce12216ba51cf0ca8d61c3d89689d02b Mon Sep 17 00:00:00 2001
From: Eneas U de Queiroz <cote2004-github@yahoo.com>
Date: Wed, 6 Jun 2018 18:11:47 -0300
Subject: [PATCH] Remove API deprecated in openssl 1.1
Openssl 1.1 has deprecated RAND_pseudo_bytes. It won't compile with
openssl built witout deprecated API.
Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
---
common/seafile-crypt.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/common/seafile-crypt.c b/common/seafile-crypt.c
index c7d1702..c3cebf5 100644
--- a/common/seafile-crypt.c
+++ b/common/seafile-crypt.c
@@ -81,9 +81,14 @@ seafile_generate_random_key (const char *passwd, char *random_key)
int rc = RAND_bytes (secret_key, sizeof(secret_key));
if (rc != 1) {
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || OPENSSL_API_COMPAT < 0x10100000L
seaf_warning ("Failed to generate secret key for repo encryption "
"with RAND_bytes(), use RAND_pseudo_bytes().\n");
RAND_pseudo_bytes (secret_key, sizeof(secret_key));
+#else
+ seaf_warning ("Failed to generate secret key for repo encryption "
+ "with RAND_bytes().\n");
+#endif
}
seafile_derive_key (passwd, strlen(passwd), 2, key, iv);
--
2.16.4

View file

@ -0,0 +1,61 @@
From 115a4583deb9ae11adbc419ea87c990d0b8572fe Mon Sep 17 00:00:00 2001
From: Joffrey Darcq <j-off@live.fr>
Date: Sat, 28 Apr 2018 22:27:28 +0200
Subject: [PATCH 1/2] fix django version 1.11
---
tools/seafile-admin | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/seafile-admin b/tools/seafile-admin
index 5e3658b..38e7288 100755
--- a/tools/seafile-admin
+++ b/tools/seafile-admin
@@ -518,10 +518,10 @@ def init_seahub():
def check_django_version():
- '''Requires django 1.8'''
+ '''Requires django 1.11'''
import django
- if django.VERSION[0] != 1 or django.VERSION[1] != 8:
- error('Django 1.8 is required')
+ if django.VERSION[0] != 1 or django.VERSION[1] != 11:
+ error('Django 1.11 is required')
del django
From bf69ff1cf1080081eae5d8115842c26468746736 Mon Sep 17 00:00:00 2001
From: Joffrey Darcq <j-off@live.fr>
Date: Sun, 3 Jun 2018 15:51:54 +0200
Subject: [PATCH 2/2] fix django version 1.11
---
tools/seafile-admin | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/seafile-admin b/tools/seafile-admin
index 38e7288..c16aab6 100755
--- a/tools/seafile-admin
+++ b/tools/seafile-admin
@@ -499,8 +499,8 @@ def init_seahub():
# create seahub_settings.py
create_seahub_settings_py()
- argv = [PYTHON, 'manage.py', 'syncdb']
- # Set proper PYTHONPATH before run django syncdb command
+ argv = [PYTHON, 'manage.py', 'migrate']
+ # Set proper PYTHONPATH before run django migrate command
env = get_seahub_env()
print
@@ -509,7 +509,7 @@ def init_seahub():
print
if run_argv(argv, cwd=seahub_dir, env=env) != 0:
- error('Seahub syncdb failed')
+ error('Seahub migrate failed')
info('done')

View file

@ -0,0 +1,26 @@
--- a/tools/seafile-admin
+++ b/tools/seafile-admin
@@ -831,7 +831,22 @@ def setup_seafile(args):
conf[CONF_SEAFILE_CENTRAL_CONF_DIR] = os.path.join(cwd, 'conf')
config_ccnet_seafile()
init_ccnet_seafile()
- init_seahub()
+
+ # make sure ccnet-server is running to avoid an error creating django superuser
+ if not is_running('ccnet-server'):
+ argv = [
+ 'ccnet-server',
+ '-F',
+ conf[CONF_SEAFILE_CENTRAL_CONF_DIR],
+ '-c',
+ conf[CONF_CCNET_DIR],
+ '-d'
+ ]
+ run_argv(argv)
+ init_seahub()
+ pkill('ccnet-server')
+ else:
+ init_seahub()
print
print '-----------------------------------------------------------------'

View file

@ -0,0 +1,40 @@
Author: David Barbion <davidb@230ruedubac.fr>
Description: Use shared object for libevhtp
Forwarded: https://github.com/haiwen/seafile-server/pull/12
Index: seafile-server/configure.ac
===================================================================
--- seafile-server.orig/configure.ac
+++ seafile-server/configure.ac
@@ -218,6 +218,10 @@ PKG_CHECK_MODULES(LIBEVENT, [libevent >=
AC_SUBST(LIBEVENT_CFLAGS)
AC_SUBST(LIBEVENT_LIBS)
+PKG_CHECK_MODULES(LIBEVHTP, [evhtp])
+AC_SUBST(LIBEVHTP_CFLAGS)
+AC_SUBST(LIBEVHTP_LIBS)
+
PKG_CHECK_MODULES(ZLIB, [zlib >= $ZLIB_REQUIRED])
AC_SUBST(ZLIB_CFLAGS)
AC_SUBST(ZLIB_LIBS)
Index: seafile-server/server/Makefile.am
===================================================================
--- seafile-server.orig/server/Makefile.am
+++ seafile-server/server/Makefile.am
@@ -13,6 +13,7 @@ AM_CFLAGS = -DPKGDATADIR=\"$(pkgdatadir)
@GLIB2_CFLAGS@ \
@MSVC_CFLAGS@ \
@LIBARCHIVE_CFLAGS@ \
+ @LIBEVHTP_CFLAGS@ \
-Wall
bin_PROGRAMS = seaf-server
@@ -114,7 +115,7 @@ seaf_server_SOURCES = \
seaf_server_LDADD = @CCNET_LIBS@ \
$(top_builddir)/lib/libseafile_common.la \
- @GLIB2_LIBS@ @GOBJECT_LIBS@ @SSL_LIBS@ @LIB_RT@ @LIB_UUID@ -lsqlite3 @LIBEVENT_LIBS@ -levhtp \
+ -lonig @GLIB2_LIBS@ @GOBJECT_LIBS@ @SSL_LIBS@ @LIB_RT@ @LIB_UUID@ -lsqlite3 @LIBEVENT_LIBS@ @LIBEVHTP_LIBS@ \
$(top_builddir)/common/cdc/libcdc.la \
$(top_builddir)/common/db-wrapper/libdbwrapper.la \
@SEARPC_LIBS@ @JANSSON_LIBS@ ${LIB_WS32} @ZLIB_LIBS@ \

View file

@ -0,0 +1,69 @@
Author: Alexandre Rossi <alexandre.rossi@gmail.com>
Description: Fix download stalling on recent libevhtp
A while ago[1], evhtp_request_pause() behavior changed: it now disables
both read and write events. seafile-server would then stall.
.
[1] https://github.com/criticalstack/libevhtp/commit/6cd89466fd6bd76c5b8624be65af5893afe3e40c
[2] https://github.com/haiwen/seafile/issues/1119
Forwarded: no
Index: seafile-server/server/access-file.c
===================================================================
--- seafile-server.orig/server/access-file.c 2018-02-01 12:23:53.209308343 +0100
+++ seafile-server/server/access-file.c 2018-02-01 12:23:53.205308288 +0100
@@ -618,7 +618,7 @@
/* Block any new request from this connection before finish
* handling this request.
*/
- evhtp_request_pause (req);
+ bufferevent_disable(bev, EV_READ);
/* Kick start data transfer by sending out http headers. */
evhtp_send_reply_start(req, EVHTP_RES_OK);
@@ -967,7 +967,7 @@
/* Block any new request from this connection before finish
* handling this request.
*/
- evhtp_request_pause (req);
+ bufferevent_disable(bev, EV_READ);
/* Kick start data transfer by sending out http headers. */
evhtp_send_reply_start(req, EVHTP_RES_PARTIAL);
@@ -1032,7 +1032,7 @@
/* Block any new request from this connection before finish
* handling this request.
*/
- evhtp_request_pause (req);
+ bufferevent_disable(bev, EV_READ);
/* Kick start data transfer by sending out http headers. */
evhtp_send_reply_start(req, EVHTP_RES_OK);
@@ -1365,7 +1365,7 @@
/* Block any new request from this connection before finish
* handling this request.
*/
- evhtp_request_pause (req);
+ bufferevent_disable(bev, EV_READ);
/* Kick start data transfer by sending out http headers. */
evhtp_send_reply_start(req, EVHTP_RES_OK);
Index: seafile-server/server/upload-file.c
===================================================================
--- seafile-server.orig/server/upload-file.c 2018-02-01 12:23:53.209308343 +0100
+++ seafile-server/server/upload-file.c 2018-02-01 12:25:14.542400155 +0100
@@ -2054,6 +2054,7 @@
if (res != EVHTP_RES_OK) {
/* Don't receive any data before the connection is closed. */
//evhtp_request_pause (req);
+ // or for later evhtp bufferevent_disable(evhtp_request_get_bev(req), EV_READ);
/* Set keepalive to 0. This will cause evhtp to close the
* connection after sending the reply.
@@ -2271,6 +2272,7 @@
err:
/* Don't receive any data before the connection is closed. */
//evhtp_request_pause (req);
+ // or for later evhtp bufferevent_disable(evhtp_request_get_bev(req), EV_READ);
/* Set keepalive to 0. This will cause evhtp to close the
* connection after sending the reply.

View file

@ -0,0 +1,85 @@
Author: Alexandre Rossi <alexandre.rossi@gmail.com>
Description: Take into account libevhtp API changes
Forwarded: no
Index: seafile-server/server/upload-file.c
===================================================================
--- seafile-server.orig/server/upload-file.c 2018-02-01 12:25:52.666911934 +0100
+++ seafile-server/server/upload-file.c 2018-02-01 12:27:37.812323399 +0100
@@ -2059,7 +2059,7 @@
/* Set keepalive to 0. This will cause evhtp to close the
* connection after sending the reply.
*/
- req->keepalive = 0;
+ req->flags &= ~EVHTP_REQ_FLAG_KEEPALIVE;
fsm->state = RECV_ERROR;
}
@@ -2260,8 +2260,8 @@
}
/* Set up per-request hooks, so that we can read file data piece by piece. */
- evhtp_set_hook (&req->hooks, evhtp_hook_on_read, upload_read_cb, fsm);
- evhtp_set_hook (&req->hooks, evhtp_hook_on_request_fini, upload_finish_cb, fsm);
+ evhtp_request_set_hook (req, evhtp_hook_on_read, upload_read_cb, fsm);
+ evhtp_request_set_hook (req, evhtp_hook_on_request_fini, upload_finish_cb, fsm);
/* Set arg for upload_cb or update_cb. */
req->cbarg = fsm;
@@ -2277,7 +2277,7 @@
/* Set keepalive to 0. This will cause evhtp to close the
* connection after sending the reply.
*/
- req->keepalive = 0;
+ req->flags &= ~EVHTP_REQ_FLAG_KEEPALIVE;
send_error_reply (req, EVHTP_RES_BADREQ, err_msg);
g_free (repo_id);
@@ -2346,38 +2346,32 @@
cb = evhtp_set_regex_cb (htp, "^/upload/.*", upload_cb, NULL);
/* upload_headers_cb() will be called after evhtp parsed all http headers. */
- evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL);
+ evhtp_callback_set_hook(cb, evhtp_hook_on_headers, upload_headers_cb, NULL);
cb = evhtp_set_regex_cb (htp, "^/upload-api/.*", upload_api_cb, NULL);
- evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL);
+ evhtp_callback_set_hook(cb, evhtp_hook_on_headers, upload_headers_cb, NULL);
cb = evhtp_set_regex_cb (htp, "^/upload-raw-blks-api/.*",
upload_raw_blks_api_cb, NULL);
- evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL);
+ evhtp_callback_set_hook(cb, evhtp_hook_on_headers, upload_headers_cb, NULL);
cb = evhtp_set_regex_cb (htp, "^/upload-blks-api/.*", upload_blks_api_cb, NULL);
- evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL);
-
- /* cb = evhtp_set_regex_cb (htp, "^/upload-blks-aj/.*", upload_blks_ajax_cb, NULL); */
- /* evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL); */
+ evhtp_callback_set_hook(cb, evhtp_hook_on_headers, upload_headers_cb, NULL);
cb = evhtp_set_regex_cb (htp, "^/upload-aj/.*", upload_ajax_cb, NULL);
- evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL);
+ evhtp_callback_set_hook(cb, evhtp_hook_on_headers, upload_headers_cb, NULL);
cb = evhtp_set_regex_cb (htp, "^/update/.*", update_cb, NULL);
- evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL);
+ evhtp_callback_set_hook(cb, evhtp_hook_on_headers, upload_headers_cb, NULL);
cb = evhtp_set_regex_cb (htp, "^/update-api/.*", update_api_cb, NULL);
- evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL);
+ evhtp_callback_set_hook(cb, evhtp_hook_on_headers, upload_headers_cb, NULL);
cb = evhtp_set_regex_cb (htp, "^/update-blks-api/.*", update_blks_api_cb, NULL);
- evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL);
-
- /* cb = evhtp_set_regex_cb (htp, "^/update-blks-aj/.*", update_blks_ajax_cb, NULL); */
- /* evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL); */
+ evhtp_callback_set_hook(cb, evhtp_hook_on_headers, upload_headers_cb, NULL);
cb = evhtp_set_regex_cb (htp, "^/update-aj/.*", update_ajax_cb, NULL);
- evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL);
+ evhtp_callback_set_hook(cb, evhtp_hook_on_headers, upload_headers_cb, NULL);
evhtp_set_regex_cb (htp, "^/upload_progress.*", upload_progress_cb, NULL);

View file

@ -18,7 +18,7 @@ RDEPEND="${PYTHON_DEPS}
!net-libs/ccnet
net-misc/ccnet-server
net-libs/libevhtp[oniguruma]
net-libs/libevhtp-haiwen[oniguruma]
dev-libs/libevent
net-misc/curl
dev-libs/glib

View file

@ -0,0 +1,74 @@
# Copyright 1999-2019 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
EAPI=7
PYTHON_COMPAT=( python2_7 )
inherit autotools python-single-r1 vala
DESCRIPTION="File syncing and sharing software with file encryption and group sharing"
HOMEPAGE="https://github.com/haiwen/seafile-server/ http://www.seafile.com/"
SRC_URI="https://github.com/haiwen/${PN}/archive/v${PV}-server.tar.gz -> ${P}.tar.gz"
LICENSE="GPL-2+-with-openssl-exception"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""
RDEPEND="${PYTHON_DEPS}
!net-libs/ccnet
net-misc/ccnet-server
net-libs/libevhtp-haiwen[oniguruma]
dev-libs/libevent
net-misc/curl
dev-libs/glib
virtual/libmysqlclient
app-arch/libarchive
dev-libs/jansson
sys-fs/fuse
dev-db/sqlite:3
dev-python/pillow[${PYTHON_USEDEP}]
>=dev-python/termcolor-1.1.0[${PYTHON_USEDEP}]
>=dev-python/requests-2.8.0[${PYTHON_USEDEP}]
>=dev-python/pytest-3.3.2[${PYTHON_USEDEP}]
>=dev-python/backports-functools-lru-cache-1.4[${PYTHON_USEDEP}]
>=dev-python/tenacity-4.8.0[${PYTHON_USEDEP}]"
#moviepy
DEPEND="${RDEPEND}
$(vala_depend)"
S="${WORKDIR}/${P}-server"
src_prepare() {
#https://github.com/haiwen/seafile-server/issues/67#issuecomment-337904800
# eapply "${FILESDIR}/libevhtp-1.2.18.patch"
#https://github.com/openwrt/packages/tree/master/net/seafile-server/patches
# eapply "${FILESDIR}/020-script-patches.patch"
eapply "${FILESDIR}/030-pidfiles-in-same-directory.patch"
eapply "${FILESDIR}/040-seafile-admin.patch"
# eapply "${FILESDIR}/050-libseafile-makefile-fixes.patch"
eapply "${FILESDIR}/060-timestamps-as-int64.patch"
eapply "${FILESDIR}/070-fuse-mount.patch"
# eapply "${FILESDIR}/080-Remove-API-deprecated-in-openssl-1.1.patch"
eapply "${FILESDIR}/090-django-11-compat.patch"
eapply "${FILESDIR}/100-seafile-admin-Make-sure-ccnet-is-running.patch"
# eapply "${FILESDIR}/110-libevhtp-linking.patch"
# eapply "${FILESDIR}/120-recent-libevhtp.patch"
# eapply "${FILESDIR}/130-newer-libevhtp.patch"
#do not overlap files with seafile
#https://github.com/haiwen/seafile-server/issues/235
eapply "${FILESDIR}/remove_pc.patch"
sed -i '/seafile_HEADERS/d' lib/Makefile.am || die
sed -i -e 's|seafile ||' python/Makefile.am || die
sed -i -e 's/valac /${VALAC} /' lib/Makefile.am || die
python_fix_shebang tools/seafile-admin
eautoreconf
vala_src_prepare
eapply_user
}

View file

@ -42,3 +42,4 @@ net-libs/libpfring
~net-libs/serf-1.3.9
~net-libs/libevhtp-1.2.18
net-libs/libevhtp-haiwen