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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chewi
Copy link
Contributor

@chewi chewi commented Sep 7, 2015

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
Copy link
Member

ddpbsd commented Sep 29, 2015

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
Copy link
Member

reyjrar commented Oct 30, 2015

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
Copy link
Contributor Author

chewi commented Oct 30, 2015

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
Copy link
Contributor Author

chewi commented Oct 30, 2015

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

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

@chewi
Copy link
Contributor Author

chewi commented Nov 13, 2015

Rebased.

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

chewi commented Nov 16, 2015

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
Copy link
Contributor Author

chewi commented Nov 18, 2015

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
Copy link
Contributor Author

chewi commented Feb 21, 2016

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
Copy link

dcid commented Feb 25, 2016

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
Copy link
Contributor Author

chewi commented Feb 25, 2016

Fair enough, renamed it to __realloc_keys.

@jrossi
Copy link
Member

jrossi commented Mar 12, 2016

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
Copy link
Member

jrossi commented Mar 12, 2016

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
Copy link
Contributor Author

chewi commented Mar 28, 2016

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
Copy link
Contributor Author

chewi commented Apr 13, 2016

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.

None yet

5 participants