Skip to content

Commit

Permalink
resolver: warn on failed fchmod, fchown
Browse files Browse the repository at this point in the history
see #1579
  • Loading branch information
Markus Raab committed Oct 29, 2017
1 parent 8bb30df commit 21cf06f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/error/specification
Expand Up @@ -591,7 +591,7 @@ ingroup:plugin
module:storage

number:99
description:could not update time of file
description:could not update metadata of file
severity:warning
ingroup:plugin
module:resolver
Expand Down
12 changes: 9 additions & 3 deletions src/plugins/resolver/resolver.c
Expand Up @@ -929,7 +929,7 @@ static int elektraSetCommit (resolverHandle * pk, Key * parentKey)
if (fd == -1)
{
ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_COULD_NOT_OPEN, parentKey,
"Could not open file again for changing properties of file because %s", strerror (errno));
"Could not open file again for changing metadata of file \"%s\", because %s", pk->tempfile, strerror (errno));
ret = -1;
}

Expand Down Expand Up @@ -981,11 +981,17 @@ static int elektraSetCommit (resolverHandle * pk, Key * parentKey)
if (buf.st_mode != pk->filemode)
{
// change mode to what it was before
fchmod (fd, pk->filemode);
if (fchmod (fd, pk->filemode) == -1)
{
ELEKTRA_ADD_WARNINGF (99, parentKey, "Could not fchmod temporary file \"%s\", because %s", pk->tempfile, strerror (errno));
}
}
if (buf.st_uid != pk->uid || buf.st_gid != pk->gid)
{
fchown (fd, pk->uid, pk->gid);
if (fchown (fd, pk->uid, pk->gid) == -1)
{
ELEKTRA_ADD_WARNINGF (99, parentKey, "Could not fchown temporary file \"%s\", because %s", pk->tempfile, strerror (errno));
}
}

DIR * dirp = opendir (pk->dirname);
Expand Down

0 comments on commit 21cf06f

Please sign in to comment.