Skip to content

Commit

Permalink
Merge pull request #830 from morrone/unpointer_flux_sec_t
Browse files Browse the repository at this point in the history
security: Remove pointer from typedef flux_sec_t
  • Loading branch information
garlick authored Oct 4, 2016
2 parents a8793ce + 16d917b commit fb19bd9
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 61 deletions.
2 changes: 1 addition & 1 deletion src/broker/broker.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ typedef struct {
/* 0MQ
*/
zctx_t *zctx; /* zeromq context (MT-safe) */
flux_sec_t sec; /* security context (MT-safe) */
flux_sec_t *sec; /* security context (MT-safe) */

/* Reactor
*/
Expand Down
4 changes: 2 additions & 2 deletions src/broker/overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct endpoint {

struct overlay_struct {
zctx_t *zctx;
flux_sec_t sec;
flux_sec_t *sec;
flux_t h;
zhash_t *children; /* child_t - by uuid */
flux_msg_handler_t *heartbeat;
Expand Down Expand Up @@ -150,7 +150,7 @@ void overlay_set_zctx (overlay_t *ov, zctx_t *zctx)
ov->zctx = zctx;
}

void overlay_set_sec (overlay_t *ov, flux_sec_t sec)
void overlay_set_sec (overlay_t *ov, flux_sec_t *sec)
{
ov->sec = sec;
}
Expand Down
2 changes: 1 addition & 1 deletion src/broker/overlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void overlay_destroy (overlay_t *ov);

/* These need to be set before connect/bind.
*/
void overlay_set_sec (overlay_t *ov, flux_sec_t sec);
void overlay_set_sec (overlay_t *ov, flux_sec_t *sec);
void overlay_set_zctx (overlay_t *ov, zctx_t *zctx);
void overlay_set_rank (overlay_t *ov, uint32_t rank);
void overlay_set_flux (overlay_t *ov, flux_t h);
Expand Down
4 changes: 2 additions & 2 deletions src/broker/snoop.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "snoop.h"

struct snoop_struct {
flux_sec_t sec;
flux_sec_t *sec;
zctx_t *zctx;
char *uri;
void *zs;
Expand All @@ -59,7 +59,7 @@ void snoop_destroy (snoop_t *sn)
}
}

void snoop_set_sec (snoop_t *sn, flux_sec_t sec)
void snoop_set_sec (snoop_t *sn, flux_sec_t *sec)
{
sn->sec = sec;
}
Expand Down
2 changes: 1 addition & 1 deletion src/broker/snoop.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef struct snoop_struct snoop_t;
snoop_t *snoop_create (void);
void snoop_destroy (snoop_t *sn);

void snoop_set_sec (snoop_t *sn, flux_sec_t sec);
void snoop_set_sec (snoop_t *sn, flux_sec_t *sec);
void snoop_set_zctx (snoop_t *sn, zctx_t *zctx);
void snoop_set_uri (snoop_t *sn, const char *fmt, ...);

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/flux-keygen.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void usage (void)
int main (int argc, char *argv[])
{
int ch;
flux_sec_t sec;
flux_sec_t *sec;
bool force = false;
bool plain = false;
const char *secdir = getenv ("FLUX_SEC_DIRECTORY");
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/flux-snoop.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void usage (void)
exit (1);
}

static void *connect_snoop (zctx_t *zctx, flux_sec_t sec, const char *uri);
static void *connect_snoop (zctx_t *zctx, flux_sec_t *sec, const char *uri);
static int snoop_cb (zloop_t *zloop, zmq_pollitem_t *item, void *arg);
static int zmon_cb (zloop_t *zloop, zmq_pollitem_t *item, void *arg);

Expand All @@ -85,7 +85,7 @@ int main (int argc, char *argv[])
void *s;
zloop_t *zloop;
zmq_pollitem_t zp;
flux_sec_t sec;
flux_sec_t *sec;
const char *secdir;

log_init ("flux-snoop");
Expand Down Expand Up @@ -201,7 +201,7 @@ int main (int argc, char *argv[])
return 0;
}

static void *connect_snoop (zctx_t *zctx, flux_sec_t sec, const char *uri)
static void *connect_snoop (zctx_t *zctx, flux_sec_t *sec, const char *uri)
{
void *s;

Expand Down
64 changes: 32 additions & 32 deletions src/common/libflux/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,32 +156,32 @@ struct flux_sec_struct {
pthread_mutex_t lock;
};

static int checksecdirs (flux_sec_t c, bool create);
static zcert_t *getcurve (flux_sec_t c, const char *role);
static int gencurve (flux_sec_t c, const char *role, bool force, bool verbose);
static char *getpasswd (flux_sec_t c, const char *user);
static int genpasswd (flux_sec_t c, const char *user, bool force, bool verbose);
static int checksecdirs (flux_sec_t *c, bool create);
static zcert_t *getcurve (flux_sec_t *c, const char *role);
static int gencurve (flux_sec_t *c, const char *role, bool force, bool verbose);
static char *getpasswd (flux_sec_t *c, const char *user);
static int genpasswd (flux_sec_t *c, const char *user, bool force, bool verbose);

static void lock_sec (flux_sec_t c)
static void lock_sec (flux_sec_t *c)
{
int e = pthread_mutex_lock (&c->lock);
if (e)
log_errn_exit (e, "pthread_mutex_lock");
}

static void unlock_sec (flux_sec_t c)
static void unlock_sec (flux_sec_t *c)
{
int e = pthread_mutex_unlock (&c->lock);
if (e)
log_errn_exit (e, "pthread_mutex_unlock");
}

const char *flux_sec_errstr (flux_sec_t c)
const char *flux_sec_errstr (flux_sec_t *c)
{
return (c->errstr ? c->errstr : "Success");
}

const char *flux_sec_confstr (flux_sec_t c)
const char *flux_sec_confstr (flux_sec_t *c)
{
lock_sec (c);
if (c->confstr)
Expand All @@ -195,7 +195,7 @@ const char *flux_sec_confstr (flux_sec_t c)
return c->confstr;
}

static void seterrstr (flux_sec_t c, const char *fmt, ...)
static void seterrstr (flux_sec_t *c, const char *fmt, ...)
{
va_list ap;

Expand All @@ -209,7 +209,7 @@ static void seterrstr (flux_sec_t c, const char *fmt, ...)
va_end (ap);
}

void flux_sec_destroy (flux_sec_t c)
void flux_sec_destroy (flux_sec_t *c)
{
if (c->domain)
free (c->domain);
Expand All @@ -235,9 +235,9 @@ void flux_sec_destroy (flux_sec_t c)
free (c);
}

flux_sec_t flux_sec_create (void)
flux_sec_t *flux_sec_create (void)
{
flux_sec_t c = xzmalloc (sizeof (*c));
flux_sec_t *c = xzmalloc (sizeof (*c));
int e;

if ((e = pthread_mutex_init (&c->lock, NULL)))
Expand All @@ -260,19 +260,19 @@ static int validate_type (int tm)
return -1;
}

void flux_sec_set_directory (flux_sec_t c, const char *confdir)
void flux_sec_set_directory (flux_sec_t *c, const char *confdir)
{
if (c->conf_dir)
free (c->conf_dir);
c->conf_dir = xstrdup (confdir);
}

const char *flux_sec_get_directory (flux_sec_t c)
const char *flux_sec_get_directory (flux_sec_t *c)
{
return c->conf_dir;
}

int flux_sec_disable (flux_sec_t c, int tm)
int flux_sec_disable (flux_sec_t *c, int tm)
{
int rc;
lock_sec (c);
Expand All @@ -282,7 +282,7 @@ int flux_sec_disable (flux_sec_t c, int tm)
return rc;
}

int flux_sec_enable (flux_sec_t c, int tm)
int flux_sec_enable (flux_sec_t *c, int tm)
{
int rc;
lock_sec (c);
Expand All @@ -296,7 +296,7 @@ int flux_sec_enable (flux_sec_t c, int tm)
return rc;
}

bool flux_sec_type_enabled (flux_sec_t c, int tm)
bool flux_sec_type_enabled (flux_sec_t *c, int tm)
{
bool ret;
lock_sec (c);
Expand All @@ -305,7 +305,7 @@ bool flux_sec_type_enabled (flux_sec_t c, int tm)
return ret;
}

int flux_sec_keygen (flux_sec_t c, bool force, bool verbose)
int flux_sec_keygen (flux_sec_t *c, bool force, bool verbose)
{
int rc = -1;
lock_sec (c);
Expand All @@ -327,7 +327,7 @@ int flux_sec_keygen (flux_sec_t c, bool force, bool verbose)
return rc;
}

int flux_sec_zauth_init (flux_sec_t c, zctx_t *zctx, const char *domain)
int flux_sec_zauth_init (flux_sec_t *c, zctx_t *zctx, const char *domain)
{
int rc = -1;
lock_sec (c);
Expand Down Expand Up @@ -356,7 +356,7 @@ int flux_sec_zauth_init (flux_sec_t c, zctx_t *zctx, const char *domain)
return rc;
}

int flux_sec_munge_init (flux_sec_t c)
int flux_sec_munge_init (flux_sec_t *c)
{
int rc = -1;
lock_sec (c);
Expand All @@ -377,7 +377,7 @@ int flux_sec_munge_init (flux_sec_t c)
return rc;
}

int flux_sec_csockinit (flux_sec_t c, void *sock)
int flux_sec_csockinit (flux_sec_t *c, void *sock)
{
int rc = -1;
lock_sec (c);
Expand All @@ -402,7 +402,7 @@ int flux_sec_csockinit (flux_sec_t c, void *sock)
return rc;
}

int flux_sec_ssockinit (flux_sec_t c, void *sock)
int flux_sec_ssockinit (flux_sec_t *c, void *sock)
{
lock_sec (c);
if ((c->typemask & (FLUX_SEC_TYPE_CURVE))) {
Expand All @@ -416,7 +416,7 @@ int flux_sec_ssockinit (flux_sec_t c, void *sock)
return 0;
}

static int checksecdir (flux_sec_t c, const char *path, bool create)
static int checksecdir (flux_sec_t *c, const char *path, bool create)
{
struct stat sb;
int rc = -1;
Expand Down Expand Up @@ -457,7 +457,7 @@ static int checksecdir (flux_sec_t c, const char *path, bool create)
return rc;
}

static int checksecdirs (flux_sec_t c, bool create)
static int checksecdirs (flux_sec_t *c, bool create)
{
/* XXX c->lock held */

Expand Down Expand Up @@ -495,7 +495,7 @@ static char * ctime_iso8601_now (char *buf, size_t sz)
return (buf);
}

static zcert_t *zcert_curve_new (flux_sec_t c)
static zcert_t *zcert_curve_new (flux_sec_t *c)
{
zcert_t *new;
char sec[41];
Expand Down Expand Up @@ -524,7 +524,7 @@ static zcert_t *zcert_curve_new (flux_sec_t c)
return new;
}

static int gencurve (flux_sec_t c, const char *role, bool force, bool verbose)
static int gencurve (flux_sec_t *c, const char *role, bool force, bool verbose)
{
char *path = NULL, *priv = NULL;;
zcert_t *cert = NULL;
Expand Down Expand Up @@ -577,7 +577,7 @@ static int gencurve (flux_sec_t c, const char *role, bool force, bool verbose)
return rc;
}

static zcert_t *getcurve (flux_sec_t c, const char *role)
static zcert_t *getcurve (flux_sec_t *c, const char *role)
{
char *path = NULL;;
zcert_t *cert = NULL;
Expand All @@ -592,7 +592,7 @@ static zcert_t *getcurve (flux_sec_t c, const char *role)
return cert;
}

static char *getpasswd (flux_sec_t c, const char *user)
static char *getpasswd (flux_sec_t *c, const char *user)
{
zhash_t *passwds;
char *passwd = NULL;
Expand All @@ -613,7 +613,7 @@ static char *getpasswd (flux_sec_t c, const char *user)
return passwd;
}

static int genpasswd (flux_sec_t c, const char *user, bool force, bool verbose)
static int genpasswd (flux_sec_t *c, const char *user, bool force, bool verbose)
{
struct stat sb;
zhash_t *passwds = NULL;
Expand Down Expand Up @@ -653,7 +653,7 @@ static int genpasswd (flux_sec_t c, const char *user, bool force, bool verbose)
return rc;
}

int flux_sec_munge_zmsg (flux_sec_t c, zmsg_t **zmsg)
int flux_sec_munge_zmsg (flux_sec_t *c, zmsg_t **zmsg)
{
char *buf = NULL, *cr = NULL;
munge_err_t e;
Expand Down Expand Up @@ -696,7 +696,7 @@ int flux_sec_munge_zmsg (flux_sec_t c, zmsg_t **zmsg)
return rc;
}

int flux_sec_unmunge_zmsg (flux_sec_t c, zmsg_t **zmsg)
int flux_sec_unmunge_zmsg (flux_sec_t *c, zmsg_t **zmsg)
{
char *cr = NULL, *buf = NULL;
int len;
Expand Down
Loading

0 comments on commit fb19bd9

Please sign in to comment.