/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release
21 by Teddy Hogeborn
* Makefile (CFLAGS): Changed to use $(WARN), $(DEBUG), $(COVERAGE) and
1
/*  -*- coding: utf-8 -*- */
2
/*
3
 * Mandos plugin runner - Run Mandos plugins
4
 *
28 by Teddy Hogeborn
* server.conf: New file.
5
 * Copyright © 2007-2008 Teddy Hogeborn & Björn Påhlsson
21 by Teddy Hogeborn
* Makefile (CFLAGS): Changed to use $(WARN), $(DEBUG), $(COVERAGE) and
6
 * 
7
 * This program is free software: you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License as
9
 * published by the Free Software Foundation, either version 3 of the
10
 * License, or (at your option) any later version.
11
 * 
12
 * This program is distributed in the hope that it will be useful, but
13
 * WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * General Public License for more details.
16
 * 
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program.  If not, see
19
 * <http://www.gnu.org/licenses/>.
20
 * 
28 by Teddy Hogeborn
* server.conf: New file.
21
 * Contact the authors at <mandos@fukt.bsnet.se>.
21 by Teddy Hogeborn
* Makefile (CFLAGS): Changed to use $(WARN), $(DEBUG), $(COVERAGE) and
22
 */
23
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
24
#define _GNU_SOURCE		/* TEMP_FAILURE_RETRY() */
25
24.1.26 by Björn Påhlsson
tally count of used symbols
26
#include <stddef.h>		/* size_t, NULL */
27
#include <stdlib.h>		/* malloc(), exit(), EXIT_FAILURE,
28
				   EXIT_SUCCESS, realloc() */
29
#include <stdbool.h>		/* bool, true, false */
30
#include <stdio.h>		/* perror, popen(), fileno(),
31
				   fprintf(), stderr, STDOUT_FILENO */
32
#include <sys/types.h>	        /* DIR, opendir(), stat(), struct
33
				   stat, waitpid(), WIFEXITED(),
34
				   WEXITSTATUS(), wait(), pid_t,
35
				   uid_t, gid_t, getuid(), getgid(),
36
				   dirfd() */
37
#include <sys/select.h>		/* fd_set, select(), FD_ZERO(),
38
				   FD_SET(), FD_ISSET(), FD_CLR */
39
#include <sys/wait.h>		/* wait(), waitpid(), WIFEXITED(),
40
				   WEXITSTATUS() */
41
#include <sys/stat.h>		/* struct stat, stat(), S_ISREG() */
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
42
#include <iso646.h>		/* and, or, not */
43
#include <dirent.h>		/* DIR, struct dirent, opendir(),
24.1.26 by Björn Påhlsson
tally count of used symbols
44
				   readdir(), closedir(), dirfd() */
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
45
#include <unistd.h>		/* struct stat, stat(), S_ISREG(),
24.1.26 by Björn Påhlsson
tally count of used symbols
46
				   fcntl(), setuid(), setgid(),
47
				   F_GETFD, F_SETFD, FD_CLOEXEC,
48
				   access(), pipe(), fork(), close()
49
				   dup2, STDOUT_FILENO, _exit(),
50
				   execv(), write(), read(),
51
				   close() */
52
#include <fcntl.h>		/* fcntl(), F_GETFD, F_SETFD,
53
				   FD_CLOEXEC */
24.1.50 by Björn Påhlsson
changed from using strtok to strsep
54
#include <string.h>		/* strsep, strlen(), strcpy(),
24.1.26 by Björn Påhlsson
tally count of used symbols
55
				   strcat() */
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
56
#include <errno.h>		/* errno */
24.1.26 by Björn Påhlsson
tally count of used symbols
57
#include <argp.h>		/* struct argp_option, struct
58
				   argp_state, struct argp,
59
				   argp_parse(), ARGP_ERR_UNKNOWN,
60
				   ARGP_KEY_END, ARGP_KEY_ARG, error_t */
61
#include <signal.h> 		/* struct sigaction, sigemptyset(),
62
				   sigaddset(), sigaction(),
63
				   sigprocmask(), SIG_BLOCK, SIGCHLD,
64
				   SIG_UNBLOCK, kill() */
65
#include <errno.h>		/* errno, EBADF */
13 by Björn Påhlsson
Added following support:
66
37 by Teddy Hogeborn
Non-tested commit for merge purposes.
67
#define BUFFER_SIZE 256
24.1.52 by Björn Påhlsson
merge + minor adjustments
68
#define ARGFILE "/conf/conf.d/mandos/plugins.conf"
37 by Teddy Hogeborn
Non-tested commit for merge purposes.
69
74 by Teddy Hogeborn
* Makefile (PREFIX, CONFDIR): New.
70
const char *argp_program_version = "plugin-runner 1.0";
24.1.35 by Björn Påhlsson
version 1.0
71
const char *argp_program_bug_address = "<mandos@fukt.bsnet.se>";
72
13 by Björn Påhlsson
Added following support:
73
struct process;
74
75
typedef struct process{
76
  pid_t pid;
77
  int fd;
78
  char *buffer;
21 by Teddy Hogeborn
* Makefile (CFLAGS): Changed to use $(WARN), $(DEBUG), $(COVERAGE) and
79
  size_t buffer_size;
80
  size_t buffer_length;
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
81
  bool eof;
82
  bool completed;
83
  int status;
13 by Björn Påhlsson
Added following support:
84
  struct process *next;
85
} process;
86
24.1.1 by Björn Påhlsson
Added syntax and support for plugbasedclient arguments and how they
87
typedef struct plugin{
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
88
  char *name;			/* can be NULL or any plugin name */
24.1.1 by Björn Påhlsson
Added syntax and support for plugbasedclient arguments and how they
89
  char **argv;
90
  int argc;
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
91
  bool disabled;
24.1.1 by Björn Påhlsson
Added syntax and support for plugbasedclient arguments and how they
92
  struct plugin *next;
93
} plugin;
94
37 by Teddy Hogeborn
Non-tested commit for merge purposes.
95
static plugin *getplugin(char *name, plugin **plugin_list){
24.1.1 by Björn Påhlsson
Added syntax and support for plugbasedclient arguments and how they
96
  for (plugin *p = *plugin_list; p != NULL; p = p->next){
97
    if ((p->name == name)
98
	or (p->name and name and (strcmp(p->name, name) == 0))){
99
      return p;
100
    }
101
  }
102
  /* Create a new plugin */
103
  plugin *new_plugin = malloc(sizeof(plugin));
104
  if (new_plugin == NULL){
105
    perror("malloc");
106
    exit(EXIT_FAILURE);
107
  }
108
  new_plugin->name = name;
109
  new_plugin->argv = malloc(sizeof(char *) * 2);
110
  if (new_plugin->argv == NULL){
111
    perror("malloc");
112
    exit(EXIT_FAILURE);
113
  }
114
  new_plugin->argv[0] = name;
115
  new_plugin->argv[1] = NULL;
116
  new_plugin->argc = 1;
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
117
  new_plugin->disabled = false;
24.1.5 by Björn Påhlsson
plugbasedclient:
118
  new_plugin->next = *plugin_list;
24.1.1 by Björn Påhlsson
Added syntax and support for plugbasedclient arguments and how they
119
  /* Append the new plugin to the list */
120
  *plugin_list = new_plugin;
121
  return new_plugin;
122
}
123
37 by Teddy Hogeborn
Non-tested commit for merge purposes.
124
static void addargument(plugin *p, char *arg){
24.1.1 by Björn Påhlsson
Added syntax and support for plugbasedclient arguments and how they
125
  p->argv[p->argc] = arg;
126
  p->argv = realloc(p->argv, sizeof(char *) * (size_t)(p->argc + 2));
127
  if (p->argv == NULL){
128
    perror("malloc");
129
    exit(EXIT_FAILURE);
130
  }
131
  p->argc++;
132
  p->argv[p->argc] = NULL;
133
}
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
134
32 by Teddy Hogeborn
* plugins.d/plugbasedclient.c (set_cloexec_flag): New function.
135
/*
136
 * Based on the example in the GNU LibC manual chapter 13.13 "File
137
 * Descriptor Flags".
138
 * *Note File Descriptor Flags:(libc)Descriptor Flags.
139
 */
37 by Teddy Hogeborn
Non-tested commit for merge purposes.
140
static int set_cloexec_flag(int fd)
32 by Teddy Hogeborn
* plugins.d/plugbasedclient.c (set_cloexec_flag): New function.
141
{
142
  int ret = fcntl(fd, F_GETFD, 0);
143
  /* If reading the flags failed, return error indication now. */
144
  if(ret < 0){
145
    return ret;
146
  }
147
  /* Store modified flag word in the descriptor. */
148
  return fcntl(fd, F_SETFD, ret | FD_CLOEXEC);
149
}
150
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
151
process *process_list = NULL;
152
153
/* Mark a process as completed when it exits, and save its exit
154
   status. */
155
void handle_sigchld(__attribute__((unused)) int sig){
156
  process *proc = process_list;
157
  int status;
158
  pid_t pid = wait(&status);
24.1.26 by Björn Påhlsson
tally count of used symbols
159
  if(pid == -1){
160
    perror("wait");
161
    return;
162
  }
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
163
  while(proc != NULL and proc->pid != pid){
24.1.8 by Björn Påhlsson
plugbasedclient
164
    proc = proc->next;
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
165
  }
166
  if(proc == NULL){
167
    /* Process not found in process list */
168
    return;
169
  }
170
  proc->status = status;
171
  proc->completed = true;
172
}
24.1.1 by Björn Påhlsson
Added syntax and support for plugbasedclient arguments and how they
173
24.1.42 by Björn Påhlsson
Added fallback to mandos-client
174
bool print_out_password(const char *buffer, size_t length){
64 by Teddy Hogeborn
* mandos-client.c (print_out_password): Strip trailing '\n'.
175
  ssize_t ret;
176
  if(length>0 and buffer[length-1] == '\n'){
177
    length--;
178
  }
179
  for(size_t written = 0; written < length; written += (size_t)ret){
24.1.42 by Björn Påhlsson
Added fallback to mandos-client
180
    ret = TEMP_FAILURE_RETRY(write(STDOUT_FILENO, buffer + written,
181
				   length - written));
182
    if(ret < 0){
183
      return false;
184
    }
185
  }
186
  return true;
187
}
188
24.1.51 by Björn Påhlsson
Added configuration files support for mandos-client
189
char ** addcustomargument(char **argv, int *argc, char *arg){
190
191
  if (argv == NULL){
192
    *argc = 1;
193
    argv = malloc(sizeof(char*) * 2);
194
    if(argv == NULL){
195
      return NULL;
196
    }
197
    argv[0] = NULL; 	/* Will be set to argv[0] in main before parsing */
198
    argv[1] = NULL;
199
  }
200
  *argc += 1;
201
  argv = realloc(argv, sizeof(char *)
202
		  * ((unsigned int) *argc + 1));
203
  if(argv == NULL){
204
    return NULL;
205
  }
206
  argv[*argc-1] = arg;
207
  argv[*argc] = NULL;   
208
  return argv;
209
}
210
13 by Björn Påhlsson
Added following support:
211
int main(int argc, char *argv[]){
74 by Teddy Hogeborn
* Makefile (PREFIX, CONFDIR): New.
212
  const char *plugindir = "/lib/mandos/plugins.d";
24.1.52 by Björn Påhlsson
merge + minor adjustments
213
  const char *argfile = ARGFILE;
24.1.51 by Björn Påhlsson
Added configuration files support for mandos-client
214
  FILE *conffp;
24.1.5 by Björn Påhlsson
plugbasedclient:
215
  size_t d_name_len;
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
216
  DIR *dir = NULL;
13 by Björn Påhlsson
Added following support:
217
  struct dirent *dirst;
218
  struct stat st;
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
219
  fd_set rfds_all;
13 by Björn Påhlsson
Added following support:
220
  int ret, maxfd = 0;
24.1.6 by Björn Påhlsson
plugbasedclient
221
  uid_t uid = 65534;
222
  gid_t gid = 65534;
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
223
  bool debug = false;
224
  int exitstatus = EXIT_SUCCESS;
24.1.7 by Björn Påhlsson
merge
225
  struct sigaction old_sigchld_action;
226
  struct sigaction sigchld_action = { .sa_handler = handle_sigchld,
227
				      .sa_flags = SA_NOCLDSTOP };
24.1.51 by Björn Påhlsson
Added configuration files support for mandos-client
228
  char **custom_argv = NULL;
229
  int custom_argc = 0;
230
  
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
231
  /* Establish a signal handler */
232
  sigemptyset(&sigchld_action.sa_mask);
233
  ret = sigaddset(&sigchld_action.sa_mask, SIGCHLD);
234
  if(ret < 0){
235
    perror("sigaddset");
236
    exit(EXIT_FAILURE);
237
  }
238
  ret = sigaction(SIGCHLD, &sigchld_action, &old_sigchld_action);
239
  if(ret < 0){
240
    perror("sigaction");
241
    exit(EXIT_FAILURE);
242
  }
243
  
24.1.1 by Björn Påhlsson
Added syntax and support for plugbasedclient arguments and how they
244
  /* The options we understand. */
245
  struct argp_option options[] = {
246
    { .name = "global-options", .key = 'g',
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
247
      .arg = "OPTION[,OPTION[,...]]",
248
      .doc = "Options passed to all plugins" },
24.1.1 by Björn Påhlsson
Added syntax and support for plugbasedclient arguments and how they
249
    { .name = "options-for", .key = 'o',
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
250
      .arg = "PLUGIN:OPTION[,OPTION[,...]]",
251
      .doc = "Options passed only to specified plugin" },
252
    { .name = "disable", .key = 'd',
253
      .arg = "PLUGIN",
254
      .doc = "Disable a specific plugin", .group = 1 },
24.1.5 by Björn Påhlsson
plugbasedclient:
255
    { .name = "plugin-dir", .key = 128,
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
256
      .arg = "DIRECTORY",
257
      .doc = "Specify a different plugin directory", .group = 2 },
24.1.6 by Björn Påhlsson
plugbasedclient
258
    { .name = "userid", .key = 129,
24.1.7 by Björn Påhlsson
merge
259
      .arg = "ID", .flags = 0,
260
      .doc = "User ID the plugins will run as", .group = 2 },
24.1.6 by Björn Påhlsson
plugbasedclient
261
    { .name = "groupid", .key = 130,
24.1.7 by Björn Påhlsson
merge
262
      .arg = "ID", .flags = 0,
263
      .doc = "Group ID the plugins will run as", .group = 2 },
264
    { .name = "debug", .key = 131,
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
265
      .doc = "Debug mode", .group = 3 },
24.1.1 by Björn Påhlsson
Added syntax and support for plugbasedclient arguments and how they
266
    { .name = NULL }
267
  };
268
  
269
  error_t parse_opt (int key, char *arg, struct argp_state *state) {
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
270
    /* Get the INPUT argument from `argp_parse', which we know is a
271
       pointer to our plugin list pointer. */
24.1.1 by Björn Påhlsson
Added syntax and support for plugbasedclient arguments and how they
272
    plugin **plugins = state->input;
273
    switch (key) {
274
    case 'g':
275
      if (arg != NULL){
24.1.50 by Björn Påhlsson
changed from using strtok to strsep
276
	char *p;
277
	while((p = strsep(&arg, ",")) != NULL){
24.1.51 by Björn Påhlsson
Added configuration files support for mandos-client
278
	  if(p[0] == '\0'){
24.1.50 by Björn Påhlsson
changed from using strtok to strsep
279
	    continue;
280
	  }
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
281
	  addargument(getplugin(NULL, plugins), p);
24.1.50 by Björn Påhlsson
changed from using strtok to strsep
282
	}
24.1.1 by Björn Påhlsson
Added syntax and support for plugbasedclient arguments and how they
283
      }
284
      break;
285
    case 'o':
286
      if (arg != NULL){
24.1.50 by Björn Påhlsson
changed from using strtok to strsep
287
	char *name = strsep(&arg, ":");
24.1.51 by Björn Påhlsson
Added configuration files support for mandos-client
288
	if(name[0] == '\0'){
24.1.50 by Björn Påhlsson
changed from using strtok to strsep
289
	  break;
290
	}
291
	char *opt = strsep(&arg, ":");
24.1.51 by Björn Påhlsson
Added configuration files support for mandos-client
292
	if(opt[0] == '\0'){
24.1.50 by Björn Påhlsson
changed from using strtok to strsep
293
	  break;
294
	}
295
	if(opt != NULL){
296
	  char *p;
297
	  while((p = strsep(&opt, ",")) != NULL){
24.1.51 by Björn Påhlsson
Added configuration files support for mandos-client
298
	    if(p[0] == '\0'){
24.1.50 by Björn Påhlsson
changed from using strtok to strsep
299
	      continue;
300
	    }
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
301
	    addargument(getplugin(name, plugins), p);
24.1.50 by Björn Påhlsson
changed from using strtok to strsep
302
	  }
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
303
	}
24.1.1 by Björn Påhlsson
Added syntax and support for plugbasedclient arguments and how they
304
      }
305
      break;
24.1.5 by Björn Påhlsson
plugbasedclient:
306
    case 'd':
307
      if (arg != NULL){
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
308
	getplugin(arg, plugins)->disabled = true;
24.1.5 by Björn Påhlsson
plugbasedclient:
309
      }
310
      break;
311
    case 128:
312
      plugindir = arg;
313
      break;
24.1.6 by Björn Påhlsson
plugbasedclient
314
    case 129:
315
      uid = (uid_t)strtol(arg, NULL, 10);
316
      break;
317
    case 130:
318
      gid = (gid_t)strtol(arg, NULL, 10);
319
      break;
24.1.7 by Björn Påhlsson
merge
320
    case 131:
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
321
      debug = true;
322
      break;
24.1.1 by Björn Påhlsson
Added syntax and support for plugbasedclient arguments and how they
323
    case ARGP_KEY_ARG:
24.1.51 by Björn Påhlsson
Added configuration files support for mandos-client
324
      fprintf(stderr, "Ignoring unknown argument \"%s\"\n", arg); 
24.1.1 by Björn Påhlsson
Added syntax and support for plugbasedclient arguments and how they
325
      break;
326
    case ARGP_KEY_END:
327
      break;
328
    default:
329
      return ARGP_ERR_UNKNOWN;
330
    }
331
    return 0;
332
  }
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
333
  
24.1.1 by Björn Påhlsson
Added syntax and support for plugbasedclient arguments and how they
334
  plugin *plugin_list = NULL;
335
  
336
  struct argp argp = { .options = options, .parser = parse_opt,
24.1.8 by Björn Påhlsson
plugbasedclient
337
		       .args_doc = "[+PLUS_SEPARATED_OPTIONS]",
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
338
		       .doc = "Mandos plugin runner -- Run plugins" };
339
  
24.1.26 by Björn Påhlsson
tally count of used symbols
340
  ret = argp_parse (&argp, argc, argv, 0, 0, &plugin_list);
341
  if (ret == ARGP_ERR_UNKNOWN){
64 by Teddy Hogeborn
* mandos-client.c (print_out_password): Strip trailing '\n'.
342
    fprintf(stderr, "Unknown error while parsing arguments\n");
24.1.26 by Björn Påhlsson
tally count of used symbols
343
    exitstatus = EXIT_FAILURE;
344
    goto end;
345
  }
24.1.51 by Björn Påhlsson
Added configuration files support for mandos-client
346
24.1.52 by Björn Påhlsson
merge + minor adjustments
347
  conffp = fopen(argfile, "r");
24.1.51 by Björn Påhlsson
Added configuration files support for mandos-client
348
  if(conffp != NULL){
349
    char *org_line = NULL;
350
    size_t size = 0;
351
    ssize_t sret;
352
    char *p, *arg, *new_arg, *line;
353
    const char whitespace_delims[] = " \r\t\f\v\n";
354
    const char comment_delim[] = "#";
355
356
    while(true){
357
      sret = getline(&org_line, &size, conffp);
358
      if(sret == -1){
359
	break;
360
      }
361
362
      line = org_line;
363
      arg = strsep(&line, comment_delim);
364
      while((p = strsep(&arg, whitespace_delims)) != NULL){
365
	if(p[0] == '\0'){
366
	  continue;
367
	}
368
	new_arg = strdup(p);
369
	custom_argv = addcustomargument(custom_argv, &custom_argc, new_arg);
370
	if (custom_argv == NULL){
371
	  perror("addcustomargument");
372
	  exitstatus = EXIT_FAILURE;
373
	  goto end;
374
	}
375
      }
376
    }
377
    free(org_line);
378
  } else{
24.1.52 by Björn Påhlsson
merge + minor adjustments
379
    /* Check for harmful errors and go to fallback. Other errors might
380
       not affect opening plugins */
24.1.51 by Björn Påhlsson
Added configuration files support for mandos-client
381
    if (errno == EMFILE or errno == ENFILE or errno == ENOMEM){
382
      perror("fopen");
24.1.8 by Björn Påhlsson
plugbasedclient
383
      exitstatus = EXIT_FAILURE;
384
      goto end;
385
    }
24.1.51 by Björn Påhlsson
Added configuration files support for mandos-client
386
  }
387
388
  if(custom_argv != NULL){
389
    custom_argv[0] = argv[0];
390
    ret = argp_parse (&argp, custom_argc, custom_argv, 0, 0, &plugin_list);
24.1.26 by Björn Påhlsson
tally count of used symbols
391
    if (ret == ARGP_ERR_UNKNOWN){
64 by Teddy Hogeborn
* mandos-client.c (print_out_password): Strip trailing '\n'.
392
      fprintf(stderr, "Unknown error while parsing arguments\n");
24.1.26 by Björn Påhlsson
tally count of used symbols
393
      exitstatus = EXIT_FAILURE;
394
      goto end;
395
    }
24.1.8 by Björn Påhlsson
plugbasedclient
396
  }
397
  
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
398
  if(debug){
399
    for(plugin *p = plugin_list; p != NULL; p=p->next){
400
      fprintf(stderr, "Plugin: %s has %d arguments\n",
32 by Teddy Hogeborn
* plugins.d/plugbasedclient.c (set_cloexec_flag): New function.
401
	      p->name ? p->name : "Global", p->argc - 1);
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
402
      for(char **a = p->argv; *a != NULL; a++){
403
	fprintf(stderr, "\tArg: %s\n", *a);
404
      }
405
    }
406
  }
24.1.8 by Björn Påhlsson
plugbasedclient
407
  
24.1.6 by Björn Påhlsson
plugbasedclient
408
  ret = setuid(uid);
409
  if (ret == -1){
410
    perror("setuid");
411
  }
24.1.7 by Björn Påhlsson
merge
412
  
24.1.6 by Björn Påhlsson
plugbasedclient
413
  setgid(gid);
414
  if (ret == -1){
39 by Teddy Hogeborn
* plugins.d/mandosclient.c (pgp_packet_decrypt): Renamed variables.
415
    perror("setgid");
24.1.6 by Björn Påhlsson
plugbasedclient
416
  }
417
  
13 by Björn Påhlsson
Added following support:
418
  dir = opendir(plugindir);
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
419
  if(dir == NULL){
420
    perror("Could not open plugin dir");
421
    exitstatus = EXIT_FAILURE;
32 by Teddy Hogeborn
* plugins.d/plugbasedclient.c (set_cloexec_flag): New function.
422
    goto end;
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
423
  }
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
424
  
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
425
  /* Set the FD_CLOEXEC flag on the directory, if possible */
426
  {
427
    int dir_fd = dirfd(dir);
428
    if(dir_fd >= 0){
429
      ret = set_cloexec_flag(dir_fd);
430
      if(ret < 0){
431
	perror("set_cloexec_flag");
432
	exitstatus = EXIT_FAILURE;
433
	goto end;
434
      }
435
    }
436
  }
24.1.1 by Björn Påhlsson
Added syntax and support for plugbasedclient arguments and how they
437
  
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
438
  FD_ZERO(&rfds_all);
13 by Björn Påhlsson
Added following support:
439
  
440
  while(true){
441
    dirst = readdir(dir);
442
    
443
    // All directory entries have been processed
444
    if(dirst == NULL){
24.1.26 by Björn Påhlsson
tally count of used symbols
445
      if (errno == EBADF){
446
	perror("readdir");
447
	exitstatus = EXIT_FAILURE;
448
	goto end;
449
      }
13 by Björn Påhlsson
Added following support:
450
      break;
451
    }
452
    
453
    d_name_len = strlen(dirst->d_name);
454
    
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
455
    // Ignore dotfiles, backup files and other junk
456
    {
457
      bool bad_name = false;
458
      
459
      const char const *bad_prefixes[] = { ".", "#", NULL };
460
      
461
      const char const *bad_suffixes[] = { "~", "#", ".dpkg-new",
462
					   ".dpkg-old",
463
					   ".dpkg-divert", NULL };
464
      for(const char **pre = bad_prefixes; *pre != NULL; pre++){
465
	size_t pre_len = strlen(*pre);
466
	if((d_name_len >= pre_len)
467
	   and strncmp((dirst->d_name), *pre, pre_len) == 0){
468
	  if(debug){
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
469
	    fprintf(stderr, "Ignoring plugin dir entry \"%s\""
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
470
		    " with bad prefix %s\n", dirst->d_name, *pre);
471
	  }
472
	  bad_name = true;
473
	  break;
474
	}
475
      }
476
      
477
      if(bad_name){
478
	continue;
479
      }
480
      
481
      for(const char **suf = bad_suffixes; *suf != NULL; suf++){
482
	size_t suf_len = strlen(*suf);
483
	if((d_name_len >= suf_len)
484
	   and (strcmp((dirst->d_name)+d_name_len-suf_len, *suf)
485
		== 0)){
486
	  if(debug){
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
487
	    fprintf(stderr, "Ignoring plugin dir entry \"%s\""
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
488
		    " with bad suffix %s\n", dirst->d_name, *suf);
489
	  }
490
	  bad_name = true;
491
	  break;
492
	}
493
      }
494
      
495
      if(bad_name){
496
	continue;
497
      }
13 by Björn Påhlsson
Added following support:
498
    }
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
499
    
24.1.5 by Björn Påhlsson
plugbasedclient:
500
    char *filename = malloc(d_name_len + strlen(plugindir) + 2);
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
501
    if (filename == NULL){
502
      perror("malloc");
24.1.46 by Björn Påhlsson
mandos-client
503
      continue;
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
504
    }
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
505
    strcpy(filename, plugindir); /* Spurious warning */
506
    strcat(filename, "/");	/* Spurious warning */
507
    strcat(filename, dirst->d_name); /* Spurious warning */
508
    
24.1.26 by Björn Påhlsson
tally count of used symbols
509
    ret = stat(filename, &st);
510
    if (ret == -1){
511
      perror("stat");
24.1.46 by Björn Påhlsson
mandos-client
512
      free(filename);
513
      continue;
24.1.26 by Björn Påhlsson
tally count of used symbols
514
    }
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
515
    
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
516
    if (not S_ISREG(st.st_mode)	or (access(filename, X_OK) != 0)){
517
      if(debug){
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
518
	fprintf(stderr, "Ignoring plugin dir entry \"%s\""
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
519
		" with bad type or mode\n", filename);
520
      }
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
521
      free(filename);
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
522
      continue;
523
    }
524
    if(getplugin(dirst->d_name, &plugin_list)->disabled){
525
      if(debug){
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
526
	fprintf(stderr, "Ignoring disabled plugin \"%s\"\n",
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
527
		dirst->d_name);
528
      }
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
529
      free(filename);
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
530
      continue;
531
    }
32 by Teddy Hogeborn
* plugins.d/plugbasedclient.c (set_cloexec_flag): New function.
532
    plugin *p = getplugin(dirst->d_name, &plugin_list);
533
    {
534
      /* Add global arguments to argument list for this plugin */
535
      plugin *g = getplugin(NULL, &plugin_list);
536
      for(char **a = g->argv + 1; *a != NULL; a++){
537
	addargument(p, *a);
538
      }
539
    }
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
540
    int pipefd[2]; 
541
    ret = pipe(pipefd);
542
    if (ret == -1){
543
      perror("pipe");
544
      exitstatus = EXIT_FAILURE;
545
      goto end;
546
    }
547
    ret = set_cloexec_flag(pipefd[0]);
548
    if(ret < 0){
549
      perror("set_cloexec_flag");
550
      exitstatus = EXIT_FAILURE;
551
      goto end;
552
    }
553
    ret = set_cloexec_flag(pipefd[1]);
554
    if(ret < 0){
555
      perror("set_cloexec_flag");
556
      exitstatus = EXIT_FAILURE;
557
      goto end;
558
    }
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
559
    /* Block SIGCHLD until process is safely in process list */
560
    ret = sigprocmask (SIG_BLOCK, &sigchld_action.sa_mask, NULL);
561
    if(ret < 0){
562
      perror("sigprocmask");
563
      exitstatus = EXIT_FAILURE;
564
      goto end;
565
    }
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
566
    // Starting a new process to be watched
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
567
    pid_t pid = fork();
24.1.46 by Björn Påhlsson
mandos-client
568
    if(pid == -1){
569
      perror("fork");
570
      exitstatus = EXIT_FAILURE;
571
      goto end;
572
    }
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
573
    if(pid == 0){
574
      /* this is the child process */
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
575
      ret = sigaction(SIGCHLD, &old_sigchld_action, NULL);
576
      if(ret < 0){
577
	perror("sigaction");
578
	_exit(EXIT_FAILURE);
579
      }
580
      ret = sigprocmask (SIG_UNBLOCK, &sigchld_action.sa_mask, NULL);
581
      if(ret < 0){
582
	perror("sigprocmask");
583
	_exit(EXIT_FAILURE);
584
      }
24.1.26 by Björn Påhlsson
tally count of used symbols
585
586
      ret = dup2(pipefd[1], STDOUT_FILENO); /* replace our stdout */
587
      if(ret == -1){
588
	perror("dup2");
589
	_exit(EXIT_FAILURE);
590
      }
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
591
      
592
      if(dirfd(dir) < 0){
593
	/* If dir has no file descriptor, we could not set FD_CLOEXEC
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
594
	   above and must now close it manually here. */
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
595
	closedir(dir);
33 by Teddy Hogeborn
* plugins.d/plugbasedclient.c (main): Close the pipe fd after dup2:ing
596
      }
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
597
      if(execv(filename, p->argv) < 0){
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
598
	perror("execv");
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
599
	_exit(EXIT_FAILURE);
600
      }
601
      /* no return */
602
    }
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
603
    /* parent process */
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
604
    free(filename);
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
605
    close(pipefd[1]);		/* close unused write end of pipe */
606
    process *new_process = malloc(sizeof(process));
607
    if (new_process == NULL){
608
      perror("malloc");
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
609
      ret = sigprocmask (SIG_UNBLOCK, &sigchld_action.sa_mask, NULL);
610
      if(ret < 0){
611
	perror("sigprocmask");
612
      }
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
613
      exitstatus = EXIT_FAILURE;
614
      goto end;
615
    }
616
    
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
617
    *new_process = (struct process){ .pid = pid,
618
				     .fd = pipefd[0],
619
				     .next = process_list };
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
620
    // List handling
621
    process_list = new_process;
622
    /* Unblock SIGCHLD so signal handler can be run if this process
623
       has already completed */
624
    ret = sigprocmask (SIG_UNBLOCK, &sigchld_action.sa_mask, NULL);
625
    if(ret < 0){
626
      perror("sigprocmask");
627
      exitstatus = EXIT_FAILURE;
628
      goto end;
629
    }
630
    
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
631
    FD_SET(new_process->fd, &rfds_all);
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
632
    
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
633
    if (maxfd < new_process->fd){
634
      maxfd = new_process->fd;
635
    }
636
    
13 by Björn Påhlsson
Added following support:
637
  }
638
  
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
639
  /* Free the plugin list */
640
  for(plugin *next; plugin_list != NULL; plugin_list = next){
641
    next = plugin_list->next;
642
    free(plugin_list->argv);
643
    free(plugin_list);
644
  }
645
  
13 by Björn Påhlsson
Added following support:
646
  closedir(dir);
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
647
  dir = NULL;
24.1.26 by Björn Påhlsson
tally count of used symbols
648
    
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
649
  if (process_list == NULL){
24.1.42 by Björn Påhlsson
Added fallback to mandos-client
650
    fprintf(stderr, "No plugin processes started. Incorrect plugin"
651
	    " directory?\n");
652
    process_list = NULL;
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
653
  }
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
654
  while(process_list){
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
655
    fd_set rfds = rfds_all;
656
    int select_ret = select(maxfd+1, &rfds, NULL, NULL, NULL);
657
    if (select_ret == -1){
658
      perror("select");
659
      exitstatus = EXIT_FAILURE;
660
      goto end;
661
    }
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
662
    /* OK, now either a process completed, or something can be read
663
       from one of them */
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
664
    for(process *proc = process_list; proc ; proc = proc->next){
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
665
      /* Is this process completely done? */
666
      if(proc->eof and proc->completed){
667
	/* Only accept the plugin output if it exited cleanly */
668
	if(not WIFEXITED(proc->status)
669
	   or WEXITSTATUS(proc->status) != 0){
670
	  /* Bad exit by plugin */
671
	  if(debug){
672
	    if(WIFEXITED(proc->status)){
60 by Teddy Hogeborn
* mandos-client.c (main): Cast pid_t to unsigned int before printing.
673
	      fprintf(stderr, "Plugin %u exited with status %d\n",
674
		      (unsigned int) (proc->pid),
675
		      WEXITSTATUS(proc->status));
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
676
	    } else if(WIFSIGNALED(proc->status)) {
60 by Teddy Hogeborn
* mandos-client.c (main): Cast pid_t to unsigned int before printing.
677
	      fprintf(stderr, "Plugin %u killed by signal %d\n",
678
		      (unsigned int) (proc->pid),
679
		      WTERMSIG(proc->status));
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
680
	    } else if(WCOREDUMP(proc->status)){
60 by Teddy Hogeborn
* mandos-client.c (main): Cast pid_t to unsigned int before printing.
681
	      fprintf(stderr, "Plugin %d dumped core\n",
682
		      (unsigned int) (proc->pid));
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
683
	    }
684
	  }
685
	  /* Remove the plugin */
686
	  FD_CLR(proc->fd, &rfds_all);
687
	  /* Block signal while modifying process_list */
688
	  ret = sigprocmask (SIG_BLOCK, &sigchld_action.sa_mask, NULL);
689
	  if(ret < 0){
690
	    perror("sigprocmask");
691
	    exitstatus = EXIT_FAILURE;
692
	    goto end;
693
	  }
694
	  /* Delete this process entry from the list */
695
	  if(process_list == proc){
696
	    /* First one - simple */
697
	    process_list = proc->next;
698
	  } else {
699
	    /* Second one or later */
700
	    for(process *p = process_list; p != NULL; p = p->next){
701
	      if(p->next == proc){
702
		p->next = proc->next;
703
		break;
704
	      }
705
	    }
706
	  }
707
	  /* We are done modifying process list, so unblock signal */
708
	  ret = sigprocmask (SIG_UNBLOCK, &sigchld_action.sa_mask,
709
			     NULL);
710
	  if(ret < 0){
711
	    perror("sigprocmask");
712
	  }
713
	  free(proc->buffer);
714
	  free(proc);
715
	  /* We deleted this process from the list, so we can't go
716
	     proc->next.  Therefore, start over from the beginning of
717
	     the process list */
718
	  break;
719
	}
720
	/* This process exited nicely, so print its buffer */
24.1.42 by Björn Påhlsson
Added fallback to mandos-client
721
722
	bool bret = print_out_password(proc->buffer, proc->buffer_length);
723
	if(not bret){
724
	  perror("print_out_password");
725
	  exitstatus = EXIT_FAILURE;
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
726
	}
727
	goto end;
728
      }
729
      /* This process has not completed.  Does it have any output? */
730
      if(proc->eof or not FD_ISSET(proc->fd, &rfds)){
731
	/* This process had nothing to say at this time */
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
732
	continue;
733
      }
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
734
      /* Before reading, make the process' data buffer large enough */
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
735
      if(proc->buffer_length + BUFFER_SIZE > proc->buffer_size){
736
	proc->buffer = realloc(proc->buffer, proc->buffer_size
737
			       + (size_t) BUFFER_SIZE);
738
	if (proc->buffer == NULL){
739
	  perror("malloc");
740
	  exitstatus = EXIT_FAILURE;
741
	  goto end;
742
	}
743
	proc->buffer_size += BUFFER_SIZE;
744
      }
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
745
      /* Read from the process */
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
746
      ret = read(proc->fd, proc->buffer + proc->buffer_length,
747
		 BUFFER_SIZE);
748
      if(ret < 0){
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
749
	/* Read error from this process; ignore the error */
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
750
	continue;
751
      }
752
      if(ret == 0){
753
	/* got EOF */
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
754
	proc->eof = true;
755
      } else {
756
	proc->buffer_length += (size_t) ret;
13 by Björn Påhlsson
Added following support:
757
      }
758
    }
759
  }
24.1.45 by Björn Påhlsson
Fixed fallback on error in mandos-client
760
761
762
 end:
24.1.42 by Björn Påhlsson
Added fallback to mandos-client
763
  
24.1.45 by Björn Påhlsson
Fixed fallback on error in mandos-client
764
  if(process_list == NULL or exitstatus != EXIT_SUCCESS){
24.1.46 by Björn Påhlsson
mandos-client
765
    /* Fallback if all plugins failed, none are found or an error occured */
24.1.42 by Björn Påhlsson
Added fallback to mandos-client
766
    bool bret;
767
    fprintf(stderr, "Going to fallback mode using getpass(3)\n");
768
    char *passwordbuffer = getpass("Password: ");
769
    bret = print_out_password(passwordbuffer, strlen(passwordbuffer));
770
    if(not bret){
771
      perror("print_out_password");
772
      exitstatus = EXIT_FAILURE;
773
      goto end;
774
    }
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
775
  }
24.1.42 by Björn Påhlsson
Added fallback to mandos-client
776
  
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
777
  /* Restore old signal handler */
778
  sigaction(SIGCHLD, &old_sigchld_action, NULL);
779
  
24.1.51 by Björn Påhlsson
Added configuration files support for mandos-client
780
  free(custom_argv);
24.1.8 by Björn Påhlsson
plugbasedclient
781
  
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
782
  /* Free the plugin list */
783
  for(plugin *next; plugin_list != NULL; plugin_list = next){
784
    next = plugin_list->next;
785
    free(plugin_list->argv);
786
    free(plugin_list);
787
  }
788
  
789
  if(dir != NULL){
790
    closedir(dir);
791
  }
792
  
793
  /* Free the process list and kill the processes */
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
794
  for(process *next; process_list != NULL; process_list = next){
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
795
    next = process_list->next;
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
796
    close(process_list->fd);
24.1.26 by Björn Påhlsson
tally count of used symbols
797
    ret = kill(process_list->pid, SIGTERM);
798
    if(ret == -1 and errno != ESRCH){
799
      /* set-uid proccesses migth not get closed */
800
      perror("kill");
801
    }
34 by Teddy Hogeborn
* plugbasedclient.c (main): Check if plugin dir could be opened. Set
802
    free(process_list->buffer);
803
    free(process_list);
13 by Björn Påhlsson
Added following support:
804
  }
805
  
35 by Teddy Hogeborn
* plugbasedclient.c (struct process): New fields "eof", "completed",
806
  /* Wait for any remaining child processes to terminate */
807
  do{
808
    ret = wait(NULL);
809
  } while(ret >= 0);
810
  if(errno != ECHILD){
811
    perror("wait");
812
  }
813
  
31 by Teddy Hogeborn
* plugins.d/plugbasedclient.c: Update include file comments.
814
  return exitstatus;
13 by Björn Påhlsson
Added following support:
815
}