2 ** Copyright (C) 2006 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
3 ** Copyright (C) 2009 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
35 pp_dblistkeys (GDBM_FILE db)
39 key = gdbm_firstkey (db);
40 while (key.dptr != NULL)
42 printf ("%s\n", key.dptr);
44 key = gdbm_nextkey (db, oldkey);
50 usage (char *programname)
52 fprintf (stderr, "%s {allow | deny} {add | del | list} [user]\n",
58 main (int argc, char **argv)
69 if (!strcmp (argv[1], "deny"))
70 db_fn = "/var/lib/popproxy/deny.db";
71 else if (!strcmp (argv[1], "allow"))
72 db_fn = "/var/lib/popproxy/allow.db";
75 if (!strcmp (argv[2], "add"))
77 else if (!strcmp (argv[2], "del"))
79 else if (!strcmp (argv[2], "list"))
83 if ((action == ACTION_ADD || action == ACTION_DEL) && argc < 4)
85 if (action != ACTION_LIST)
89 key.dsize = strlen (username);
93 db = gdbm_open (db_fn, 0, GDBM_WRCREAT, 0600, NULL);
96 fprintf (stderr, "Could not create database.\n");
102 r = gdbm_store (db, key, data, GDBM_REPLACE);
105 r = gdbm_delete (db, key);
112 fprintf (stderr, "Action unrecognized.\n");