Date: Tue, 11 Feb 2014 11:27:26 +0000 (UTC) From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r261759 - head/usr.sbin/ctld Message-ID: <201402111127.s1BBRQgT055173@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: trasz Date: Tue Feb 11 11:27:25 2014 New Revision: 261759 URL: http://svnweb.freebsd.org/changeset/base/261759 Log: Make it possible to redefine portal-group "default". Sponsored by: The FreeBSD Foundation Modified: head/usr.sbin/ctld/ctld.h head/usr.sbin/ctld/parse.y Modified: head/usr.sbin/ctld/ctld.h ============================================================================== --- head/usr.sbin/ctld/ctld.h Tue Feb 11 11:26:05 2014 (r261758) +++ head/usr.sbin/ctld/ctld.h Tue Feb 11 11:27:25 2014 (r261759) @@ -146,6 +146,9 @@ struct conf { uint16_t conf_last_portal_group_tag; struct pidfh *conf_pidfh; + + bool conf_default_pg_defined; + bool conf_default_ag_defined; }; #define CONN_SESSION_TYPE_NONE 0 Modified: head/usr.sbin/ctld/parse.y ============================================================================== --- head/usr.sbin/ctld/parse.y Tue Feb 11 11:26:05 2014 (r261758) +++ head/usr.sbin/ctld/parse.y Tue Feb 11 11:27:25 2014 (r261759) @@ -224,7 +224,17 @@ portal_group: PORTAL_GROUP portal_group_ portal_group_name: STR { - portal_group = portal_group_new(conf, $1); + /* + * Make it possible to redefine default + * portal-group. but only once. + */ + if (strcmp($1, "default") == 0 && + conf->conf_default_pg_defined == false) { + portal_group = portal_group_find(conf, $1); + conf->conf_default_pg_defined = true; + } else { + portal_group = portal_group_new(conf, $1); + } free($1); if (portal_group == NULL) return (1); @@ -703,6 +713,7 @@ conf_new_from_file(const char *path) conf = conf_new(); ag = auth_group_new(conf, "no-authentication"); + assert(ag != NULL); ag->ag_type = AG_TYPE_NO_AUTHENTICATION; /* @@ -710,11 +721,11 @@ conf_new_from_file(const char *path) * any entries and thus will always deny access. */ ag = auth_group_new(conf, "no-access"); + assert(ag != NULL); ag->ag_type = AG_TYPE_CHAP; pg = portal_group_new(conf, "default"); - portal_group_add_listen(pg, "0.0.0.0:3260", false); - portal_group_add_listen(pg, "[::]:3260", false); + assert(pg != NULL); yyin = fopen(path, "r"); if (yyin == NULL) { @@ -736,6 +747,15 @@ conf_new_from_file(const char *path) return (NULL); } + if (conf->conf_default_pg_defined == false) { + log_debugx("portal-group \"default\" not defined; " + "going with defaults"); + pg = portal_group_find(conf, "default"); + assert(pg != NULL); + portal_group_add_listen(pg, "0.0.0.0:3260", false); + portal_group_add_listen(pg, "[::]:3260", false); + } + error = conf_verify(conf); if (error != 0) { conf_delete(conf);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201402111127.s1BBRQgT055173>