summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-11-20 11:09:25 +0100
committerStephan Bergmann <sbergman@redhat.com>2014-11-20 11:09:52 +0100
commit6dbaf74eea8ffeaeeaed3f84e95bff9a7a5fbe5d (patch)
treeb231e468dde0c43b86aa2977df6e131bbc0e521d /sal
parent9557ae7baf3683a3c55bc55934fefba22a7c5759 (diff)
Let attemptChangeMetadata work on symlink itself
Change-Id: I42a81e70e76cb4699052815cfd415a8efd902b03
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/unx/file_misc.cxx26
1 files changed, 16 insertions, 10 deletions
diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx
index 6972f36520bc..fd1d902566cb 100644
--- a/sal/osl/unx/file_misc.cxx
+++ b/sal/osl/unx/file_misc.cxx
@@ -868,31 +868,37 @@ void attemptChangeMetadata( const sal_Char* pszFileName, mode_t nMode, time_t nA
{
struct utimbuf aTimeBuffer;
- if ( chmod(pszFileName,nMode) < 0 )
+ if ( fchmodat(AT_FDCWD, pszFileName, nMode, AT_SYMLINK_NOFOLLOW) < 0 )
{
int e = errno;
SAL_INFO(
- "sal.osl", "chmod(" << pszFileName << ") failed with errno " << e);
+ "sal.osl",
+ "fchmodat(" << pszFileName << ") failed with errno " << e);
}
- aTimeBuffer.actime=nAcTime;
- aTimeBuffer.modtime=nModTime;
- if ( utime(pszFileName,&aTimeBuffer) < 0 )
+ // No way to change utime of a symlink itself:
+ if (!S_ISLNK(nMode))
{
- int e = errno;
- SAL_INFO(
- "sal.osl", "utime(" << pszFileName << ") failed with errno " << e);
+ aTimeBuffer.actime=nAcTime;
+ aTimeBuffer.modtime=nModTime;
+ if ( utime(pszFileName,&aTimeBuffer) < 0 )
+ {
+ int e = errno;
+ SAL_INFO(
+ "sal.osl",
+ "utime(" << pszFileName << ") failed with errno " << e);
+ }
}
if ( nUID != getuid() )
{
nUID=getuid();
}
- if ( chown(pszFileName,nUID,nGID) < 0 )
+ if ( lchown(pszFileName,nUID,nGID) < 0 )
{
int e = errno;
SAL_INFO(
- "sal.osl", "chown(" << pszFileName << ") failed with errno " << e);
+ "sal.osl", "lchown(" << pszFileName << ") failed with errno " << e);
}
}