Skip to content

Commit

Permalink
[Additional for #52] Updated javadocs and removed one option.
Browse files Browse the repository at this point in the history
  • Loading branch information
hierynomus committed Feb 4, 2013
1 parent 37360b6 commit 5e25a7b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -360,36 +360,57 @@ public class SshConnectionBuilder implements OverthereConnectionBuilder {
public static final String SUDO_TEMP_MKDIRS_COMMAND_DEFAULT = "mkdir -p -m 1777 {0}";

/**
* Name of the {@link ConnectionOptions connection option} used to specify the command used to ... when using an SSH/SCP connection.
* Name of the {@link ConnectionOptions connection option} used to specify the command used to copy files from the connection temporary directory
* when using an SSH/SUDO connection.
*/
public static final String SUDO_COPY_FROM_TEMP_FILE_COMMAND = "sudoCopyFromTempFileCommand";

/**
* Default value (<code>cp -pr {0} {1}</code>) of the {@link ConnectionOptions connection option} used to specify the command used to copy files
* from the connection temporary directory while preserving the file attributes (See: {@link SUDO_PRESERVE_ATTRIBUTES_ON_COPY_FROM_TEMP_FILE}
* using an SSH/SUDO connection.
*/
public static final String SUDO_COPY_FROM_TEMP_FILE_COMMAND_DEFAULT_PRESERVE_ATTRIBUTES = "cp -pr {0} {1}";

/**
* Default value (<code>cp -r {0} {1}</code>) of the {@link ConnectionOptions connection option} used to specify the command used to copy files
* from the connection temporary directory while not preserving the file attributes (See: {@link SUDO_PRESERVE_ATTRIBUTES_ON_COPY_FROM_TEMP_FILE}
* using an SSH/SUDO connection.
*/
public static final String SUDO_COPY_FROM_TEMP_FILE_COMMAND_DEFAULT_NO_PRESERVE_ATTRIBUTES = "cp -r {0} {1}";

/**
* Name of the {@link ConnectionOptions connection option} used to specify the command used to ... when using an SSH/SCP connection.
* Name of the {@link ConnectionOptions connection option} used to specify the command used to override the umask after copying a file or directory
* when using an SSH/SUDO connection.
* The placeholder <code>{0}</code> is replaced with the copied file/directory.
*/
public static final String SUDO_OVERRIDE_UMASK_COMMAND = "sudoOverrideUmaskCommand";

/**
* Default value (<code>chmod -R go+rX {0}</code>) of the {@link ConnectionOptions connection option} used to specify the command used to override
* the umask after copying a file or directory when using an SSH/SUDO connection.
*/
public static final String SUDO_OVERRIDE_UMASK_COMMAND_DEFAULT = "chmod -R go+rX {0}";

/**
* Name of the {@link ConnectionOptions connection option} used to specify the command used to ... when using an SSH/SCP connection.
* Name of the {@link ConnectionOptions connection option} used to specify the command used to copy files to the connection temporary directory when using
* an SSH/SUDO connection.
*/
public static final String SUDO_COPY_TO_TEMP_FILE_COMMAND = "sudoCopyToTempFileCommand";

/**
* Default value (<code>cp -pr {0} {1}</code>) of the {@link ConnectionOptions connection option} used to specify the command used to copy files
* to the connection temporary directory while preserving the file attributes (See: {@link SUDO_PRESERVE_ATTRIBUTES_ON_COPY_TO_TEMP_FILE}
* using an SSH/SUDO connection.
*/
public static final String SUDO_COPY_TO_TEMP_FILE_COMMAND_DEFAULT_PRESERVE_ATTRIBUTES = "cp -pr {0} {1}";

public static final String SUDO_COPY_TO_TEMP_FILE_COMMAND_DEFAULT_NO_PRESERVE_ATTRIBUTES = "cp -r {0} {1}";

/**
* Name of the {@link ConnectionOptions connection option} used to specify the command used to ... when using an SSH/SCP connection.
* Default value (<code>cp -r {0} {1}</code>) of the {@link ConnectionOptions connection option} used to specify the command used to copy files
* to the connection temporary directory while not preserving the file attributes (See: {@link SUDO_PRESERVE_ATTRIBUTES_ON_COPY_TO_TEMP_FILE}
* using an SSH/SUDO connection.
*/
public static final String SUDO_COPY_TO_TEMP_FILE_CHMOD_COMMAND = "sudoCopyToTempFileChmodCommand";

public static final String SUDO_COPY_TO_TEMP_FILE_CHMOD_COMMAND_DEFAULT = "chmod -R go+rX {0}";
public static final String SUDO_COPY_TO_TEMP_FILE_COMMAND_DEFAULT_NO_PRESERVE_ATTRIBUTES = "cp -r {0} {1}";

protected SshConnection connection;

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/xebialabs/overthere/ssh/SshSudoFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,9 @@ void copyToTempFile(OverthereFile tempFile) {
throw new RuntimeIOException("Cannot copy actual file " + this + " to temporary file " + tempFile + " before download: " + errorMessage);
}

// TODO: Do we need to extract this to a separate command, or re-use the SUDO_OVERRIDE_UMASK_COMMAND?
CmdLine chmodCmdLine = CmdLine.build(NOCD_PSEUDO_COMMAND)
.addTemplatedFragment(getCommand(SUDO_COPY_TO_TEMP_FILE_CHMOD_COMMAND, SUDO_COPY_TO_TEMP_FILE_CHMOD_COMMAND_DEFAULT), tempFile.getPath());
.addTemplatedFragment(getCommand(SUDO_OVERRIDE_UMASK_COMMAND, SUDO_OVERRIDE_UMASK_COMMAND_DEFAULT), tempFile.getPath());

CapturingOverthereExecutionOutputHandler chmodCapturedOutput = capturingHandler();
int chmodResult = getConnection().execute(multiHandler(loggingOutputHandler(logger), chmodCapturedOutput), multiHandler(loggingErrorHandler(logger), chmodCapturedOutput), chmodCmdLine);
Expand Down

0 comments on commit 5e25a7b

Please sign in to comment.