Kaydet (Commit) 6dbaf74e authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Let attemptChangeMetadata work on symlink itself

Change-Id: I42a81e70e76cb4699052815cfd415a8efd902b03
üst 9557ae7b
...@@ -868,31 +868,37 @@ void attemptChangeMetadata( const sal_Char* pszFileName, mode_t nMode, time_t nA ...@@ -868,31 +868,37 @@ void attemptChangeMetadata( const sal_Char* pszFileName, mode_t nMode, time_t nA
{ {
struct utimbuf aTimeBuffer; struct utimbuf aTimeBuffer;
if ( chmod(pszFileName,nMode) < 0 ) if ( fchmodat(AT_FDCWD, pszFileName, nMode, AT_SYMLINK_NOFOLLOW) < 0 )
{ {
int e = errno; int e = errno;
SAL_INFO( SAL_INFO(
"sal.osl", "chmod(" << pszFileName << ") failed with errno " << e); "sal.osl",
"fchmodat(" << pszFileName << ") failed with errno " << e);
} }
aTimeBuffer.actime=nAcTime; // No way to change utime of a symlink itself:
aTimeBuffer.modtime=nModTime; if (!S_ISLNK(nMode))
if ( utime(pszFileName,&aTimeBuffer) < 0 )
{ {
int e = errno; aTimeBuffer.actime=nAcTime;
SAL_INFO( aTimeBuffer.modtime=nModTime;
"sal.osl", "utime(" << pszFileName << ") failed with errno " << e); if ( utime(pszFileName,&aTimeBuffer) < 0 )
{
int e = errno;
SAL_INFO(
"sal.osl",
"utime(" << pszFileName << ") failed with errno " << e);
}
} }
if ( nUID != getuid() ) if ( nUID != getuid() )
{ {
nUID=getuid(); nUID=getuid();
} }
if ( chown(pszFileName,nUID,nGID) < 0 ) if ( lchown(pszFileName,nUID,nGID) < 0 )
{ {
int e = errno; int e = errno;
SAL_INFO( SAL_INFO(
"sal.osl", "chown(" << pszFileName << ") failed with errno " << e); "sal.osl", "lchown(" << pszFileName << ") failed with errno " << e);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment