Diff for /embedaddon/sudo/common/fileops.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 28 Line 28
 # include <sys/file.h>  # include <sys/file.h>
 #endif /* HAVE_FLOCK */  #endif /* HAVE_FLOCK */
 #include <stdio.h>  #include <stdio.h>
   #ifdef HAVE_STDBOOL_H
   # include <stdbool.h>
   #else
   # include "compat/stdbool.h"
   #endif
 #ifdef HAVE_STRING_H  #ifdef HAVE_STRING_H
 # include <string.h>  # include <string.h>
 #endif /* HAVE_STRING_H */  #endif /* HAVE_STRING_H */
Line 43 Line 48
 #if TIME_WITH_SYS_TIME  #if TIME_WITH_SYS_TIME
 # include <time.h>  # include <time.h>
 #endif  #endif
#ifndef HAVE_TIMESPEC#ifndef HAVE_STRUCT_TIMESPEC
 # include "compat/timespec.h"  # include "compat/timespec.h"
 #endif  #endif
   
 #include "missing.h"  #include "missing.h"
 #include "fileops.h"  #include "fileops.h"
   #include "sudo_debug.h"
   
 #ifndef LINE_MAX  #ifndef LINE_MAX
 # define LINE_MAX 2048  # define LINE_MAX 2048
Line 61  int Line 67  int
 touch(int fd, char *path, struct timeval *tvp)  touch(int fd, char *path, struct timeval *tvp)
 {  {
     struct timeval times[2];      struct timeval times[2];
       int rval = -1;
       debug_decl(touch, SUDO_DEBUG_UTIL)
   
     if (tvp != NULL) {      if (tvp != NULL) {
         times[0].tv_sec = times[1].tv_sec = tvp->tv_sec;          times[0].tv_sec = times[1].tv_sec = tvp->tv_sec;
Line 69  touch(int fd, char *path, struct timeval *tvp) Line 77  touch(int fd, char *path, struct timeval *tvp)
   
 #if defined(HAVE_FUTIME) || defined(HAVE_FUTIMES)  #if defined(HAVE_FUTIME) || defined(HAVE_FUTIMES)
     if (fd != -1)      if (fd != -1)
        return futimes(fd, tvp ? times : NULL);        rval = futimes(fd, tvp ? times : NULL);
     else      else
 #endif  #endif
     if (path != NULL)      if (path != NULL)
        return utimes(path, tvp ? times : NULL);        rval = utimes(path, tvp ? times : NULL);
    else    debug_return_int(rval);
        return -1; 
 }  }
   
 /*  /*
  * Lock/unlock a file.   * Lock/unlock a file.
  */   */
 #ifdef HAVE_LOCKF  #ifdef HAVE_LOCKF
intbool
 lock_file(int fd, int lockit)  lock_file(int fd, int lockit)
 {  {
     int op = 0;      int op = 0;
       debug_decl(lock_file, SUDO_DEBUG_UTIL)
   
     switch (lockit) {      switch (lockit) {
         case SUDO_LOCK:          case SUDO_LOCK:
Line 98  lock_file(int fd, int lockit) Line 106  lock_file(int fd, int lockit)
             op = F_ULOCK;              op = F_ULOCK;
             break;              break;
     }      }
    return lockf(fd, op, 0) == 0;    debug_return_bool(lockf(fd, op, 0) == 0);
 }  }
 #elif HAVE_FLOCK  #elif HAVE_FLOCK
intbool
 lock_file(int fd, int lockit)  lock_file(int fd, int lockit)
 {  {
     int op = 0;      int op = 0;
       debug_decl(lock_file, SUDO_DEBUG_UTIL)
   
     switch (lockit) {      switch (lockit) {
         case SUDO_LOCK:          case SUDO_LOCK:
Line 117  lock_file(int fd, int lockit) Line 126  lock_file(int fd, int lockit)
             op = LOCK_UN;              op = LOCK_UN;
             break;              break;
     }      }
    return flock(fd, op) == 0;    debug_return_bool(flock(fd, op) == 0);
 }  }
 #else  #else
intbool
 lock_file(int fd, int lockit)  lock_file(int fd, int lockit)
 {  {
 #ifdef F_SETLK  #ifdef F_SETLK
     int func;      int func;
     struct flock lock;      struct flock lock;
       debug_decl(lock_file, SUDO_DEBUG_UTIL)
   
     lock.l_start = 0;      lock.l_start = 0;
     lock.l_len = 0;      lock.l_len = 0;
Line 134  lock_file(int fd, int lockit) Line 144  lock_file(int fd, int lockit)
     lock.l_whence = SEEK_SET;      lock.l_whence = SEEK_SET;
     func = (lockit == SUDO_LOCK) ? F_SETLKW : F_SETLK;      func = (lockit == SUDO_LOCK) ? F_SETLKW : F_SETLK;
   
    return fcntl(fd, func, &lock) == 0;    debug_return_bool(fcntl(fd, func, &lock) == 0);
 #else  #else
    return TRUE;    return true;
 #endif  #endif
 }  }
 #endif  #endif
Line 151  sudo_parseln(FILE *fp) Line 161  sudo_parseln(FILE *fp)
     size_t len;      size_t len;
     char *cp = NULL;      char *cp = NULL;
     static char buf[LINE_MAX];      static char buf[LINE_MAX];
       debug_decl(sudo_parseln, SUDO_DEBUG_UTIL)
   
     if (fgets(buf, sizeof(buf), fp) != NULL) {      if (fgets(buf, sizeof(buf), fp) != NULL) {
         /* Remove comments */          /* Remove comments */
Line 164  sudo_parseln(FILE *fp) Line 175  sudo_parseln(FILE *fp)
         for (cp = buf; isblank((unsigned char)*cp); cp++)          for (cp = buf; isblank((unsigned char)*cp); cp++)
             continue;              continue;
     }      }
    return cp;    debug_return_str(cp);
 }  }

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


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