Skip to content

Commit

Permalink
Squashed commit of the following: (fixes #283)
Browse files Browse the repository at this point in the history
commit d71cb6c
Author: andy5995 <[email protected]>
Date:   Wed Apr 28 13:40:28 2021 -0500

    .travis.yml:add xcode 9.4 and 10.3

commit 67d47a9
Author: andy5995 <[email protected]>
Date:   Wed Apr 28 13:36:39 2021 -0500

    remove extra check before removing (for now)

    (fixes #283)

commit d359bfb
Author: andy5995 <[email protected]>
Date:   Wed Apr 28 13:06:25 2021 -0500

    remove is_modified(), use exists() instead

    (#283)
  • Loading branch information
andy5995 committed Apr 28, 2021
1 parent c3eebb9 commit 62da667
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 49 deletions.
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ matrix:
dist: focal
compiler: clang

# purging test fails on osx
# See https://github.com/theimpossibleastronaut/rmw/issues/283 for details
# osx
- os: osx
osx_image: xcode11.2
osx_image: xcode9.4
env: XCODE="true"
- os: osx
osx_image: xcode10.3
env: XCODE="true"
- os: osx
osx_image: xcode11.6
Expand All @@ -117,8 +117,8 @@ matrix:
osx_image: xcode12.2
env: XCODE="true"

allow_failures:
- os: osx
# allow_failures:
# - os: osx

before_install:
- echo $CC
Expand Down
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
=== rmw ChangeLog ===

2021-04-28

* bugfix: fixes test failing on osx using xcode 11.5 and above (#283)

2021-04-26

* rmw v0.7.07 released
Expand Down
27 changes: 5 additions & 22 deletions src/purging_rmw.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,14 @@ rmdir_recursive (const char *dirname, short unsigned level,
struct stat st;
if (lstat (st_dirname_properties.path, &st))
msg_err_lstat (st_dirname_properties.path, __func__, __LINE__);
unsigned long int orig_dev = st.st_dev;
unsigned long int orig_inode = st.st_ino;

if (force >= 2 && ~st.st_mode & S_IWUSR) /* use >= 2 to protect against future changes */
if (force >= 2 && ~st.st_mode & S_IWUSR)
{
if (!chmod (st_dirname_properties.path, 00700))
{
/* Now that the mode has changed, lstat must be run again */
if (lstat (st_dirname_properties.path, &st))
msg_err_lstat (st_dirname_properties.path, __func__, __LINE__);
orig_dev = st.st_dev;
orig_inode = st.st_ino;
}
else
{
Expand All @@ -124,18 +120,15 @@ rmdir_recursive (const char *dirname, short unsigned level,
{
if (!S_ISDIR (st.st_mode))
{
if (!is_modified (st_dirname_properties.path, orig_dev, orig_inode))
remove_result = remove (st_dirname_properties.path);
else
remove_result = -1;

if (remove_result == 0)
if (remove (st_dirname_properties.path) == 0)
{
deleted_files_ctr++;
bytes_freed += st.st_size;
}
else
{
perror ("rmdir_recursive -> remove");
}
}
else
{
Expand All @@ -159,7 +152,6 @@ rmdir_recursive (const char *dirname, short unsigned level,
}
}
}

else
{
printf ("\nPermission denied while deleting\n");
Expand Down Expand Up @@ -388,9 +380,6 @@ purge (st_config * st_config_data,
}
}

int orig_dev = st.st_dev;
int orig_inode = st.st_ino;

if (S_ISDIR (st.st_mode))
{
if (cli_user_options->want_dry_run == false)
Expand Down Expand Up @@ -448,13 +437,7 @@ purge (st_config * st_config_data,
else
{
if (cli_user_options->want_dry_run == false)
{
if (!is_modified
(corresponding_file_to_purge, orig_dev, orig_inode))
status = remove (corresponding_file_to_purge);
else
status = -1;
}
status = remove (corresponding_file_to_purge);
else
status = 0;
if (status == 0)
Expand Down
18 changes: 0 additions & 18 deletions src/utils_rmw.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,24 +177,6 @@ user_verify (void)
}


/* used to prevent a TOCTOU race condtion */
bool
is_modified (const char* file, dev_t dev, const unsigned long int inode)
{
struct stat st;
if (lstat (file, &st))
msg_err_lstat (file, __func__, __LINE__);

if (dev == st.st_dev && inode == st.st_ino)
return false;

print_msg_warn ();
printf ("%s ", file);
puts ("has been modified since last check, not removing");
return true;
}


/*!
*
* According to RFC2396, we must escape any character that's
Expand Down
3 changes: 0 additions & 3 deletions src/utils_rmw.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ human_readable_size (off_t size);
bool
user_verify (void);

bool
is_modified (const char* file, dev_t dev, const unsigned long int inode);

bool
escape_url (const char *str, char *dest, const int len);

Expand Down

0 comments on commit 62da667

Please sign in to comment.