/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to plugbasedclient.c

  • Committer: Teddy Hogeborn
  • Date: 2008-08-02 10:48:24 UTC
  • Revision ID: teddy@fukt.bsnet.se-20080802104824-fx0miwp9o4g9r31e
* plugbasedclient.c (struct process): New fields "eof", "completed",
                                      and "status".
  (handle_sigchld): New function.
  (main): Initialize "dir" to NULL to only closedir() it if necessary.
          Move "process_list" to be a global variable to be accessible
          by "handle_sigchld".  Make "handle_sigchld" handle SIGCHLD.
          Remove redundant check for NULL "dir".  Free "filename" when
          no longer used.  Block SIGCHLD around fork()/exec().
          Restore normal signals in child.  Only loop while running
          processes exist.  Print process buffer when the process is
          done and it has emitted EOF, not when it only emits EOF.
          Remove processes from list which exit non-cleanly.  In
          cleaning up, closedir() if necessary.  Bug fix: set next
          pointer correctly when freeing process list.

* plugins.d/passprompt.c (main): Do not ignore SIGQUIT.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
                                   struct argp_state, struct argp,
51
51
                                   argp_parse() */
52
52
 
53
 
#define BUFFER_SIZE 256
54
 
 
55
53
struct process;
56
54
 
57
55
typedef struct process{
74
72
  struct plugin *next;
75
73
} plugin;
76
74
 
77
 
static plugin *getplugin(char *name, plugin **plugin_list){
 
75
plugin *getplugin(char *name, plugin **plugin_list){
78
76
  for (plugin *p = *plugin_list; p != NULL; p = p->next){
79
77
    if ((p->name == name)
80
78
        or (p->name and name and (strcmp(p->name, name) == 0))){
103
101
  return new_plugin;
104
102
}
105
103
 
106
 
static void addargument(plugin *p, char *arg){
 
104
void addargument(plugin *p, char *arg){
107
105
  p->argv[p->argc] = arg;
108
106
  p->argv = realloc(p->argv, sizeof(char *) * (size_t)(p->argc + 2));
109
107
  if (p->argv == NULL){
119
117
 * Descriptor Flags".
120
118
 * *Note File Descriptor Flags:(libc)Descriptor Flags.
121
119
 */
122
 
static int set_cloexec_flag(int fd)
 
120
int set_cloexec_flag(int fd)
123
121
{
124
122
  int ret = fcntl(fd, F_GETFD, 0);
125
123
  /* If reading the flags failed, return error indication now. */
130
128
  return fcntl(fd, F_SETFD, ret | FD_CLOEXEC);
131
129
}
132
130
 
 
131
#define BUFFER_SIZE 256
 
132
 
133
133
const char *argp_program_version = "plugbasedclient 0.9";
134
134
const char *argp_program_bug_address = "<mandos@fukt.bsnet.se>";
135
135