bin_PROGRAMS =
lib_LTLIBRARIES =
+noinst_LIBRARIES =
include_HEADERS =
dist_man_MANS =
CLEANFILES =
EXTRA_DIST =
+LDADD =
+
+###--------------------------------------------------------------------------
+### Programs.
+
+## Common stuff.
+noinst_LIBRARIES += libutils.a
+libutils_a_SOURCES =
+LDADD += libutils.a
+
+libutils_a_SOURCES += utils.c
+libutils_a_SOURCES += utils.h
+
+## chkpath
+bin_PROGRAMS += chkpath
+dist_man_MANS += chkpath.1
+
+## tmpdir
+bin_PROGRAMS += tmpdir
+dist_man_MANS += tmpdir.1
###--------------------------------------------------------------------------
### Library.
libcheckpath_la_LDFLAGS = -version-info $(LIBTOOL_VERSION_INFO)
libcheckpath_la_LIBADD = $(mLib_LIBS)
dist_man_MANS += checkpath.3
+LDADD += libcheckpath.la
libcheckpath_la_SOURCES += checkpath.c
include_HEADERS += checkpath.h
mv $@.new $@
###--------------------------------------------------------------------------
-### Programs.
-
-LDADD = libcheckpath.la $(mLib_LIBS)
-
-## chkpath
-bin_PROGRAMS += chkpath
-dist_man_MANS += chkpath.1
-
-## tmpdir
-bin_PROGRAMS += tmpdir
-dist_man_MANS += tmpdir.1
-
-###--------------------------------------------------------------------------
### Other finishing touches.
## Version stamp.
## Build tools.
EXTRA_DIST += config/confsubst
+## External libraries.
+LDADD += $(mLib_LIBS)
+
###--------------------------------------------------------------------------
### Debian.
#include <mLib/report.h>
#include "checkpath.h"
+#include "utils.h"
/*----- Static variables --------------------------------------------------*/
fp);
}
-/* --- @allowgroup@ --- *
- *
- * Arguments: @const char *gname@ = trust group @gname@
- *
- * Returns: ---
- *
- * Use: Adds the gid corresponding to @gname@ (which may be a number)
- * to the list of things we trust.
- */
-
-static void allowgroup(const char *gname)
-{
- struct group *gr;
- const char *p;
- gid_t g;
-
- /* --- Check for numeric group spec --- */
-
- for (p = gname; *p; p++) {
- if (!isdigit((unsigned char)*p))
- goto lookup;
- }
- g = atoi(gname);
- goto insert;
-
- /* --- Look up a group by name --- */
-
-lookup:
- if ((gr = getgrnam(gname)) == 0)
- die(1, "group %s not found", gname);
- g = gr->gr_gid;
-
- /* --- Insert the group into the table --- */
-
-insert:
- if (cp.cp_gids >= N(cp.cp_gid))
- die(1, "too many groups");
- cp.cp_gid[cp.cp_gids++] = g;
-}
-
/* --- @main@ --- *
*
* Arguments: @int argc@ = number of command line arguments
return (!fullcheck(optarg));
break;
case 'g':
- allowgroup(optarg);
+ allowgroup(&cp, optarg);
break;
case 'v':
cp.cp_verbose++;
--- /dev/null
+/* -*-c-*-
+ *
+ * Utilities not worth librarifying
+ *
+ * (c) 2008 Mark Wooding
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of chkpath.
+ *
+ * chkpath is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * chkpath is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with chkpath; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/*----- Header files ------------------------------------------------------*/
+
+#include "config.h"
+
+#include <ctype.h>
+
+#include <sys/types.h>
+
+#include <grp.h>
+
+#include <mLib/macros.h>
+#include <mLib/report.h>
+
+#include "checkpath.h"
+#include "utils.h"
+
+/*----- Main code ---------------------------------------------------------*/
+
+/* --- @allowgroup@ --- *
+ *
+ * Arguments: @struct checkpath *cp@ = pointer to structure to mess with
+ * @const char *gname@ = trust group @gname@
+ *
+ * Returns: ---
+ *
+ * Use: Adds the gid corresponding to @gname@ (which may be a number)
+ * to the list of things we trust.
+ */
+
+void allowgroup(struct checkpath *cp, const char *gname)
+{
+ struct group *gr;
+ const char *p;
+ gid_t g;
+
+ /* --- Check for numeric group spec --- */
+
+ for (p = gname; *p; p++) {
+ if (!isdigit((unsigned char)*p))
+ goto lookup;
+ }
+ g = atoi(gname);
+ goto insert;
+
+ /* --- Look up a group by name --- */
+
+lookup:
+ if ((gr = getgrnam(gname)) == 0)
+ die(1, "group %s not found", gname);
+ g = gr->gr_gid;
+
+ /* --- Insert the group into the table --- */
+
+insert:
+ if (cp->cp_gids >= N(cp->cp_gid))
+ die(1, "too many groups");
+ cp->cp_gid[cp->cp_gids++] = g;
+}
+
+/*----- That's all, folks -------------------------------------------------*/
--- /dev/null
+/* -*-c-*-
+ *
+ * Utilities not worth librarifying
+ *
+ * (c) 2008 Mark Wooding
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of chkpath.
+ *
+ * chkpath is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * chkpath is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with chkpath; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef UTILS_H
+#define UTILS_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/*----- Header files ------------------------------------------------------*/
+
+#include "checkpath.h"
+
+/*----- Functions provided ------------------------------------------------*/
+
+/* --- @allowgroup@ --- *
+ *
+ * Arguments: @struct checkpath *cp@ = pointer to structure to mess with
+ * @const char *gname@ = trust group @gname@
+ *
+ *
+ * Returns: ---
+ *
+ * Use: Adds the gid corresponding to @gname@ (which may be a number)
+ * to the list of things we trust.
+ */
+
+extern void allowgroup(struct checkpath */*cp*/, const char */*gname*/);
+
+/*----- That's all, folks -------------------------------------------------*/
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif