mirror of
https://github.com/iterate-ch/cyberduck.git
synced 2026-05-26 19:10:49 +00:00
Extract interface for permissions.
This commit is contained in:
+10
-2
@@ -1,8 +1,16 @@
|
||||
# Changelog
|
||||
|
||||
[9.5.0](https://github.com/iterate-ch/cyberduck/compare/release-9-4-1...release-9-5-0)
|
||||
|
||||
* [Feature] AWS IAM Identity Center Support (S3) ([#13377](https://trac.cyberduck.io/ticket/13377))
|
||||
* [Feature] Connect with credentials from `credential_process` configuration directive in ~/.aws (
|
||||
S3) ([#11664](https://trac.cyberduck.io/ticket/11664))
|
||||
|
||||
[9.4.1](https://github.com/iterate-ch/cyberduck/compare/release-9-4-0...release-9-4-1)
|
||||
* Cleartext uploads to unlocked vault with auto detect disabled in Preferences (Cryptomator) ([#17893](https://trac.cyberduck.io/ticket/17893))
|
||||
* Unable to lock vault (Cryptomator) ([#17892](https://trac.cyberduck.io/ticket/17892))
|
||||
|
||||
* [Bugfix] Cleartext uploads to unlocked vault with auto detect disabled in Preferences (
|
||||
Cryptomator) ([#17893](https://trac.cyberduck.io/ticket/17893))
|
||||
* [Bugfix] Unable to lock vault (Cryptomator) ([#17892](https://trac.cyberduck.io/ticket/17892))
|
||||
|
||||
[9.4.0](https://github.com/iterate-ch/cyberduck/compare/release-9-3-1...release-9-4-0)
|
||||
* [Feature] Rewrite protocol implementation (iRODS)
|
||||
|
||||
@@ -20,6 +20,7 @@ import ch.cyberduck.core.ListProgressListener;
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.PathAttributes;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.brick.io.swagger.client.ApiException;
|
||||
import ch.cyberduck.core.brick.io.swagger.client.api.FilesApi;
|
||||
import ch.cyberduck.core.brick.io.swagger.client.model.FileEntity;
|
||||
@@ -78,7 +79,7 @@ public class BrickAttributesFinderFeature implements AttributesFinder, Attribute
|
||||
attr.setModificationDate(entity.getMtime().getMillis());
|
||||
}
|
||||
if(entity.getPermissions() != null) {
|
||||
final Permission permission = new Permission();
|
||||
final StaticPermission permission = new StaticPermission();
|
||||
if(entity.getPermissions().contains(PermissionType.r.name())) {
|
||||
permission.setUser(permission.getUser().or(Permission.Action.read));
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package ch.cyberduck.cli;
|
||||
import ch.cyberduck.core.DisabledConnectionTimeout;
|
||||
import ch.cyberduck.core.Local;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.cryptomator.CryptoVault;
|
||||
import ch.cyberduck.core.cryptomator.random.FastSecureRandomProvider;
|
||||
import ch.cyberduck.core.preferences.Preferences;
|
||||
@@ -105,7 +106,7 @@ public class TerminalPreferences extends Preferences {
|
||||
|
||||
public TerminalPreferences withDefaults(final CommandLine input) {
|
||||
if(input.hasOption(TerminalOptionsBuilder.Params.chmod.name())) {
|
||||
final Permission permission = new Permission(input.getOptionValue(TerminalOptionsBuilder.Params.chmod.name()));
|
||||
final Permission permission = new StaticPermission(input.getOptionValue(TerminalOptionsBuilder.Params.chmod.name()));
|
||||
this.setDefault("queue.upload.permissions.change", String.valueOf(true));
|
||||
this.setDefault("queue.upload.permissions.default", String.valueOf(true));
|
||||
this.setDefault("queue.upload.permissions.file.default", permission.getMode());
|
||||
|
||||
@@ -168,7 +168,7 @@ public class FinderLocalAttributes extends LocalAttributes {
|
||||
|
||||
@Override
|
||||
public Permission getPermission() {
|
||||
return new FinderLocalPermission(super.getPermission().getMode());
|
||||
return new FinderLocalPermission();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,18 +197,6 @@ public class FinderLocalAttributes extends LocalAttributes {
|
||||
* Executable, readable and writable flags based on <code>NSFileManager</code>.
|
||||
*/
|
||||
private final class FinderLocalPermission extends LocalPermission {
|
||||
private FinderLocalPermission() {
|
||||
//
|
||||
}
|
||||
|
||||
private FinderLocalPermission(final String mode) {
|
||||
super(mode);
|
||||
}
|
||||
|
||||
private FinderLocalPermission(final int mode) {
|
||||
super(mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExecutable() {
|
||||
final NSURL resolved;
|
||||
|
||||
@@ -19,6 +19,7 @@ import ch.cyberduck.core.AlphanumericRandomStringService;
|
||||
import ch.cyberduck.core.Local;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.SerializerFactory;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.exception.AccessDeniedException;
|
||||
import ch.cyberduck.core.exception.LocalAccessDeniedException;
|
||||
import ch.cyberduck.core.exception.NotfoundException;
|
||||
@@ -114,7 +115,7 @@ public class FinderLocalTest {
|
||||
public void testWriteUnixPermission() throws Exception {
|
||||
Local l = new FinderLocal(System.getProperty("java.io.tmpdir"), new AlphanumericRandomStringService().random());
|
||||
new DefaultLocalTouchFeature().touch(l);
|
||||
final Permission permission = new Permission(644);
|
||||
final Permission permission = new StaticPermission(644);
|
||||
l.attributes().setPermission(permission);
|
||||
assertEquals(permission, l.attributes().getPermission());
|
||||
l.delete();
|
||||
|
||||
@@ -162,7 +162,7 @@ public class DefaultPathAttributes implements PathAttributes, Attributes, Serial
|
||||
created = copy.getCreationDate();
|
||||
owner = copy.getOwner();
|
||||
group = copy.getGroup();
|
||||
permission = Permission.EMPTY == copy.getPermission() ? Permission.EMPTY : new Permission(copy.getPermission());
|
||||
permission = Permission.EMPTY == copy.getPermission() ? Permission.EMPTY : new StaticPermission(copy.getPermission());
|
||||
acl = Acl.EMPTY == copy.getAcl() ? Acl.EMPTY : new Acl(copy.getAcl());
|
||||
checksum = Checksum.NONE == copy.getChecksum() ? Checksum.NONE : new Checksum(copy.getChecksum());
|
||||
etag = copy.getETag();
|
||||
|
||||
@@ -27,13 +27,14 @@ import java.io.IOException;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.LinkOption;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.nio.file.attribute.FileTime;
|
||||
import java.nio.file.attribute.PosixFileAttributes;
|
||||
import java.nio.file.attribute.PosixFilePermission;
|
||||
import java.nio.file.attribute.PosixFilePermissions;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public class LocalAttributes implements Attributes {
|
||||
private static final Logger log = LogManager.getLogger(LocalAttributes.class);
|
||||
@@ -122,14 +123,6 @@ public class LocalAttributes implements Attributes {
|
||||
|
||||
@Override
|
||||
public Permission getPermission() {
|
||||
if(FileSystems.getDefault().supportedFileAttributeViews().contains("posix")) {
|
||||
try {
|
||||
return new LocalPermission(PosixFilePermissions.toString(readAttributes(path, PosixFileAttributes.class).permissions()));
|
||||
}
|
||||
catch(IOException e) {
|
||||
return Permission.EMPTY;
|
||||
}
|
||||
}
|
||||
return new LocalPermission();
|
||||
}
|
||||
|
||||
@@ -177,45 +170,7 @@ public class LocalAttributes implements Attributes {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the file permissions of a given path into a {@link Permission.Action} object.
|
||||
* The resulting {@link Permission.Action} includes read, write, and execute permissions
|
||||
* based on the file attributes of the specified path.
|
||||
*
|
||||
* @param path The file system path for which the permissions need to be determined.
|
||||
* This is a string representing the absolute or relative path of the file
|
||||
* or directory.
|
||||
* @return A {@link Permission.Action} object representing the available actions
|
||||
* (read, write, execute) for the specified path.
|
||||
*/
|
||||
private static Permission.Action toAction(final String path) {
|
||||
Permission.Action actions = Permission.Action.none;
|
||||
final Path p = Paths.get(path);
|
||||
if(Files.isReadable(p)) {
|
||||
actions = actions.or(Permission.Action.read);
|
||||
}
|
||||
if(Files.isWritable(p)) {
|
||||
actions = actions.or(Permission.Action.write);
|
||||
}
|
||||
if(Files.isExecutable(p)) {
|
||||
actions = actions.or(Permission.Action.execute);
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
protected class LocalPermission extends Permission {
|
||||
public LocalPermission() {
|
||||
super(toAction(path), Action.none, Action.none);
|
||||
}
|
||||
|
||||
public LocalPermission(final String mode) {
|
||||
super(mode);
|
||||
}
|
||||
|
||||
public LocalPermission(final int mode) {
|
||||
super(mode);
|
||||
}
|
||||
|
||||
protected class LocalPermission implements Permission {
|
||||
@Override
|
||||
public boolean isReadable() {
|
||||
return Files.isReadable(Paths.get(path));
|
||||
@@ -230,6 +185,78 @@ public class LocalAttributes implements Attributes {
|
||||
public boolean isExecutable() {
|
||||
return Files.isExecutable(Paths.get(path));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action getUser() {
|
||||
if(FileSystems.getDefault().supportedFileAttributeViews().contains("posix")) {
|
||||
try {
|
||||
final Set<PosixFilePermission> set = readAttributes(path, PosixFileAttributes.class).permissions();
|
||||
Action action = Action.none;
|
||||
if(set.contains(PosixFilePermission.OWNER_READ)) {
|
||||
action = action.or(Action.read);
|
||||
}
|
||||
if(set.contains(PosixFilePermission.OWNER_WRITE)) {
|
||||
action = action.or(Action.write);
|
||||
}
|
||||
if(set.contains(PosixFilePermission.OWNER_EXECUTE)) {
|
||||
action = action.or(Action.execute);
|
||||
}
|
||||
return action;
|
||||
}
|
||||
catch(IOException e) {
|
||||
return Action.none;
|
||||
}
|
||||
}
|
||||
return Action.none;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action getGroup() {
|
||||
if(FileSystems.getDefault().supportedFileAttributeViews().contains("posix")) {
|
||||
try {
|
||||
final Set<PosixFilePermission> set = readAttributes(path, PosixFileAttributes.class).permissions();
|
||||
Action action = Action.none;
|
||||
if(set.contains(PosixFilePermission.GROUP_READ)) {
|
||||
action = action.or(Action.read);
|
||||
}
|
||||
if(set.contains(PosixFilePermission.GROUP_WRITE)) {
|
||||
action = action.or(Action.write);
|
||||
}
|
||||
if(set.contains(PosixFilePermission.GROUP_EXECUTE)) {
|
||||
action = action.or(Action.execute);
|
||||
}
|
||||
return action;
|
||||
}
|
||||
catch(IOException e) {
|
||||
return Action.none;
|
||||
}
|
||||
}
|
||||
return Action.none;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action getOther() {
|
||||
if(FileSystems.getDefault().supportedFileAttributeViews().contains("posix")) {
|
||||
try {
|
||||
final Set<PosixFilePermission> set = readAttributes(path, PosixFileAttributes.class).permissions();
|
||||
Action action = Action.none;
|
||||
if(set.contains(PosixFilePermission.OTHERS_READ)) {
|
||||
action = action.or(Action.read);
|
||||
}
|
||||
if(set.contains(PosixFilePermission.OTHERS_WRITE)) {
|
||||
action = action.or(Action.write);
|
||||
}
|
||||
if(set.contains(PosixFilePermission.OTHERS_EXECUTE)) {
|
||||
action = action.or(Action.execute);
|
||||
}
|
||||
return action;
|
||||
}
|
||||
catch(IOException e) {
|
||||
return Action.none;
|
||||
}
|
||||
}
|
||||
return Action.none;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,42 +1,46 @@
|
||||
package ch.cyberduck.core;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013 David Kocher. All rights reserved.
|
||||
* http://cyberduck.ch/
|
||||
* Copyright (c) 2002-2026 iterate GmbH. All rights reserved.
|
||||
* https://cyberduck.io/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* Bug fixes, suggestions and comments should be sent to:
|
||||
* feedback@cyberduck.ch
|
||||
*/
|
||||
|
||||
import ch.cyberduck.core.serializer.Serializer;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Encapsulating UNIX file permissions.
|
||||
*/
|
||||
public class Permission implements Serializable {
|
||||
private static final Logger log = LogManager.getLogger(Permission.class);
|
||||
|
||||
public static final Permission EMPTY = new Permission(Action.none, Action.none, Action.none) {
|
||||
public interface Permission extends Serializable {
|
||||
Permission EMPTY = new Permission() {
|
||||
@Override
|
||||
public boolean isExecutable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action getUser() {
|
||||
return Action.none;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action getGroup() {
|
||||
return Action.none;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action getOther() {
|
||||
return Action.none;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadable() {
|
||||
return true;
|
||||
@@ -47,11 +51,6 @@ public class Permission implements Serializable {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "--";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMode() {
|
||||
return "--";
|
||||
@@ -63,358 +62,137 @@ public class Permission implements Serializable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUser(final Action user) {
|
||||
// No-op
|
||||
public String toString() {
|
||||
return "--";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroup(final Action group) {
|
||||
// No-op
|
||||
public boolean equals(final Object obj) {
|
||||
if(null == obj) {
|
||||
return false;
|
||||
}
|
||||
if(obj instanceof Permission) {
|
||||
return ((Permission) obj).getUser().implies(Action.none)
|
||||
&& ((Permission) obj).getGroup().implies(Action.none)
|
||||
&& ((Permission) obj).getOther().implies(Action.none);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOther(final Action other) {
|
||||
// No-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSetuid(final boolean setuid) {
|
||||
// No-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSetgid(final boolean setgid) {
|
||||
// No-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSticky(final boolean sticky) {
|
||||
// No-op
|
||||
public int hashCode() {
|
||||
return Objects.hash(Action.none, Action.none, Action.none);
|
||||
}
|
||||
};
|
||||
|
||||
private Action user;
|
||||
private Action group;
|
||||
private Action other;
|
||||
/**
|
||||
* set user ID upon execution
|
||||
*/
|
||||
private boolean setuid;
|
||||
/**
|
||||
* set group ID upon execution
|
||||
*/
|
||||
private boolean setgid;
|
||||
private boolean sticky;
|
||||
|
||||
public Permission() {
|
||||
this.set(Action.none, Action.none, Action.none, false, false, false);
|
||||
}
|
||||
|
||||
public Permission(final String mode) {
|
||||
if(NumberUtils.isParsable(mode)) {
|
||||
this.fromInteger(Integer.parseInt(mode, 8));
|
||||
}
|
||||
else {
|
||||
this.fromSymbol(mode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct by the given {@link Action}.
|
||||
* Determines if the current permission setting allows reading.
|
||||
*
|
||||
* @param u user action
|
||||
* @param g group action
|
||||
* @param o other action
|
||||
* @return true if the permission is set to allow reading; false otherwise.
|
||||
*/
|
||||
public Permission(final Action u, final Action g, final Action o) {
|
||||
this.set(u, g, o, false, false, false);
|
||||
}
|
||||
|
||||
public Permission(final Action u, final Action g, final Action o,
|
||||
final boolean stickybit, final boolean setuid, final boolean setgid) {
|
||||
this.set(u, g, o, stickybit, setuid, setgid);
|
||||
default boolean isReadable() {
|
||||
return this.getUser().implies(Action.read);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modes may be absolute or symbolic. An absolute mode is an octal number constructed from the sum of one or more of the following values:
|
||||
* <p/>
|
||||
* 4000 (the set-user-ID-on-execution bit) Executable files with this bit set will run with effective uid set to the uid of the file owner.
|
||||
* Directories with the set-user-id bit set will force all files and sub-directories created in them to be owned by the directory owner
|
||||
* and not by the uid of the creating process, if the underlying file system supports this feature: see chmod(2) and the suiddir option to
|
||||
* mount(8).
|
||||
* 2000 (the set-group-ID-on-execution bit) Executable files with this bit set will run with effective gid set to the gid of the file owner.
|
||||
* 1000 (the sticky bit) See chmod(2) and sticky(8).
|
||||
* 0400 Allow read by owner.
|
||||
* 0200 Allow write by owner.
|
||||
* 0100 For files, allow execution by owner. For directories, allow the owner to search in the directory.
|
||||
* 0040 Allow read by group members.
|
||||
* 0020 Allow write by group members.
|
||||
* 0010 For files, allow execution by group members. For directories, allow group members to search in the directory.
|
||||
* 0004 Allow read by others.
|
||||
* 0002 Allow write by others.
|
||||
* 0001 For files, allow execution by others. For directories allow others to search in the directory.
|
||||
* Determines if the current permission setting allows writing.
|
||||
*
|
||||
* @param mode Mode
|
||||
* @return true if the permission is set to allow writing; false otherwise.
|
||||
*/
|
||||
public Permission(final int mode) {
|
||||
try {
|
||||
this.fromInteger(Integer.valueOf(Integer.toString(mode), 8));
|
||||
}
|
||||
catch(NumberFormatException e) {
|
||||
log.warn("Failure parsing {}", mode);
|
||||
this.set(Permission.EMPTY);
|
||||
}
|
||||
default boolean isWritable() {
|
||||
return this.getUser().implies(Action.write);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor
|
||||
* Determines if the current permission setting allows execution.
|
||||
*
|
||||
* @param other other permission
|
||||
* @return true if the permission is set to allow execution; false otherwise.
|
||||
*/
|
||||
public Permission(final Permission other) {
|
||||
this.set(other.user, other.group, other.other,
|
||||
other.sticky, other.setuid, other.setgid);
|
||||
default boolean isExecutable() {
|
||||
return this.getUser().implies(Action.execute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the action associated with the user permissions.
|
||||
*
|
||||
* @return The {@link Action} representing the user's permission level.
|
||||
*/
|
||||
Action getUser();
|
||||
|
||||
/**
|
||||
* Retrieves the action associated with the group permissions.
|
||||
*
|
||||
* @return The {@link Action} representing the group's permission level.
|
||||
*/
|
||||
Action getGroup();
|
||||
|
||||
/**
|
||||
* Retrieves the action associated with the other permissions.
|
||||
*
|
||||
* @return The {@link Action} representing the other's permission level.
|
||||
*/
|
||||
Action getOther();
|
||||
|
||||
/**
|
||||
* Constructs and retrieves the octal representation of the permission levels
|
||||
* for the user, group, and others based on their ordinal values.
|
||||
*
|
||||
* @return A string representing the octal permission mode. This value is
|
||||
* constructed by combining the permission levels of the user, group, and others
|
||||
* into a single integer, then converting it to its octal representation.
|
||||
*/
|
||||
default String getMode() {
|
||||
return Integer.toString(this.getUser().ordinal() << 6 |
|
||||
this.getGroup().ordinal() << 3 |
|
||||
this.getOther().ordinal(), 8);
|
||||
}
|
||||
|
||||
default boolean isSetuid() {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean isSetgid() {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean isSticky() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs and retrieves a symbolic representation of the user's permissions
|
||||
* based on readable, writable, and executable states.
|
||||
*
|
||||
* @return A string representing the symbolic notation of the user's permissions.
|
||||
* The string consists of three characters - 'r' for readable, 'w' for writable,
|
||||
* and 'x' for executable, or '-' for the absence of these permissions.
|
||||
*/
|
||||
default String getSymbol() {
|
||||
return String.format("%s%s%s",
|
||||
this.getUser().symbolic, this.getGroup().symbolic, this.getOther().symbolic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T serialize(final Serializer<T> dict) {
|
||||
default <T> T serialize(final Serializer<T> dict) {
|
||||
dict.setStringForKey(this.getSymbol(), "Mask");
|
||||
return dict.getSerialized();
|
||||
}
|
||||
|
||||
private void set(final Permission other) {
|
||||
this.set(other.user, other.group, other.other,
|
||||
other.sticky, other.setuid, other.setgid);
|
||||
}
|
||||
|
||||
private void set(final Action u, final Action g, final Action o,
|
||||
final boolean s, final boolean setuid, final boolean setgid) {
|
||||
this.user = u;
|
||||
this.group = g;
|
||||
this.other = o;
|
||||
this.sticky = s;
|
||||
this.setuid = setuid;
|
||||
this.setgid = setgid;
|
||||
}
|
||||
|
||||
private void fromInteger(int n) {
|
||||
Action[] v = Action.values();
|
||||
set(
|
||||
v[(n >>> 6) & 7],
|
||||
v[(n >>> 3) & 7],
|
||||
v[n & 7],
|
||||
((n >>> 9) & 1) == 1,
|
||||
((n >>> 9) & 4) == 4,
|
||||
((n >>> 9) & 2) == 2
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode the object to a integer.
|
||||
* Retrieves a descriptive representation of the permission.
|
||||
* The description combines the symbolic representation of the user's permissions
|
||||
* with the octal permission mode.
|
||||
*
|
||||
* @return A string representing the permission description in the format "symbolic (octal)".
|
||||
*/
|
||||
private int toInteger() {
|
||||
return (sticky ? 1 << 9 : 0) | (setuid ? 4 << 9 : 0) | (setgid ? 2 << 9 : 0) |
|
||||
user.ordinal() << 6 |
|
||||
group.ordinal() << 3 |
|
||||
other.ordinal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param symbol The perm symbols represent the portions of the mode bits as follows:
|
||||
* <p/>
|
||||
* r The read bits.
|
||||
* s The set-user-ID-on-execution and set-group-ID-on-execution bits.
|
||||
* t The sticky bit.
|
||||
* w The write bits.
|
||||
* x The execute/search bits.
|
||||
* X The execute/search bits if the file is a directory or any of the execute/search bits are set in the original (unmodified) mode. Operations with the perm symbol ``X'' are only
|
||||
* meaningful in conjunction with the op symbol ``+'', and are ignored in all other cases.
|
||||
* u The user permission bits in the original mode of the file.
|
||||
* g The group permission bits in the original mode of the file.
|
||||
* o The other permission bits in the original mode of the file.
|
||||
*/
|
||||
private void fromSymbol(final String symbol) {
|
||||
try {
|
||||
int n = 0;
|
||||
for(int i = 0; i < symbol.length(); i++) {
|
||||
n = n << 1;
|
||||
char c = symbol.charAt(i);
|
||||
n += (c == '-' || c == 'T' || c == 'S') ? 0 : 1;
|
||||
}
|
||||
// Add sticky bit value if set. The sticky bit is represented by the letter t in the final
|
||||
// character-place. If the sticky-bit is set on a file or directory without the execution bit set for the others category
|
||||
// (non-user-owner and non-group-owner), it is indicated with a capital T
|
||||
if(symbol.charAt(8) == 't' || symbol.charAt(8) == 'T') {
|
||||
// sticky bit octal integer
|
||||
n += 01000;
|
||||
}
|
||||
if(symbol.charAt(5) == 's' || symbol.charAt(5) == 'S') {
|
||||
//setgid octal integer
|
||||
n += 02000;
|
||||
}
|
||||
if(symbol.charAt(2) == 's' || symbol.charAt(2) == 'S') {
|
||||
//setuid octal integer
|
||||
n += 04000;
|
||||
}
|
||||
this.fromInteger(n);
|
||||
}
|
||||
catch(StringIndexOutOfBoundsException e) {
|
||||
log.warn("Failure parsing {}", symbol);
|
||||
this.set(Permission.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a thee-dimensional boolean array representing read, write
|
||||
* and execute permissions (in that order) of the file owner.
|
||||
*/
|
||||
public Action getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(final Action user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a thee-dimensional boolean array representing read, write
|
||||
* and execute permissions (in that order) of the group
|
||||
*/
|
||||
public Action getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public void setGroup(final Action group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a thee-dimensional boolean array representing read, write
|
||||
* and execute permissions (in that order) of any user
|
||||
*/
|
||||
public Action getOther() {
|
||||
return other;
|
||||
}
|
||||
|
||||
public void setOther(final Action other) {
|
||||
this.other = other;
|
||||
}
|
||||
|
||||
public boolean isSetuid() {
|
||||
return setuid;
|
||||
}
|
||||
|
||||
public void setSetuid(final boolean setuid) {
|
||||
this.setuid = setuid;
|
||||
}
|
||||
|
||||
public boolean isSetgid() {
|
||||
return setgid;
|
||||
}
|
||||
|
||||
public void setSetgid(final boolean setgid) {
|
||||
this.setgid = setgid;
|
||||
}
|
||||
|
||||
public boolean isSticky() {
|
||||
return sticky;
|
||||
}
|
||||
|
||||
public void setSticky(final boolean sticky) {
|
||||
this.sticky = sticky;
|
||||
}
|
||||
|
||||
public String getSymbol() {
|
||||
final StringBuilder symbolic = new StringBuilder();
|
||||
symbolic.append(setuid ? user.implies(Action.execute) ?
|
||||
StringUtils.substring(user.symbolic, 0, 2) + "s" : StringUtils.substring(user.symbolic, 0, 2) + "S" :
|
||||
user.symbolic);
|
||||
symbolic.append(setgid ? group.implies(Action.execute) ?
|
||||
StringUtils.substring(group.symbolic, 0, 2) + "s" : StringUtils.substring(group.symbolic, 0, 2) + "S" :
|
||||
group.symbolic);
|
||||
symbolic.append(sticky ? other.implies(Action.execute) ?
|
||||
StringUtils.substring(other.symbolic, 0, 2) + "t" : StringUtils.substring(other.symbolic, 0, 2) + "T" :
|
||||
other.symbolic);
|
||||
return symbolic.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The unix equivalent octal access code like 0777
|
||||
*/
|
||||
public String getMode() {
|
||||
return Integer.toString(toInteger(), 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return i.e. rwxrwxrwx (777)
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
default String getDescription() {
|
||||
return String.format("%s (%s)", this.getSymbol(), this.getMode());
|
||||
}
|
||||
|
||||
public boolean isExecutable() {
|
||||
return this.getUser().implies(Action.execute)
|
||||
|| this.getGroup().implies(Action.execute)
|
||||
|| this.getOther().implies(Action.execute);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if readable for user, group and world
|
||||
*/
|
||||
public boolean isReadable() {
|
||||
return this.getUser().implies(Action.read)
|
||||
|| this.getGroup().implies(Action.read)
|
||||
|| this.getOther().implies(Action.read);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if writable for user, group and world
|
||||
*/
|
||||
public boolean isWritable() {
|
||||
return this.getUser().implies(Action.write)
|
||||
|| this.getGroup().implies(Action.write)
|
||||
|| this.getOther().implies(Action.write);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if(this == o) {
|
||||
return true;
|
||||
}
|
||||
if(!(o instanceof Permission)) {
|
||||
return false;
|
||||
}
|
||||
final Permission that = (Permission) o;
|
||||
if(setgid != that.setgid) {
|
||||
return false;
|
||||
}
|
||||
if(setuid != that.setuid) {
|
||||
return false;
|
||||
}
|
||||
if(sticky != that.sticky) {
|
||||
return false;
|
||||
}
|
||||
if(group != that.group) {
|
||||
return false;
|
||||
}
|
||||
if(other != that.other) {
|
||||
return false;
|
||||
}
|
||||
if(user != that.user) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return toInteger();
|
||||
}
|
||||
|
||||
/**
|
||||
* POSIX style
|
||||
*/
|
||||
public enum Action {
|
||||
enum Action {
|
||||
none("---"),
|
||||
execute("--x"),
|
||||
write("-w-"),
|
||||
|
||||
@@ -60,7 +60,7 @@ public class PermissionOverwrite {
|
||||
}
|
||||
|
||||
public Permission resolve(final Permission original) {
|
||||
return new Permission(
|
||||
return new StaticPermission(
|
||||
user.resolve(original.getUser()),
|
||||
group.resolve(original.getGroup()),
|
||||
other.resolve(original.getOther()),
|
||||
|
||||
@@ -0,0 +1,333 @@
|
||||
package ch.cyberduck.core;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013 David Kocher. All rights reserved.
|
||||
* http://cyberduck.ch/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* Bug fixes, suggestions and comments should be sent to:
|
||||
* feedback@cyberduck.ch
|
||||
*/
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Encapsulating UNIX file permissions.
|
||||
*/
|
||||
public class StaticPermission implements Permission, Serializable {
|
||||
private static final Logger log = LogManager.getLogger(StaticPermission.class);
|
||||
|
||||
private Action user;
|
||||
private Action group;
|
||||
private Action other;
|
||||
/**
|
||||
* set user ID upon execution
|
||||
*/
|
||||
private boolean setuid;
|
||||
/**
|
||||
* set group ID upon execution
|
||||
*/
|
||||
private boolean setgid;
|
||||
private boolean sticky;
|
||||
|
||||
public StaticPermission() {
|
||||
this.set(Action.none, Action.none, Action.none, false, false, false);
|
||||
}
|
||||
|
||||
public StaticPermission(final Permission other) {
|
||||
this.set(other.getUser(), other.getGroup(), other.getOther(), false, false, false);
|
||||
}
|
||||
|
||||
public StaticPermission(final String mode) {
|
||||
if(NumberUtils.isParsable(mode)) {
|
||||
this.fromInteger(Integer.parseInt(mode, 8));
|
||||
}
|
||||
else {
|
||||
this.fromSymbol(mode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct by the given {@link Action}.
|
||||
*
|
||||
* @param u user action
|
||||
* @param g group action
|
||||
* @param o other action
|
||||
*/
|
||||
public StaticPermission(final Action u, final Action g, final Action o) {
|
||||
this.set(u, g, o, false, false, false);
|
||||
}
|
||||
|
||||
public StaticPermission(final Action u, final Action g, final Action o,
|
||||
final boolean stickybit, final boolean setuid, final boolean setgid) {
|
||||
this.set(u, g, o, stickybit, setuid, setgid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modes may be absolute or symbolic. An absolute mode is an octal number constructed from the sum of one or more of the following values:
|
||||
* <p/>
|
||||
* 4000 (the set-user-ID-on-execution bit) Executable files with this bit set will run with effective uid set to the uid of the file owner.
|
||||
* Directories with the set-user-id bit set will force all files and sub-directories created in them to be owned by the directory owner
|
||||
* and not by the uid of the creating process, if the underlying file system supports this feature: see chmod(2) and the suiddir option to
|
||||
* mount(8).
|
||||
* 2000 (the set-group-ID-on-execution bit) Executable files with this bit set will run with effective gid set to the gid of the file owner.
|
||||
* 1000 (the sticky bit) See chmod(2) and sticky(8).
|
||||
* 0400 Allow read by owner.
|
||||
* 0200 Allow write by owner.
|
||||
* 0100 For files, allow execution by owner. For directories, allow the owner to search in the directory.
|
||||
* 0040 Allow read by group members.
|
||||
* 0020 Allow write by group members.
|
||||
* 0010 For files, allow execution by group members. For directories, allow group members to search in the directory.
|
||||
* 0004 Allow read by others.
|
||||
* 0002 Allow write by others.
|
||||
* 0001 For files, allow execution by others. For directories allow others to search in the directory.
|
||||
*
|
||||
* @param mode Mode
|
||||
*/
|
||||
public StaticPermission(final int mode) {
|
||||
try {
|
||||
this.fromInteger(Integer.valueOf(Integer.toString(mode), 8));
|
||||
}
|
||||
catch(NumberFormatException e) {
|
||||
log.warn("Failure parsing {}", mode);
|
||||
this.set(Action.none, Action.none, Action.none, false, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor
|
||||
*
|
||||
* @param other other permission
|
||||
*/
|
||||
public StaticPermission(final StaticPermission other) {
|
||||
this.set(other.user, other.group, other.other,
|
||||
other.sticky, other.setuid, other.setgid);
|
||||
}
|
||||
|
||||
private void set(final Action u, final Action g, final Action o,
|
||||
final boolean s, final boolean setuid, final boolean setgid) {
|
||||
this.user = u;
|
||||
this.group = g;
|
||||
this.other = o;
|
||||
this.sticky = s;
|
||||
this.setuid = setuid;
|
||||
this.setgid = setgid;
|
||||
}
|
||||
|
||||
private void fromInteger(int n) {
|
||||
Action[] v = Action.values();
|
||||
set(
|
||||
v[(n >>> 6) & 7],
|
||||
v[(n >>> 3) & 7],
|
||||
v[n & 7],
|
||||
((n >>> 9) & 1) == 1,
|
||||
((n >>> 9) & 4) == 4,
|
||||
((n >>> 9) & 2) == 2
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode the object to a integer.
|
||||
*/
|
||||
private int toInteger() {
|
||||
return (sticky ? 1 << 9 : 0) | (setuid ? 4 << 9 : 0) | (setgid ? 2 << 9 : 0) |
|
||||
user.ordinal() << 6 |
|
||||
group.ordinal() << 3 |
|
||||
other.ordinal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param symbol The perm symbols represent the portions of the mode bits as follows:
|
||||
* <p/>
|
||||
* r The read bits.
|
||||
* s The set-user-ID-on-execution and set-group-ID-on-execution bits.
|
||||
* t The sticky bit.
|
||||
* w The write bits.
|
||||
* x The execute/search bits.
|
||||
* X The execute/search bits if the file is a directory or any of the execute/search bits are set in the original (unmodified) mode. Operations with the perm symbol ``X'' are only
|
||||
* meaningful in conjunction with the op symbol ``+'', and are ignored in all other cases.
|
||||
* u The user permission bits in the original mode of the file.
|
||||
* g The group permission bits in the original mode of the file.
|
||||
* o The other permission bits in the original mode of the file.
|
||||
*/
|
||||
private void fromSymbol(final String symbol) {
|
||||
try {
|
||||
int n = 0;
|
||||
for(int i = 0; i < symbol.length(); i++) {
|
||||
n = n << 1;
|
||||
char c = symbol.charAt(i);
|
||||
n += (c == '-' || c == 'T' || c == 'S') ? 0 : 1;
|
||||
}
|
||||
// Add sticky bit value if set. The sticky bit is represented by the letter t in the final
|
||||
// character-place. If the sticky-bit is set on a file or directory without the execution bit set for the others category
|
||||
// (non-user-owner and non-group-owner), it is indicated with a capital T
|
||||
if(symbol.charAt(8) == 't' || symbol.charAt(8) == 'T') {
|
||||
// sticky bit octal integer
|
||||
n += 01000;
|
||||
}
|
||||
if(symbol.charAt(5) == 's' || symbol.charAt(5) == 'S') {
|
||||
//setgid octal integer
|
||||
n += 02000;
|
||||
}
|
||||
if(symbol.charAt(2) == 's' || symbol.charAt(2) == 'S') {
|
||||
//setuid octal integer
|
||||
n += 04000;
|
||||
}
|
||||
this.fromInteger(n);
|
||||
}
|
||||
catch(StringIndexOutOfBoundsException e) {
|
||||
log.warn("Failure parsing {}", symbol);
|
||||
this.set(Action.none, Action.none, Action.none, false, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a thee-dimensional boolean array representing read, write
|
||||
* and execute permissions (in that order) of the file owner.
|
||||
*/
|
||||
@Override
|
||||
public Action getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(final Action user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a thee-dimensional boolean array representing read, write
|
||||
* and execute permissions (in that order) of the group
|
||||
*/
|
||||
@Override
|
||||
public Action getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public void setGroup(final Action group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a thee-dimensional boolean array representing read, write
|
||||
* and execute permissions (in that order) of any user
|
||||
*/
|
||||
@Override
|
||||
public Action getOther() {
|
||||
return other;
|
||||
}
|
||||
|
||||
public void setOther(final Action other) {
|
||||
this.other = other;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSetuid() {
|
||||
return setuid;
|
||||
}
|
||||
|
||||
public void setSetuid(final boolean setuid) {
|
||||
this.setuid = setuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSetgid() {
|
||||
return setgid;
|
||||
}
|
||||
|
||||
public void setSetgid(final boolean setgid) {
|
||||
this.setgid = setgid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSticky() {
|
||||
return sticky;
|
||||
}
|
||||
|
||||
public void setSticky(final boolean sticky) {
|
||||
this.sticky = sticky;
|
||||
}
|
||||
|
||||
public String getSymbol() {
|
||||
final StringBuilder symbolic = new StringBuilder();
|
||||
symbolic.append(setuid ? user.implies(Action.execute) ?
|
||||
StringUtils.substring(user.symbolic, 0, 2) + "s" : StringUtils.substring(user.symbolic, 0, 2) + "S" :
|
||||
user.symbolic);
|
||||
symbolic.append(setgid ? group.implies(Action.execute) ?
|
||||
StringUtils.substring(group.symbolic, 0, 2) + "s" : StringUtils.substring(group.symbolic, 0, 2) + "S" :
|
||||
group.symbolic);
|
||||
symbolic.append(sticky ? other.implies(Action.execute) ?
|
||||
StringUtils.substring(other.symbolic, 0, 2) + "t" : StringUtils.substring(other.symbolic, 0, 2) + "T" :
|
||||
other.symbolic);
|
||||
return symbolic.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The unix equivalent octal access code like 0777
|
||||
*/
|
||||
public String getMode() {
|
||||
return Integer.toString(this.toInteger(), 8);
|
||||
}
|
||||
|
||||
public boolean isExecutable() {
|
||||
return this.getUser().implies(Action.execute)
|
||||
|| this.getGroup().implies(Action.execute)
|
||||
|| this.getOther().implies(Action.execute);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if readable for user, group and world
|
||||
*/
|
||||
public boolean isReadable() {
|
||||
return this.getUser().implies(Action.read)
|
||||
|| this.getGroup().implies(Action.read)
|
||||
|| this.getOther().implies(Action.read);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if writable for user, group and world
|
||||
*/
|
||||
public boolean isWritable() {
|
||||
return this.getUser().implies(Action.write)
|
||||
|| this.getGroup().implies(Action.write)
|
||||
|| this.getOther().implies(Action.write);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(null == obj) {
|
||||
return false;
|
||||
}
|
||||
if(obj instanceof Permission) {
|
||||
if(!(user == ((Permission) obj).getUser())) {
|
||||
return false;
|
||||
}
|
||||
if(!(group == ((Permission) obj).getGroup())) {
|
||||
return false;
|
||||
}
|
||||
if(!(other == ((Permission) obj).getOther())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(user, group, other);
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ public class UnsecureHostPasswordStore extends DefaultHostPasswordStore {
|
||||
log.warn("Failure saving credentials to {}. {}", file.getAbsolute(), e.getMessage());
|
||||
throw new LocalAccessDeniedException(e.getMessage(), e);
|
||||
}
|
||||
file.attributes().setPermission(new Permission(600));
|
||||
file.attributes().setPermission(new StaticPermission(600));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@ package ch.cyberduck.core.features;
|
||||
import ch.cyberduck.core.Acl;
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.exception.BackgroundException;
|
||||
import ch.cyberduck.core.preferences.Preferences;
|
||||
import ch.cyberduck.core.preferences.PreferencesFactory;
|
||||
@@ -73,10 +74,10 @@ public interface AclPermission {
|
||||
default Acl getDefault(final Path file) throws BackgroundException {
|
||||
if(preferences.getBoolean("queue.upload.permissions.default")) {
|
||||
if(file.getType().contains(Path.Type.file)) {
|
||||
return toAcl(new Permission(preferences.getInteger("queue.upload.permissions.file.default")));
|
||||
return toAcl(new StaticPermission(preferences.getInteger("queue.upload.permissions.file.default")));
|
||||
}
|
||||
else {
|
||||
return toAcl(new Permission(preferences.getInteger("queue.upload.permissions.folder.default")));
|
||||
return toAcl(new StaticPermission(preferences.getInteger("queue.upload.permissions.folder.default")));
|
||||
}
|
||||
}
|
||||
return Acl.EMPTY;
|
||||
|
||||
@@ -17,6 +17,7 @@ package ch.cyberduck.core.features;
|
||||
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.exception.BackgroundException;
|
||||
import ch.cyberduck.core.preferences.Preferences;
|
||||
import ch.cyberduck.core.preferences.PreferencesFactory;
|
||||
@@ -50,10 +51,10 @@ public interface UnixPermission {
|
||||
default Permission getDefault(final Path workdir, final EnumSet<Path.Type> type) {
|
||||
if(preferences.getBoolean("queue.upload.permissions.default")) {
|
||||
if(type.contains(Path.Type.file)) {
|
||||
return new Permission(preferences.getInteger("queue.upload.permissions.file.default"));
|
||||
return new StaticPermission(preferences.getInteger("queue.upload.permissions.file.default"));
|
||||
}
|
||||
else {
|
||||
return new Permission(preferences.getInteger("queue.upload.permissions.folder.default"));
|
||||
return new StaticPermission(preferences.getInteger("queue.upload.permissions.folder.default"));
|
||||
}
|
||||
}
|
||||
return Permission.EMPTY;
|
||||
|
||||
@@ -20,6 +20,7 @@ package ch.cyberduck.core.serializer;
|
||||
|
||||
import ch.cyberduck.core.DeserializerFactory;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
|
||||
public class PermissionDictionary<T> {
|
||||
|
||||
@@ -35,6 +36,6 @@ public class PermissionDictionary<T> {
|
||||
|
||||
public Permission deserialize(T serialized) {
|
||||
final Deserializer<T> dict = deserializer.create(serialized);
|
||||
return new Permission(dict.stringForKey("Mask"));
|
||||
return new StaticPermission(dict.stringForKey("Mask"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import ch.cyberduck.core.PathAttributes;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.ProgressListener;
|
||||
import ch.cyberduck.core.Session;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.UrlProvider;
|
||||
import ch.cyberduck.core.exception.AccessDeniedException;
|
||||
import ch.cyberduck.core.exception.BackgroundException;
|
||||
@@ -163,11 +164,11 @@ public abstract class AbstractDownloadFilter implements TransferPathFilter {
|
||||
Permission permission = Permission.EMPTY;
|
||||
if(preferences.getBoolean("queue.download.permissions.default")) {
|
||||
if(file.isFile()) {
|
||||
permission = new Permission(
|
||||
permission = new StaticPermission(
|
||||
preferences.getInteger("queue.download.permissions.file.default"));
|
||||
}
|
||||
if(file.isDirectory()) {
|
||||
permission = new Permission(
|
||||
permission = new StaticPermission(
|
||||
preferences.getInteger("queue.download.permissions.folder.default"));
|
||||
}
|
||||
}
|
||||
@@ -314,17 +315,18 @@ public abstract class AbstractDownloadFilter implements TransferPathFilter {
|
||||
}
|
||||
}
|
||||
if(!Permission.EMPTY.equals(status.getPermission())) {
|
||||
final StaticPermission applied = new StaticPermission(status.getPermission());
|
||||
if(file.isDirectory()) {
|
||||
// Make sure we can read & write files to directory created.
|
||||
status.getPermission().setUser(status.getPermission().getUser().or(Permission.Action.read).or(Permission.Action.write).or(Permission.Action.execute));
|
||||
applied.setUser(applied.getUser().or(Permission.Action.read).or(Permission.Action.write).or(Permission.Action.execute));
|
||||
}
|
||||
if(file.isFile()) {
|
||||
// Make sure the owner can always read and write.
|
||||
status.getPermission().setUser(status.getPermission().getUser().or(Permission.Action.read).or(Permission.Action.write));
|
||||
applied.setUser(applied.getUser().or(Permission.Action.read).or(Permission.Action.write));
|
||||
}
|
||||
log.info("Updating permissions of {} to {}", local, status.getPermission());
|
||||
log.info("Updating permissions of {} to {}", local, applied);
|
||||
try {
|
||||
local.attributes().setPermission(status.getPermission());
|
||||
local.attributes().setPermission(applied);
|
||||
}
|
||||
catch(AccessDeniedException e) {
|
||||
// Ignore
|
||||
|
||||
@@ -27,7 +27,7 @@ public class DefaultPathAttributesTest {
|
||||
attributes.setVersionId(new AlphanumericRandomStringService().random());
|
||||
attributes.setDuplicate(true);
|
||||
attributes.setLockId(new AlphanumericRandomStringService().random());
|
||||
attributes.setPermission(new Permission(644));
|
||||
attributes.setPermission(new StaticPermission(644));
|
||||
attributes.setVerdict(PathAttributes.Verdict.pending);
|
||||
attributes.setTrashed(true);
|
||||
attributes.setHidden(true);
|
||||
@@ -75,7 +75,7 @@ public class DefaultPathAttributesTest {
|
||||
final DefaultPathAttributes attributes = new DefaultPathAttributes();
|
||||
attributes.setSize(100);
|
||||
attributes.setModificationDate(System.currentTimeMillis());
|
||||
attributes.setPermission(new Permission("644"));
|
||||
attributes.setPermission(new StaticPermission("644"));
|
||||
final Acl acl = new Acl();
|
||||
acl.addAll(new Acl.CanonicalUser("user1"), new Acl.Role(Acl.Role.READ), new Acl.Role(Acl.Role.WRITE));
|
||||
acl.addAll(new Acl.CanonicalUser("user2"), new Acl.Role(Acl.Role.FULL));
|
||||
|
||||
@@ -1,180 +0,0 @@
|
||||
package ch.cyberduck.core;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005 David Kocher. All rights reserved.
|
||||
* http://cyberduck.ch/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* Bug fixes, suggestions and comments should be sent to:
|
||||
* dkocher@cyberduck.ch
|
||||
*/
|
||||
|
||||
import ch.cyberduck.core.serializer.PermissionDictionary;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class PermissionTest {
|
||||
|
||||
@Test
|
||||
public void testGetAsDictionary() {
|
||||
assertEquals(new Permission(777), new PermissionDictionary().deserialize(new Permission(777).serialize(SerializerFactory.get())));
|
||||
assertEquals(new Permission(700), new PermissionDictionary().deserialize(new Permission(700).serialize(SerializerFactory.get())));
|
||||
assertEquals(new Permission(400), new PermissionDictionary().deserialize(new Permission(400).serialize(SerializerFactory.get())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSymbol() {
|
||||
Permission p1 = new Permission(777);
|
||||
assertEquals("rwxrwxrwx", p1.getSymbol());
|
||||
Permission p2 = new Permission(666);
|
||||
assertEquals("rw-rw-rw-", p2.getSymbol());
|
||||
}
|
||||
|
||||
/**
|
||||
* 4000 (the set-user-ID-on-execution bit) Executable files with this bit set will run with effective uid set to the uid of the file owner.
|
||||
* Directories with the set-user-id bit set will force all files and sub-directories created in them to be owned by the directory owner
|
||||
* and not by the uid of the creating process, if the underlying file system supports this feature: see chmod(2) and the suiddir option to
|
||||
* mount(8).
|
||||
*/
|
||||
@Test
|
||||
public void testSetUid() {
|
||||
assertTrue(new Permission(Permission.Action.read, Permission.Action.none, Permission.Action.none,
|
||||
false, true, false).isSetuid());
|
||||
assertTrue(new Permission(4755).isSetuid());
|
||||
assertTrue(new Permission(6755).isSetuid());
|
||||
assertTrue(new Permission(5755).isSetuid());
|
||||
assertFalse(new Permission(1755).isSetuid());
|
||||
assertEquals("--S------", new Permission(4000).getSymbol());
|
||||
assertEquals("4000", new Permission(4000).getMode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 2000 (the set-group-ID-on-execution bit) Executable files with this bit set will run with effective gid set to the gid of the file owner.
|
||||
*/
|
||||
@Test
|
||||
public void testSetGid() {
|
||||
assertTrue(new Permission(Permission.Action.read, Permission.Action.none, Permission.Action.none,
|
||||
false, false, true).isSetgid());
|
||||
assertTrue(new Permission(2755).isSetgid());
|
||||
assertTrue(new Permission(3755).isSetgid());
|
||||
assertTrue(new Permission(6755).isSetgid());
|
||||
assertFalse(new Permission(1755).isSetgid());
|
||||
assertEquals("-----S---", new Permission(2000).getSymbol());
|
||||
assertEquals("2000", new Permission(2000).getMode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 1000 (the sticky bit) See chmod(2) and sticky(8).
|
||||
*/
|
||||
@Test
|
||||
public void testSetSticky() {
|
||||
assertTrue(new Permission(1755).isSticky());
|
||||
assertTrue(new Permission(3755).isSticky());
|
||||
assertTrue(new Permission(5755).isSticky());
|
||||
assertFalse(new Permission(2755).isSticky());
|
||||
assertFalse(new Permission(6755).isSticky());
|
||||
assertEquals("1000", new Permission(1000).getMode());
|
||||
assertEquals("--------T", new Permission(1000).getSymbol());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActions() {
|
||||
assertEquals(Permission.Action.read_write, Permission.Action.all.and(Permission.Action.execute.not()));
|
||||
assertEquals(Permission.Action.read, Permission.Action.none.or(Permission.Action.read));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToMode() {
|
||||
final Permission permission = new Permission(Permission.Action.read,
|
||||
Permission.Action.none, Permission.Action.none);
|
||||
assertEquals("400", permission.getMode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFromMode() {
|
||||
assertEquals(Permission.Action.all, (new Permission("rwxrwxrwx").getUser()));
|
||||
assertEquals(Permission.Action.all, (new Permission("rwxrwxrwx").getGroup()));
|
||||
assertEquals(Permission.Action.all, (new Permission("rwxrwxrwx").getOther()));
|
||||
assertEquals(Permission.Action.all, (new Permission("rwxrwxrwt").getOther()));
|
||||
assertEquals(Permission.Action.read_write, (new Permission("rwxrwxrwT").getOther()));
|
||||
assertEquals(Permission.Action.read, (new Permission("r--r--r--").getUser()));
|
||||
assertEquals(Permission.Action.read, (new Permission("s--r--r--").getUser()));
|
||||
assertEquals(Permission.Action.none, (new Permission("S--r--r--").getUser()));
|
||||
assertEquals(Permission.Action.read, (new Permission("r--r--r--").getGroup()));
|
||||
assertEquals(Permission.Action.read, (new Permission("r--r--r--").getOther()));
|
||||
assertEquals(Permission.Action.read_write, (new Permission("rw-rw-rw-").getUser()));
|
||||
assertEquals(Permission.Action.read_write, (new Permission("rw-rw-rw-").getGroup()));
|
||||
assertEquals(Permission.Action.read_write, (new Permission("rw-rw-rw-").getOther()));
|
||||
assertEquals(Permission.Action.read_execute, (new Permission("r-xr-xr-x").getUser()));
|
||||
assertEquals(Permission.Action.read_execute, (new Permission("r-xr-xr-x").getGroup()));
|
||||
assertEquals(Permission.Action.read_execute, (new Permission("r-xr-xr-x").getOther()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModeStickyBit() {
|
||||
final Permission permission = new Permission(Permission.Action.read,
|
||||
Permission.Action.none, Permission.Action.none, true, false, false);
|
||||
assertEquals("1400", permission.getMode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailureParsing() {
|
||||
assertEquals(Permission.EMPTY, new Permission("rwx"));
|
||||
assertEquals(Permission.EMPTY, new Permission(888));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmpty() {
|
||||
assertEquals(Permission.EMPTY, new Permission());
|
||||
assertEquals(Permission.EMPTY, new Permission(0));
|
||||
assertTrue(Permission.EMPTY.isReadable());
|
||||
assertTrue(Permission.EMPTY.isWritable());
|
||||
assertTrue(Permission.EMPTY.isExecutable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInit() {
|
||||
assertEquals(new Permission(1000), new Permission("--------T"));
|
||||
assertEquals(new Permission(2000), new Permission("-----S---"));
|
||||
assertEquals(new Permission(2010), new Permission("-----s---"));
|
||||
assertEquals(new Permission(4000), new Permission("--S------"));
|
||||
assertEquals(new Permission(4100), new Permission("--s------"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitMode() {
|
||||
assertEquals(new Permission("rwxr-x---"), new Permission("0750"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImplies() {
|
||||
assertTrue(new Permission("r--------").getUser().implies(Permission.Action.read));
|
||||
assertTrue(new Permission("r-x------").getUser().implies(Permission.Action.execute));
|
||||
assertTrue(new Permission("r-s------").getUser().implies(Permission.Action.execute));
|
||||
assertFalse(new Permission("r-S------").getUser().implies(Permission.Action.execute));
|
||||
assertTrue(new Permission("r--------").isReadable());
|
||||
assertFalse(new Permission("r--------").isWritable());
|
||||
assertTrue(new Permission("-w-------").getUser().implies(Permission.Action.write));
|
||||
assertTrue(new Permission("-w-------").isWritable());
|
||||
assertTrue(new Permission("--x------").getUser().implies(Permission.Action.execute));
|
||||
assertTrue(new Permission("--x------").isExecutable());
|
||||
assertTrue(new Permission("---r-----").getGroup().implies(Permission.Action.read));
|
||||
assertTrue(new Permission("---r-x---").getGroup().implies(Permission.Action.execute));
|
||||
assertTrue(new Permission("---r-s---").getGroup().implies(Permission.Action.execute));
|
||||
assertFalse(new Permission("---r-S---").getGroup().implies(Permission.Action.execute));
|
||||
assertTrue(new Permission("--------x").getOther().implies(Permission.Action.execute));
|
||||
assertTrue(new Permission("--------t").getOther().implies(Permission.Action.execute));
|
||||
assertFalse(new Permission("--------T").getOther().implies(Permission.Action.execute));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package ch.cyberduck.core;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005 David Kocher. All rights reserved.
|
||||
* http://cyberduck.ch/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* Bug fixes, suggestions and comments should be sent to:
|
||||
* dkocher@cyberduck.ch
|
||||
*/
|
||||
|
||||
import ch.cyberduck.core.serializer.PermissionDictionary;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class StaticPermissionTest {
|
||||
|
||||
@Test
|
||||
public void testGetAsDictionary() {
|
||||
assertEquals(new StaticPermission(777), new PermissionDictionary<>().deserialize(new StaticPermission(777).serialize(SerializerFactory.get())));
|
||||
assertEquals(new StaticPermission(700), new PermissionDictionary<>().deserialize(new StaticPermission(700).serialize(SerializerFactory.get())));
|
||||
assertEquals(new StaticPermission(400), new PermissionDictionary<>().deserialize(new StaticPermission(400).serialize(SerializerFactory.get())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSymbol() {
|
||||
Permission p1 = new StaticPermission(777);
|
||||
assertEquals("rwxrwxrwx", p1.getSymbol());
|
||||
Permission p2 = new StaticPermission(666);
|
||||
assertEquals("rw-rw-rw-", p2.getSymbol());
|
||||
}
|
||||
|
||||
/**
|
||||
* 4000 (the set-user-ID-on-execution bit) Executable files with this bit set will run with effective uid set to the uid of the file owner.
|
||||
* Directories with the set-user-id bit set will force all files and sub-directories created in them to be owned by the directory owner
|
||||
* and not by the uid of the creating process, if the underlying file system supports this feature: see chmod(2) and the suiddir option to
|
||||
* mount(8).
|
||||
*/
|
||||
@Test
|
||||
public void testSetUid() {
|
||||
assertTrue(new StaticPermission(Permission.Action.read, Permission.Action.none, Permission.Action.none,
|
||||
false, true, false).isSetuid());
|
||||
assertTrue(new StaticPermission(4755).isSetuid());
|
||||
assertTrue(new StaticPermission(6755).isSetuid());
|
||||
assertTrue(new StaticPermission(5755).isSetuid());
|
||||
assertFalse(new StaticPermission(1755).isSetuid());
|
||||
assertEquals("--S------", new StaticPermission(4000).getSymbol());
|
||||
assertEquals("4000", new StaticPermission(4000).getMode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 2000 (the set-group-ID-on-execution bit) Executable files with this bit set will run with effective gid set to the gid of the file owner.
|
||||
*/
|
||||
@Test
|
||||
public void testSetGid() {
|
||||
assertTrue(new StaticPermission(Permission.Action.read, Permission.Action.none, Permission.Action.none,
|
||||
false, false, true).isSetgid());
|
||||
assertTrue(new StaticPermission(2755).isSetgid());
|
||||
assertTrue(new StaticPermission(3755).isSetgid());
|
||||
assertTrue(new StaticPermission(6755).isSetgid());
|
||||
assertFalse(new StaticPermission(1755).isSetgid());
|
||||
assertEquals("-----S---", new StaticPermission(2000).getSymbol());
|
||||
assertEquals("2000", new StaticPermission(2000).getMode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 1000 (the sticky bit) See chmod(2) and sticky(8).
|
||||
*/
|
||||
@Test
|
||||
public void testSetSticky() {
|
||||
assertTrue(new StaticPermission(1755).isSticky());
|
||||
assertTrue(new StaticPermission(3755).isSticky());
|
||||
assertTrue(new StaticPermission(5755).isSticky());
|
||||
assertFalse(new StaticPermission(2755).isSticky());
|
||||
assertFalse(new StaticPermission(6755).isSticky());
|
||||
assertEquals("1000", new StaticPermission(1000).getMode());
|
||||
assertEquals("--------T", new StaticPermission(1000).getSymbol());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActions() {
|
||||
assertEquals(Permission.Action.read_write, Permission.Action.all.and(Permission.Action.execute.not()));
|
||||
assertEquals(Permission.Action.read, Permission.Action.none.or(Permission.Action.read));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToMode() {
|
||||
final Permission permission = new StaticPermission(Permission.Action.read,
|
||||
Permission.Action.none, Permission.Action.none);
|
||||
assertEquals("400", permission.getMode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFromMode() {
|
||||
assertEquals(Permission.Action.all, (new StaticPermission("rwxrwxrwx").getUser()));
|
||||
assertEquals(Permission.Action.all, (new StaticPermission("rwxrwxrwx").getGroup()));
|
||||
assertEquals(Permission.Action.all, (new StaticPermission("rwxrwxrwx").getOther()));
|
||||
assertEquals(Permission.Action.all, (new StaticPermission("rwxrwxrwt").getOther()));
|
||||
assertEquals(Permission.Action.read_write, (new StaticPermission("rwxrwxrwT").getOther()));
|
||||
assertEquals(Permission.Action.read, (new StaticPermission("r--r--r--").getUser()));
|
||||
assertEquals(Permission.Action.read, (new StaticPermission("s--r--r--").getUser()));
|
||||
assertEquals(Permission.Action.none, (new StaticPermission("S--r--r--").getUser()));
|
||||
assertEquals(Permission.Action.read, (new StaticPermission("r--r--r--").getGroup()));
|
||||
assertEquals(Permission.Action.read, (new StaticPermission("r--r--r--").getOther()));
|
||||
assertEquals(Permission.Action.read_write, (new StaticPermission("rw-rw-rw-").getUser()));
|
||||
assertEquals(Permission.Action.read_write, (new StaticPermission("rw-rw-rw-").getGroup()));
|
||||
assertEquals(Permission.Action.read_write, (new StaticPermission("rw-rw-rw-").getOther()));
|
||||
assertEquals(Permission.Action.read_execute, (new StaticPermission("r-xr-xr-x").getUser()));
|
||||
assertEquals(Permission.Action.read_execute, (new StaticPermission("r-xr-xr-x").getGroup()));
|
||||
assertEquals(Permission.Action.read_execute, (new StaticPermission("r-xr-xr-x").getOther()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModeStickyBit() {
|
||||
final Permission permission = new StaticPermission(Permission.Action.read,
|
||||
Permission.Action.none, Permission.Action.none, true, false, false);
|
||||
assertEquals("1400", permission.getMode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailureParsing() {
|
||||
assertEquals(Permission.EMPTY, new StaticPermission("rwx"));
|
||||
assertEquals(Permission.EMPTY, new StaticPermission(888));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmpty() {
|
||||
assertEquals(Permission.EMPTY, new StaticPermission());
|
||||
assertEquals(Permission.EMPTY, new StaticPermission(0));
|
||||
assertTrue(Permission.EMPTY.isReadable());
|
||||
assertTrue(Permission.EMPTY.isWritable());
|
||||
assertTrue(Permission.EMPTY.isExecutable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInit() {
|
||||
assertEquals(new StaticPermission(1000), new StaticPermission("--------T"));
|
||||
assertEquals(new StaticPermission(2000), new StaticPermission("-----S---"));
|
||||
assertEquals(new StaticPermission(2010), new StaticPermission("-----s---"));
|
||||
assertEquals(new StaticPermission(4000), new StaticPermission("--S------"));
|
||||
assertEquals(new StaticPermission(4100), new StaticPermission("--s------"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitMode() {
|
||||
assertEquals(new StaticPermission("rwxr-x---"), new StaticPermission("0750"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImplies() {
|
||||
assertTrue(new StaticPermission("r--------").getUser().implies(Permission.Action.read));
|
||||
assertTrue(new StaticPermission("r-x------").getUser().implies(Permission.Action.execute));
|
||||
assertTrue(new StaticPermission("r-s------").getUser().implies(Permission.Action.execute));
|
||||
assertFalse(new StaticPermission("r-S------").getUser().implies(Permission.Action.execute));
|
||||
assertTrue(new StaticPermission("r--------").isReadable());
|
||||
assertFalse(new StaticPermission("r--------").isWritable());
|
||||
assertTrue(new StaticPermission("-w-------").getUser().implies(Permission.Action.write));
|
||||
assertTrue(new StaticPermission("-w-------").isWritable());
|
||||
assertTrue(new StaticPermission("--x------").getUser().implies(Permission.Action.execute));
|
||||
assertTrue(new StaticPermission("--x------").isExecutable());
|
||||
assertTrue(new StaticPermission("---r-----").getGroup().implies(Permission.Action.read));
|
||||
assertTrue(new StaticPermission("---r-x---").getGroup().implies(Permission.Action.execute));
|
||||
assertTrue(new StaticPermission("---r-s---").getGroup().implies(Permission.Action.execute));
|
||||
assertFalse(new StaticPermission("---r-S---").getGroup().implies(Permission.Action.execute));
|
||||
assertTrue(new StaticPermission("--------x").getOther().implies(Permission.Action.execute));
|
||||
assertTrue(new StaticPermission("--------t").getOther().implies(Permission.Action.execute));
|
||||
assertFalse(new StaticPermission("--------T").getOther().implies(Permission.Action.execute));
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package ch.cyberduck.core;
|
||||
|
||||
public class TestPermissionAttributes extends DefaultPathAttributes {
|
||||
public TestPermissionAttributes(Permission.Action action) {
|
||||
this(action, action);
|
||||
}
|
||||
|
||||
public TestPermissionAttributes(Permission.Action userGroup, Permission.Action other) {
|
||||
this(userGroup, userGroup, other);
|
||||
}
|
||||
|
||||
public TestPermissionAttributes(Permission.Action user, Permission.Action group, Permission.Action other) {
|
||||
super();
|
||||
setPermission(new Permission(user, group, other));
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import ch.cyberduck.core.DescriptiveUrl;
|
||||
import ch.cyberduck.core.PathAttributes;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.SerializerFactory;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.io.Checksum;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -36,7 +37,7 @@ public class PathAttributesDictionaryTest {
|
||||
attributes.setTrashed(true);
|
||||
attributes.setHidden(true);
|
||||
attributes.setModificationDate(System.currentTimeMillis());
|
||||
attributes.setPermission(new Permission(Permission.Action.none, Permission.Action.write, Permission.Action.execute));
|
||||
attributes.setPermission(new StaticPermission(Permission.Action.none, Permission.Action.write, Permission.Action.execute));
|
||||
PathAttributes clone = new PathAttributesDictionary<>().deserialize(attributes.serialize(SerializerFactory.get()));
|
||||
assertEquals(clone.getPermission(), attributes.getPermission());
|
||||
assertEquals(clone.getModificationDate(), attributes.getModificationDate());
|
||||
@@ -64,7 +65,7 @@ public class PathAttributesDictionaryTest {
|
||||
@Test
|
||||
public void testSerializeHashCode() {
|
||||
PathAttributes attributes = new DefaultPathAttributes();
|
||||
attributes.setPermission(new Permission(644));
|
||||
attributes.setPermission(new StaticPermission(644));
|
||||
attributes.setDuplicate(true);
|
||||
attributes.setVersionId("v-1");
|
||||
attributes.setFileId("myUniqueId");
|
||||
|
||||
@@ -7,6 +7,7 @@ import ch.cyberduck.core.NullTransferSession;
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.ProgressListener;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.TestProtocol;
|
||||
import ch.cyberduck.core.exception.BackgroundException;
|
||||
import ch.cyberduck.core.features.Find;
|
||||
@@ -89,7 +90,7 @@ public class OverwriteFilterTest {
|
||||
final HashMap<Path, Path> files = new HashMap<>();
|
||||
final Path source = new Path("a", EnumSet.of(Path.Type.file));
|
||||
source.attributes().setSize(1L);
|
||||
source.attributes().setPermission(new Permission(777));
|
||||
source.attributes().setPermission(new StaticPermission(777));
|
||||
final Long time = System.currentTimeMillis();
|
||||
source.attributes().setModificationDate(time);
|
||||
final boolean[] timestampWrite = new boolean[1];
|
||||
@@ -130,7 +131,7 @@ public class OverwriteFilterTest {
|
||||
|
||||
@Override
|
||||
public void setUnixPermission(final Path file, final TransferStatus status) {
|
||||
assertEquals(new Permission(777), status.getPermission());
|
||||
assertEquals(new StaticPermission(777), status.getPermission());
|
||||
permissionWrite[0] = true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@ import ch.cyberduck.core.NullTransferSession;
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.ProgressListener;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.TestProtocol;
|
||||
import ch.cyberduck.core.exception.AccessDeniedException;
|
||||
import ch.cyberduck.core.local.DefaultLocalTouchFeature;
|
||||
@@ -63,7 +64,7 @@ public class OverwriteFilterTest {
|
||||
final Path p = new Path("a", EnumSet.of(Path.Type.file));
|
||||
p.attributes().setSize(8L);
|
||||
p.attributes().setModificationDate(1L);
|
||||
p.attributes().setPermission(new Permission(777));
|
||||
p.attributes().setPermission(new StaticPermission(777));
|
||||
final TransferStatus status = f.prepare(p, new NullLocal("a") {
|
||||
@Override
|
||||
public LocalAttributes attributes() {
|
||||
@@ -82,7 +83,7 @@ public class OverwriteFilterTest {
|
||||
}, new TransferStatus(), ProgressListener.noop);
|
||||
assertEquals(8L, status.getLength(), 0L);
|
||||
assertEquals(1L, status.getModified(), 0L);
|
||||
assertEquals(new Permission(777), status.getPermission());
|
||||
assertEquals(new StaticPermission(777), status.getPermission());
|
||||
}
|
||||
|
||||
@Test(expected = AccessDeniedException.class)
|
||||
|
||||
@@ -17,12 +17,13 @@ package ch.cyberduck.core.worker;
|
||||
* Bug fixes, suggestions and comments should be sent to feedback@cyberduck.ch
|
||||
*/
|
||||
|
||||
import ch.cyberduck.core.DefaultPathAttributes;
|
||||
import ch.cyberduck.core.Host;
|
||||
import ch.cyberduck.core.NullSession;
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.PermissionOverwrite;
|
||||
import ch.cyberduck.core.TestPermissionAttributes;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.TestProtocol;
|
||||
import ch.cyberduck.core.exception.BackgroundException;
|
||||
import ch.cyberduck.core.features.UnixPermission;
|
||||
@@ -43,8 +44,11 @@ public class ReadPermissionWorkerTest {
|
||||
public void testRun() throws Exception {
|
||||
final ReadPermissionWorker worker = new ReadPermissionWorker(
|
||||
Arrays.asList(
|
||||
new Path("/a", EnumSet.of(Path.Type.file), new TestPermissionAttributes(Permission.Action.all, Permission.Action.all, Permission.Action.none)),
|
||||
new Path("/b", EnumSet.of(Path.Type.file), new TestPermissionAttributes(Permission.Action.all, Permission.Action.read_write, Permission.Action.read)))) {
|
||||
new Path("/a", EnumSet.of(Path.Type.file), new DefaultPathAttributes().setPermission(
|
||||
new StaticPermission(Permission.Action.all, Permission.Action.all, Permission.Action.none))),
|
||||
new Path("/b", EnumSet.of(Path.Type.file), new DefaultPathAttributes().setPermission(
|
||||
new StaticPermission(Permission.Action.all, Permission.Action.read_write, Permission.Action.read))))
|
||||
) {
|
||||
@Override
|
||||
public void cleanup(final PermissionOverwrite result) {
|
||||
//
|
||||
|
||||
@@ -19,6 +19,7 @@ package ch.cyberduck.core.worker;
|
||||
*/
|
||||
|
||||
import ch.cyberduck.core.AttributedList;
|
||||
import ch.cyberduck.core.DefaultPathAttributes;
|
||||
import ch.cyberduck.core.Host;
|
||||
import ch.cyberduck.core.ListProgressListener;
|
||||
import ch.cyberduck.core.NullSession;
|
||||
@@ -26,7 +27,7 @@ import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.PermissionOverwrite;
|
||||
import ch.cyberduck.core.ProgressListener;
|
||||
import ch.cyberduck.core.TestPermissionAttributes;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.TestProtocol;
|
||||
import ch.cyberduck.core.exception.BackgroundException;
|
||||
import ch.cyberduck.core.features.UnixPermission;
|
||||
@@ -51,14 +52,16 @@ public class WritePermissionWorkerTest {
|
||||
new PermissionOverwrite.Action(true, false, false)
|
||||
);
|
||||
// Tests all actions set to read
|
||||
final Path path = new Path("a", EnumSet.of(Path.Type.directory), new TestPermissionAttributes(Permission.Action.read));
|
||||
final Path path = new Path("a", EnumSet.of(Path.Type.directory), new DefaultPathAttributes().setPermission(
|
||||
new StaticPermission(Permission.Action.read, Permission.Action.read, Permission.Action.read)));
|
||||
final WritePermissionWorker worker = new WritePermissionWorker(Collections.singletonList(path), permission, new BooleanRecursiveCallback<>(true), ProgressListener.noop);
|
||||
worker.run(new NullSession(new Host(new TestProtocol())) {
|
||||
@Override
|
||||
public AttributedList<Path> list(final Path file, final ListProgressListener listener) {
|
||||
final AttributedList<Path> children = new AttributedList<>();
|
||||
// test just group set to read
|
||||
children.add(new Path("b", EnumSet.of(Path.Type.file), new TestPermissionAttributes(Permission.Action.none, Permission.Action.read, Permission.Action.none)));
|
||||
children.add(new Path("b", EnumSet.of(Path.Type.file), new DefaultPathAttributes().setPermission(
|
||||
new StaticPermission(Permission.Action.none, Permission.Action.read, Permission.Action.none))));
|
||||
return children;
|
||||
}
|
||||
|
||||
@@ -84,7 +87,7 @@ public class WritePermissionWorkerTest {
|
||||
|
||||
@Override
|
||||
public void setUnixPermission(final Path file, final TransferStatus status) throws BackgroundException {
|
||||
assertEquals(new Permission(744), status.getPermission());
|
||||
assertEquals(new StaticPermission(744), status.getPermission());
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -101,7 +104,8 @@ public class WritePermissionWorkerTest {
|
||||
new PermissionOverwrite.Action(false, true, false),
|
||||
new PermissionOverwrite.Action(false, true, false)
|
||||
);
|
||||
final Path a = new Path("a", EnumSet.of(Path.Type.directory), new TestPermissionAttributes(Permission.Action.all));
|
||||
final Path a = new Path("a", EnumSet.of(Path.Type.directory), new DefaultPathAttributes().setPermission(
|
||||
new StaticPermission(Permission.Action.all, Permission.Action.all, Permission.Action.all)));
|
||||
final WritePermissionWorker worker = new WritePermissionWorker(Collections.singletonList(a), permission, new BooleanRecursiveCallback<>(true), ProgressListener.noop);
|
||||
worker.run(new NullSession(new Host(new TestProtocol())) {
|
||||
@Override
|
||||
@@ -109,7 +113,7 @@ public class WritePermissionWorkerTest {
|
||||
if(file.equals(a)) {
|
||||
final AttributedList<Path> children = new AttributedList<>();
|
||||
final Path d = new Path("d", EnumSet.of(Path.Type.directory));
|
||||
d.attributes().setPermission(new Permission(744));
|
||||
d.attributes().setPermission(new StaticPermission(744));
|
||||
children.add(d);
|
||||
children.add(new Path("f", EnumSet.of(Path.Type.file)));
|
||||
return children;
|
||||
@@ -141,13 +145,13 @@ public class WritePermissionWorkerTest {
|
||||
public void setUnixPermission(final Path file, final TransferStatus status) {
|
||||
switch(file.getName()) {
|
||||
case "a":
|
||||
assertEquals(new Permission(644), status.getPermission());
|
||||
assertEquals(new StaticPermission(644), status.getPermission());
|
||||
break;
|
||||
case "d":
|
||||
assertEquals(new Permission(544), status.getPermission());
|
||||
assertEquals(new StaticPermission(544), status.getPermission());
|
||||
break;
|
||||
case "f":
|
||||
assertEquals(new Permission(644), status.getPermission());
|
||||
assertEquals(new StaticPermission(644), status.getPermission());
|
||||
break;
|
||||
default:
|
||||
fail();
|
||||
@@ -165,7 +169,7 @@ public class WritePermissionWorkerTest {
|
||||
@Ignore
|
||||
public void testRunRecursiveSetDirectoryExecute() throws Exception {
|
||||
final Path a = new Path("a", EnumSet.of(Path.Type.directory));
|
||||
a.attributes().setPermission(new Permission(774));
|
||||
a.attributes().setPermission(new StaticPermission(774));
|
||||
final Path f = new Path("f", EnumSet.of(Path.Type.file));
|
||||
final Path d = new Path("d", EnumSet.of(Path.Type.directory));
|
||||
final WritePermissionWorker worker = new WritePermissionWorker(Collections.singletonList(a), new PermissionOverwrite(
|
||||
@@ -178,9 +182,9 @@ public class WritePermissionWorkerTest {
|
||||
public AttributedList<Path> list(final Path file, final ListProgressListener listener) {
|
||||
if(file.equals(a)) {
|
||||
final AttributedList<Path> children = new AttributedList<>();
|
||||
d.attributes().setPermission(new Permission(774));
|
||||
d.attributes().setPermission(new StaticPermission(774));
|
||||
children.add(d);
|
||||
d.attributes().setPermission(new Permission(666));
|
||||
d.attributes().setPermission(new StaticPermission(666));
|
||||
children.add(f);
|
||||
return children;
|
||||
}
|
||||
@@ -210,13 +214,13 @@ public class WritePermissionWorkerTest {
|
||||
@Override
|
||||
public void setUnixPermission(final Path file, final TransferStatus status) throws BackgroundException {
|
||||
if(file.equals(a)) {
|
||||
assertEquals(file.toString(), new Permission(775), status.getPermission());
|
||||
assertEquals(file.toString(), new StaticPermission(775), status.getPermission());
|
||||
}
|
||||
if(file.equals(d)) {
|
||||
assertEquals(file.toString(), new Permission(775), status.getPermission());
|
||||
assertEquals(file.toString(), new StaticPermission(775), status.getPermission());
|
||||
}
|
||||
if(file.equals(f)) {
|
||||
assertEquals(file.toString(), new Permission(664), status.getPermission());
|
||||
assertEquals(file.toString(), new StaticPermission(664), status.getPermission());
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -234,7 +238,7 @@ public class WritePermissionWorkerTest {
|
||||
new PermissionOverwrite.Action(true, false, false)
|
||||
);
|
||||
final Path path = new Path("a", EnumSet.of(Path.Type.directory));
|
||||
path.attributes().setPermission(new Permission(Permission.Action.none, Permission.Action.read, Permission.Action.none,
|
||||
path.attributes().setPermission(new StaticPermission(Permission.Action.none, Permission.Action.read, Permission.Action.none,
|
||||
true, false, false));
|
||||
final WritePermissionWorker worker = new WritePermissionWorker(Collections.singletonList(path), permission, new BooleanRecursiveCallback<>(true), ProgressListener.noop);
|
||||
worker.run(new NullSession(new Host(new TestProtocol())) {
|
||||
@@ -242,7 +246,8 @@ public class WritePermissionWorkerTest {
|
||||
public AttributedList<Path> list(final Path file, final ListProgressListener listener) {
|
||||
final AttributedList<Path> children = new AttributedList<>();
|
||||
// File has all set
|
||||
children.add(new Path("b", EnumSet.of(Path.Type.file), new TestPermissionAttributes(Permission.Action.all)));
|
||||
children.add(new Path("b", EnumSet.of(Path.Type.file), new DefaultPathAttributes().setPermission(
|
||||
new StaticPermission(Permission.Action.all, Permission.Action.all, Permission.Action.all))));
|
||||
return children;
|
||||
}
|
||||
|
||||
@@ -268,7 +273,7 @@ public class WritePermissionWorkerTest {
|
||||
|
||||
@Override
|
||||
public void setUnixPermission(final Path file, final TransferStatus status) {
|
||||
assertEquals(new Permission(1744), status.getPermission());
|
||||
assertEquals(new StaticPermission(1744), status.getPermission());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -484,7 +484,7 @@ public class CryptoVault implements Vault {
|
||||
final PathAttributes attributes = new DefaultPathAttributes(file.attributes());
|
||||
if(this.isDirectory(inflated)) {
|
||||
if(Permission.EMPTY != attributes.getPermission()) {
|
||||
final Permission permission = new Permission(attributes.getPermission());
|
||||
final StaticPermission permission = new StaticPermission(attributes.getPermission());
|
||||
permission.setUser(permission.getUser().or(Permission.Action.execute));
|
||||
permission.setGroup(permission.getGroup().or(Permission.Action.execute));
|
||||
permission.setOther(permission.getOther().or(Permission.Action.execute));
|
||||
|
||||
@@ -20,6 +20,7 @@ import ch.cyberduck.core.DefaultPathAttributes;
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.PathAttributes;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.exception.BackgroundException;
|
||||
import ch.cyberduck.core.features.AttributesAdapter;
|
||||
import ch.cyberduck.core.features.Quota;
|
||||
@@ -116,7 +117,7 @@ public class SDSAttributesAdapter implements AttributesAdapter<Node> {
|
||||
attributes.setSize(node.getSize());
|
||||
attributes.setOwner(node.getDeletedBy().getDisplayName());
|
||||
// Read of file in trash not supported
|
||||
attributes.setPermission(new Permission(Permission.Action.none, Permission.Action.none, Permission.Action.none));
|
||||
attributes.setPermission(new StaticPermission(Permission.Action.none, Permission.Action.none, Permission.Action.none));
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@@ -136,7 +137,7 @@ public class SDSAttributesAdapter implements AttributesAdapter<Node> {
|
||||
}
|
||||
|
||||
protected Permission toPermission(final Node node) {
|
||||
final Permission permission = new Permission();
|
||||
final StaticPermission permission = new StaticPermission();
|
||||
if(node.getPermissions() != null) {
|
||||
switch(node.getType()) {
|
||||
case FOLDER:
|
||||
|
||||
@@ -19,6 +19,7 @@ import ch.cyberduck.core.AttributedList;
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.PathNormalizer;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.ftp.parser.FTPExtendedFile;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -142,7 +143,7 @@ public class FTPListResponseReader implements FTPDataResponseReader {
|
||||
if(f.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION)) {
|
||||
o = o.or(Permission.Action.execute);
|
||||
}
|
||||
final Permission permission = new Permission(u, g, o);
|
||||
final StaticPermission permission = new StaticPermission(u, g, o);
|
||||
if(f instanceof FTPExtendedFile) {
|
||||
permission.setSetuid(((FTPExtendedFile) f).isSetuid());
|
||||
permission.setSetgid(((FTPExtendedFile) f).isSetgid());
|
||||
|
||||
@@ -19,6 +19,7 @@ import ch.cyberduck.core.AttributedList;
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.PathNormalizer;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.date.InvalidDateException;
|
||||
import ch.cyberduck.core.date.MDTMMillisecondsDateFormatter;
|
||||
import ch.cyberduck.core.date.MDTMSecondsDateFormatter;
|
||||
@@ -127,7 +128,7 @@ public class FTPMlsdListResponseReader implements FTPDataResponseReader {
|
||||
parsed.attributes().setGroup(facts.get("unix.group"));
|
||||
}
|
||||
if(facts.containsKey("unix.mode")) {
|
||||
parsed.attributes().setPermission(new Permission(facts.get("unix.mode")));
|
||||
parsed.attributes().setPermission(new StaticPermission(facts.get("unix.mode")));
|
||||
}
|
||||
else if(facts.containsKey("perm")) {
|
||||
if(PreferencesFactory.get().getBoolean("ftp.parser.mlsd.perm.enable")) {
|
||||
@@ -148,7 +149,7 @@ public class FTPMlsdListResponseReader implements FTPDataResponseReader {
|
||||
user = user.or(Permission.Action.read);
|
||||
}
|
||||
}
|
||||
final Permission permission = new Permission(user, Permission.Action.none, Permission.Action.none);
|
||||
final Permission permission = new StaticPermission(user, Permission.Action.none, Permission.Action.none);
|
||||
parsed.attributes().setPermission(permission);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package ch.cyberduck.core.ftp.parser;
|
||||
*/
|
||||
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.net.ftp.FTPFile;
|
||||
@@ -179,7 +180,7 @@ public class EPLFFTPEntryParser extends FTPFileEntryParserImpl {
|
||||
private Permission createSpecifiedPermission() {
|
||||
try {
|
||||
int perm = Integer.valueOf(facts.get("up"), 8);
|
||||
return new Permission(perm);
|
||||
return new StaticPermission(perm);
|
||||
}
|
||||
catch(NumberFormatException ignored) {
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package ch.cyberduck.core.ftp;
|
||||
import ch.cyberduck.core.DisabledListProgressListener;
|
||||
import ch.cyberduck.core.LoginCallback;
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.exception.InteroperabilityException;
|
||||
import ch.cyberduck.core.features.Delete;
|
||||
import ch.cyberduck.core.ftp.list.FTPListService;
|
||||
@@ -28,7 +28,7 @@ public class FTPUnixPermissionFeatureTest extends AbstractFTPTest {
|
||||
final Path home = workdir.find();
|
||||
final Path test = new Path(home, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
|
||||
new FTPTouchFeature(session).touch(new FTPWriteFeature(session), test, new TransferStatus());
|
||||
new FTPUnixPermissionFeature(session).setUnixPermission(test, new Permission(666));
|
||||
new FTPUnixPermissionFeature(session).setUnixPermission(test, new StaticPermission(666));
|
||||
assertEquals("666", new FTPListService(session).list(home, new DisabledListProgressListener()).get(test).attributes().getPermission().getMode());
|
||||
new FTPDeleteFeature(session).delete(Collections.singletonList(test), LoginCallback.noop, new Delete.DisabledCallback());
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ package ch.cyberduck.core.ftp.list;
|
||||
|
||||
import ch.cyberduck.core.AttributedList;
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.exception.ListCanceledException;
|
||||
import ch.cyberduck.core.ftp.FTPParserSelector;
|
||||
import ch.cyberduck.core.ftp.parser.CompositeFileEntryParser;
|
||||
@@ -64,7 +64,7 @@ public class FTPListResponseReaderTest {
|
||||
assertTrue(parsed.isSymbolicLink());
|
||||
assertEquals("/www/basic/mk", parsed.getSymlinkTarget().getAbsolute());
|
||||
assertEquals("/www/basic", parsed.getSymlinkTarget().getParent().getAbsolute());
|
||||
assertEquals(new Permission("rwxrwxrwx"), parsed.attributes().getPermission());
|
||||
assertEquals(new StaticPermission("rwxrwxrwx"), parsed.attributes().getPermission());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,7 +80,7 @@ public class FTPListResponseReaderTest {
|
||||
assertEquals("/.dovecot.sieve", parsed.getAbsolute());
|
||||
assertEquals("/sieve/managesieve.sieve", parsed.getSymlinkTarget().getAbsolute());
|
||||
assertEquals("/sieve", parsed.getSymlinkTarget().getParent().getAbsolute());
|
||||
assertEquals(new Permission("rwxrwxrwx"), parsed.attributes().getPermission());
|
||||
assertEquals(new StaticPermission("rwxrwxrwx"), parsed.attributes().getPermission());
|
||||
}
|
||||
|
||||
@Test(expected = FTPInvalidListException.class)
|
||||
@@ -102,10 +102,10 @@ public class FTPListResponseReaderTest {
|
||||
);
|
||||
final Path parsed = list.get(new Path("/t", EnumSet.of(Path.Type.file)));
|
||||
assertNotNull(parsed);
|
||||
assertTrue(parsed.attributes().getPermission().isSticky());
|
||||
assertTrue(parsed.attributes().getPermission().isSetuid());
|
||||
assertTrue(parsed.attributes().getPermission().isSetgid());
|
||||
assertEquals(new Permission("rwsrwSr-T"), parsed.attributes().getPermission());
|
||||
assertTrue(((StaticPermission) parsed.attributes().getPermission()).isSticky());
|
||||
assertTrue(((StaticPermission) parsed.attributes().getPermission()).isSetuid());
|
||||
assertTrue(((StaticPermission) parsed.attributes().getPermission()).isSetgid());
|
||||
assertEquals(new StaticPermission("rwsrwSr-T"), parsed.attributes().getPermission());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -141,9 +141,9 @@ public class FTPListResponseReaderTest {
|
||||
final Path parsed = list.get(0);
|
||||
assertEquals("WelcomeTo_PeakFTP", parsed.getName());
|
||||
assertEquals("/data/FTP_pub", parsed.getParent().getAbsolute());
|
||||
assertFalse(parsed.attributes().getPermission().isSticky());
|
||||
assertFalse(parsed.attributes().getPermission().isSetuid());
|
||||
assertFalse(parsed.attributes().getPermission().isSetgid());
|
||||
assertFalse(((StaticPermission) parsed.attributes().getPermission()).isSticky());
|
||||
assertFalse(((StaticPermission) parsed.attributes().getPermission()).isSetuid());
|
||||
assertFalse(((StaticPermission) parsed.attributes().getPermission()).isSetgid());
|
||||
}
|
||||
|
||||
@Test(expected = ListCanceledException.class)
|
||||
|
||||
@@ -21,6 +21,7 @@ import ch.cyberduck.core.DescriptiveUrl;
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.PathAttributes;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.URIEncoder;
|
||||
import ch.cyberduck.core.features.AttributesAdapter;
|
||||
import ch.cyberduck.core.io.Checksum;
|
||||
@@ -43,7 +44,7 @@ public final class MantaObjectAttributeAdapter implements AttributesAdapter<Mant
|
||||
@Override
|
||||
public PathAttributes toAttributes(final MantaObject object) {
|
||||
final PathAttributes attributes = new DefaultPathAttributes();
|
||||
attributes.setPermission(new Permission(
|
||||
attributes.setPermission(new StaticPermission(
|
||||
session.isUserWritable(object) ? Permission.Action.all : Permission.Action.read,
|
||||
Permission.Action.none,
|
||||
session.isWorldReadable(object) ? Permission.Action.read : Permission.Action.none));
|
||||
|
||||
@@ -20,7 +20,7 @@ import ch.cyberduck.core.Host;
|
||||
import ch.cyberduck.core.HostKeyCallback;
|
||||
import ch.cyberduck.core.LoginCallback;
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.features.Delete;
|
||||
import ch.cyberduck.core.proxy.DisabledProxyFinder;
|
||||
import ch.cyberduck.core.threading.CancelCallback;
|
||||
@@ -48,14 +48,14 @@ public class LocalUnixPermissionFeatureTest {
|
||||
{
|
||||
final Path file = new Path(workdir, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
|
||||
new LocalTouchFeature(session).touch(new LocalWriteFeature(session), file, new TransferStatus());
|
||||
new LocalUnixPermissionFeature(session).setUnixPermission(file, new Permission(666));
|
||||
new LocalUnixPermissionFeature(session).setUnixPermission(file, new StaticPermission(666));
|
||||
assertEquals("666", new LocalListService(session).list(workdir, new DisabledListProgressListener()).get(file).attributes().getPermission().getMode());
|
||||
new LocalDeleteFeature(session).delete(Collections.<Path>singletonList(file), LoginCallback.noop, new Delete.DisabledCallback());
|
||||
}
|
||||
{
|
||||
final Path directory = new Path(workdir, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory));
|
||||
new LocalDirectoryFeature(session).mkdir(new LocalWriteFeature(session), directory, new TransferStatus());
|
||||
new LocalUnixPermissionFeature(session).setUnixPermission(directory, new Permission(666));
|
||||
new LocalUnixPermissionFeature(session).setUnixPermission(directory, new StaticPermission(666));
|
||||
assertEquals("666", new LocalListService(session).list(workdir, new DisabledListProgressListener()).get(directory).attributes().getPermission().getMode());
|
||||
new LocalDeleteFeature(session).delete(Collections.<Path>singletonList(directory), LoginCallback.noop, new Delete.DisabledCallback());
|
||||
}
|
||||
|
||||
@@ -2292,7 +2292,7 @@ public class InfoController extends ToolbarWindowController {
|
||||
if(StringUtils.isNotBlank(octalField.stringValue())) {
|
||||
if(StringUtils.length(octalField.stringValue()) >= 3) {
|
||||
if(StringUtils.isNumeric(octalField.stringValue())) {
|
||||
return new Permission(Integer.parseInt(octalField.stringValue()));
|
||||
return new StaticPermission(Integer.parseInt(octalField.stringValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -734,10 +734,10 @@ public class PreferencesController extends ToolbarWindowController {
|
||||
public void chmodUploadTypePopupChanged(NSPopUpButton sender) {
|
||||
Permission p = null;
|
||||
if(sender.selectedItem().tag() == 0) {
|
||||
p = new Permission(preferences.getInteger("queue.upload.permissions.file.default"));
|
||||
p = new StaticPermission(preferences.getInteger("queue.upload.permissions.file.default"));
|
||||
}
|
||||
if(sender.selectedItem().tag() == 1) {
|
||||
p = new Permission(preferences.getInteger("queue.upload.permissions.folder.default"));
|
||||
p = new StaticPermission(preferences.getInteger("queue.upload.permissions.folder.default"));
|
||||
}
|
||||
if(null == p) {
|
||||
log.error("No selected item for:{}", sender);
|
||||
@@ -774,10 +774,10 @@ public class PreferencesController extends ToolbarWindowController {
|
||||
public void chmodDownloadTypePopupChanged(NSPopUpButton sender) {
|
||||
Permission p = null;
|
||||
if(sender.selectedItem().tag() == 0) {
|
||||
p = new Permission(preferences.getInteger("queue.download.permissions.file.default"));
|
||||
p = new StaticPermission(preferences.getInteger("queue.download.permissions.file.default"));
|
||||
}
|
||||
if(sender.selectedItem().tag() == 1) {
|
||||
p = new Permission(preferences.getInteger("queue.download.permissions.folder.default"));
|
||||
p = new StaticPermission(preferences.getInteger("queue.download.permissions.folder.default"));
|
||||
}
|
||||
if(null == p) {
|
||||
log.error("No selected item for:{}", sender);
|
||||
@@ -1087,7 +1087,7 @@ public class PreferencesController extends ToolbarWindowController {
|
||||
if(dotherx.state() == NSCell.NSOnState) {
|
||||
o = o.or(Permission.Action.execute);
|
||||
}
|
||||
final Permission permission = new Permission(u, g, o);
|
||||
final Permission permission = new StaticPermission(u, g, o);
|
||||
if(chmodDownloadTypePopup.selectedItem().tag() == 0) {
|
||||
preferences.setProperty("queue.download.permissions.file.default", permission.getMode());
|
||||
}
|
||||
@@ -1221,7 +1221,7 @@ public class PreferencesController extends ToolbarWindowController {
|
||||
if(uotherx.state() == NSCell.NSOnState) {
|
||||
o = o.or(Permission.Action.execute);
|
||||
}
|
||||
final Permission permission = new Permission(u, g, o);
|
||||
final Permission permission = new StaticPermission(u, g, o);
|
||||
if(chmodUploadTypePopup.selectedItem().tag() == 0) {
|
||||
preferences.setProperty("queue.upload.permissions.file.default", permission.getMode());
|
||||
}
|
||||
|
||||
@@ -29,7 +29,20 @@ import ch.cyberduck.binding.foundation.NSFileManager;
|
||||
import ch.cyberduck.binding.foundation.NSMutableArray;
|
||||
import ch.cyberduck.binding.foundation.NSObject;
|
||||
import ch.cyberduck.binding.foundation.NSURL;
|
||||
import ch.cyberduck.core.*;
|
||||
import ch.cyberduck.core.AbstractHostCollection;
|
||||
import ch.cyberduck.core.Acl;
|
||||
import ch.cyberduck.core.AttributedList;
|
||||
import ch.cyberduck.core.Cache;
|
||||
import ch.cyberduck.core.DefaultPathAttributes;
|
||||
import ch.cyberduck.core.Host;
|
||||
import ch.cyberduck.core.HostParser;
|
||||
import ch.cyberduck.core.Local;
|
||||
import ch.cyberduck.core.LocalFactory;
|
||||
import ch.cyberduck.core.LocaleFactory;
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.Scheme;
|
||||
import ch.cyberduck.core.UserDateFormatterFactory;
|
||||
import ch.cyberduck.core.cache.LRUCache;
|
||||
import ch.cyberduck.core.date.AbstractUserDateFormatter;
|
||||
import ch.cyberduck.core.exception.AccessDeniedException;
|
||||
@@ -256,7 +269,7 @@ public abstract class BrowserTableDataSource extends ProxyController implements
|
||||
else {
|
||||
final Permission permission = item.attributes().getPermission();
|
||||
value = NSAttributedString.attributedStringWithAttributes(
|
||||
permission.toString(),
|
||||
permission.getDescription(),
|
||||
TableCellAttributes.browserFontLeftAlignment());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import ch.cyberduck.core.DefaultPathAttributes;
|
||||
import ch.cyberduck.core.ListProgressListener;
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.PathAttributes;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.exception.BackgroundException;
|
||||
import ch.cyberduck.core.exception.NotfoundException;
|
||||
import ch.cyberduck.core.features.AttributesAdapter;
|
||||
@@ -96,7 +96,7 @@ public class SFTPAttributesFinderFeature implements AttributesFinder, Attributes
|
||||
}
|
||||
if(0 != stat.getMode().getPermissionsMask()) {
|
||||
if(!this.isServerBlacklisted()) {
|
||||
attributes.setPermission(new Permission(Integer.toString(stat.getMode().getPermissionsMask(), 8)));
|
||||
attributes.setPermission(new StaticPermission(Integer.toString(stat.getMode().getPermissionsMask(), 8)));
|
||||
attributes.setOwner(String.valueOf(stat.getUID()));
|
||||
attributes.setGroup(String.valueOf(stat.getGID()));
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import ch.cyberduck.core.DisabledListProgressListener;
|
||||
import ch.cyberduck.core.LoginCallback;
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.exception.NotfoundException;
|
||||
import ch.cyberduck.core.features.Delete;
|
||||
import ch.cyberduck.core.transfer.TransferStatus;
|
||||
@@ -56,7 +57,7 @@ public class SFTPListServiceTest extends AbstractSFTPTest {
|
||||
new SFTPSymlinkFeature(session).symlink(symlinkRelative, file.getName());
|
||||
new SFTPSymlinkFeature(session).symlink(symlinkAbsolute, file.getAbsolute());
|
||||
new SFTPDirectoryFeature(session).mkdir(new SFTPWriteFeature(session), directory, new TransferStatus());
|
||||
final Permission permission = new Permission(Permission.Action.read_write, Permission.Action.read_write, Permission.Action.read_write);
|
||||
final Permission permission = new StaticPermission(Permission.Action.read_write, Permission.Action.read_write, Permission.Action.read_write);
|
||||
new SFTPUnixPermissionFeature(session).setUnixPermission(file, permission);
|
||||
final AttributedList<Path> list = new SFTPListService(session).list(home, new DisabledListProgressListener());
|
||||
assertTrue(list.contains(file));
|
||||
|
||||
@@ -22,7 +22,7 @@ import ch.cyberduck.core.AttributedList;
|
||||
import ch.cyberduck.core.DisabledListProgressListener;
|
||||
import ch.cyberduck.core.LoginCallback;
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.features.Delete;
|
||||
import ch.cyberduck.core.transfer.TransferStatus;
|
||||
import ch.cyberduck.test.IntegrationTest;
|
||||
@@ -44,7 +44,7 @@ public class SFTPTouchFeatureTest extends AbstractSFTPTest {
|
||||
final Path home = new SFTPHomeDirectoryService(session).find();
|
||||
final Path test = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
|
||||
new SFTPTouchFeature(session).touch(new SFTPWriteFeature(session), test, new TransferStatus());
|
||||
new SFTPUnixPermissionFeature(session).setUnixPermission(test, new Permission("664"));
|
||||
new SFTPUnixPermissionFeature(session).setUnixPermission(test, new StaticPermission("664"));
|
||||
// Test override
|
||||
new SFTPTouchFeature(session).touch(new SFTPWriteFeature(session), test, new TransferStatus());
|
||||
final AttributedList<Path> list = new SFTPListService(session).list(home, new DisabledListProgressListener());
|
||||
|
||||
@@ -21,6 +21,7 @@ import ch.cyberduck.core.DisabledListProgressListener;
|
||||
import ch.cyberduck.core.LoginCallback;
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.features.Delete;
|
||||
import ch.cyberduck.core.transfer.TransferStatus;
|
||||
import ch.cyberduck.test.IntegrationTest;
|
||||
@@ -64,14 +65,14 @@ public class SFTPUnixPermissionFeatureTest extends AbstractSFTPTest {
|
||||
{
|
||||
final Path file = new Path(home, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
|
||||
new SFTPTouchFeature(session).touch(new SFTPWriteFeature(session), file, new TransferStatus());
|
||||
new SFTPUnixPermissionFeature(session).setUnixPermission(file, new Permission(666));
|
||||
new SFTPUnixPermissionFeature(session).setUnixPermission(file, new StaticPermission(666));
|
||||
assertEquals("666", new SFTPListService(session).list(home, new DisabledListProgressListener()).get(file).attributes().getPermission().getMode());
|
||||
new SFTPDeleteFeature(session).delete(Collections.<Path>singletonList(file), LoginCallback.noop, new Delete.DisabledCallback());
|
||||
}
|
||||
{
|
||||
final Path directory = new Path(home, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory));
|
||||
new SFTPDirectoryFeature(session).mkdir(new SFTPWriteFeature(session), directory, new TransferStatus());
|
||||
new SFTPUnixPermissionFeature(session).setUnixPermission(directory, new Permission(666));
|
||||
new SFTPUnixPermissionFeature(session).setUnixPermission(directory, new StaticPermission(666));
|
||||
assertEquals("666", new SFTPListService(session).list(home, new DisabledListProgressListener()).get(directory).attributes().getPermission().getMode());
|
||||
new SFTPDeleteFeature(session).delete(Collections.<Path>singletonList(directory), LoginCallback.noop, new Delete.DisabledCallback());
|
||||
}
|
||||
@@ -84,21 +85,21 @@ public class SFTPUnixPermissionFeatureTest extends AbstractSFTPTest {
|
||||
new SFTPTouchFeature(session).touch(new SFTPWriteFeature(session), test, new TransferStatus());
|
||||
final SFTPUnixPermissionFeature feature = new SFTPUnixPermissionFeature(session);
|
||||
feature.setUnixPermission(test,
|
||||
new Permission(Permission.Action.all, Permission.Action.read, Permission.Action.read,
|
||||
new StaticPermission(Permission.Action.all, Permission.Action.read, Permission.Action.read,
|
||||
true, false, false));
|
||||
assertEquals(new Permission(Permission.Action.all, Permission.Action.read, Permission.Action.read,
|
||||
assertEquals(new StaticPermission(Permission.Action.all, Permission.Action.read, Permission.Action.read,
|
||||
true, false, false), new SFTPListService(session).list(test.getParent(), new DisabledListProgressListener()).get(
|
||||
test).attributes().getPermission());
|
||||
feature.setUnixPermission(test,
|
||||
new Permission(Permission.Action.all, Permission.Action.read, Permission.Action.read,
|
||||
new StaticPermission(Permission.Action.all, Permission.Action.read, Permission.Action.read,
|
||||
false, true, false));
|
||||
assertEquals(new Permission(Permission.Action.all, Permission.Action.read, Permission.Action.read,
|
||||
assertEquals(new StaticPermission(Permission.Action.all, Permission.Action.read, Permission.Action.read,
|
||||
false, true, false), new SFTPListService(session).list(test.getParent(), new DisabledListProgressListener()).get(
|
||||
test).attributes().getPermission());
|
||||
feature.setUnixPermission(test,
|
||||
new Permission(Permission.Action.all, Permission.Action.read, Permission.Action.read,
|
||||
new StaticPermission(Permission.Action.all, Permission.Action.read, Permission.Action.read,
|
||||
false, false, true));
|
||||
assertEquals(new Permission(Permission.Action.all, Permission.Action.read, Permission.Action.read,
|
||||
assertEquals(new StaticPermission(Permission.Action.all, Permission.Action.read, Permission.Action.read,
|
||||
false, false, true), new SFTPListService(session).list(test.getParent(), new DisabledListProgressListener()).get(
|
||||
test).attributes().getPermission());
|
||||
new SFTPDeleteFeature(session).delete(Collections.<Path>singletonList(test), LoginCallback.noop, new Delete.DisabledCallback());
|
||||
|
||||
@@ -9,7 +9,7 @@ import ch.cyberduck.core.LoginCallback;
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.PathAttributes;
|
||||
import ch.cyberduck.core.PathCache;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.exception.NotfoundException;
|
||||
import ch.cyberduck.core.features.AttributesFinder;
|
||||
import ch.cyberduck.core.features.Delete;
|
||||
@@ -55,11 +55,11 @@ public class CachingAttributesFinderFeatureTest extends AbstractSFTPTest {
|
||||
final AttributesFinder f = new CachingAttributesFinderFeature(session, cache, new DefaultAttributesFinderFeature(session));
|
||||
final Path workdir = new SFTPHomeDirectoryService(session).find();
|
||||
final Path file = new SFTPTouchFeature(session).touch(new SFTPWriteFeature(session), new Path(workdir, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
|
||||
new SFTPUnixPermissionFeature(session).setUnixPermission(file, new Permission("-rw-rw-rw-"));
|
||||
new SFTPUnixPermissionFeature(session).setUnixPermission(file, new StaticPermission("-rw-rw-rw-"));
|
||||
final Attributes lookup = f.find(file);
|
||||
assertEquals(0L, lookup.getSize());
|
||||
assertNotNull(lookup.getOwner());
|
||||
assertEquals(new Permission("-rw-rw-rw-"), lookup.getPermission());
|
||||
assertEquals(new StaticPermission("-rw-rw-rw-"), lookup.getPermission());
|
||||
// Test cache
|
||||
assertSame(lookup, new CachingAttributesFinderFeature(session, cache, new AttributesFinder() {
|
||||
@Override
|
||||
|
||||
@@ -4,7 +4,7 @@ import ch.cyberduck.core.AlphanumericRandomStringService;
|
||||
import ch.cyberduck.core.Attributes;
|
||||
import ch.cyberduck.core.LoginCallback;
|
||||
import ch.cyberduck.core.Path;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.exception.NotfoundException;
|
||||
import ch.cyberduck.core.features.AttributesFinder;
|
||||
import ch.cyberduck.core.features.Delete;
|
||||
@@ -40,11 +40,11 @@ public class DefaultAttributesFinderFeatureTest extends AbstractSFTPTest {
|
||||
final Path workdir = new SFTPHomeDirectoryService(session).find();
|
||||
final Path file = new Path(workdir, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
|
||||
new SFTPTouchFeature(session).touch(new SFTPWriteFeature(session), file, new TransferStatus());
|
||||
new SFTPUnixPermissionFeature(session).setUnixPermission(file, new Permission("-rw-rw-rw-"));
|
||||
new SFTPUnixPermissionFeature(session).setUnixPermission(file, new StaticPermission("-rw-rw-rw-"));
|
||||
final Attributes attributes = f.find(file);
|
||||
assertEquals(0L, attributes.getSize());
|
||||
assertNotNull(attributes.getOwner());
|
||||
assertEquals(new Permission("-rw-rw-rw-"), attributes.getPermission());
|
||||
assertEquals(new StaticPermission("-rw-rw-rw-"), attributes.getPermission());
|
||||
// Test wrong type
|
||||
try {
|
||||
f.find(new Path(workdir, file.getName(), EnumSet.of(Path.Type.directory)));
|
||||
|
||||
+4
-3
@@ -23,6 +23,7 @@ import ch.cyberduck.core.PathAttributes;
|
||||
import ch.cyberduck.core.PathContainerService;
|
||||
import ch.cyberduck.core.PathNormalizer;
|
||||
import ch.cyberduck.core.Permission;
|
||||
import ch.cyberduck.core.StaticPermission;
|
||||
import ch.cyberduck.core.URIEncoder;
|
||||
import ch.cyberduck.core.exception.BackgroundException;
|
||||
import ch.cyberduck.core.exception.NotfoundException;
|
||||
@@ -104,12 +105,12 @@ public class StoregateAttributesFinderFeature implements AttributesFinder, Attri
|
||||
// ReadWrite 2
|
||||
// Synchronize 4 Read, write access and permission to syncronize using desktop client.
|
||||
// FullControl 99
|
||||
final Permission permission;
|
||||
final StaticPermission permission;
|
||||
if((f.getPermission() & 2) == 2 || (f.getPermission() & 4) == 4) {
|
||||
permission = new Permission(Permission.Action.read_write, Permission.Action.none, Permission.Action.none);
|
||||
permission = new StaticPermission(Permission.Action.read_write, Permission.Action.none, Permission.Action.none);
|
||||
}
|
||||
else {
|
||||
permission = new Permission(Permission.Action.read, Permission.Action.none, Permission.Action.none);
|
||||
permission = new StaticPermission(Permission.Action.read, Permission.Action.none, Permission.Action.none);
|
||||
}
|
||||
if((f.getFlags() & 1) == 1) {
|
||||
// This item is a folder
|
||||
|
||||
@@ -492,11 +492,11 @@ namespace Ch.Cyberduck.Ui.Controller
|
||||
Permission p = null;
|
||||
if (ForFiles.Equals(View.ChmodUploadType))
|
||||
{
|
||||
p = new Permission(PreferencesFactory.get().getInteger("queue.upload.permissions.file.default"));
|
||||
p = new StaticPermission(PreferencesFactory.get().getInteger("queue.upload.permissions.file.default"));
|
||||
}
|
||||
if (ForFolders.Equals(View.ChmodUploadType))
|
||||
{
|
||||
p = new Permission(PreferencesFactory.get().getInteger("queue.upload.permissions.folder.default"));
|
||||
p = new StaticPermission(PreferencesFactory.get().getInteger("queue.upload.permissions.folder.default"));
|
||||
}
|
||||
if (null == p)
|
||||
{
|
||||
@@ -538,11 +538,11 @@ namespace Ch.Cyberduck.Ui.Controller
|
||||
Permission p = null;
|
||||
if (ForFiles.Equals(View.ChmodDownloadType))
|
||||
{
|
||||
p = new Permission(PreferencesFactory.get().getInteger("queue.download.permissions.file.default"));
|
||||
p = new StaticPermission(PreferencesFactory.get().getInteger("queue.download.permissions.file.default"));
|
||||
}
|
||||
if (ForFolders.Equals(View.ChmodDownloadType))
|
||||
{
|
||||
p = new Permission(PreferencesFactory.get().getInteger("queue.download.permissions.folder.default"));
|
||||
p = new StaticPermission(PreferencesFactory.get().getInteger("queue.download.permissions.folder.default"));
|
||||
}
|
||||
if (null == p)
|
||||
{
|
||||
@@ -619,7 +619,7 @@ namespace Ch.Cyberduck.Ui.Controller
|
||||
{
|
||||
o = o.or(Permission.Action.execute);
|
||||
}
|
||||
Permission permission = new Permission(u, g, o);
|
||||
Permission permission = new StaticPermission(u, g, o);
|
||||
if (ForFiles.Equals(View.ChmodUploadType))
|
||||
{
|
||||
PreferencesFactory.get().setProperty("queue.upload.permissions.file.default", permission.getMode());
|
||||
@@ -671,7 +671,7 @@ namespace Ch.Cyberduck.Ui.Controller
|
||||
{
|
||||
o = o.or(Permission.Action.execute);
|
||||
}
|
||||
Permission permission = new Permission(u, g, o);
|
||||
Permission permission = new StaticPermission(u, g, o);
|
||||
if (ForFiles.Equals(View.ChmodDownloadType))
|
||||
{
|
||||
PreferencesFactory.get().setProperty("queue.download.permissions.file.default", permission.getMode());
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace Ch.Cyberduck.Ui.Controller
|
||||
return s.ToString();
|
||||
}
|
||||
Permission permission = path.attributes().getPermission();
|
||||
return permission.toString();
|
||||
return permission.getDescription();
|
||||
}
|
||||
|
||||
public object GetKind(Path path)
|
||||
|
||||
Reference in New Issue
Block a user