1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-20 06:35:50 +02:00

[246234] Change of file permissions changes the file owner

This commit is contained in:
David McKnight 2008-09-04 18:10:53 +00:00
parent d5a6ac1fba
commit 076f019680

View file

@ -36,6 +36,7 @@
* Martin Oberhuber (Wind River) - [199854][api] Improve error reporting for archive handlers * Martin Oberhuber (Wind River) - [199854][api] Improve error reporting for archive handlers
* David McKnight (IBM) - [226561] [apidoc] Add API markup to RSE Javadocs where extend / implement is allowed * David McKnight (IBM) - [226561] [apidoc] Add API markup to RSE Javadocs where extend / implement is allowed
* David McKnight (IBM) - [244277] [dstore] NPE on file save from old client * David McKnight (IBM) - [244277] [dstore] NPE on file save from old client
* David McKnight (IBM) - [246234] Change of file permissions changes the file owner
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.dstore.universal.miners; package org.eclipse.rse.dstore.universal.miners;
@ -104,6 +105,11 @@ public class UniversalFileSystemMiner extends Miner {
public static final String CLASSNAME = "UniversalFileSystemMiner"; //$NON-NLS-1$ public static final String CLASSNAME = "UniversalFileSystemMiner"; //$NON-NLS-1$
protected HashMap _cancellableThreads; protected HashMap _cancellableThreads;
private static final int PERMISSION_OWNER = 0;
private static final int PERMISSION_GROUP = 1;
private static final int PERMISSION_BITS = 2;
private static final int PERMISSION_ALL = 3;
private boolean _isWindows = false; private boolean _isWindows = false;
@ -1896,7 +1902,15 @@ public class UniversalFileSystemMiner extends Miner {
{ {
File file = getFileFor(subject); File file = getFileFor(subject);
String result = getFilePermission(file, PERMISSION_ALL);
status.setAttribute(DE.A_SOURCE, result);
statusDone(status);
return status;
}
private String getFilePermission(File file, int permission)
{
// permissions in form "drwxrwxrwx ..." // permissions in form "drwxrwxrwx ..."
String ldStr = simpleShellCommand("ls -ld", file); //$NON-NLS-1$ String ldStr = simpleShellCommand("ls -ld", file); //$NON-NLS-1$
@ -1910,13 +1924,33 @@ public class UniversalFileSystemMiner extends Miner {
tokenizer.nextToken(); // nothing important tokenizer.nextToken(); // nothing important
String user = tokenizer.nextToken(); // 3rd String user = tokenizer.nextToken(); // 3rd
String group = tokenizer.nextToken(); // 4th String group = tokenizer.nextToken(); // 4th
String result = octalPermissions + '|' + user + '|' + group; String result = null;
status.setAttribute(DE.A_SOURCE, result); switch (permission){
statusDone(status); case PERMISSION_BITS:
result = octalPermissions;
return status; break;
case PERMISSION_OWNER:
result = user;
break;
case PERMISSION_GROUP:
result = group;
break;
case PERMISSION_ALL:
default:
result = octalPermissions + '|' + user + '|' + group;
break;
}
return result;
} }
/** /**
* Set file permissions including user and group * Set file permissions including user and group
@ -1935,12 +1969,20 @@ public class UniversalFileSystemMiner extends Miner {
// set the permissions // set the permissions
String result = simpleShellCommand("chmod " + permAttributes[0], file); //$NON-NLS-1$ String result = simpleShellCommand("chmod " + permAttributes[0], file); //$NON-NLS-1$
// set the user String previousGroup = getFilePermission(file, PERMISSION_GROUP);
simpleShellCommand("chown " + permAttributes[1], file); //$NON-NLS-1$ if (!previousGroup.equals(permAttributes[2])){
// set the group
// set the group simpleShellCommand("chown :" + permAttributes[2], file); //$NON-NLS-1$
simpleShellCommand("chown :" + permAttributes[2], file); //$NON-NLS-1$ }
String previousUser = getFilePermission(file, PERMISSION_OWNER);
if (!previousUser.equals(permAttributes[1])){
// set the user
simpleShellCommand("chown " + permAttributes[1], file); //$NON-NLS-1$
}
status.setAttribute(DE.A_SOURCE, result); status.setAttribute(DE.A_SOURCE, result);
statusDone(status); statusDone(status);