Skip to content

Commit

Permalink
anonymous user no longer has the 'you are logged in as' message
Browse files Browse the repository at this point in the history
  • Loading branch information
billyfish committed Apr 19, 2017
1 parent 3019bc8 commit e505821
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 107 deletions.
93 changes: 28 additions & 65 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,16 @@ void *davrods_create_dir_config(apr_pool_t *p, char *dir) {
conf -> davrods_api_path_s = NULL;
conf -> davrods_public_username_s = NULL;
conf -> davrods_public_password_s = NULL;
conf -> theme_p = AllocateHtmlTheme (p);
conf -> themed_listings = 0;
InitHtmlTheme (& (conf -> theme));
}
return conf;
}

void *davrods_merge_dir_config(apr_pool_t *p, void *_parent, void *_child) {
davrods_dir_conf_t *parent = _parent;
davrods_dir_conf_t *child = _child;
davrods_dir_conf_t *conf = davrods_create_dir_config(p, "merge__");

#define DAVRODS_PROP_MERGE(_prop) \
conf->_prop = child->_prop \
? child->_prop \
: parent->_prop \
? parent->_prop \
: conf->_prop
davrods_dir_conf_t *parent_p = _parent;
davrods_dir_conf_t *child_p = _child;
davrods_dir_conf_t *conf_p = davrods_create_dir_config(p, "merge__");

DAVRODS_PROP_MERGE(rods_host);
DAVRODS_PROP_MERGE(rods_port);
Expand All @@ -109,11 +102,11 @@ void *davrods_merge_dir_config(apr_pool_t *p, void *_parent, void *_child) {
DAVRODS_PROP_MERGE(rods_env_file);
DAVRODS_PROP_MERGE(rods_auth_scheme);

const char *exposed_root = child->rods_exposed_root
? child->rods_exposed_root
: parent->rods_exposed_root
? parent->rods_exposed_root
: conf->rods_exposed_root;
const char *exposed_root = child_p->rods_exposed_root
? child_p->rods_exposed_root
: parent_p->rods_exposed_root
? parent_p->rods_exposed_root
: conf_p->rods_exposed_root;

DAVRODS_PROP_MERGE(rods_tx_buffer_size);
DAVRODS_PROP_MERGE(rods_rx_buffer_size);
Expand All @@ -124,49 +117,19 @@ void *davrods_merge_dir_config(apr_pool_t *p, void *_parent, void *_child) {
DAVRODS_PROP_MERGE(davrods_api_path_s);
DAVRODS_PROP_MERGE(davrods_public_username_s);
DAVRODS_PROP_MERGE(davrods_public_password_s);

DAVRODS_PROP_MERGE(themed_listings);
DAVRODS_PROP_MERGE(theme.ht_head_s);
DAVRODS_PROP_MERGE(theme.ht_top_s);
DAVRODS_PROP_MERGE(theme.ht_bottom_s);
DAVRODS_PROP_MERGE(theme.ht_collection_icon_s);
DAVRODS_PROP_MERGE(theme.ht_object_icon_s);
DAVRODS_PROP_MERGE(theme.ht_parent_icon_s);
DAVRODS_PROP_MERGE(theme.ht_listing_class_s);
DAVRODS_PROP_MERGE(theme.ht_show_metadata_flag);
DAVRODS_PROP_MERGE(theme.ht_show_ids_flag);

if (child -> theme.ht_icons_map_p)
{
if (parent -> theme.ht_icons_map_p)
{
conf -> theme.ht_icons_map_p = apr_table_overlay (p, parent -> theme.ht_icons_map_p, child -> theme.ht_icons_map_p);
}
else
{
conf -> theme.ht_icons_map_p = child -> theme.ht_icons_map_p;
}
}
else
{
if (parent -> theme.ht_icons_map_p)
{
conf -> theme.ht_icons_map_p = parent -> theme.ht_icons_map_p;
}
else
{
conf -> theme.ht_icons_map_p = NULL;
}
}

if (set_exposed_root (conf, exposed_root) < 0)
MergeThemeConfigs (conf_p, parent_p, child_p, p);


if (set_exposed_root (conf_p, exposed_root) < 0)
{
ap_log_perror (APLOG_MARK, APLOG_DEBUG, APR_EGENERAL, p, "davrods_merge_dir_config: set_exposed_root failed");
conf = NULL;
conf_p = NULL;
}

#undef DAVRODS_PROP_MERGE

return conf;
return conf_p;
}

// Config setters {{{
Expand Down Expand Up @@ -342,7 +305,7 @@ static const char *cmd_davrods_html_header (cmd_parms *cmd_p, void *config_p, co
{
davrods_dir_conf_t *conf_p = (davrods_dir_conf_t*) config_p;

conf_p -> theme.ht_head_s = arg_p;
conf_p -> theme_p -> ht_head_s = arg_p;

return NULL;
}
Expand All @@ -353,7 +316,7 @@ static const char *cmd_davrods_html_top (cmd_parms *cmd_p, void *config_p, const
{
davrods_dir_conf_t *conf_p = (davrods_dir_conf_t*) config_p;

conf_p -> theme.ht_top_s = arg_p;
conf_p -> theme_p -> ht_top_s = arg_p;

return NULL;
}
Expand All @@ -364,7 +327,7 @@ static const char *cmd_davrods_html_bottom (cmd_parms *cmd_p, void *config_p, co
{
davrods_dir_conf_t *conf_p = (davrods_dir_conf_t*) config_p;

conf_p -> theme.ht_bottom_s = arg_p;
conf_p -> theme_p -> ht_bottom_s = arg_p;

return NULL;
}
Expand All @@ -375,7 +338,7 @@ static const char *cmd_davrods_html_collection_icon (cmd_parms *cmd_p, void *con
{
davrods_dir_conf_t *conf_p = (davrods_dir_conf_t*) config_p;

conf_p -> theme.ht_collection_icon_s = arg_p;
conf_p -> theme_p -> ht_collection_icon_s = arg_p;

return NULL;
}
Expand All @@ -386,7 +349,7 @@ static const char *cmd_davrods_html_object_icon (cmd_parms *cmd_p, void *config_
{
davrods_dir_conf_t *conf_p = (davrods_dir_conf_t*) config_p;

conf_p -> theme.ht_object_icon_s = arg_p;
conf_p -> theme_p -> ht_object_icon_s = arg_p;

return NULL;
}
Expand All @@ -397,7 +360,7 @@ static const char *cmd_davrods_html_parent_icon (cmd_parms *cmd_p, void *config_
{
davrods_dir_conf_t *conf_p = (davrods_dir_conf_t*) config_p;

conf_p -> theme.ht_parent_icon_s = arg_p;
conf_p -> theme_p -> ht_parent_icon_s = arg_p;

return NULL;
}
Expand All @@ -407,7 +370,7 @@ static const char *cmd_davrods_html_listing_class (cmd_parms *cmd_p, void *confi
{
davrods_dir_conf_t *conf_p = (davrods_dir_conf_t*) config_p;

conf_p -> theme.ht_listing_class_s = arg_p;
conf_p -> theme_p -> ht_listing_class_s = arg_p;

return NULL;
}
Expand All @@ -431,7 +394,7 @@ static const char *cmd_davrods_html_metadata (cmd_parms *cmd_p, void *config_p,

if (!strcasecmp (arg_p, "true"))
{
conf_p -> theme.ht_show_metadata_flag = 1;
conf_p -> theme_p -> ht_show_metadata_flag = 1;
}

return NULL;
Expand All @@ -444,7 +407,7 @@ static const char *cmd_davrods_html_ids (cmd_parms *cmd_p, void *config_p, const

if (!strcasecmp (arg_p, "true"))
{
conf_p -> theme.ht_show_ids_flag = 1;
conf_p -> theme_p -> ht_show_ids_flag = 1;
}

return NULL;
Expand Down Expand Up @@ -482,13 +445,13 @@ static const char *cmd_davrods_html_add_icon (cmd_parms *cmd_p, void *config_p,
{
davrods_dir_conf_t *conf_p = (davrods_dir_conf_t*) config_p;

if (! (conf_p -> theme.ht_icons_map_p))
if (! (conf_p -> theme_p -> ht_icons_map_p))
{
const int INITIAL_TABLE_SIZE = 16;
conf_p -> theme.ht_icons_map_p = apr_table_make (cmd_p -> pool, INITIAL_TABLE_SIZE);
conf_p -> theme_p -> ht_icons_map_p = apr_table_make (cmd_p -> pool, INITIAL_TABLE_SIZE);
}

apr_table_set (conf_p -> theme.ht_icons_map_p, suffix_s, icon_s);
apr_table_set (conf_p -> theme_p -> ht_icons_map_p, suffix_s, icon_s);

return NULL;
}
Expand Down
16 changes: 13 additions & 3 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@

#include "mod_davrods.h"

#include "theme.h"
/* forawrd declaration */
struct HtmlTheme;

/**
* \brief Davrods per-directory config structure.
*/
typedef struct {
typedef struct davrods_dir_conf {
const char *rods_host;
uint16_t rods_port;
const char *rods_zone;
Expand Down Expand Up @@ -64,7 +65,7 @@ typedef struct {
} rods_exposed_root_type;

int themed_listings;
struct HtmlTheme theme;
struct HtmlTheme *theme_p;

const char *davrods_api_path_s;
const char *davrods_public_username_s;
Expand All @@ -77,4 +78,13 @@ extern const command_rec davrods_directives[];
void *davrods_create_dir_config(apr_pool_t *p, char *dir);
void *davrods_merge_dir_config( apr_pool_t *p, void *base, void *overrides);


#define DAVRODS_PROP_MERGE(_prop) \
conf_p->_prop = child_p->_prop \
? child_p->_prop \
: parent_p->_prop \
? parent_p->_prop \
: conf_p->_prop


#endif /* _DAVRODS_CONFIG_H_ */
1 change: 1 addition & 0 deletions listing.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "repo.h"
#include "meta.h"
#include "theme.h"

#include "apr_strings.h"
#include "apr_time.h"
Expand Down
10 changes: 5 additions & 5 deletions meta.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "common.h"
#include "rest.h"
#include "auth.h"
#include "theme.h"

/*************************************/

Expand Down Expand Up @@ -438,10 +439,9 @@ char *DoMetadataSearch (const char * const key_s, const char *value_s, const Sea
SearchOperator ops_p [] = { SO_EQUALS, op };
int select_columns_p [] = { COL_META_DATA_ATTR_ID, -1, -1};
genQueryOut_t *meta_id_results_p = NULL;
struct HtmlTheme *theme_p = & (conf_p -> theme);
apr_bucket_brigade *bucket_brigade_p = apr_brigade_create (pool_p, bucket_allocator_p);

apr_status_t apr_status = PrintAllHTMLBeforeListing (theme_p, relative_uri_s, username_s, conf_p -> rods_zone, conf_p -> davrods_api_path_s, req_p, bucket_brigade_p, pool_p);
apr_status_t apr_status = PrintAllHTMLBeforeListing (relative_uri_s, username_s, conf_p, req_p, bucket_brigade_p, pool_p);

/*
* SELECT meta_id FROM r_meta_main WHERE meta_attr_name = ' ' AND meta_attr_value = ' ';
Expand Down Expand Up @@ -542,7 +542,7 @@ char *DoMetadataSearch (const char * const key_s, const char *value_s, const Sea

SetIRodsObject (&irods_obj, COLL_OBJ_T, id_s, NULL, collection_s, stat_p -> ownerName, stat_p -> modifyTime, stat_p -> objSize);

apr_status = PrintItem (theme_p, &irods_obj, &irods_config, bucket_brigade_p, pool_p, connection_p, req_p);
apr_status = PrintItem (conf_p -> theme_p, &irods_obj, &irods_config, bucket_brigade_p, pool_p, connection_p, req_p);

if (apr_status != APR_SUCCESS)
{
Expand Down Expand Up @@ -657,7 +657,7 @@ char *DoMetadataSearch (const char * const key_s, const char *value_s, const Sea

SetIRodsObject (&irods_obj, DATA_OBJ_T, id_s, data_name_s, collection_s, stat_p -> ownerName, stat_p -> modifyTime, stat_p -> objSize);

apr_status = PrintItem (theme_p, &irods_obj, &irods_config, bucket_brigade_p, pool_p, connection_p, req_p);
apr_status = PrintItem (conf_p -> theme_p, &irods_obj, &irods_config, bucket_brigade_p, pool_p, connection_p, req_p);

if (apr_status != APR_SUCCESS)
{
Expand Down Expand Up @@ -707,7 +707,7 @@ char *DoMetadataSearch (const char * const key_s, const char *value_s, const Sea
} /* if (meta_id_results_p) */


apr_status = PrintAllHTMLAfterListing (theme_p, req_p, bucket_brigade_p, pool_p);
apr_status = PrintAllHTMLAfterListing (conf_p -> theme_p, req_p, bucket_brigade_p, pool_p);


CloseBucketsStream (bucket_brigade_p);
Expand Down
Loading

0 comments on commit e505821

Please sign in to comment.