Skip to content

Don't consider an empty client.keys to be a failure condition#662

Open
chewi wants to merge 1 commit into
ossec:masterfrom
yakara-ltd:empty_keys
Open

Don't consider an empty client.keys to be a failure condition#662
chewi wants to merge 1 commit into
ossec:masterfrom
yakara-ltd:empty_keys

Conversation

@chewi

@chewi chewi commented Sep 7, 2015

Copy link
Copy Markdown
Contributor

client.keys is already reloaded each time a given key is not found in memory so there's no harm in this file being empty. In fact, it's downright annoying if you're using authd because you have to wait for the first agent to register and then manually restart the server before they can start communicating. Removing this check would make the Chef cookbook less clunky.

Disclaimer: I haven't tested this at all because I've already sunk too much time into the cookbook. The change seems simple enough though.

Review on Reviewable

@ddpbsd

ddpbsd commented Sep 29, 2015

Copy link
Copy Markdown
Member

Can someone test this? I think it's a great change, but want to make sure it works first. (adding it to my list of things to do when I can make time)

@reyjrar

reyjrar commented Oct 30, 2015

Copy link
Copy Markdown
Member

I think this may break some stuff. This function is called by the agent and the server. I agree, on the server, this shouldn't be fatal, but I'm not so sure on the agent if this would fly.

@chewi

chewi commented Oct 30, 2015

Copy link
Copy Markdown
Contributor Author

I thought about sticking ifdef CLIENT around it but I see that agentd is built for TARGET=server as well. It would somehow need to determine whether it is an agent or server process at runtime.

@chewi

chewi commented Oct 30, 2015

Copy link
Copy Markdown
Contributor Author

It's not fantastic but since ARGV0 is hardcoded, how about this?

if (strcmp(__local_name, "ossec-remoted") != 0) {
  …
}

@chewi

chewi commented Nov 13, 2015

Copy link
Copy Markdown
Contributor Author

Rebased.

@chewi chewi force-pushed the empty_keys branch 2 times, most recently from 3b476f0 to a40bed1 Compare November 16, 2015 14:26
@chewi

chewi commented Nov 16, 2015

Copy link
Copy Markdown
Contributor Author

I finally gave this a try myself and found it segfaulted because keys->keyentries wasn't initialised. I've reworked it and now ossec-remoted at least doesn't crash any more.

@chewi

chewi commented Nov 18, 2015

Copy link
Copy Markdown
Contributor Author

I've now also got it to create client.keys on startup like authd does. This has to happen before dropping privileges because ossecr should not have write access. The file permissions could still be tightened up (currently root:root and 644) but authd doesn't make any effort to do this and the directory permissions at least prevent world read access. One for later perhaps.

@chewi

chewi commented Feb 21, 2016

Copy link
Copy Markdown
Contributor Author

Any chance of getting this merged now? I haven't seen any ill effects since and yet another person asked about this problem on the mailing list.

@dcid

dcid commented Feb 25, 2016

Copy link
Copy Markdown

It looks good now, except for this function:

__realloc

Really confusing to use a standard C function name for this. Can you change to something more adequate to what it does? (allocate key mem)

@chewi

chewi commented Feb 25, 2016

Copy link
Copy Markdown
Contributor Author

Fair enough, renamed it to __realloc_keys.

@jrossi

jrossi commented Mar 12, 2016

Copy link
Copy Markdown
Member

Reviewed 4 of 4 files at r1.
Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


src/os_crypto/shared/keys.c, line 262 [r1] (raw file):
I dislike this for some reason. This does not mean it's wrong just something feels wrong that this is needed.


Comments from the review on Reviewable.io

@jrossi

jrossi commented Mar 12, 2016

Copy link
Copy Markdown
Member

Sorry i am taking so long need to review some more things within the code base.


Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


Comments from the review on Reviewable.io

@chewi

chewi commented Mar 28, 2016

Copy link
Copy Markdown
Contributor Author

Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


src/os_crypto/shared/keys.c, line 262 [r1] (raw file):
Believe me, I tried to think of a better way but couldn't find one. You're welcome to try.


Comments from the review on Reviewable.io

@chewi

chewi commented Apr 13, 2016

Copy link
Copy Markdown
Contributor Author

I'm concerned that 2.9 may get released without this and that would be very frustrating. The code smell mentioned above isn't a showstopper and could always be improved later.

client.keys is already reloaded each time a given key is not found in
memory so there's no harm in this file being empty. In fact, it's
downright annoying if you're using authd because you have to wait for
the first agent to register and then manually restart the server
before they can start communicating. Removing this check would make
the Chef cookbook less clunky.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants