"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/tree_walker.c" between
srm-1.2.14.tar.gz and srm-1.2.15.tar.gz

About: srm is a secure replacement for standard "rm" (to prevent command-line recovery it overwrites the data in the target files before unlinking them).

tree_walker.c  (srm-1.2.14):tree_walker.c  (srm-1.2.15)
skipping to change at line 69 skipping to change at line 69
return inbuf[0]=='y' || inbuf[0]=='Y'; return inbuf[0]=='y' || inbuf[0]=='Y';
} }
/** /**
* check file permissions for path and modify them so we can remove the file eve ntually. * check file permissions for path and modify them so we can remove the file eve ntually.
* @return true if permissions are find; false otherwise. * @return true if permissions are find; false otherwise.
*/ */
static int check_perms(const char *path) static int check_perms(const char *path)
{ {
int fd=-1; int fd=-1;
#ifdef _MSC_VER
struct __stat64 statbuf;
#else
struct stat statbuf; struct stat statbuf;
#endif
if(!path) return 0; if(!path) return 0;
if( (stat(path, &statbuf) < 0) && (lstat(path, &statbuf) < 0) ) #ifdef _MSC_VER
return 0; if (_stat64(path, &statbuf) < 0)
#else
if (lstat(path, &statbuf) < 0)
#endif
{
return 0;
}
if ( S_ISREG(statbuf.st_mode) && ((fd = open(path, O_WRONLY)) < 0) && (errno = = EACCES) ) if ( S_ISREG(statbuf.st_mode) && ((fd = open(path, O_WRONLY)) < 0) && (errno = = EACCES) )
{ {
if ( chmod(path, S_IRUSR | S_IWUSR) < 0 ) if ( chmod(path, S_IRUSR | S_IWUSR) < 0 )
{ {
errorp("Unable to reset %s to writable (probably not owner) ... skippin g", path); errorp("Unable to reset %s to writable (probably not owner) ... skippin g", path);
return 0; return 0;
} }
} }
skipping to change at line 98 skipping to change at line 108
} }
/** /**
* ask the user for confirmation to remove path. * ask the user for confirmation to remove path.
* @param options bitfield of SRM_OPT_* bits * @param options bitfield of SRM_OPT_* bits
* @return true if the file should be removed; false otherwise. * @return true if the file should be removed; false otherwise.
*/ */
static int prompt_file(const char *path, const int options) static int prompt_file(const char *path, const int options)
{ {
int fd=-1, return_value=1; int fd=-1, return_value=1;
#ifdef _MSC_VER
struct __stat64 statbuf;
#else
struct stat statbuf; struct stat statbuf;
#endif
if(!path) return 0; if(!path) return 0;
if (options & SRM_OPT_F) if (options & SRM_OPT_F)
{ {
if (options & SRM_OPT_V) if (options & SRM_OPT_V)
error("removing %s", path); error("removing %s", path);
return check_perms(path); return check_perms(path);
} }
if( (stat(path, &statbuf) < 0) && (lstat(path, &statbuf) < 0) ) #ifdef _MSC_VER
if (_stat64(path, &statbuf) < 0)
#else
if (lstat(path, &statbuf) < 0)
#endif
{ {
errorp("could not stat %s", path); errorp("could not stat %s", path);
return 0; return 0;
} }
if ( S_ISREG(statbuf.st_mode) && ((fd = open(path, O_WRONLY)) < 0) && (errno = = EACCES) ) if ( S_ISREG(statbuf.st_mode) && ((fd = open(path, O_WRONLY)) < 0) && (errno = = EACCES) )
{ {
/* Not a symlink, not writable */ /* Not a symlink, not writable */
return_value = prompt_user("Remove write protected file %s? (y/n) ", path) ; return_value = prompt_user("Remove write protected file %s? (y/n) ", path) ;
if(return_value == 1) if(return_value == 1)
 End of changes. 6 change blocks. 
3 lines changed or deleted 21 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS