On Fri, Apr 4, 2008 at 9:19 AM, Maarten Coene <[EMAIL PROTECTED]> wrote:
> It was hardcoded to 0600 in Scp.java before I made this change. To keep it > BC, I defaulted it to the same value. OK, I didn't see that, I thought it was using umask according to the discussions on the issue. Sorry about that. > As far as I could see, the umask wasn't used. Since this attribute is only > used for publishing modules, not for module retrieval, I think we should at > least keep "publish" in the attribute name, but renaming 'mode' to > 'permissions' (or something else) is fine for me. Indeed, so I prefer publishPermissions. Xavier > > Maarten > > ----- Original Message ---- > From: Xavier Hanin <[EMAIL PROTECTED]> > To: dev@ant.apache.org > Sent: Friday, April 4, 2008 8:51:18 AM > Subject: Re: svn commit: r644541 - in /ant/ivy/core/trunk: CHANGES.txt > doc/resolver/ssh.html > src/java/org/apache/ivy/plugins/repository/ssh/Scp.java > src/java/org/apache/ivy/plugins/repository/ssh/SshRepository.java > > On Fri, Apr 4, 2008 at 12:49 AM, <[EMAIL PROTECTED]> wrote: > > > Author: maartenc > > Date: Thu Apr 3 15:49:49 2008 > > New Revision: 644541 > > > > URL: http://svn.apache.org/viewvc?rev=644541&view=rev > > Log: > > IMPROVEMENT: make it possible to specify permissions of published files > > for the SSH resolver (IVY-764) + removal of some unused code > > > > Modified: > > ant/ivy/core/trunk/CHANGES.txt > > ant/ivy/core/trunk/doc/resolver/ssh.html > > > > > ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java > > > > > > ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshRepository.java > > > > Modified: ant/ivy/core/trunk/CHANGES.txt > > URL: > > > http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=644541&r1=644540&r2=644541&view=diff > > > > > ============================================================================== > > --- ant/ivy/core/trunk/CHANGES.txt (original) > > +++ ant/ivy/core/trunk/CHANGES.txt Thu Apr 3 15:49:49 2008 > > @@ -69,6 +69,7 @@ > > - NEW: Add a new resolve mode (optionally per module) to utilize > dynamic > > constraint rule metadata (IVY-740) > > - NEW: Add transitive dependency version and branch override mechanism > > (IVY-784) > > > > +- IMPROVEMENT: make it possible to specify permissions of published > files > > for the SSH resolver (IVY-764) > > - IMPROVEMENT: Load Ivy version number into some Ant property (IVY-790) > > - IMPROVEMENT: Make Ivy standalone runnable with no required > dependencies > > (IVY-757) > > - IMPROVEMENT: add branch attribute in ivy:install task (IVY-727) > > > > Modified: ant/ivy/core/trunk/doc/resolver/ssh.html > > URL: > > > http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/resolver/ssh.html?rev=644541&r1=644540&r2=644541&view=diff > > > > > ============================================================================== > > --- ant/ivy/core/trunk/doc/resolver/ssh.html (original) > > +++ ant/ivy/core/trunk/doc/resolver/ssh.html Thu Apr 3 15:49:49 2008 > > @@ -56,6 +56,8 @@ > > <td>No, defaults to host given on the patterns, fail if none is > > set</td></tr> > > <tr><td>port</td><td>The port to connect to</td> > > <td>No, defaults to 22</td></tr> > > + <tr><td>publishMode</td><td>A four digit string (e.g., 0644, see > "man > > chmod", "man open") specifying the permissions of the published files. > <span > > class="since">(since 2.0)</span> > > +</td><td>No, defaults to 0600</td></tr> > > Is it a good idea to give a default value to this attribute? This will > break > BC, it used to be using the umask, right? I wonder if the default > shouldn't > be "use the umask" to preserve BC. WDYT? > > BTW, I don't like the name "publishMode". What do you think of > "permissions" > or "umask"? > > Xavier > > > > > > > </tbody> > > </table> > > <h1>Child elements</h1> > > > > Modified: > > > ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java > > URL: > > > http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java?rev=644541&r1=644540&r2=644541&view=diff > > > > > ============================================================================== > > --- > > > ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java > > (original) > > +++ > > > ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/Scp.java > > Thu Apr 3 15:49:49 2008 > > @@ -276,41 +276,6 @@ > > fileInfo.setLastModified(modtime); > > } > > > > - private void sendBytes(Channel channel, byte[] data, String > fileName, > > String mode) > > - throws IOException, RemoteScpException { > > - OutputStream os = channel.getOutputStream(); > > - InputStream is = new BufferedInputStream( > > - channel.getInputStream(), SEND_BYTES_BUFFER_LENGTH); > > - > > - try { > > - if (channel.isConnected()) { > > - channel.start(); > > - } else { > > - channel.connect(); > > - } > > - } catch (JSchException e1) { > > - throw (IOException) new IOException("Channel connection > > problems").initCause(e1); > > - } > > - > > - readResponse(is); > > - > > - String cline = "C" + mode + " " + data.length + " " + fileName > + > > "\n"; > > - > > - os.write(cline.getBytes()); > > - os.flush(); > > - > > - readResponse(is); > > - > > - os.write(data, 0, data.length); > > - os.write(0); > > - os.flush(); > > - > > - readResponse(is); > > - > > - os.write("E\n".getBytes()); > > - os.flush(); > > - } > > - > > private void sendFile(Channel channel, String localFile, String > > remoteName, String mode) > > throws IOException, RemoteScpException { > > byte[] buffer = new byte[BUFFER_SIZE]; > > @@ -480,101 +445,6 @@ > > os.flush(); > > } > > return fileInfo; > > - } > > - > > - /** > > - * Copy a local file to a remote directory, uses mode 0600 when > > creating the file on the remote > > - * side. > > - * > > - * @param localFile > > - * Path and name of local file. > > - * @param remoteTargetDirectory > > - * Remote target directory where the file has to end up > > (optional) > > - * @param remoteName > > - * target filename to use > > - * @throws IOException > > - * in case of network problems > > - * @throws RemoteScpException > > - * in case of problems on the target system (connection > > ok) > > - */ > > - public void put(String localFile, String remoteTargetDirectory, > > String remoteName) > > - throws IOException, RemoteScpException { > > - put(localFile, remoteTargetDirectory, remoteName, "0600"); > > - } > > - > > - /** > > - * Create a remote file and copy the contents of the passed byte > > array into it. Uses mode 0600 > > - * for creating the remote file. > > - * > > - * @param data > > - * the data to be copied into the remote file. > > - * @param remoteFileName > > - * The name of the file which will be created in the > > remote target directory. > > - * @param remoteTargetDirectory > > - * Remote target directory where the file has to end up > > (optional) > > - * @throws IOException > > - * in case of network problems > > - * @throws RemoteScpException > > - * in case of problems on the target system (connection > > ok) > > - */ > > - > > - public void put(byte[] data, String remoteFileName, String > > remoteTargetDirectory) > > - throws IOException, RemoteScpException { > > - put(data, remoteFileName, remoteTargetDirectory, "0600"); > > - } > > - > > - /** > > - * Create a remote file and copy the contents of the passed byte > > array into it. The method use > > - * the specified mode when creating the file on the remote side. > > - * > > - * @param data > > - * the data to be copied into the remote file. > > - * @param remoteFileName > > - * The name of the file which will be created in the > > remote target directory. > > - * @param remoteTargetDirectory > > - * Remote target directory where the file has to end up > > (optional) > > - * @param mode > > - * a four digit string (e.g., 0644, see "man chmod", > "man > > open") > > - * @throws IOException > > - * in case of network problems > > - * @throws RemoteScpException > > - * in case of problems on the target system (connection > > ok) > > - */ > > - public void put(byte[] data, String remoteFileName, String > > remoteTargetDirectory, String mode) > > - throws IOException, RemoteScpException { > > - ChannelExec channel = null; > > - > > - if ((remoteFileName == null) || (mode == null)) { > > - throw new IllegalArgumentException("Null argument."); > > - } > > - > > - if (mode.length() != MODE_LENGTH) { > > - throw new IllegalArgumentException("Invalid mode."); > > - } > > - > > - for (int i = 0; i < mode.length(); i++) { > > - if (!Character.isDigit(mode.charAt(i))) { > > - throw new IllegalArgumentException("Invalid mode."); > > - } > > - } > > - > > - String cmd = "scp -t "; > > - if (remoteTargetDirectory != null && > > remoteTargetDirectory.length() > 0) { > > - cmd = cmd + "-d " + remoteTargetDirectory; > > - } > > - > > - try { > > - channel = getExecChannel(); > > - channel.setCommand(cmd); > > - sendBytes(channel, data, remoteFileName, mode); > > - // channel.disconnect(); > > - } catch (JSchException e) { > > - if (channel != null) { > > - channel.disconnect(); > > - } > > - throw (IOException) new IOException("Error during SCP > > transfer." + e.getMessage()) > > - .initCause(e); > > - } > > } > > > > /** > > > > Modified: > > > ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshRepository.java > > URL: > > > http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshRepository.java?rev=644541&r1=644540&r2=644541&view=diff > > > > > ============================================================================== > > --- > > > ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshRepository.java > > (original) > > +++ > > > ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshRepository.java > > Thu Apr 3 15:49:49 2008 > > @@ -54,6 +54,8 @@ > > private String existCommand = "ls"; > > > > private String createDirCommand = "mkdir"; > > + > > + private String publishMode = "0600"; > > > > /** > > * create a new resource with lazy initializing > > @@ -259,7 +261,7 @@ > > makePath(path, session); > > } > > Scp myCopy = new Scp(session); > > - myCopy.put(source.getCanonicalPath(), path, name); > > + myCopy.put(source.getCanonicalPath(), path, name, > > publishMode); > > } catch (IOException e) { > > if (session != null) { > > releaseSession(session, destination); > > @@ -421,6 +423,14 @@ > > */ > > public void setFileSeparator(char fileSeparator) { > > this.fileSeparator = fileSeparator; > > + } > > + > > + /** > > + * A four digit string (e.g., 0644, see "man chmod", "man open") > > specifying the permissions > > + * of the published files. > > + */ > > + public void setPublishMode(String mode) { > > + this.publishMode = mode; > > } > > > > /** > > > > > > > > > -- > Xavier Hanin - Independent Java Consultant > http://xhab.blogspot.com/ > http://ant.apache.org/ivy/ > http://www.xoocode.org/ > > > > > > > > ____________________________________________________________________________________ > You rock. That's why Blockbuster's offering you one month of Blockbuster > Total Access, No Cost. > http://tc.deals.yahoo.com/tc/blockbuster/text5.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Xavier Hanin - Independent Java Consultant http://xhab.blogspot.com/ http://ant.apache.org/ivy/ http://www.xoocode.org/