~mdw
/
become
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
src/become.c: Reintroduce missing newline in usage message.
[become]
/
src
/
netg.c
diff --git
a/src/netg.c
b/src/netg.c
index
87afce0
..
b92e83a
100644
(file)
--- a/
src/netg.c
+++ b/
src/netg.c
@@
-1,10
+1,10
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: netg.c,v 1.
1 1997/08/07 09:45:0
0 mdw Exp $
+ * $Id: netg.c,v 1.
7 2004/04/08 01:36:2
0 mdw Exp $
*
* A local database of netgroups
*
*
* A local database of netgroups
*
- * (c) 199
7
EBI
+ * (c) 199
8
EBI
*/
/*----- Licensing notice --------------------------------------------------*
*/
/*----- Licensing notice --------------------------------------------------*
@@
-26,14
+26,6
@@
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-/*----- Revision history --------------------------------------------------*
- *
- * $Log: netg.c,v $
- * Revision 1.1 1997/08/07 09:45:00 mdw
- * New source file added to maintain a netgroups database.
- *
- */
-
/*----- Header files ------------------------------------------------------*/
/* --- ANSI headers --- */
/*----- Header files ------------------------------------------------------*/
/* --- ANSI headers --- */
@@
-49,12
+41,6
@@
#include <sys/types.h>
#include <sys/types.h>
-#ifdef HAVE_YP
-# include <rpc/rpc.h>
-# include <rpcsvc/ypclnt.h>
-# include <rpcsvc/yp_prot.h>
-#endif
-
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@
-63,14
+49,20
@@
#include <netdb.h>
#include <unistd.h>
#include <netdb.h>
#include <unistd.h>
+/* --- mLib headers --- */
+
+#include <mLib/alloc.h>
+#include <mLib/report.h>
+#include <mLib/sym.h>
+#include <mLib/trace.h>
+
/* --- Local headers --- */
#include "become.h"
#include "config.h"
#include "netg.h"
/* --- Local headers --- */
#include "become.h"
#include "config.h"
#include "netg.h"
-#include "sym.h"
#include "userdb.h"
#include "userdb.h"
-#include "
utils
.h"
+#include "
ypstuff
.h"
/*----- Type definitions --------------------------------------------------*/
/*----- Type definitions --------------------------------------------------*/
@@
-338,6
+330,8
@@
static int netg__foreach(int st, char *k, int ksz,
goto duff_restart;
}
goto duff_restart;
}
+ free(c->car.atom);
+ free(c);
free(kc);
free(vc);
return (0);
free(kc);
free(vc);
return (0);
@@
-353,7
+347,7
@@
static int netg__foreach(int st, char *k, int ksz,
* Use: Dumps the netgroup given.
*/
* Use: Dumps the netgroup given.
*/
-#if
def TRACING
+#if
ndef NTRACE
static void netg__dumpGroup(netg__cons *c, int lev)
{
static void netg__dumpGroup(netg__cons *c, int lev)
{
@@
-402,21
+396,23
@@
static void netg__dumpGroup(netg__cons *c, int lev)
* Use: Dumps the netgroups table.
*/
* Use: Dumps the netgroups table.
*/
+#ifndef NTRACE
+
static void netg__dump(void)
{
sym_iter i;
netg__sym *sng;
static void netg__dump(void)
{
sym_iter i;
netg__sym *sng;
-#ifdef TRACING
trace(TRACE_DEBUG, "debug: dumping netgroups file");
trace(TRACE_DEBUG, "debug: dumping netgroups file");
- for (sym_
createI
ter(&i, &netg__table); (sng = sym_next(&i)) != 0; ) {
+ for (sym_
mki
ter(&i, &netg__table); (sng = sym_next(&i)) != 0; ) {
trace(TRACE_DEBUG, "debug: netgroup `%s'...", sng->_base.name);
sng->cons->f &= ~f_visit;
netg__dumpGroup(sng->cons, 1);
}
trace(TRACE_DEBUG, "debug: netgroup `%s'...", sng->_base.name);
sng->cons->f &= ~f_visit;
netg__dumpGroup(sng->cons, 1);
}
-#endif
}
}
+#endif
+
/* --- @netg_iterate@, @netg_iterate_r@ --- *
*
* Arguments: @netg_iter *i@ = pointer to a netgroup iterator object
/* --- @netg_iterate@, @netg_iterate_r@ --- *
*
* Arguments: @netg_iter *i@ = pointer to a netgroup iterator object
@@
-427,7
+423,7
@@
static void netg__dump(void)
*/
void netg_iterate(void) { netg_iterate_r(&netg__iter); }
*/
void netg_iterate(void) { netg_iterate_r(&netg__iter); }
-void netg_iterate_r(netg_iter *i) { sym_
createI
ter(i, &netg__table); }
+void netg_iterate_r(netg_iter *i) { sym_
mki
ter(i, &netg__table); }
/* --- @netg_next@, @netg_next_r@ --- *
*
/* --- @netg_next@, @netg_next_r@ --- *
*
@@
-546,29
+542,23
@@
static void netg__breakCycle(netg__cons *c)
void netg_init(void)
{
void netg_init(void)
{
- char *ypdom;
-
/* --- Initialise my symbol table --- */
/* --- Initialise my symbol table --- */
- sym_create
Table
(&netg__table);
+ sym_create(&netg__table);
/* --- Bind myself unto a YP server --- */
/* --- Bind myself unto a YP server --- */
- if (yp_get_default_domain(&ypdom) ||
-
yp_bind(ypdom)
)
+ ypstuff_bind();
+
if (!yp_domain
)
return;
/* --- Now try to read all the netgroup entries --- */
{
static struct ypall_callback ncb = { netg__foreach, 0 };
return;
/* --- Now try to read all the netgroup entries --- */
{
static struct ypall_callback ncb = { netg__foreach, 0 };
- yp_all(yp
dom
, "netgroup", &ncb);
+ yp_all(yp
_domain
, "netgroup", &ncb);
}
}
- /* --- Unbind from the server --- */
-
- yp_unbind(ypdom);
-
/* --- Dump the table --- */
IF_TRACING(TRACE_DEBUG, netg__dump(); )
/* --- Dump the table --- */
IF_TRACING(TRACE_DEBUG, netg__dump(); )
@@
-581,7
+571,7
@@
void netg_init(void)
netg__cons *c;
netg__atom *a;
netg__cons *c;
netg__atom *a;
- for (sym_
createI
ter(&i, &netg__table); (sng = sym_next(&i)) != 0; ) {
+ for (sym_
mki
ter(&i, &netg__table); (sng = sym_next(&i)) != 0; ) {
for (c = sng->cons; c; c = c->cdr) {
if ((c->f & f_cons) == 0 && c->car.atom->n) {
a = c->car.atom;
for (c = sng->cons; c; c = c->cdr) {
if ((c->f & f_cons) == 0 && c->car.atom->n) {
a = c->car.atom;
@@
-606,9
+596,9
@@
void netg_init(void)
sym_iter i;
netg__sym *sng;
sym_iter i;
netg__sym *sng;
- for (sym_
createI
ter(&i, &netg__table); (sng = sym_next(&i)) != 0; )
+ for (sym_
mki
ter(&i, &netg__table); (sng = sym_next(&i)) != 0; )
sng->cons->f &= ~f_uncycled;
sng->cons->f &= ~f_uncycled;
- for (sym_
createI
ter(&i, &netg__table); (sng = sym_next(&i)) != 0; )
+ for (sym_
mki
ter(&i, &netg__table); (sng = sym_next(&i)) != 0; )
netg__breakCycle(sng->cons);
}
netg__breakCycle(sng->cons);
}
@@
-617,16
+607,16
@@
void netg_init(void)
IF_TRACING(TRACE_DEBUG, netg__dump(); )
}
IF_TRACING(TRACE_DEBUG, netg__dump(); )
}
-/* --- @netg_
reinit
@ --- *
+/* --- @netg_
end
@ --- *
*
* Arguments: ---
*
* Returns: ---
*
*
* Arguments: ---
*
* Returns: ---
*
- * Use:
Forces a re-read of the netgroups fil
e.
+ * Use:
Empties the netgroups databas
e.
*/
*/
-void netg_
reinit
(void)
+void netg_
end
(void)
{
sym_iter i;
netg__sym *sng;
{
sym_iter i;
netg__sym *sng;
@@
-634,7
+624,7
@@
void netg_reinit(void)
/* --- Remove all the old netgroups rubbish --- */
/* --- Remove all the old netgroups rubbish --- */
- for (sym_
createI
ter(&i, &netg__table); (sng = sym_next(&i)) != 0; ) {
+ for (sym_
mki
ter(&i, &netg__table); (sng = sym_next(&i)) != 0; ) {
c = sng->cons;
while (c) {
cc = c->cdr;
c = sng->cons;
while (c) {
cc = c->cdr;
@@
-643,6
+633,7
@@
void netg_reinit(void)
if (c->car.atom->h) free(c->car.atom->h);
if (c->car.atom->u) free(c->car.atom->u);
if (c->car.atom->d) free(c->car.atom->d);
if (c->car.atom->h) free(c->car.atom->h);
if (c->car.atom->u) free(c->car.atom->u);
if (c->car.atom->d) free(c->car.atom->d);
+ free(c->car.atom);
}
free(c);
c = cc;
}
free(c);
c = cc;
@@
-650,9
+641,7
@@
void netg_reinit(void)
sym_remove(&netg__table, sng);
}
sym_remove(&netg__table, sng);
}
- /* --- Now rebuild the world --- */
-
- netg_init();
+ sym_destroy(&netg__table);
}
/*----- Test driver -------------------------------------------------------*/
}
/*----- Test driver -------------------------------------------------------*/
@@
-670,7
+659,7
@@
int main(void)
{
netg *n;
ego("netg-test");
{
netg *n;
ego("netg-test");
- traceon(stderr, TRACE_ALL);
+ trace
_
on(stderr, TRACE_ALL);
netg_init();
for (netg_iterate(); (n = netg_next()) != 0; ) {
fprintf(stderr, "netgroup %s\n", netg_name(n));
netg_init();
for (netg_iterate(); (n = netg_next()) != 0; ) {
fprintf(stderr, "netgroup %s\n", netg_name(n));