Diff for /embedaddon/sudo/src/sudo_edit.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 16:23:02 version 1.1.1.2, 2012/05/29 12:26:49
Line 16 Line 16
   
 #include <config.h>  #include <config.h>
   
 #if defined(HAVE_SETRESUID) || defined(HAVE_SETREUID) || defined(HAVE_SETEUID)  
   
 #include <sys/types.h>  #include <sys/types.h>
 #include <sys/param.h>  #include <sys/param.h>
 #include <sys/stat.h>  #include <sys/stat.h>
Line 54 Line 52
   
 #include "sudo.h"  #include "sudo.h"
   
   #if defined(HAVE_SETRESUID) || defined(HAVE_SETREUID) || defined(HAVE_SETEUID)
   
 static void  static void
 switch_user(uid_t euid, gid_t egid, int ngroups, GETGROUPS_T *groups)  switch_user(uid_t euid, gid_t egid, int ngroups, GETGROUPS_T *groups)
 {  {
     int serrno = errno;      int serrno = errno;
       debug_decl(switch_user, SUDO_DEBUG_EDIT)
   
     /* When restoring root, change euid first; otherwise change it last. */      /* When restoring root, change euid first; otherwise change it last. */
     if (euid == ROOT_UID) {      if (euid == ROOT_UID) {
Line 74  switch_user(uid_t euid, gid_t egid, int ngroups, GETGR Line 75  switch_user(uid_t euid, gid_t egid, int ngroups, GETGR
         if (seteuid(euid) != 0)          if (seteuid(euid) != 0)
             error(1, "seteuid(%d)", (int)euid);              error(1, "seteuid(%d)", (int)euid);
     }      }
   
     errno = serrno;      errno = serrno;
   
       debug_return;
 }  }
   
 /*  /*
Line 98  sudo_edit(struct command_details *command_details) Line 100  sudo_edit(struct command_details *command_details)
         char *ofile;          char *ofile;
         struct timeval omtim;          struct timeval omtim;
         off_t osize;          off_t osize;
    } *tf;    } *tf = NULL;
     debug_decl(sudo_edit, SUDO_DEBUG_EDIT)
   
     /*      /*
      * Set real, effective and saved uids to root.       * Set real, effective and saved uids to root.
Line 106  sudo_edit(struct command_details *command_details) Line 109  sudo_edit(struct command_details *command_details)
      */       */
     if (setuid(ROOT_UID) != 0) {      if (setuid(ROOT_UID) != 0) {
         warning(_("unable to change uid to root (%u)"), ROOT_UID);          warning(_("unable to change uid to root (%u)"), ROOT_UID);
        return 1;        goto cleanup;
     }      }
   
     /*      /*
Line 138  sudo_edit(struct command_details *command_details) Line 141  sudo_edit(struct command_details *command_details)
     }      }
     if (nfiles == 0) {      if (nfiles == 0) {
         warningx(_("plugin error: missing file list for sudoedit"));          warningx(_("plugin error: missing file list for sudoedit"));
        return 1;        goto cleanup;
     }      }
   
     /*      /*
Line 220  sudo_edit(struct command_details *command_details) Line 223  sudo_edit(struct command_details *command_details)
         j++;          j++;
     }      }
     if ((nfiles = j) == 0)      if ((nfiles = j) == 0)
        return 1;                       /* no files readable, you lose */        goto cleanup;                /* no files readable, you lose */
   
     /*      /*
      * Allocate space for the new argument vector and fill it in.       * Allocate space for the new argument vector and fill it in.
Line 317  sudo_edit(struct command_details *command_details) Line 320  sudo_edit(struct command_details *command_details)
         }          }
         close(ofd);          close(ofd);
     }      }
       debug_return_int(rval);
   
     return rval;  
 cleanup:  cleanup:
     /* Clean up temp files and return. */      /* Clean up temp files and return. */
    for (i = 0; i < nfiles; i++) {    if (tf != NULL) {
        if (tf[i].tfile != NULL)        for (i = 0; i < nfiles; i++) {
            unlink(tf[i].tfile);            if (tf[i].tfile != NULL)
                 unlink(tf[i].tfile);
         }
     }      }
    return 1;    debug_return_int(1);
 }  }
   
 #else /* HAVE_SETRESUID || HAVE_SETREUID || HAVE_SETEUID */  #else /* HAVE_SETRESUID || HAVE_SETREUID || HAVE_SETEUID */
Line 336  cleanup: Line 341  cleanup:
 int  int
 sudo_edit(struct command_details *command_details)  sudo_edit(struct command_details *command_details)
 {  {
    return 1;    debug_decl(sudo_edit, SUDO_DEBUG_EDIT)
     debug_return_int(1);
 }  }
   
 #endif /* HAVE_SETRESUID || HAVE_SETREUID || HAVE_SETEUID */  #endif /* HAVE_SETRESUID || HAVE_SETREUID || HAVE_SETEUID */

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


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