Wed, 22 May 2013 13:27:31 +0200
added net_writev
--- a/src/server/daemon/keyfile_auth.c Sat May 11 13:28:26 2013 +0200 +++ b/src/server/daemon/keyfile_auth.c Wed May 22 13:27:31 2013 +0200 @@ -141,7 +141,7 @@ * the SSHA hash is already base64 decoded */ - char *salt = user->hash + user->hashlen - 8; // last 8 bytes are salt + char *salt = user->hash + user->hashlen - 8; // last 8 bytes are the salt size_t pwlen = strlen(password); size_t saltpwlen = pwlen + 8; @@ -153,11 +153,8 @@ SHA1((const unsigned char*)saltpw, saltpwlen, pwhash); if(!memcmp(user->hash, pwhash, 20)) { - free(pwhash); return 1; + } else { + return 0; } - - free(pwhash); - - return 0; }
--- a/src/server/public/nsapi.h Sat May 11 13:28:26 2013 +0200 +++ b/src/server/public/nsapi.h Wed May 22 13:27:31 2013 +0200 @@ -1191,7 +1191,9 @@ ssize_t net_write(SYS_NETFD fd, void *buf, size_t nbytes); +ssize_t net_writev(SYS_NETFD fd, struct iovec *iovec, int iovcnt); +// NSAPI extension ssize_t net_printf(SYS_NETFD fd, char *format, ...);
--- a/src/server/util/io.c Sat May 11 13:28:26 2013 +0200 +++ b/src/server/util/io.c Wed May 22 13:27:31 2013 +0200 @@ -42,12 +42,14 @@ IOStream native_io_funcs = { system_write, + system_writev, system_read, NULL }; IOStream net_io_funcs = { net_stream_write, + net_stream_writev, net_stream_read, net_stream_sendfile }; @@ -64,6 +66,10 @@ return write(((SystemIOStream*)st)->fd, buf, nbytes); } +ssize_t system_writev(IOStream *st, struct iovec *iovec, int iovcnt) { + return writev(((SystemIOStream*)st)->fd, iovec, iovcnt); +} + ssize_t system_read(IOStream *st, void *buf, size_t nbytes) { return read(((SystemIOStream*)st)->fd, buf, nbytes); } @@ -82,6 +88,10 @@ return write(((NetIOStream*)st)->fd, buf, nbytes); } +ssize_t net_stream_writev(IOStream *st, struct iovec *iovec, int iovcnt) { + return writev(((NetIOStream*)st)->fd, iovec, iovcnt); +} + ssize_t net_stream_read(IOStream *st, void *buf, size_t nbytes) { NetIOStream *n = (NetIOStream*)st; if(n->max_read != 0 && n->rd >= n->max_read) { @@ -124,14 +134,22 @@ return r; } +ssize_t net_writev(SYS_NETFD fd, struct iovec *iovec, int iovcnt) { + ssize_t r = ((IOStream*)fd)->writev(fd, iovec, iovcnt); + if(r < 0) { + return IO_ERROR; + } + return r; +} + ssize_t net_printf(SYS_NETFD fd, char *format, ...) { va_list arg; va_start(arg, format); char *buf; ssize_t len = vasprintf(&buf, format, arg); - net_write(fd, buf, len); + ssize_t r = net_write(fd, buf, len); free(buf); - return len; + return r; } ssize_t net_sendfile(SYS_NETFD fd, sendfiledata *sfd) {
--- a/src/server/util/io.h Sat May 11 13:28:26 2013 +0200 +++ b/src/server/util/io.h Wed May 22 13:27:31 2013 +0200 @@ -38,11 +38,13 @@ typedef struct io_stream IOStream; typedef ssize_t(*io_write_f)(IOStream *, void *, size_t); +typedef ssize_t(*io_writev_f)(IOStream *, struct iovec *, int); typedef ssize_t(*io_read_f)(IOStream *, void *, size_t); typedef ssize_t(*io_sendfile_f)(IOStream *, sendfiledata *); struct io_stream { io_write_f write; + io_writev_f writev; io_read_f read; io_sendfile_f sendfile; }; @@ -80,12 +82,14 @@ IOStream* stream_new_from_fd(pool_handle_t *pool, int fd); ssize_t system_write(IOStream *st, void *buf, size_t nbytes); +ssize_t system_writev(IOStream *st, struct iovec *iovec, int iovcnt); ssize_t system_read(IOStream *st, void *buf, size_t nbytes); /* net stream */ IOStream* net_stream_from_fd(pool_handle_t *pool, int fd); ssize_t net_stream_write(IOStream *st, void *buf, size_t nbytes); +ssize_t net_stream_writev(IOStream *st, struct iovec *iovec, int iovcnt); ssize_t net_stream_read(IOStream *st, void *buf, size_t nbytes); ssize_t net_stream_sendfile(IOStream *st, sendfiledata *sfd);
--- a/src/server/webdav/webdav.c Sat May 11 13:28:26 2013 +0200 +++ b/src/server/webdav/webdav.c Wed May 22 13:27:31 2013 +0200 @@ -275,6 +275,9 @@ davrq->isdir = S_ISDIR(st.st_mode); davrq->persistencemgr->propfind_begin(davrq->persistencemgr, davrq); + // create the response for the requested resource + dav_resource_response(davrq, sstr(ppath), sstr(uri)); + /* * if the requested webdav resource(file) is a directory, we create * a response for every child @@ -294,9 +297,6 @@ } } - // create the response for the requested resource - dav_resource_response(davrq, sstr(ppath), sstr(uri)); - // end propfind davrq->persistencemgr->propfind_begin(davrq->persistencemgr, davrq);