Fix evaluation of default modes

This commit is contained in:
wbaumann 2013-08-13 19:48:25 +00:00
parent 03b620d90f
commit f7ea24cd4c
5 changed files with 16 additions and 122 deletions

View File

@ -1,7 +1,15 @@
ChangeLog for davfs2
--------------------

2013-08-12 Werner Baumann (werner.baumann@onlinehome.de)
2013-08-13 Werner Baumann (werner.baumann@onlinehome.de)
* defaults.h, mount_davfs.c:
Fix evaluation of default modes.

2013-08-13 Werner Baumann (werner.baumann@onlinehome.de)
* webdav.c, configure.ac:
Remove support for Neon versions < 0.27.

2013-08-13 Werner Baumann (werner.baumann@onlinehome.de)
* cache.c, webdav.c, webdav.h:
Remove support for property 'Execute'.


View File

@ -39,7 +39,7 @@ gl_INIT
# Checks for libraries.
AM_GNU_GETTEXT_VERSION(0.18)
AM_GNU_GETTEXT([external])
NE_REQUIRE_VERSIONS([0], [25 26 27 28 29])
NE_REQUIRE_VERSIONS([0], [27 28 29 30])
DAV_CHECK_NEON

# Checks for header files.

View File

@ -109,11 +109,11 @@

/* Mode of directories.
May be overridden by command line or fstab. */
#define DAV_DIR_MODE (S_IFDIR | S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
#define DAV_DIR_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)

/* Mode of regular files.
May be overridden by command line or fstab. */
#define DAV_FILE_MODE (S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
#define DAV_FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)


/* WebDAV */

View File

@ -936,6 +936,9 @@ parse_config(dav_args *args)
args->dav_group);
args->dav_gid = grp->gr_gid;

args->dir_mode |= S_IFDIR;
args->file_mode |= S_IFREG;

if (args->trust_ca_cert)
args->ca_cert = read_cert(&args->trust_ca_cert, args);


View File

@ -230,10 +230,8 @@ static FILE *log_stream;
/* A user defined header that is added to all requests. */
char *custom_header;

#if NE_VERSION_MINOR > 25
/* Session cookie. */
static char *cookie;
#endif


/* Private function prototypes and inline functions */
@ -279,20 +277,6 @@ auth(void *userdata, const char *realm, int attempt, char *user, char *pwd);
static int
file_reader(void *userdata, const char *block, size_t length);

#if NE_VERSION_MINOR < 26

static void
lock_result(void *userdata, const struct ne_lock *lock, const char *uri,
const ne_status *status);

static void
prop_result(void *userdata, const char *href, const ne_prop_result_set *set);

static void
quota_result(void *userdata, const char *href, const ne_prop_result_set *set);

#else /* NE_VERSION_MINOR >= 26 */

static void
lock_result(void *userdata, const struct ne_lock *lock, const ne_uri *uri,
const ne_status *status);
@ -303,18 +287,14 @@ prop_result(void *userdata, const ne_uri *uri, const ne_prop_result_set *set);
static void
quota_result(void *userdata, const ne_uri *uri, const ne_prop_result_set *set);

#endif /* NE_VERSION_MINOR >= 26 */

static int
quota_reader(void *userdata, const char *block, size_t length);

static int
ssl_verify(void *userdata, int failures, const ne_ssl_certificate *cert);

#if NE_VERSION_MINOR > 25
static int
update_cookie(ne_request *req, void *userdata, const ne_status *status);
#endif /* NE_VERSION_MINOR > 25 */


/* Public functions */
@ -374,9 +354,7 @@ dav_init_webdav(dav_args *args)

ne_set_read_timeout(session, args->read_timeout);

#if NE_VERSION_MINOR > 26
ne_set_connect_timeout(session, args->connect_timeout);
#endif /* NE_VERSION_MINOR > 26 */

char *useragent = xasprintf("%s/%s", PACKAGE_TARNAME, PACKAGE_VERSION);
ne_set_useragent(session, useragent);
@ -386,11 +364,7 @@ dav_init_webdav(dav_args *args)
username = xstrdup(args->username);
if (args->password)
password = xstrdup(args->password);
#if NE_VERSION_MINOR < 26
ne_set_server_auth(session, auth, "server");
#else /* NE_VERSION_MINOR >= 26 */
ne_add_server_auth(session, NE_AUTH_ALL, auth, "server");
#endif /* NE_VERSION_MINOR >= 26 */

if (args->useproxy && args->p_host) {
ne_session_proxy(session, args->p_host, args->p_port);
@ -398,11 +372,7 @@ dav_init_webdav(dav_args *args)
p_username = xstrdup(args->p_user);
if (args->p_passwd)
p_password = xstrdup(args->p_passwd);
#if NE_VERSION_MINOR < 26
ne_set_proxy_auth(session, auth, "proxy");
#else /* NE_VERSION_MINOR >= 26 */
ne_add_proxy_auth(session, NE_AUTH_ALL, auth, "proxy");
#endif /* NE_VERSION_MINOR >= 26 */
}

if (strcmp(args->scheme, "https") == 0) {
@ -444,10 +414,8 @@ dav_init_webdav(dav_args *args)
ne_hook_pre_send(session, add_header, custom_header);
}

#if NE_VERSION_MINOR > 25
if (args->allow_cookie)
ne_hook_post_send(session, update_cookie, NULL);
#endif /* NE_VERSION_MINOR > 25 */

use_expect100 = args->expect100;
has_if_match_bug = args->if_match_bug;
@ -793,11 +761,7 @@ dav_lock(const char *path, time_t *expire, int *exists)
return 0;
}

#if NE_VERSION_MINOR > 25
if (precheck && has_if_match_bug && !*exists) {
#else /* NE_VERSION_MINOR == 25 */
if (precheck && !*exists) {
#endif /* NE_VERSION_MINOR == 25 */
if (dav_head(path, NULL, NULL, NULL) == 0) {
return EEXIST;
}
@ -819,19 +783,15 @@ dav_lock(const char *path, time_t *expire, int *exists)
lock->owner = xstrdup(owner);
lock->timeout = lock_timeout;

#if NE_VERSION_MINOR > 25
if (!has_if_match_bug && !*exists)
ne_hook_pre_send(session, add_header, none_match_header);
#endif /* NE_VERSION_MINOR > 25 */
ret = ne_lock(session, lock);
ret = get_error(ret, "LOCK");
#if NE_VERSION_MINOR > 25
if (!has_if_match_bug && !*exists) {
ne_unhook_pre_send(session, add_header, none_match_header);
if (ret && strtol(ne_get_error(session), NULL, 10) == 412)
ret = EEXIST;
}
#endif /* NE_VERSION_MINOR > 25 */

if (!ret) {
ne_lockstore_add(locks, lock);
@ -982,18 +942,10 @@ dav_put(const char *path, const char *cache_path, int *exists, time_t *expire,
}

if (use_expect100)
#if NE_VERSION_MINOR == 25
ne_set_request_expect100(req, 1);
#else /* NE_VERSION_MINOR > 25 */
ne_set_request_flag(req, NE_REQFLAG_EXPECT100, 1);
#endif /* NE_VERSION_MINOR > 25 */

ne_lock_using_resource(req, spath, 0);
#if _FILE_OFFSET_BITS == 64 && NE_VERSION_MINOR < 27
ne_set_request_body_fd64(req, fd, 0, st.st_size);
#else /* _FILE_OFFSET_BITS != 64 || NE_VERSION_MINOR >= 27 */
ne_set_request_body_fd(req, fd, 0, st.st_size);
#endif /* _FILE_OFFSET_BITS != 64 || NE_VERSION_MINOR >= 27 */

ret = ne_request_dispatch(req);
ret = get_error(ret, "PUT");
@ -1013,18 +965,10 @@ dav_put(const char *path, const char *cache_path, int *exists, time_t *expire,
}

if (use_expect100)
#if NE_VERSION_MINOR == 25
ne_set_request_expect100(req, 1);
#else /* NE_VERSION_MINOR > 25 */
ne_set_request_flag(req, NE_REQFLAG_EXPECT100, 1);
#endif /* NE_VERSION_MINOR > 25 */

ne_lock_using_resource(req, spath, 0);
#if _FILE_OFFSET_BITS == 64 && NE_VERSION_MINOR < 27
ne_set_request_body_fd64(req, fd, 0, st.st_size);
#else /* _FILE_OFFSET_BITS != 64 || NE_VERSION_MINOR >= 27 */
ne_set_request_body_fd(req, fd, 0, st.st_size);
#endif /* _FILE_OFFSET_BITS != 64 || NE_VERSION_MINOR >= 27 */

ret = ne_request_dispatch(req);
ret = get_error(ret, "PUT");
@ -1572,23 +1516,10 @@ file_reader(void *userdata, const char *block, size_t length)
lock : a lock found by ne_lock_discover() on the server.
uri : not used.
status : not used. */
#if NE_VERSION_MINOR < 26

static void
lock_result(void *userdata, const struct ne_lock *lock, const char *uri,
const ne_status *status)
{

#else /* NE_VERSION_MINOR >= 26 */

static void
lock_result(void *userdata, const struct ne_lock *lock, const ne_uri *uri,
const ne_status *status)
{

#endif /* NE_VERSION_MINOR >= 26 */

if (!locks || !owner || !userdata || !lock || !lock->owner)
return;

@ -1618,34 +1549,8 @@ lock_result(void *userdata, const struct ne_lock *lock, const ne_uri *uri,
that is not a directory or that is less specific.
userdata : A pointer to a propfind_context structure containing the path of
the collection and the linked list of properties.
if NE_VERSION_MINOR < 26
href : Value of the href propertiy returned by the server. It may be
the complete URL of the collection or the path only.
else
uri : ne_uri of the resource as returned from the server.
endif
set : Points to the set of properties returned from the server.*/

#if NE_VERSION_MINOR < 26

static void
prop_result(void *userdata, const char *href, const ne_prop_result_set *set)
{
propfind_context *ctx = (propfind_context *) userdata;
if (!ctx || !href || !set)
return;

ne_uri uri;
if (ne_uri_parse(href, &uri) != 0 || !uri.path) {
ne_uri_free(&uri);
return;
}

char *tmp_path = (char *) xmalloc(strlen(uri.path) + 1);
const char *from = uri.path;

#else /* NE_VERSION_MINOR >= 26 */

static void
prop_result(void *userdata, const ne_uri *uri, const ne_prop_result_set *set)
{
@ -1655,9 +1560,6 @@ prop_result(void *userdata, const ne_uri *uri, const ne_prop_result_set *set)

char *tmp_path = (char *) xmalloc(strlen(uri->path) + 1);
const char *from = uri->path;

#endif /* NE_VERSION_MINOR >= 26 */

char *to = tmp_path;
while (*from) {
while (*from == '/' && *(from + 1) == '/')
@ -1669,11 +1571,6 @@ prop_result(void *userdata, const ne_uri *uri, const ne_prop_result_set *set)
result->path = ne_path_unescape(tmp_path);
free (tmp_path);

#if NE_VERSION_MINOR < 26
ne_uri_free(&uri);
#endif


if (!result->path || strlen(result->path) < 1) {
dav_delete_props(result);
return;
@ -1794,17 +1691,6 @@ quota_reader(void *userdata, const char *block, size_t length)

/* Reads available and used bytes from set and stores them in
userdata. */
#if NE_VERSION_MINOR < 26

static void
quota_result(void *userdata, const char *href, const ne_prop_result_set *set)
{
quota_context *ctx = (quota_context *) userdata;
if (!ctx || !href || !set)
return;

#else /* NE_VERSION_MINOR >= 26 */

static void
quota_result(void *userdata, const ne_uri *uri, const ne_prop_result_set *set)
{
@ -1812,8 +1698,6 @@ quota_result(void *userdata, const ne_uri *uri, const ne_prop_result_set *set)
if (!ctx || !uri || !uri->path || !set)
return;

#endif /* NE_VERSION_MINOR >= 26 */

const char *data = ne_propset_value(set, &quota_names[AVAILABLE]);
if (data) {
ctx->total = strtoull(data, NULL, 10);
@ -1939,7 +1823,6 @@ ssl_verify(void *userdata, int failures, const ne_ssl_certificate *cert)
}


#if NE_VERSION_MINOR > 25
static int
update_cookie(ne_request *req, void *userdata, const ne_status *status)
{
@ -1977,4 +1860,4 @@ update_cookie(ne_request *req, void *userdata, const ne_status *status)
ne_hook_pre_send(session, add_header, cookie);
return NE_OK;
}
#endif /* NE_VERSION_MINOR > 25 */