Diff for /embedaddon/sudo/plugins/sample/sample_plugin.c between versions 1.1.1.2 and 1.1.1.4

version 1.1.1.2, 2012/05/29 12:26:49 version 1.1.1.4, 2013/07/22 10:46:12
Line 1 Line 1
 /*  /*
 * Copyright (c) 2010-2011 Todd C. Miller <Todd.Miller@courtesan.com> * Copyright (c) 2010-2013 Todd C. Miller <Todd.Miller@courtesan.com>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 17 Line 17
 #include <config.h>  #include <config.h>
   
 #include <sys/types.h>  #include <sys/types.h>
 #include <sys/param.h>  
 #include <sys/stat.h>  #include <sys/stat.h>
 #include <sys/wait.h>  #include <sys/wait.h>
   
Line 237  check_passwd(void) Line 236  check_passwd(void)
 }  }
   
 static char **  static char **
build_command_info(char *command)build_command_info(const char *command)
 {  {
     static char **command_info;      static char **command_info;
     int i = 0;      int i = 0;
Line 306  find_editor(int nfiles, char * const files[], char **a Line 305  find_editor(int nfiles, char * const files[], char **a
     cp = strtok(editor, " \t");      cp = strtok(editor, " \t");
     if (cp == NULL ||      if (cp == NULL ||
         (editor_path = find_in_path(editor, plugin_state.envp)) == NULL) {          (editor_path = find_in_path(editor, plugin_state.envp)) == NULL) {
           free(editor);
         return NULL;          return NULL;
     }      }
       if (editor_path != editor)
           free(editor);
     nargv = (char **) malloc((nargc + 1 + nfiles + 1) * sizeof(char *));      nargv = (char **) malloc((nargc + 1 + nfiles + 1) * sizeof(char *));
     if (nargv == NULL) {      if (nargv == NULL) {
         sudo_log(SUDO_CONV_ERROR_MSG, "unable to allocate memory\n");          sudo_log(SUDO_CONV_ERROR_MSG, "unable to allocate memory\n");
           free(editor_path);
         return NULL;          return NULL;
     }      }
     for (ac = 0; cp != NULL && ac < nargc; ac++) {      for (ac = 0; cp != NULL && ac < nargc; ac++) {
Line 357  policy_check(int argc, char * const argv[], Line 360  policy_check(int argc, char * const argv[],
   
     if (use_sudoedit) {      if (use_sudoedit) {
         /* Rebuild argv using editor */          /* Rebuild argv using editor */
           free(command);
         command = find_editor(argc - 1, argv + 1, argv_out);          command = find_editor(argc - 1, argv + 1, argv_out);
         if (command == NULL) {          if (command == NULL) {
             sudo_log(SUDO_CONV_ERROR_MSG, "unable to find valid editor\n");              sudo_log(SUDO_CONV_ERROR_MSG, "unable to find valid editor\n");
Line 373  policy_check(int argc, char * const argv[], Line 377  policy_check(int argc, char * const argv[],
   
     /* Setup command info. */      /* Setup command info. */
     *command_info_out = build_command_info(command);      *command_info_out = build_command_info(command);
       free(command);
     if (*command_info_out == NULL) {      if (*command_info_out == NULL) {
         sudo_log(SUDO_CONV_ERROR_MSG, "out of memory\n");          sudo_log(SUDO_CONV_ERROR_MSG, "out of memory\n");
         return -1;          return -1;
Line 498  struct policy_plugin sample_policy = { Line 503  struct policy_plugin sample_policy = {
  * Note: This plugin does not differentiate between tty and pipe I/O.   * Note: This plugin does not differentiate between tty and pipe I/O.
  *       It all gets logged to the same file.   *       It all gets logged to the same file.
  */   */
struct io_plugin sample_io = {__dso_public struct io_plugin sample_io = {
     SUDO_IO_PLUGIN,      SUDO_IO_PLUGIN,
     SUDO_API_VERSION,      SUDO_API_VERSION,
     io_open,      io_open,

Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.4


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>