Package: mandos
Severity: minor
Usertags: clang-ftbfs
User: [email protected]
Tag: patch


Hello,

Using the rebuild infrastructure, your package fails to build with clang
(instead of gcc).

Thanks,
Arthur
diff -Naur mandos.orig/mandos-1.6.5/debian/changelog mandos/mandos-1.6.5/debian/changelog
--- mandos.orig/mandos-1.6.5/debian/changelog	2014-06-03 19:23:38.775550983 -0500
+++ mandos/mandos-1.6.5/debian/changelog	2014-06-03 20:35:00.211625542 -0500
@@ -1,3 +1,13 @@
+mandos (1.6.5-3) unstable; urgency=low
+
+  * Fix FTBFS with clang:
+    - Fixed "function declaration not allowed" in
+      plugin-runner.c
+      plugins.d/mandos-client.c
+      plugins.d/password-prompt.c
+
+ -- Arthur Marble <[email protected]>  Tue, 03 Jun 2014 20:35:00 -0500
+
 mandos (1.6.5-2) unstable; urgency=medium
 
   * debian/rules (override_dh_auto_test-arch): New; does nothing.  Fixes
diff -Naur mandos.orig/mandos-1.6.5/debian/patches/clang-ftbfs.diff mandos/mandos-1.6.5/debian/patches/clang-ftbfs.diff 
--- mandos.orig/mandos-1.6.5/debian/patches/clang-ftbfs.diff	1969-12-31 18:00:00.000000000 -0600
+++ mandos/mandos-1.6.5/debian/patches/clang-ftbfs.diff	2014-06-03 20:45:29.595636503 -0500
@@ -0,0 +1,923 @@
+--- a/plugin-runner.c
++++ b/plugin-runner.c
+@@ -344,6 +344,193 @@ static void free_plugin_list(void){
+   }
+ }
+ 
++__attribute__((nonnull(3)))
++static error_t parse_opt(int key, char *arg, struct argp_state *state, char *plugindir,
++	          uid_t uid, gid_t gid, bool debug){
++  errno = 0;
++  switch(key){
++    char *tmp;
++    intmax_t tmp_id;
++  case 'g': 			/* --global-options */
++    {
++      char *plugin_option;
++      while((plugin_option = strsep(&arg, ",")) != NULL){
++	if(not add_argument(getplugin(NULL), plugin_option)){
++	  break;
++	}
++      }
++      errno = 0;
++    }
++    break;
++  case 'G':			/* --global-env */
++    if(add_environment(getplugin(NULL), arg, true)){
++      errno = 0;
++    }
++    break;
++  case 'o':			/* --options-for */
++    {
++      char *option_list = strchr(arg, ':');
++      if(option_list == NULL){
++	argp_error(state, "No colon in \"%s\"", arg);
++	errno = EINVAL;
++	break;
++      }
++      *option_list = '\0';
++      option_list++;
++      if(arg[0] == '\0'){
++	argp_error(state, "Empty plugin name");
++	errno = EINVAL;
++	break;
++      }
++      char *option;
++      while((option = strsep(&option_list, ",")) != NULL){
++	if(not add_argument(getplugin(arg), option)){
++	  break;
++	}
++      }
++      errno = 0;
++    }
++    break;
++  case 'E':			/* --env-for */
++    {
++      char *envdef = strchr(arg, ':');
++      if(envdef == NULL){
++	argp_error(state, "No colon in \"%s\"", arg);
++	errno = EINVAL;
++	break;
++      }
++      *envdef = '\0';
++      envdef++;
++      if(arg[0] == '\0'){
++	argp_error(state, "Empty plugin name");
++	errno = EINVAL;
++	break;
++      }
++      if(add_environment(getplugin(arg), envdef, true)){
++	errno = 0;
++      }
++    }
++    break;
++  case 'd':			/* --disable */
++    {
++      plugin *p = getplugin(arg);
++      if(p != NULL){
++	p->disabled = true;
++	errno = 0;
++      }
++    }
++    break;
++  case 'e':			/* --enable */
++    {
++      plugin *p = getplugin(arg);
++      if(p != NULL){
++	p->disabled = false;
++	errno = 0;
++      }
++    }
++    break;
++  case 128:			/* --plugin-dir */
++    free(plugindir);
++    plugindir = strdup(arg);
++    if(plugindir != NULL){
++      errno = 0;
++    }
++    break;
++  case 129:			/* --config-file */
++    /* This is already done by parse_opt_config_file() */
++    break;
++  case 130:			/* --userid */
++    tmp_id = strtoimax(arg, &tmp, 10);
++    if(errno != 0 or tmp == arg or *tmp != '\0'
++       or tmp_id != (uid_t)tmp_id){
++      argp_error(state, "Bad user ID number: \"%s\", using %"
++		 PRIdMAX, arg, (intmax_t)uid);
++      break;
++    }
++    uid = (uid_t)tmp_id;
++    errno = 0;
++    break;
++  case 131:			/* --groupid */
++    tmp_id = strtoimax(arg, &tmp, 10);
++    if(errno != 0 or tmp == arg or *tmp != '\0'
++       or tmp_id != (gid_t)tmp_id){
++      argp_error(state, "Bad group ID number: \"%s\", using %"
++		 PRIdMAX, arg, (intmax_t)gid);
++      break;
++    }
++    gid = (gid_t)tmp_id;
++    errno = 0;
++    break;
++  case 132:			/* --debug */
++    debug = true;
++    break;
++    /*
++     * These reproduce what we would get without ARGP_NO_HELP
++     */
++  case '?':			/* --help */
++    state->flags &= ~(unsigned int)ARGP_NO_EXIT; /* force exit */
++    argp_state_help(state, state->out_stream, ARGP_HELP_STD_HELP);
++  case -3:			/* --usage */
++    state->flags &= ~(unsigned int)ARGP_NO_EXIT; /* force exit */
++    argp_state_help(state, state->out_stream,
++		      ARGP_HELP_USAGE | ARGP_HELP_EXIT_OK);
++  case 'V':			/* --version */
++    fprintf(state->out_stream, "%s\n", argp_program_version);
++    exit(EXIT_SUCCESS);
++    break;
++/*
++ * When adding more options before this line, remember to also add a
++ * "case" to the "parse_opt_config_file" function below.
++ */
++  case ARGP_KEY_ARG:
++    /* Cryptsetup always passes an argument, which is an empty
++       string if "none" was specified in /etc/crypttab.  So if
++       argument was empty, we ignore it silently. */
++    if(arg[0] == '\0'){
++      break;
++    }
++  default:
++    return ARGP_ERR_UNKNOWN;
++  }
++  return errno;		/* Set to 0 at start */
++}
++
++/* This option parser is the same as parse_opt() above, except it
++   ignores everything but the --config-file option. */
++static error_t parse_opt_config_file(int key, char *arg,
++			      __attribute__((unused))
++			      struct argp_state *state, char *argfile){
++  errno = 0;
++  switch(key){
++  case 'g': 			/* --global-options */
++  case 'G':			/* --global-env */
++  case 'o':			/* --options-for */
++  case 'E':			/* --env-for */
++  case 'd':			/* --disable */
++  case 'e':			/* --enable */
++  case 128:			/* --plugin-dir */
++    break;
++  case 129:			/* --config-file */
++    free(argfile);
++    argfile = strdup(arg);
++    if(argfile != NULL){
++      errno = 0;
++    }
++    break;
++  case 130:			/* --userid */
++  case 131:			/* --groupid */
++  case 132:			/* --debug */
++  case '?':			/* --help */
++  case -3:			/* --usage */
++  case 'V':			/* --version */
++  case ARGP_KEY_ARG:
++    break;
++  default:
++    return ARGP_ERR_UNKNOWN;
++  }
++  return errno;
++}
++
+ int main(int argc, char *argv[]){
+   char *plugindir = NULL;
+   char *argfile = NULL;
+@@ -426,192 +613,6 @@ int main(int argc, char *argv[]){
+     { .name = NULL }
+   };
+   
+-  __attribute__((nonnull(3)))
+-  error_t parse_opt(int key, char *arg, struct argp_state *state){
+-    errno = 0;
+-    switch(key){
+-      char *tmp;
+-      intmax_t tmp_id;
+-    case 'g': 			/* --global-options */
+-      {
+-	char *plugin_option;
+-	while((plugin_option = strsep(&arg, ",")) != NULL){
+-	  if(not add_argument(getplugin(NULL), plugin_option)){
+-	    break;
+-	  }
+-	}
+-	errno = 0;
+-      }
+-      break;
+-    case 'G':			/* --global-env */
+-      if(add_environment(getplugin(NULL), arg, true)){
+-	errno = 0;
+-      }
+-      break;
+-    case 'o':			/* --options-for */
+-      {
+-	char *option_list = strchr(arg, ':');
+-	if(option_list == NULL){
+-	  argp_error(state, "No colon in \"%s\"", arg);
+-	  errno = EINVAL;
+-	  break;
+-	}
+-	*option_list = '\0';
+-	option_list++;
+-	if(arg[0] == '\0'){
+-	  argp_error(state, "Empty plugin name");
+-	  errno = EINVAL;
+-	  break;
+-	}
+-	char *option;
+-	while((option = strsep(&option_list, ",")) != NULL){
+-	  if(not add_argument(getplugin(arg), option)){
+-	    break;
+-	  }
+-	}
+-	errno = 0;
+-      }
+-      break;
+-    case 'E':			/* --env-for */
+-      {
+-	char *envdef = strchr(arg, ':');
+-	if(envdef == NULL){
+-	  argp_error(state, "No colon in \"%s\"", arg);
+-	  errno = EINVAL;
+-	  break;
+-	}
+-	*envdef = '\0';
+-	envdef++;
+-	if(arg[0] == '\0'){
+-	  argp_error(state, "Empty plugin name");
+-	  errno = EINVAL;
+-	  break;
+-	}
+-	if(add_environment(getplugin(arg), envdef, true)){
+-	  errno = 0;
+-	}
+-      }
+-      break;
+-    case 'd':			/* --disable */
+-      {
+-	plugin *p = getplugin(arg);
+-	if(p != NULL){
+-	  p->disabled = true;
+-	  errno = 0;
+-	}
+-      }
+-      break;
+-    case 'e':			/* --enable */
+-      {
+-	plugin *p = getplugin(arg);
+-	if(p != NULL){
+-	  p->disabled = false;
+-	  errno = 0;
+-	}
+-      }
+-      break;
+-    case 128:			/* --plugin-dir */
+-      free(plugindir);
+-      plugindir = strdup(arg);
+-      if(plugindir != NULL){
+-	errno = 0;
+-      }
+-      break;
+-    case 129:			/* --config-file */
+-      /* This is already done by parse_opt_config_file() */
+-      break;
+-    case 130:			/* --userid */
+-      tmp_id = strtoimax(arg, &tmp, 10);
+-      if(errno != 0 or tmp == arg or *tmp != '\0'
+-	 or tmp_id != (uid_t)tmp_id){
+-	argp_error(state, "Bad user ID number: \"%s\", using %"
+-		   PRIdMAX, arg, (intmax_t)uid);
+-	break;
+-      }
+-      uid = (uid_t)tmp_id;
+-      errno = 0;
+-      break;
+-    case 131:			/* --groupid */
+-      tmp_id = strtoimax(arg, &tmp, 10);
+-      if(errno != 0 or tmp == arg or *tmp != '\0'
+-	 or tmp_id != (gid_t)tmp_id){
+-	argp_error(state, "Bad group ID number: \"%s\", using %"
+-		   PRIdMAX, arg, (intmax_t)gid);
+-	break;
+-      }
+-      gid = (gid_t)tmp_id;
+-      errno = 0;
+-      break;
+-    case 132:			/* --debug */
+-      debug = true;
+-      break;
+-      /*
+-       * These reproduce what we would get without ARGP_NO_HELP
+-       */
+-    case '?':			/* --help */
+-      state->flags &= ~(unsigned int)ARGP_NO_EXIT; /* force exit */
+-      argp_state_help(state, state->out_stream, ARGP_HELP_STD_HELP);
+-    case -3:			/* --usage */
+-      state->flags &= ~(unsigned int)ARGP_NO_EXIT; /* force exit */
+-      argp_state_help(state, state->out_stream,
+-		      ARGP_HELP_USAGE | ARGP_HELP_EXIT_OK);
+-    case 'V':			/* --version */
+-      fprintf(state->out_stream, "%s\n", argp_program_version);
+-      exit(EXIT_SUCCESS);
+-      break;
+-/*
+- * When adding more options before this line, remember to also add a
+- * "case" to the "parse_opt_config_file" function below.
+- */
+-    case ARGP_KEY_ARG:
+-      /* Cryptsetup always passes an argument, which is an empty
+-	 string if "none" was specified in /etc/crypttab.  So if
+-	 argument was empty, we ignore it silently. */
+-      if(arg[0] == '\0'){
+-	break;
+-      }
+-    default:
+-      return ARGP_ERR_UNKNOWN;
+-    }
+-    return errno;		/* Set to 0 at start */
+-  }
+-  
+-  /* This option parser is the same as parse_opt() above, except it
+-     ignores everything but the --config-file option. */
+-  error_t parse_opt_config_file(int key, char *arg,
+-				__attribute__((unused))
+-				struct argp_state *state){
+-    errno = 0;
+-    switch(key){
+-    case 'g': 			/* --global-options */
+-    case 'G':			/* --global-env */
+-    case 'o':			/* --options-for */
+-    case 'E':			/* --env-for */
+-    case 'd':			/* --disable */
+-    case 'e':			/* --enable */
+-    case 128:			/* --plugin-dir */
+-      break;
+-    case 129:			/* --config-file */
+-      free(argfile);
+-      argfile = strdup(arg);
+-      if(argfile != NULL){
+-	errno = 0;
+-      }
+-      break;
+-    case 130:			/* --userid */
+-    case 131:			/* --groupid */
+-    case 132:			/* --debug */
+-    case '?':			/* --help */
+-    case -3:			/* --usage */
+-    case 'V':			/* --version */
+-    case ARGP_KEY_ARG:
+-      break;
+-    default:
+-      return ARGP_ERR_UNKNOWN;
+-    }
+-    return errno;
+-  }
+-  
+   struct argp argp = { .options = options,
+ 		       .parser = parse_opt_config_file,
+ 		       .args_doc = "",
+--- a/plugins.d/password-prompt.c
++++ b/plugins.d/password-prompt.c
+@@ -103,111 +103,112 @@ static void termination_handler(int sign
+   signal_received = signum;
+ }
+ 
+-bool conflict_detection(void){
++__attribute__((nonnull))
++static int is_plymouth(const struct dirent *proc_entry){
++  int ret;
++  int cl_fd;
++  {
++    uintmax_t proc_id;
++    char *tmp;
++    errno = 0;
++    proc_id = strtoumax(proc_entry->d_name, &tmp, 10);
+ 
+-  /* plymouth conflicts with password-prompt since both want to read
+-     from the terminal.  Password-prompt will exit if it detects
+-     plymouth since plymouth performs the same functionality.
+-   */
+-  __attribute__((nonnull))
+-  int is_plymouth(const struct dirent *proc_entry){
+-    int ret;
+-    int cl_fd;
+-    {
+-      uintmax_t proc_id;
+-      char *tmp;
+-      errno = 0;
+-      proc_id = strtoumax(proc_entry->d_name, &tmp, 10);
+-      
+-      if(errno != 0 or *tmp != '\0'
+-	 or proc_id != (uintmax_t)((pid_t)proc_id)){
+-	return 0;
+-      }
+-    }
+-    
+-    char *cmdline_filename;
+-    ret = asprintf(&cmdline_filename, "/proc/%s/cmdline",
+-		   proc_entry->d_name);
+-    if(ret == -1){
+-      error_plus(0, errno, "asprintf");
++    if(errno != 0 or *tmp != '\0'
++       or proc_id != (uintmax_t)((pid_t)proc_id)){
+       return 0;
+     }
++  }
+     
+-    /* Open /proc/<pid>/cmdline */
+-    cl_fd = open(cmdline_filename, O_RDONLY);
+-    free(cmdline_filename);
+-    if(cl_fd == -1){
+-      if(errno != ENOENT){
+-	error_plus(0, errno, "open");
+-      }
+-      return 0;
++  char *cmdline_filename;
++  ret = asprintf(&cmdline_filename, "/proc/%s/cmdline",
++		 proc_entry->d_name);
++  if(ret == -1){
++    error_plus(0, errno, "asprintf");
++    return 0;
++  }
++
++  /* Open /proc/<pid>/cmdline */
++  cl_fd = open(cmdline_filename, O_RDONLY);
++  free(cmdline_filename);
++  if(cl_fd == -1){
++    if(errno != ENOENT){
++      error_plus(0, errno, "open");
+     }
+-    
+-    char *cmdline = NULL;
+-    {
+-      size_t cmdline_len = 0;
+-      size_t cmdline_allocated = 0;
+-      char *tmp;
+-      const size_t blocksize = 1024;
+-      ssize_t sret;
+-      do {
+-	/* Allocate more space? */
+-	if(cmdline_len + blocksize + 1 > cmdline_allocated){
+-	  tmp = realloc(cmdline, cmdline_allocated + blocksize + 1);
+-	  if(tmp == NULL){
+-	    error_plus(0, errno, "realloc");
+-	    free(cmdline);
+-	    close(cl_fd);
+-	    return 0;
+-	  }
+-	  cmdline = tmp;
+-	  cmdline_allocated += blocksize;
+-	}
+-	
+-	/* Read data */
+-	sret = read(cl_fd, cmdline + cmdline_len,
+-		    cmdline_allocated - cmdline_len);
+-	if(sret == -1){
+-	  error_plus(0, errno, "read");
++    return 0;
++  }
++
++  char *cmdline = NULL;
++  {
++    size_t cmdline_len = 0;
++    size_t cmdline_allocated = 0;
++    char *tmp;
++    const size_t blocksize = 1024;
++    ssize_t sret;
++    do {
++      /* Allocate more space? */
++      if(cmdline_len + blocksize + 1 > cmdline_allocated){
++	tmp = realloc(cmdline, cmdline_allocated + blocksize + 1);
++	if(tmp == NULL){
++	  error_plus(0, errno, "realloc");
+ 	  free(cmdline);
+ 	  close(cl_fd);
+ 	  return 0;
+ 	}
+-	cmdline_len += (size_t)sret;
+-      } while(sret != 0);
+-      ret = close(cl_fd);
+-      if(ret == -1){
+-	error_plus(0, errno, "close");
++	cmdline = tmp;
++	cmdline_allocated += blocksize;
++      }
++
++      /* Read data */
++      sret = read(cl_fd, cmdline + cmdline_len,
++		  cmdline_allocated - cmdline_len);
++      if(sret == -1){
++	error_plus(0, errno, "read");
+ 	free(cmdline);
++	close(cl_fd);
+ 	return 0;
+       }
+-      cmdline[cmdline_len] = '\0'; /* Make sure it is terminated */
+-    }
+-    /* we now have cmdline */
+-    
+-    /* get basename */
+-    char *cmdline_base = strrchr(cmdline, '/');
+-    if(cmdline_base != NULL){
+-      cmdline_base += 1;		/* skip the slash */
+-    } else {
+-      cmdline_base = cmdline;
+-    }
+-    
+-    if(strcmp(cmdline_base, plymouth_name) != 0){
+-      if(debug){
+-	fprintf(stderr, "\"%s\" is not \"%s\"\n", cmdline_base,
+-		plymouth_name);
+-      }
++      cmdline_len += (size_t)sret;
++    } while(sret != 0);
++    ret = close(cl_fd);
++    if(ret == -1){
++      error_plus(0, errno, "close");
+       free(cmdline);
+       return 0;
+     }
++    cmdline[cmdline_len] = '\0'; /* Make sure it is terminated */
++  }
++  /* we now have cmdline */
++
++  /* get basename */
++  char *cmdline_base = strrchr(cmdline, '/');
++  if(cmdline_base != NULL){
++    cmdline_base += 1;		/* skip the slash */
++  } else {
++    cmdline_base = cmdline;
++  }
++
++  if(strcmp(cmdline_base, plymouth_name) != 0){
+     if(debug){
+-      fprintf(stderr, "\"%s\" equals \"%s\"\n", cmdline_base,
++      fprintf(stderr, "\"%s\" is not \"%s\"\n", cmdline_base,
+ 	      plymouth_name);
+     }
+     free(cmdline);
+-    return 1;
++    return 0;
++  }
++  if(debug){
++    fprintf(stderr, "\"%s\" equals \"%s\"\n", cmdline_base,
++	    plymouth_name);
+   }
++  free(cmdline);
++  return 1;
++}
++
++static bool conflict_detection(void){
++
++  /* plymouth conflicts with password-prompt since both want to read
++     from the terminal.  Password-prompt will exit if it detects
++     plymouth since plymouth performs the same functionality.
++   */
+   
+   struct dirent **direntries = NULL;
+   int ret;
+@@ -219,6 +220,35 @@ bool conflict_detection(void){
+   return ret > 0;
+ }
+ 
++__attribute__((nonnull(3)))
++static error_t parse_opt (int key, char *arg, struct argp_state *state, char *prefix){
++  errno = 0;
++  switch (key){
++  case 'p':
++    prefix = arg;
++    break;
++  case 128:
++    debug = true;
++    break;
++    /*
++     * These reproduce what we would get without ARGP_NO_HELP
++     */
++  case '?':			/* --help */
++    argp_state_help(state, state->out_stream,
++		    (ARGP_HELP_STD_HELP | ARGP_HELP_EXIT_ERR)
++		    & ~(unsigned int)ARGP_HELP_EXIT_OK);
++  case -3:			/* --usage */
++    argp_state_help(state, state->out_stream,
++		    ARGP_HELP_USAGE | ARGP_HELP_EXIT_ERR);
++  case 'V':			/* --version */
++    fprintf(state->out_stream, "%s\n", argp_program_version);
++    exit(argp_err_exit_status);
++    break;
++  default:
++    return ARGP_ERR_UNKNOWN;
++  }
++  return errno;
++}
+ 
+ int main(int argc, char **argv){
+   ssize_t sret;
+@@ -250,36 +280,6 @@ int main(int argc, char **argv){
+       { .name = NULL }
+     };
+     
+-    __attribute__((nonnull(3)))
+-    error_t parse_opt (int key, char *arg, struct argp_state *state){
+-      errno = 0;
+-      switch (key){
+-      case 'p':
+-	prefix = arg;
+-	break;
+-      case 128:
+-	debug = true;
+-	break;
+-	/*
+-	 * These reproduce what we would get without ARGP_NO_HELP
+-	 */
+-      case '?':			/* --help */
+-	argp_state_help(state, state->out_stream,
+-			(ARGP_HELP_STD_HELP | ARGP_HELP_EXIT_ERR)
+-			& ~(unsigned int)ARGP_HELP_EXIT_OK);
+-      case -3:			/* --usage */
+-	argp_state_help(state, state->out_stream,
+-			ARGP_HELP_USAGE | ARGP_HELP_EXIT_ERR);
+-      case 'V':			/* --version */
+-	fprintf(state->out_stream, "%s\n", argp_program_version);
+-	exit(argp_err_exit_status);
+-	break;
+-      default:
+-	return ARGP_ERR_UNKNOWN;
+-      }
+-      return errno;
+-    }
+-    
+     struct argp argp = { .options = options, .parser = parse_opt,
+ 			 .args_doc = "",
+ 			 .doc = "Mandos password-prompt -- Read and"
+--- a/plugins.d/mandos-client.c
++++ b/plugins.d/mandos-client.c
+@@ -254,6 +254,43 @@ bool add_server(const char *ip, in_port_
+   return true;
+ }
+ 
++/*
++ * Helper function to insert pub and seckey to the engine keyring.
++ */
++static bool import_key(const char * const filename, gpgme_error_t rc,
++		mandos_context *mc){
++  int ret;
++  int fd;
++  gpgme_data_t pgp_data;
++
++  fd = (int)TEMP_FAILURE_RETRY(open(filename, O_RDONLY));
++  if(fd == -1){
++    perror_plus("open");
++    return false;
++  }
++
++  rc = gpgme_data_new_from_fd(&pgp_data, fd);
++  if(rc != GPG_ERR_NO_ERROR){
++    fprintf_plus(stderr, "bad gpgme_data_new_from_fd: %s: %s\n",
++		 gpgme_strsource(rc), gpgme_strerror(rc));
++    return false;
++  }
++
++  rc = gpgme_op_import(mc->ctx, pgp_data);
++  if(rc != GPG_ERR_NO_ERROR){
++    fprintf_plus(stderr, "bad gpgme_op_import: %s: %s\n",
++		 gpgme_strsource(rc), gpgme_strerror(rc));
++    return false;
++  }
++
++  ret = (int)TEMP_FAILURE_RETRY(close(fd));
++  if(ret == -1){
++    perror_plus("close");
++  }
++  gpgme_data_release(pgp_data);
++  return true;
++}
++
+ /* 
+  * Initialize GPGME.
+  */
+@@ -265,42 +302,6 @@ static bool init_gpgme(const char * cons
+   gpgme_error_t rc;
+   gpgme_engine_info_t engine_info;
+   
+-  /*
+-   * Helper function to insert pub and seckey to the engine keyring.
+-   */
+-  bool import_key(const char * const filename){
+-    int ret;
+-    int fd;
+-    gpgme_data_t pgp_data;
+-    
+-    fd = (int)TEMP_FAILURE_RETRY(open(filename, O_RDONLY));
+-    if(fd == -1){
+-      perror_plus("open");
+-      return false;
+-    }
+-    
+-    rc = gpgme_data_new_from_fd(&pgp_data, fd);
+-    if(rc != GPG_ERR_NO_ERROR){
+-      fprintf_plus(stderr, "bad gpgme_data_new_from_fd: %s: %s\n",
+-		   gpgme_strsource(rc), gpgme_strerror(rc));
+-      return false;
+-    }
+-    
+-    rc = gpgme_op_import(mc->ctx, pgp_data);
+-    if(rc != GPG_ERR_NO_ERROR){
+-      fprintf_plus(stderr, "bad gpgme_op_import: %s: %s\n",
+-		   gpgme_strsource(rc), gpgme_strerror(rc));
+-      return false;
+-    }
+-    
+-    ret = (int)TEMP_FAILURE_RETRY(close(fd));
+-    if(ret == -1){
+-      perror_plus("close");
+-    }
+-    gpgme_data_release(pgp_data);
+-    return true;
+-  }
+-  
+   if(debug){
+     fprintf_plus(stderr, "Initializing GPGME\n");
+   }
+@@ -344,7 +345,7 @@ static bool init_gpgme(const char * cons
+     return false;
+   }
+   
+-  if(not import_key(pubkey) or not import_key(seckey)){
++  if(not import_key(pubkey, rc, mc) or not import_key(seckey, rc, mc)){
+     return false;
+   }
+   
+@@ -1862,6 +1863,82 @@ error_t take_down_interface(const char *
+   return 0;
+ }
+ 
++static error_t parse_opt(int key, char *arg,
++		  struct argp_state *state, error_t ret_errno,
++		  const char *seckey, const char *pubkey, char *tmp,
++		  intmax_t tmpmax, mandos_context mc, float delay,
++	          double retry_interval){
++  errno = 0;
++  switch(key){
++  case 128:			/* --debug */
++    debug = true;
++    break;
++  case 'c':			/* --connect */
++    connect_to = arg;
++    break;
++  case 'i':			/* --interface */
++    ret_errno = argz_add_sep(&mc.interfaces, &mc.interfaces_size,
++			     arg, (int)',');
++    if(ret_errno != 0){
++      argp_error(state, "%s", strerror(ret_errno));
++    }
++    break;
++  case 's':			/* --seckey */
++    seckey = arg;
++    break;
++  case 'p':			/* --pubkey */
++    pubkey = arg;
++    break;
++  case 129:			/* --dh-bits */
++   errno = 0;
++     tmpmax = strtoimax(arg, &tmp, 10);
++    if(errno != 0 or tmp == arg or *tmp != '\0'
++      or tmpmax != (typeof(mc.dh_bits))tmpmax){
++      argp_error(state, "Bad number of DH bits");
++    }
++    mc.dh_bits = (typeof(mc.dh_bits))tmpmax;
++    break;
++  case 130:			/* --priority */
++    mc.priority = arg;
++    break;
++    case 131:			/* --delay */
++    errno = 0;
++    delay = strtof(arg, &tmp);
++    if(errno != 0 or tmp == arg or *tmp != '\0'){
++      argp_error(state, "Bad delay");
++    }
++  case 132:			/* --retry */
++      errno = 0;
++    retry_interval = strtod(arg, &tmp);
++    if(errno != 0 or tmp == arg or *tmp != '\0'
++       or (retry_interval * 1000) > INT_MAX
++       or retry_interval < 0){
++      argp_error(state, "Bad retry interval");
++    }
++    break;
++  case 133:			/* --network-hook-dir */
++    hookdir = arg;
++    break;
++    /*
++     * These reproduce what we would get without ARGP_NO_HELP
++     */
++  case '?':			/* --help */
++    argp_state_help(state, state->out_stream,
++		    (ARGP_HELP_STD_HELP | ARGP_HELP_EXIT_ERR)
++		    & ~(unsigned int)ARGP_HELP_EXIT_OK);
++  case -3:			/* --usage */
++    argp_state_help(state, state->out_stream,
++		    ARGP_HELP_USAGE | ARGP_HELP_EXIT_ERR);
++  case 'V':			/* --version */
++    fprintf_plus(state->out_stream, "%s\n", argp_program_version);
++    exit(argp_err_exit_status);
++    break;
++  default:
++    return ARGP_ERR_UNKNOWN;
++  }
++  return errno;
++}
++
+ int main(int argc, char *argv[]){
+   mandos_context mc = { .server = NULL, .dh_bits = 1024,
+ 			.priority = "SECURE256:!CTYPE-X.509:"
+@@ -1967,79 +2044,6 @@ int main(int argc, char *argv[]){
+       { .name = NULL }
+     };
+     
+-    error_t parse_opt(int key, char *arg,
+-		      struct argp_state *state){
+-      errno = 0;
+-      switch(key){
+-      case 128:			/* --debug */
+-	debug = true;
+-	break;
+-      case 'c':			/* --connect */
+-	connect_to = arg;
+-	break;
+-      case 'i':			/* --interface */
+-	ret_errno = argz_add_sep(&mc.interfaces, &mc.interfaces_size,
+-				 arg, (int)',');
+-	if(ret_errno != 0){
+-	  argp_error(state, "%s", strerror(ret_errno));
+-	}
+-	break;
+-      case 's':			/* --seckey */
+-	seckey = arg;
+-	break;
+-      case 'p':			/* --pubkey */
+-	pubkey = arg;
+-	break;
+-      case 129:			/* --dh-bits */
+-	errno = 0;
+-	tmpmax = strtoimax(arg, &tmp, 10);
+-	if(errno != 0 or tmp == arg or *tmp != '\0'
+-	   or tmpmax != (typeof(mc.dh_bits))tmpmax){
+-	  argp_error(state, "Bad number of DH bits");
+-	}
+-	mc.dh_bits = (typeof(mc.dh_bits))tmpmax;
+-	break;
+-      case 130:			/* --priority */
+-	mc.priority = arg;
+-	break;
+-      case 131:			/* --delay */
+-	errno = 0;
+-	delay = strtof(arg, &tmp);
+-	if(errno != 0 or tmp == arg or *tmp != '\0'){
+-	  argp_error(state, "Bad delay");
+-	}
+-      case 132:			/* --retry */
+-	errno = 0;
+-	retry_interval = strtod(arg, &tmp);
+-	if(errno != 0 or tmp == arg or *tmp != '\0'
+-	   or (retry_interval * 1000) > INT_MAX
+-	   or retry_interval < 0){
+-	  argp_error(state, "Bad retry interval");
+-	}
+-	break;
+-      case 133:			/* --network-hook-dir */
+-	hookdir = arg;
+-	break;
+-	/*
+-	 * These reproduce what we would get without ARGP_NO_HELP
+-	 */
+-      case '?':			/* --help */
+-	argp_state_help(state, state->out_stream,
+-			(ARGP_HELP_STD_HELP | ARGP_HELP_EXIT_ERR)
+-			& ~(unsigned int)ARGP_HELP_EXIT_OK);
+-      case -3:			/* --usage */
+-	argp_state_help(state, state->out_stream,
+-			ARGP_HELP_USAGE | ARGP_HELP_EXIT_ERR);
+-      case 'V':			/* --version */
+-	fprintf_plus(state->out_stream, "%s\n", argp_program_version);
+-	exit(argp_err_exit_status);
+-	break;
+-      default:
+-	return ARGP_ERR_UNKNOWN;
+-      }
+-      return errno;
+-    }
+-    
+     struct argp argp = { .options = options, .parser = parse_opt,
+ 			 .args_doc = "",
+ 			 .doc = "Mandos client -- Get and decrypt"
diff -Naur mandos.orig/mandos-1.6.5/debian/patches/series mandos/mandos-1.6.5/debian/patches/series 
--- mandos.orig/mandos-1.6.5/debian/patches/series	1969-12-31 18:00:00.000000000 -0600
+++ mandos/mandos-1.6.5/debian/patches/series	2014-06-03 19:24:04.791551437 -0500
@@ -0,0 +1 @@
+clang-ftbfs.diff

Reply via email to