-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Fix manage agents keys #336
Conversation
Worked a lot on this over the weekend to hopefully implement everything requested in #292. This now creates temporary files with proper permissions, writes the data to those files and replace the existing files in an atomic operation (hopefully). Tested on RHEL6, Windows Server 2003, Windows Server 2008R2, Windows Server 2012 and Windows Server 2012R2. I made a lot of guesses on how the Windows stuff will/should work. There are still some times where atomic operations don't happen. Specifically in the UI when the There was also some progress toward #182. Atleast, I hope so. I'm hoping @mstarks01 can review this a bit further but the new Again, I am hoping that is a step in the right direction to achieving #182. Still a lot of work to do on that front though. Also, I am hoping this fixes #303. I think it should since Finally, as mentioned in the pull request, I opted toward having a If this pull request does get accepted and we opt to keep the |
Wow - this good stuff :) some research on my end; great stuff. Thank you much. As for tmp for I agree makes sense. To add this just look at InstallServer.sh and InstallAgent.sh. |
Thanks. Yeah, |
This should be all that is necessary hopefully. Let me know what you think. |
Sorry. Few more small fixes. Hopefully that is it but would really like @mstarks01 to review the permissions I have setup to see if I'm headed in the right direction or not so I can made the necessary adjustments. |
I added the |
Yeah I would the new system is much better :) sorry about the double work. |
Actually, it looks like everything is already there. https://github.com/ossec/ossec-hids/blob/master/src/Makefile#L280 |
@cgzones is winning :) |
Can you merge in master to allow for clean merging and travis ci? Thank you |
Sorry the merge went a little poorly. Maybe I should have rebased instead. Only seems like the install files were affected. I can redo this pull request if you want. |
It's fine the issue looks to be with .old files we will be deteleting soon :) |
Create temporary files in a secure manner on both NIX and Windows platforms that will be used to write client.keys and ossec.conf data to. Then use atomic operations where possible to replace the current versions when making updates. On Windows, decided to hardcode the location of COMSPEC instead of pulling it from an environment variable each time. It is highly unlikely the location of this will change but may re-examine in the future. Since temporary files are now a possibility on agent only installs I updated the Windows installer to inclue a tmp directory. Need to figure out what is involved with doing the same on the NIX side.
This code should make the temporary file names a bit more consistant with what gets set in the global constants. This way if those ever change the temporary files should as well and hopefully continue to make sense as to what they do.
This lets the user see progress and where errors/warnings are happening a bit easier. It also is similar to how the output done by the Make stuff on the NIX side.
bcb81b4
to
b2f184b
Compare
I did a rebase. Seems okay. I never really run into these more "complicated" situtaions with git that often so I saw an opportunity to try and learn something. |
I like the rebase function too. About the
It matches not quiet the gnu specification, but almost:
my_basename:
or maybe replace
with
|
Avoid possible segfault by creating a non-constant copy of macros to pass to basename_ex() since there is the possibility the arguments passed could be modified. This is one of the suggestions made in the documentation. Thanks to @cgzones for catching this issue.
@cgzones Good catch. I decided to go with your second suggestion since it is mentioned in the documentation you linked to. |
Anyway this can get merged into master soon? This is getting increasingly harder to merge as time goes on. |
Sorry yeah reviewed it the other day did not merge. My bad.
|
Do you want to rebase onto master and merge or shall I? |
Just merge / rebate I will accept once it's clean.
|
I am not even sure the best way to do that at this point. |
No problem I will do it from home. |
Actually, I will git it a shot tomorrow morning and let you know if I need help if things go south. |
Example of how if you want to play: # git checkout master
# git pull https://github.com/ossec/ossec-hids master
# git checkout fix-manage-client-keys
# git merge master
# fix errors
# git add files-fixed
# git commit -m "merge master"
# git push origin fix-mange-client-keys" |
Conflicts: src/InstallAgent.sh.old src/addagent/manage_keys.c
Create temporary files in a secure manner on both NIX and Windows
platforms that will be used to write client.keys and ossec.conf data to.
Then use atomic operations where possible to replace the current
versions when making updates.
On Windows, decided to hard code the location of COMSPEC instead of
pulling it from an environment variable each time. It is highly unlikely
the location of this will change but may re-examine in the future.
Since temporary files are now a possibility on agent only installs I
updated the Windows installer to include a tmp directory. Need to figure
out what is involved with doing the same on the NIX side.