aboutsummaryrefslogtreecommitdiff
path: root/src/pies.h
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-10-12 21:14:00 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2009-10-12 21:14:00 +0300
commitaf04ed630f18e9003756317cc627a11084d0d59a (patch)
tree828cf1fc2c326842777942441c14e853d9894cc7 /src/pies.h
parent989a5bbb74c3620abaa2191ce2c4f8d5968dbf0a (diff)
downloadpies-af04ed630f18e9003756317cc627a11084d0d59a.tar.gz
pies-af04ed630f18e9003756317cc627a11084d0d59a.tar.bz2
Do not require Mailutils. Provide missing functions.
* Makefile.am (ACLOCAL_AMFLAGS): Add grecs/am * bootstrap.conf: Skip po. Initialize submodule. * configure.ac: Mailutils no longer needed. (AC_CONFIG_FILES): Add new subdirs. * gnulib.modules: Add more modules. Arrange entries alphabetically. * lib/Makefile.am: Rename library to libpies. * lib/libpies.h (mf_privs) (switch_to_privs, get_user_groups) (mf_priv_setup, mf_epriv_setup): Move to src/pies.h (config_array_to_argv, config_array_to_string) (config_cb_timeout): Remove. (tokendef): New struct. (strtotok_len, strtotok_len_ci) (strtotok, strtotok_ci, toktostr): New prototypes. * lib/nls.c: Remove call to mu_init_nls. * src/acl.c: New file. * src/addrfmt.c: New file. * src/diag.c: New file. * src/meta.c: New file. * src/url.c: New file. * src/userprivs.c: New file. * src/acl.h: New file. * src/pp-setup: New file. * src/Makefile.am (pies_SOURCES): Add acl.c, addrfmt.c, diag.c, meta.c, url.c, userprivs.c. (noinst_HEADERS): Add acl.h. (inc_DATA): Add pp-setup. * src/limits.c, src/meta1gram.y, src/meta1lex.h, src/meta1lex.l, src/pies.c, src/pies.h, src/progman.c, src/socket.c, src/userprivs.c: Remove calls to functions from Mailutils.
Diffstat (limited to 'src/pies.h')
-rw-r--r--src/pies.h133
1 files changed, 113 insertions, 20 deletions
diff --git a/src/pies.h b/src/pies.h
index add175c..c57a104 100644
--- a/src/pies.h
+++ b/src/pies.h
@@ -1,23 +1,24 @@
-/* This file is part of Mailfromd.
+/* This file is part of Pies.
Copyright (C) 2008, 2009 Sergey Poznyakoff
- This program is free software; you can redistribute it and/or modify
+ Pies 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 3, or (at your option)
any later version.
- This program is distributed in the hope that it will be useful,
+ Pies 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 this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with Pies. If not, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
+#include <sys/socket.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -35,18 +36,27 @@
#include <pwd.h>
#include <grp.h>
#include <signal.h>
+#include <time.h>
#include <sysexits.h>
+#include <argp.h>
-#include <mailutils/mailutils.h>
-#include <mailutils/daemon.h>
-#include <mailutils/libargp.h>
-#include <mailutils/syslog.h>
+#include <grecs.h>
+#include <wordsplit.h>
+#include "progname.h"
#include "inttostr.h"
#include "c-ctype.h"
#include "xalloc.h"
+#define obstack_chunk_alloc xmalloc
+#define obstack_chunk_free free
+#include "obstack.h"
+#include "xvasprintf.h"
+
+#include "acl.h"
#include "libpies.h"
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
+
#define TESTTIME 2*60
#define SLEEPTIME 5*60
#define MAXSPAWN 10
@@ -88,11 +98,20 @@ struct action
size_t nstat;
unsigned *status;
enum return_action act; /* Action to take when the component terminates */
- mu_address_t addr; /* Addresses to notify about it. */
+ char *addr; /* Addresses to notify about it. */
char *message; /* Notification mail. */
char *command; /* Execute this command */
};
+
+/* user privs */
+struct pies_privs
+{
+ char *user;
+ int allgroups;
+ gl_list_t groups;
+};
+
enum pies_comp_mode
{
/* Execute the component, no sockets are opened. This is the default
@@ -121,23 +140,23 @@ struct component
char **argv; /* Program command line */
char **env; /* Program environment */
char *dir; /* Working directory */
- mu_list_t prereq; /* Prerequisites */
- mu_list_t depend; /* Dependency targets */
+ gl_list_t prereq; /* Prerequisites */
+ gl_list_t depend; /* Dependency targets */
unsigned settle_timeout; /* Time needed for started prerequisites to
settle */
/* FIXME: disabled and precious can be encoded as bits in mode */
int disabled; /* The componenet is disabled */
int precious; /* The component is precious (cannot be disabled) */
char *rmfile; /* Try to remove this file before starting */
- struct mf_privs privs; /* UID/GIDS+groups to run under */
+ struct pies_privs privs; /* UID/GIDS+groups to run under */
mode_t umask; /* Umask to install before starting */
limits_record_t limits; /* System limits */
- mu_url_t socket_url; /* Socket to listen on
- (if mode != pies_comp_exec) */
+ struct pies_url *socket_url; /* Socket to listen on
+ (if mode != pies_comp_exec) */
char *pass_fd_socket; /* Socket to pass fd on
(if mode == pies_comp_pass_fd) */
- mu_acl_t acl;
- /* Retranslators: */
+ pies_acl_t acl;
+ /* Redirectors: */
int facility; /* Syslog facility. */
struct redirector redir[2]; /* Repeaters for stdout and stderr */
/* Actions to execute on various exit codes: */
@@ -145,11 +164,12 @@ struct component
struct action act_temp; /* Auxiliary object used during configuration */
};
-extern char *syslog_tag;
+extern int log_to_stderr;
+extern char *log_tag;
+extern int log_facility;
extern unsigned long shutdown_timeout;
extern struct component default_component;
-extern mu_acl_t pies_acl;
-extern mu_debug_t pies_debug;
+pies_acl_t pies_acl;
extern limits_record_t pies_limits;
void register_prog (struct component *comp);
@@ -187,11 +207,36 @@ unsigned depmap_first (pies_depmap_t dmap, enum pies_depmap_direction dir,
unsigned coord, pies_depmap_pos_t *ppos);
unsigned depmap_next (pies_depmap_t dmap, pies_depmap_pos_t pos);
+int assert_grecs_value_type (grecs_locus_t *locus,
+ const grecs_value_t *value, int type);
+
+struct component *component_create (const char *name);
+void component_finish (struct component *comp, grecs_locus_t *locus);
+struct grecs_keyword *find_component_keyword (const char *ident);
+
+
+/* url.c */
+struct pies_url
+{
+ char *string;
+ char *proto;
+ char *host;
+ int port;
+ char *path;
+ char *user;
+ char *passwd;
+ int argc;
+ char **argv;
+};
+
+int pies_url_create (struct pies_url **purl, const char *str);
+void pies_url_destroy (struct pies_url **purl);
+const char * pies_url_get_arg (struct pies_url *url, const char *argname);
void pies_pause (void);
int register_listener (int fd);
int pass_fd (const char *socket, int fd);
-int create_socket (mu_url_t url, const char *user, mode_t umask);
+int create_socket (struct pies_url *url, const char *user, mode_t umask);
int parse_limits (limits_record_t *plrec, char *str, char **endp);
@@ -203,3 +248,51 @@ int meta1lex (void);
int meta1error (char *s);
int meta1parse (void);
+
+void logmsg (int prio, const char *fmt, ...);
+void logmsg_printf (int prio, const char *fmt, ...);
+void logmsg_vprintf (int prio, const char *fmt, va_list ap);
+
+extern unsigned debug_level;
+extern int source_info_option;
+void debug_msg (const char *fmt, ...);
+
+#define debug(lev, args) \
+ do \
+ if (debug_level >= lev) \
+ { \
+ if (source_info_option) \
+ logmsg_printf (LOG_DEBUG, "%s:%lu:%s: ", \
+ __FILE__, __LINE__, __FUNCTION__); \
+ debug_msg args; \
+ } \
+ while (0)
+
+
+/* meta.c */
+struct metadef
+{
+ char *kw;
+ char *value;
+ const char *(*expand) (struct metadef *, void *);
+ char *storage;
+ void *data;
+};
+
+char *meta_expand_string (const char *string, struct metadef *def, void *data);
+void meta_free (struct metadef *def);
+
+
+/* addrfmt.c */
+void sockaddr_to_str (const struct sockaddr *sa, int salen,
+ char *bufptr, size_t buflen,
+ size_t *plen);
+char *sockaddr_to_astr (const struct sockaddr *sa, int salen);
+
+
+/* userprivs.c */
+int switch_to_privs (uid_t uid, gid_t gid, gl_list_t retain_groups);
+
+void pies_priv_setup (struct pies_privs *);
+void pies_epriv_setup (struct pies_privs *);
+

Return to:

Send suggestions and report system problems to the System administrator.