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

Fix some privilege separation regressions #471

Closed
wants to merge 5 commits into from
Closed

Fix some privilege separation regressions #471

wants to merge 5 commits into from

Conversation

HonzaCholasta
Copy link
Contributor

@HonzaCholasta HonzaCholasta commented Feb 16, 2017

client install: create /etc/ipa/nssdb with correct mode

The NSS database directory is created with mode 640, which causes the IPA
client to fail to connect to any IPA server, because it is unable to read
trusted CA certificates from the NSS database.

Create the directory with mode 644 to fix the issue.

server upgrade: fix upgrade in CA-less

Use /etc/httpd/alias instead of /var/lib/ipa/radb in upload_cacrt, as
/var/lib/ipa/radb is not populated in CA-less.

Do not migrate ipaCert from /etc/httpd/alias to /var/lib/ipa/radb in
CA-less, as it might be an incorrect certificate from previous CA-ful
install, and is not necessary anyway.

server upgrade: fix upgrade from pre-4.0

update_ca_renewal_master uses ipaCert certmonger tracking information to
decide whether the local server is the CA renewal master or not. The
information is lost when migrating from /etc/httpd/alias to
/var/lib/ipa/radb in update_ra_cert_store.

Make sure update_ra_cert_store is executed after update_ca_renewal_master
so that correct information is used.

server upgrade: always upgrade KRA agent PEM file

Before the KRA agent PEM file is exported in server upgrade, the sysupgrade
state file is consulted. This causes the KRA agent PEM file not to be
exported to the new location if the upgrade was executed in the past.

Do not consult the sysupgrade state file to decide whether to upgrade the
KRA agent PEM file or not, the existence of the file is enough to make this
decision.

https://fedorahosted.org/freeipa/ticket/5959
https://fedorahosted.org/freeipa/ticket/6675

if sysupgrade.get_upgrade_state('http', 'export_kra_agent_pem'):
sysupgrade.remove_upgrade_state('http', 'export_kra_agent_pem')

if os.path.exists(paths.KRA_AGENT_PEM):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way who takes care of renewal of kra-agent.pem file? certmonger only tracks the cert in NSSDB.

Request ID '20170215101245':
        status: MONITORING
        stuck: no
        key pair storage: type=NSSDB,location='/var/lib/ipa/radb',nickname='ipaCert',token='NSS Certificate DB',pinfile='/var/lib/ipa/radb/pwdfile.txt'
        certificate: type=NSSDB,location='/var/lib/ipa/radb',nickname='ipaCert',token='NSS Certificate DB'
        CA: IPA
        issuer: CN=Certificate Authority,O=IPA.EXAMPLE
        subject: CN=IPA RA,O=IPA.EXAMPLE
        expires: 2019-02-03 15:26:21 UTC
        key usage: digitalSignature,nonRepudiation,keyEncipherment,dataEncipherment
        eku: id-kp-serverAuth,id-kp-clientAuth
        pre-save command: 
        post-save command: 
        track: yes
        auto-renew: yes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a separate issue. I created https://fedorahosted.org/freeipa/ticket/6680 to track it.

@stlaz
Copy link
Contributor

stlaz commented Feb 16, 2017

LGTM

@stlaz stlaz self-assigned this Feb 16, 2017
@stlaz
Copy link
Contributor

stlaz commented Feb 16, 2017

Upgrade still fails when run for the first time during dnf update:
http://pastebin.com/H4kt6hVb
When I run it by hand after this failure, it gets a bit further, but NSSConnection fails in the [Migrating certificate profiles to LDAP] step:
http://pastebin.com/8tBjYjkU

edit: This is CA-full upgrade
note: Client installation works now.

@tiran
Copy link
Member

tiran commented Feb 17, 2017

@HonzaCholasta, we got merge conflicts.

Jan Cholasta added 3 commits February 20, 2017 08:10
The NSS database directory is created with mode 640, which causes the IPA
client to fail to connect to any IPA server, because it is unable to read
trusted CA certificates from the NSS database.

Create the directory with mode 644 to fix the issue.

https://fedorahosted.org/freeipa/ticket/5959
Use /etc/httpd/alias instead of /var/lib/ipa/radb in upload_cacrt, as
/var/lib/ipa/radb is not populated in CA-less.

Do not migrate ipaCert from /etc/httpd/alias to /var/lib/ipa/radb in
CA-less, as it might be an incorrect certificate from previous CA-ful
install, and is not necessary anyway.

https://fedorahosted.org/freeipa/ticket/5959
update_ca_renewal_master uses ipaCert certmonger tracking information to
decide whether the local server is the CA renewal master or not. The
information is lost when migrating from /etc/httpd/alias to
/var/lib/ipa/radb in update_ra_cert_store.

Make sure update_ra_cert_store is executed after update_ca_renewal_master
so that correct information is used.

https://fedorahosted.org/freeipa/ticket/5959
@HonzaCholasta
Copy link
Contributor Author

@stlaz, not sure what's going on there, but not my fault, these failures happen even without this PR.

"""
ipa_memcached = service.SimpleServiceInstance('ipa_memcached')

enabled = not ipa_memcached.restore_state("enabled")
ipa_memcached.restore_state("running")

if enabled is not None and not enabled:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally OT: enabled will never be None so the first part of the condition is redundant.

"""
ipa_memcached = service.SimpleServiceInstance('ipa_memcached')

enabled = not ipa_memcached.restore_state("enabled")
ipa_memcached.restore_state("running")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the same problem exist with kpasswd which is where this copy-paste code has its origin?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No one complained since the code was added in 2012, so I guess it doesn't.

@stlaz
Copy link
Contributor

stlaz commented Feb 20, 2017

Note that KRA_AGENT_PEM will not be moved to the correct folder if KRA is not installed but that's fine with me.
/bin/systemctl status ipa_memcached.service still shows the service as running although there's the strange line Loaded: not-found (Reason: No such file or directory). That does not seem ok, should we stop the service as well?

Jan Cholasta added 2 commits February 20, 2017 12:14
Before the KRA agent PEM file is exported in server upgrade, the sysupgrade
state file is consulted. This causes the KRA agent PEM file not to be
exported to the new location if the upgrade was executed in the past.

Do not consult the sysupgrade state file to decide whether to upgrade the
KRA agent PEM file or not, the existence of the file is enough to make this
decision.

https://fedorahosted.org/freeipa/ticket/6675
Make sure ipa_memcached is not running and no stale state is left in the
sysupgrade state file on server upgrade.

https://fedorahosted.org/freeipa/ticket/5959
@stlaz
Copy link
Contributor

stlaz commented Feb 20, 2017

The raised issues seem to have been fixed. ACK.

@stlaz stlaz added the ack Pull Request approved, can be merged label Feb 20, 2017
@HonzaCholasta HonzaCholasta added the pushed Pull Request has already been pushed label Feb 20, 2017
@stlaz stlaz mentioned this pull request Feb 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ack Pull Request approved, can be merged pushed Pull Request has already been pushed
Projects
None yet
3 participants