Classified Classified - 25 days ago 21
Java Question

How to remove access to a dir from a jar file with embedded jetty?

Sorry, this is a weird problem so I don't know where to start. It might be phrased poorly by me so I apologize for that.

We are running the Kafka Offset Monitor program. The cmd looks like this:

java -cp KafkaOffsetMonitor-assembly-0.2.0.jar com.quantifind.kafka.offsetapp.OffsetGetterWeb --zk zk1.domain.com zk2.domain.com zk3.domain.com --port 8000 --refresh 10.seconds --retain 2.days


This cmd seems to run a webserver off port 8000 and allows us to look at the different queues of Kafka on our server from a browser.

If we go to http://webpage.domain.com:8000/scripts, it shows the contents of this "directory". I expanded the jar file in a tmp dir and I found a "directory" called scripts.

I need to restrict showing the contents of the scripts directory but seeing how this is inside a jar file that is acting like a web server, how do I do this? There's no dir for me to run chmod 000 on to restrict access.

Thanks in advance for anyone's help. Google doesn't understand me so I need a human to understand my confused ramblings.

UPDATE: I found several stack overflow postings that had a potential solution. However, it didn't work for me either. I un-jarred the KafkaOffsetMonitor jar file and found a webdefault.xml file. I edited dirAllowed to be false but for some reason it's still showing the contents of the scripts directory.

<init-param>
<param-name>dirAllowed</param-name>
<param-value>false</param-value>
</init-param>


What else do I need to do to not list the contents of a directory? I think I'm really close and just need one more thing to get the solution above working.

Answer

Not sure if this is a solution or a workaround. I had set dirAllowed to be false in the webdefault.xml file. I re-tarred the jar file but for some reason, it still listed the directory content.

However, in each of the directories, I included a blank index.html file and that seemed to prevent the contents of the directories from being listed.

Comments