make/src/classes/build/tools/module/ModuleArchive.java

Print this page
rev 11064 : 8066766: The commands in the modular images are executable by the owner only
Summary: Also simplify the 'set executable' step of jspawnhelper in ImageBuilder.java
Reviewed-by: chegar


 177 
 178         @Override
 179         public void accept(Archive.Entry entry) {
 180             try {
 181                 FileEntry e = (FileEntry)entry;
 182                 Section section = e.getSection();
 183                 String filename = e.getName();
 184 
 185                 try (InputStream in = entry.getInputStream()) {
 186                     switch (section) {
 187                         case CLASSES:
 188                             if (!filename.startsWith("_the.") && !filename.equals("javac_state"))
 189                                 writeEntry(in);
 190                             break;
 191                         case LIBS:
 192                             writeEntry(in, destFile(nativeDir(filename), filename));
 193                             break;
 194                         case CMDS:
 195                             Path path = destFile("bin", filename);
 196                             writeEntry(in, path);
 197                             path.toFile().setExecutable(true);
 198                             break;
 199                         case CONFIGS:
 200                             writeEntry(in, destFile("conf", filename));
 201                             break;
 202                         default:
 203                             throw new InternalError("unexpected entry: " + filename);
 204                     }
 205                 }
 206             } catch (IOException x) {
 207                 throw new UncheckedIOException(x);
 208             }
 209         }
 210 
 211         private Path destFile(String dir, String filename) {
 212             return root.resolve(dir).resolve(filename);
 213         }
 214 
 215         private static void writeEntry(InputStream in, Path dstFile) throws IOException {
 216             if (Files.notExists(dstFile.getParent()))
 217                 Files.createDirectories(dstFile.getParent());




 177 
 178         @Override
 179         public void accept(Archive.Entry entry) {
 180             try {
 181                 FileEntry e = (FileEntry)entry;
 182                 Section section = e.getSection();
 183                 String filename = e.getName();
 184 
 185                 try (InputStream in = entry.getInputStream()) {
 186                     switch (section) {
 187                         case CLASSES:
 188                             if (!filename.startsWith("_the.") && !filename.equals("javac_state"))
 189                                 writeEntry(in);
 190                             break;
 191                         case LIBS:
 192                             writeEntry(in, destFile(nativeDir(filename), filename));
 193                             break;
 194                         case CMDS:
 195                             Path path = destFile("bin", filename);
 196                             writeEntry(in, path);
 197                             path.toFile().setExecutable(true, false);
 198                             break;
 199                         case CONFIGS:
 200                             writeEntry(in, destFile("conf", filename));
 201                             break;
 202                         default:
 203                             throw new InternalError("unexpected entry: " + filename);
 204                     }
 205                 }
 206             } catch (IOException x) {
 207                 throw new UncheckedIOException(x);
 208             }
 209         }
 210 
 211         private Path destFile(String dir, String filename) {
 212             return root.resolve(dir).resolve(filename);
 213         }
 214 
 215         private static void writeEntry(InputStream in, Path dstFile) throws IOException {
 216             if (Files.notExists(dstFile.getParent()))
 217                 Files.createDirectories(dstFile.getParent());