Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starting server with no FS space free leaves it unstartable #12

Open
daveloyall opened this issue Oct 2, 2019 · 0 comments
Open

Starting server with no FS space free leaves it unstartable #12

daveloyall opened this issue Oct 2, 2019 · 0 comments

Comments

@daveloyall
Copy link

daveloyall commented Oct 2, 2019

Take a look at these lines which are called every time you start the server.

// write the keystore back to the file
FileOutputStream fos = new FileOutputStream(keyStoreFile);
keyStore.store(fos, keyStorePassword);
IOUtils.closeQuietly(fos);

There is some circumstance[1] where those lines will result in a zero byte keystore file on disk. That's worse than the file being missing. The server will create a new file if it is missing, but it will fail to start if the keystore file is zero bytes (corrupted). And as long as that zero-byte keystore file remains there, the server will continue to fail to start, even if all other issues are addressed.

I think that the simplest fix that will prevent the problem I experienced is to treat a zero-byte file the same way you treat a missing file: make a new one.

You'd make that change here:

..Just change that line to something like this:

    if (keyStoreFile.exists() && keyStoreFile.canRead() && keyStoreFile.length() > 0) {

But, please consider reviewing this whole initializeSecuritySettings() method first. Is re-writing that JKS file every server start really what you want to do? (Is this not where you store the self-signed cert? How come my browser doesn't notice if it is regenerated all the time? Is it generated in a deterministic manner? Is that good?) I have not reviewed this method, these are just some questions that come to mind after glancing over it. Ideally each of those concerns turns out to be nothing.

1: Filesystem full (on NTFS, if that matters) while server is starting, possibly including other processes trying to write (claiming any free blocks) at the same time.

@daveloyall daveloyall changed the title Starting server when config filesystem leaves it unstartable Starting server with no FS space free leaves it unstartable Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant