~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
/
bcquery.c
diff --git
a/src/bcquery.c
b/src/bcquery.c
index
e43d075
..
ddad501
100644
(file)
--- a/
src/bcquery.c
+++ b/
src/bcquery.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: bcquery.c,v 1.
1 1998/04/23 13:20
:20 mdw Exp $
+ * $Id: bcquery.c,v 1.
6 2004/04/08 01:36
:20 mdw Exp $
*
* Query and dump Become's configuration file
*
*
* Query and dump Become's configuration file
*
@@
-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: bcquery.c,v $
- * Revision 1.1 1998/04/23 13:20:20 mdw
- * Added new program to verify and query Become configuration files.
- *
- */
-
/*----- Header files ------------------------------------------------------*/
/* --- ANSI headers --- */
/*----- Header files ------------------------------------------------------*/
/* --- ANSI headers --- */
@@
-63,6
+55,14
@@
#include <syslog.h>
#include <unistd.h>
#include <syslog.h>
#include <unistd.h>
+/* --- mLib headers --- */
+
+#include <mLib/alloc.h>
+#include <mLib/mdwopt.h>
+#include <mLib/quis.h>
+#include <mLib/report.h>
+#include <mLib/sym.h>
+
/* --- Local headers --- */
#include "become.h"
/* --- Local headers --- */
#include "become.h"
@@
-70,13
+70,10
@@
#include "config.h"
#include "daemon.h"
#include "lexer.h"
#include "config.h"
#include "daemon.h"
#include "lexer.h"
-#include "mdwopt.h"
#include "name.h"
#include "netg.h"
#include "name.h"
#include "netg.h"
-#include "parse
r
.h"
+#include "parse.h"
#include "rule.h"
#include "rule.h"
-#include "sym.h"
-#include "utils.h"
#include "userdb.h"
/*----- Type definitions --------------------------------------------------*/
#include "userdb.h"
/*----- Type definitions --------------------------------------------------*/
@@
-258,7
+255,7
@@
again:
bit = cat_what;
goto setbits;
default:
bit = cat_what;
goto setbits;
default:
- die("unknown column specifier `%c'", *p);
+ die(
1,
"unknown column specifier `%c'", *p);
break;
setbits:
if (mode == m_replace) {
break;
setbits:
if (mode == m_replace) {
@@
-270,7
+267,7
@@
again:
else if (mode == m_remove)
outmask &= ~bit;
else
else if (mode == m_remove)
outmask &= ~bit;
else
- die("bad mode while setting output mask: %u", mode);
+ die(
1,
"bad mode while setting output mask: %u", mode);
break;
}
p++;
break;
}
p++;
@@
-278,7
+275,7
@@
again:
goto again;
}
case '?':
goto again;
}
case '?':
- die("type `%s --help' for usage information", quis());
+ die(
1,
"type `%s --help' for usage information", quis());
case 0:
if (optarg[0] && optarg[1] == 0) switch (optarg[0]) {
case '(': case ')':
case 0:
if (optarg[0] && optarg[1] == 0) switch (optarg[0]) {
case '(': case ')':
@@
-287,7
+284,7
@@
again:
break;
}
if (!opt)
break;
}
if (!opt)
- die("unexpected text `%s' found", optarg);
+ die(
1,
"unexpected text `%s' found", optarg);
break;
}
break;
}
@@
-315,7
+312,7
@@
static qnode *qparse_atom(void)
nextopt();
q = qparse_expr();
if (opt != ')')
nextopt();
q = qparse_expr();
if (opt != ')')
- die("syntax error: expected `)', found `%s'", optname());
+ die(
1,
"syntax error: expected `)', found `%s'", optname());
nextopt();
return (q);
}
nextopt();
return (q);
}
@@
-324,9
+321,9
@@
static qnode *qparse_atom(void)
qnode *q = xmalloc(sizeof(*q));
h = gethostbyname(optarg);
if (!h)
qnode *q = xmalloc(sizeof(*q));
h = gethostbyname(optarg);
if (!h)
- die("unknown host `%s'", optarg);
+ die(
1,
"unknown host `%s'", optarg);
q->q_cat = cat_where;
q->q_cat = cat_where;
- memcpy(&q->q_in, h->h_addr, sizeof(
struct in_addr
));
+ memcpy(&q->q_in, h->h_addr, sizeof(
q->q_in
));
nextopt();
return (q);
}
nextopt();
return (q);
}
@@
-345,7
+342,7
@@
static qnode *qparse_atom(void)
}
pw = userdb_userByName(optarg);
if (!pw)
}
pw = userdb_userByName(optarg);
if (!pw)
- die("unknown user `%s'", optarg);
+ die(
1,
"unknown user `%s'", optarg);
q->q_uid = pw->pw_uid;
}
nextopt();
q->q_uid = pw->pw_uid;
}
nextopt();
@@
-359,7
+356,7
@@
static qnode *qparse_atom(void)
return (q);
}
default:
return (q);
}
default:
- die("unexpected token: `%s'", optname());
+ die(
1,
"unexpected token: `%s'", optname());
}
return (0);
}
}
return (0);
}
@@
-429,7
+426,7
@@
static qnode *qparse(void)
return (0);
q = qparse_expr();
if (opt != EOF)
return (0);
q = qparse_expr();
if (opt != EOF)
- die("syntax error: `%s' unexpected", optname());
+ die(
1,
"syntax error: `%s' unexpected", optname());
return (q);
}
return (q);
}
@@
-445,8
+442,10
@@
static qnode *qparse(void)
static void dumptree(qnode *q, int indent)
{
static void dumptree(qnode *q, int indent)
{
- if (!q)
+ if (!q)
{
printf("<empty> -- magic query which matches everything\n");
printf("<empty> -- magic query which matches everything\n");
+ return;
+ }
again:
printf("%*s", indent * 2, "");
again:
printf("%*s", indent * 2, "");
@@
-531,7
+530,7
@@
again:
/* --- Anything else is bogus (and a bug) --- */
/* --- Anything else is bogus (and a bug) --- */
- die("unexpected cat code %u in checkrule", q->q_cat);
+ die(
1,
"unexpected cat code %u in checkrule", q->q_cat);
return (-1);
}
return (-1);
}
@@
-570,7
+569,7
@@
static void classfirstrow(class_node *c, const char *fmt, sym_iter *i,
break;
case clNode_hash: {
sym_base *b;
break;
case clNode_hash: {
sym_base *b;
- sym_
createI
ter(i, &c->v.t);
+ sym_
mki
ter(i, &c->v.t);
b = sym_next(i);
if (!b) {
printf(fmt, "");
b = sym_next(i);
if (!b) {
printf(fmt, "");
@@
-606,7
+605,7
@@
static void showclass(class_node *c,
case clNode_hash: {
sym_iter i;
sym_base *b;
case clNode_hash: {
sym_iter i;
sym_base *b;
- sym_
createI
ter(&i, &c->v.t);
+ sym_
mki
ter(&i, &c->v.t);
fputc('(', stdout);
if ((b = sym_next(&i)) != 0) {
sh(b);
fputc('(', stdout);
if ((b = sym_next(&i)) != 0) {
sh(b);
@@
-814,7
+813,7
@@
int main(int argc, char *argv[])
int ok;
if (!fp)
int ok;
if (!fp)
- die("couldn't open configuration file `%s': %s", cf, strerror(errno));
+ die(
1,
"couldn't open configuration file `%s': %s", cf, strerror(errno));
lexer_scan(fp);
ok = parse();
if (flags & f_check)
lexer_scan(fp);
ok = parse();
if (flags & f_check)
@@
-859,7
+858,7
@@
int main(int argc, char *argv[])
/* --- Done --- */
if (!(flags & f_match))
/* --- Done --- */
if (!(flags & f_match))
- die("no match");
+ die(
1,
"no match");
return (0);
}
return (0);
}