Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions booth.spec
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
%bcond_with html_man

%if 0%{?suse_version}
%global booth_docdir %{_defaultdocdir}/%{name}
%else
Expand Down Expand Up @@ -26,7 +28,11 @@
Name: booth
Url: https://github.com/ClusterLabs/booth
Summary: Ticket Manager for Multi-site Clusters
%if 0%{?suse_version}
License: GPL-2.0+
%else
License: GPLv2+
%endif
Group: %{pkg_group}
Version: 1.0
Release: 0
Expand All @@ -36,7 +42,12 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: asciidoc
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: pkgconfig
%if 0%{?suse_version}
BuildRequires: glib2-devel
%else
BuildRequires: pkgconfig(glib-2.0)
%fi

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be %endif, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 18/04/16 08:21 -0700, Dejan Muhamedagic wrote:

BuildRequires: glib2-devel
+%else
+BuildRequires: pkgconfig(glib-2.0)
+%fi

This should be %endif, right?

Right, thanks for noticing.
(I blame vim highlighter for showing "%if" the same way as "%fi").

Jan (Poki)

BuildRequires: libgcrypt-devel
%if 0%{?fedora} || 0%{?centos} || 0%{?rhel}
BuildRequires: cluster-glue-libs-devel
Expand All @@ -46,7 +57,6 @@ BuildRequires: libglue-devel
BuildRequires: libpacemaker-devel
%endif
BuildRequires: libxml2-devel
BuildRequires: pkgconfig
%if 0%{?fedora} || 0%{?centos} || 0%{?rhel}
Requires: pacemaker >= 1.1.8
Requires: cluster-glue-libs >= 1.0.6
Expand All @@ -67,14 +77,11 @@ Pacemaker.
./autogen.sh
%configure \
--with-initddir=%{_initrddir} \
--docdir=%{booth_docdir}
--docdir=%{booth_docdir} \
%{!?with_html_man:--without-html_man}

make

#except check
#%check
#make check

%install
make DESTDIR=$RPM_BUILD_ROOT install docdir=%{booth_docdir}

Expand Down Expand Up @@ -118,9 +125,6 @@ make check
echo "%%run_build_tests set to %run_build_tests; skipping tests"
%endif

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root,-)
%{_sbindir}/booth
Expand Down
18 changes: 7 additions & 11 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,8 @@ AC_PATH_PROGS(ASCIIDOC, asciidoc)
AC_PATH_PROGS(XML2CONFIG, xml2-config)

AM_CONDITIONAL(BUILD_ASCIIDOC, test x"${ASCIIDOC}" != x"")

# Checks for libraries.
AC_CHECK_LIB([socket], [socket])
AC_CHECK_LIB([nsl], [t_open])
AC_CHECK_LIB([gpl], [cl_log])
AM_CONDITIONAL(BUILD_ASCIIDOC_HTML_MAN,
test "x${ASCIIDOC}" != "x" && test "x$with_html_man" = "xyes")

# libgcrypt or mhash for hmac
libgcrypt_installed="yes"
Expand Down Expand Up @@ -202,21 +199,20 @@ AC_ARG_ENABLE([small-memory-footprint],
[ default="no" ])

AC_ARG_WITH([initddir],
[ --with-initddir=DIR : path to init script directory. ],
[ --with-initddir=DIR : path to init script directory. ],
[ INITDDIR="$withval" ],
[ INITDDIR="$sysconfdir/init.d" ])

test -s .git_info &&
GIT_VER="`cat .git_info`"

AC_ARG_WITH([build-version],
[ --with-build-version=STR : build version ],
[ --with-build-version=STR : build version ],
[ BOOTH_BUILD_VERSION="$withval" ],
[ BOOTH_BUILD_VERSION="${GIT_VER:-$PACKAGE_VERSION}" ])

AC_ARG_ENABLE([resource-monitor],
[ --enable-resource-monitor : Enabling Resource Monitor ],
[ default="no" ])
AC_ARG_WITH([html_man],
[ --without-html_man : Avoid generating man pages in HTML.])

# OS detection
# THIS SECTION MUST DIE!
Expand Down Expand Up @@ -450,7 +446,7 @@ AC_MSG_RESULT([ System configuration = ${sysconfdir}])
AC_MSG_RESULT([ System init.d directory = ${INITDDIR}])
AC_MSG_RESULT([ booth config dir = ${BOOTHSYSCONFDIR}])
AC_MSG_RESULT([ SOCKETDIR = ${SOCKETDIR}])
AC_MSG_RESULT([ Features =${PACKAGE_FEATURES}])
AC_MSG_RESULT([ Features = ${PACKAGE_FEATURES}])
AC_MSG_RESULT([])
AC_MSG_RESULT([$PACKAGE build info:])
AC_MSG_RESULT([ Library SONAME = ${SONAME}])
Expand Down
4 changes: 3 additions & 1 deletion docs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ doc_DATA = $(generated_docs)
generated_docs =
generated_mans =

if BUILD_ASCIIDOC
if BUILD_ASCIIDOC_HTML_MAN
generated_docs += $(ascii:%.txt=%.html) $(asciiman:%.txt=%.html)
endif
if BUILD_ASCIIDOC
generated_mans += $(asciiman:%.8.txt=%.8)
$(generated_mans): $(asciiman)
man8_MANS = $(generated_mans)
Expand Down
4 changes: 2 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ boothd_SOURCES += auth.c
endif

boothd_LDFLAGS = $(OS_DYFLAGS) -L./
boothd_LDADD = -lplumb -lplumbgpl -lz -lm -lglib-2.0
boothd_CPPFLAGS = $(GLIB_CFLAGS)
boothd_LDADD = -lplumb -lplumbgpl -lz -lm $(GLIB_LIBS)
boothd_CFLAGS = $(GLIB_CFLAGS)

noinst_HEADERS = booth.h pacemaker.h \
config.h log.h raft.h ticket.h transport.h handler.h request.h attr.h
Expand Down
9 changes: 7 additions & 2 deletions src/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include <assert.h>
#include <stdio.h>
#include <string.h>
#include "attr.h"
#include "booth.h"
#include "ticket.h"
#include "pacemaker.h"

Expand Down Expand Up @@ -244,7 +247,8 @@ static void free_geo_attr(gpointer data)
g_free(a);
}

int store_geo_attr(struct ticket_config *tk, const char *name, char *val, int notime)
int store_geo_attr(struct ticket_config *tk, const char *name,
const char *val, int notime)
{
struct geo_attr *a;
GDestroyNotify free_geo_attr_notify = free_geo_attr;
Expand Down Expand Up @@ -274,8 +278,9 @@ int store_geo_attr(struct ticket_config *tk, const char *name, char *val, int no
if (!notime)
get_time(&a->update_ts);

assert(strnlen(name, BOOTH_NAME_LEN) < BOOTH_NAME_LEN);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather have booth continue to run, even with a truncated attribute name. iirc, this was not unpremeditated.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I understand that it might be too easy (accidentally or not) to push booth layer out of the function with a single crafted geo attribute in CIB/crm_ticket one-liner. So does turning that into warning sounds better? Then, we should likely warn also in case of trying to set/delete such a troublesome (too long in either name or value) attribute being provided by the user to geostore command.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Tue, Apr 19, 2016 at 06:26:49AM -0700, Jan Pokorný wrote:

@@ -274,8 +277,9 @@ int store_geo_attr(struct ticket_config *tk, const char *name, char *val, int no
if (!notime)
get_time(&a->update_ts);

  • assert(strnlen(name, BOOTH_NAME_LEN) < BOOTH_NAME_LEN);

OK, I understand that it might be too easy (accidentally or not) to push booth layer out of the function with a single crafted geo attribute in CIB/crm_ticket one-liner. So does turning that into warning sounds better? Then, we should likely warn also in case of trying to set/delete such a troublesome (too long in either name or value) attribute being provided by the user to geostore command.

Yes, warning seems to be better.

g_hash_table_insert(tk->attr,
g_strndup(name, BOOTH_NAME_LEN), a);
g_strndup(name, BOOTH_NAME_LEN-1), a);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ int test_attr_reply(cmd_result_t reply_code, cmd_request_t cmd);
int do_attr_command(cmd_request_t cmd);
int process_attr_request(struct client *req_client, void *buf);
int attr_recv(void *buf, struct booth_site *source);
int store_geo_attr(struct ticket_config *tk, const char *name, char *val, int notime);
int store_geo_attr(struct ticket_config *tk, const char *name, const char *val, int notime);

#endif /* _ATTR_H */
2 changes: 1 addition & 1 deletion src/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* at result for the MAC
*/
int calc_hmac(const void *data, size_t datalen,
int hid, unsigned char *result, char *key, int keylen)
int hid, unsigned char *result, char *key, unsigned int keylen)
{
static gcry_md_hd_t digest;
gcry_error_t err;
Expand Down
2 changes: 1 addition & 1 deletion src/auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#define BOOTH_HASH GCRY_MD_SHA1

int calc_hmac(const void *data, size_t datalen,
int hid, unsigned char *result, char *key, int keylen);
int hid, unsigned char *result, char *key, unsigned int keylen);
int verify_hmac(const void *data, size_t datalen,
int hid, unsigned char *hmac, char *key, int keylen);
#endif
Expand Down
10 changes: 5 additions & 5 deletions src/booth.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@
#define TICKET_LOST CHAR2CONST('L', 'O', 'S', 'T')


typedef unsigned char boothc_site [BOOTH_NAME_LEN];
typedef unsigned char boothc_ticket[BOOTH_NAME_LEN];
typedef unsigned char boothc_attr[BOOTH_NAME_LEN];
typedef unsigned char boothc_attr_value[BOOTH_ATTRVAL_LEN];
typedef char boothc_site[BOOTH_NAME_LEN];
typedef char boothc_ticket[BOOTH_NAME_LEN];
typedef char boothc_attr[BOOTH_NAME_LEN];
typedef char boothc_attr_value[BOOTH_ATTRVAL_LEN];

/* message option bits */
enum {
Expand Down Expand Up @@ -290,7 +290,7 @@ struct booth_site {
/** Roles, like ACCEPTOR, PROPOSER, or LEARNER. Not really used ATM. */
int role;

char addr_string[BOOTH_NAME_LEN];
boothc_site addr_string;

int tcp_fd;
int udp_fd;
Expand Down
12 changes: 6 additions & 6 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ static int ticket_realloc(void)
}


int add_site(char *address, int type);
int add_site(char *addr_string, int type)
static int add_site(char *addr_string, int type)
{
int rv;
struct booth_site *site;
Expand All @@ -76,7 +75,8 @@ int add_site(char *addr_string, int type)
log_error("too many nodes");
goto out;
}
if (strlen(addr_string)+1 >= sizeof(booth_conf->site[0].addr_string)) {
if (strnlen(addr_string, sizeof(booth_conf->site[0].addr_string))
>= sizeof(booth_conf->site[0].addr_string)) {
log_error("site address \"%s\" too long", addr_string);
goto out;
}
Expand All @@ -87,7 +87,7 @@ int add_site(char *addr_string, int type)
site->type = type;
/* Make site_id start at a non-zero point.
* Perhaps use hash over string or address? */
strcpy(site->addr_string, addr_string);
strncpy(site->addr_string, addr_string, sizeof(site->addr_string));


site->index = booth_conf->site_count;
Expand Down Expand Up @@ -909,7 +909,7 @@ static int get_other_site(struct booth_site **node)
}


int find_site_by_name(unsigned char *site, struct booth_site **node, int any_type)
int find_site_by_name(char *site, struct booth_site **node, int any_type)
{
struct booth_site *n;
int i;
Expand All @@ -923,7 +923,7 @@ int find_site_by_name(unsigned char *site, struct booth_site **node, int any_typ
for (i = 0; i < booth_conf->site_count; i++) {
n = booth_conf->site + i;
if ((n->type == SITE || any_type) &&
strcmp(n->addr_string, site) == 0) {
strncmp(n->addr_string, site, sizeof(n->addr_string)) == 0) {
*node = n;
return 1;
}
Expand Down
4 changes: 2 additions & 2 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ struct booth_config {
/** File containing the authentication file. */
char authfile[BOOTH_PATH_LEN];
struct stat authstat;
unsigned char authkey[BOOTH_MAX_KEY_LEN];
char authkey[BOOTH_MAX_KEY_LEN];
int authkey_len;
/** Maximum time skew between peers allowed */
int maxtimeskew;
Expand Down Expand Up @@ -297,7 +297,7 @@ int read_config(const char *path, int type);

int check_config(int type);

int find_site_by_name(unsigned char *site, struct booth_site **node, int any_type);
int find_site_by_name(char *site, struct booth_site **node, int any_type);
int find_site_by_id(uint32_t site_id, struct booth_site **node);

const char *type_to_string(int type);
Expand Down
14 changes: 8 additions & 6 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ static int format_peers(char **pdata, unsigned int *len)
void list_peers(int fd)
{
char *data;
int olen;
unsigned int olen;
struct boothc_hdr_msg hdr;

if (format_peers(&data, &olen) < 0)
Expand All @@ -274,7 +274,7 @@ void list_peers(int fd)
*/
static void trim_key()
{
unsigned char *p;
char *p;
int i;

for (i=0, p=booth_conf->authkey; i < booth_conf->authkey_len; i++, p++)
Expand Down Expand Up @@ -746,7 +746,8 @@ static int do_command(cmd_request_t cmd)
if (!cl.msg.ticket.id[0]) {
/* If the loaded configuration has only a single ticket defined, use that. */
if (booth_conf->ticket_count == 1) {
strcpy(cl.msg.ticket.id, booth_conf->ticket[0].name);
strncpy(cl.msg.ticket.id, booth_conf->ticket[0].name,
sizeof(cl.msg.ticket.id));
} else {
log_error("No ticket given.");
goto out_close;
Expand Down Expand Up @@ -1457,7 +1458,7 @@ static int do_server(int type)
return rv;

if (cl_enable_coredumps(TRUE) < 0){
cl_log(LOG_ERR, "enabling core dump failed");
log_error("enabling core dump failed");
}
cl_cdtocoredir();
prctl(PR_SET_DUMPABLE, (unsigned long)TRUE, 0UL, 0UL, 0UL);
Expand Down Expand Up @@ -1510,7 +1511,8 @@ static int do_attr(void)
if (!cl.attr_msg.attr.tkt_id[0]) {
/* If the loaded configuration has only a single ticket defined, use that. */
if (booth_conf->ticket_count == 1) {
strcpy(cl.attr_msg.attr.tkt_id, booth_conf->ticket[0].name);
strncpy(cl.attr_msg.attr.tkt_id, booth_conf->ticket[0].name,
sizeof(cl.attr_msg.attr.tkt_id));
} else {
rv = 1;
log_error("No ticket given.");
Expand All @@ -1537,7 +1539,7 @@ static int do_attr(void)
int main(int argc, char *argv[], char *envp[])
{
int rv;
char *cp;
const char *cp;

init_set_proc_title(argc, argv, envp);
get_time(&start_time);
Expand Down
Loading