Use rpmfiConfigConflictIndex() for modified config testing on erase too

- Besides eliminating another copy-paste variant of the config file
  digest calculation and comparison, this fixes the case modified
  %config symlink gets silently erased. Unlike a regular config file,
  a symlink does not contain a whole lot of carefully tuned data, but
  if it's marked %config I think we should honor the %config file rules.
- Adjust test-suite expectations to match the new behavior.
This commit is contained in:
Panu Matilainen 2012-08-22 11:56:12 +03:00
parent 79f8122f41
commit a3a08a4b0a
2 changed files with 3 additions and 17 deletions

View File

@ -544,21 +544,9 @@ assert(otherFi != NULL);
break;
/* Pre-existing modified config files need to be saved. */
if (S_ISREG(FMode) && (FFlags & RPMFILE_CONFIG)) {
int algo = 0;
size_t diglen = 0;
const unsigned char *digest;
if ((digest = rpmfiFDigestIndex(fi, i, &algo, &diglen))) {
unsigned char fdigest[diglen];
char *fn = rpmfiFNIndex(fi, i);
int modified = (!rpmDoDigest(algo, fn, 0, fdigest, NULL) &&
memcmp(digest, fdigest, diglen));
free(fn);
if (modified) {
rpmfsSetAction(fs, i, FA_BACKUP);
break;
}
}
if (rpmfiConfigConflictIndex(fi, i)) {
rpmfsSetAction(fs, i, FA_BACKUP);
break;
}
/* Otherwise, we can just erase. */

View File

@ -92,10 +92,8 @@ test ! -L "${cf}"
AT_CLEANUP
# Erase modified config link
# Broken, no backup taken
AT_SETUP([erase changed config link])
AT_KEYWORDS([install])
AT_XFAIL_IF([test $RPM_XFAIL -gt 0])
AT_CHECK([
RPMDB_CLEAR
RPMDB_INIT