Skip to content

Update platforms.py "superuser privileges" check#6600

Merged
thedrow merged 23 commits into
celery:masterfrom
namloc2001:patch-1
Mar 4, 2021
Merged

Update platforms.py "superuser privileges" check#6600
thedrow merged 23 commits into
celery:masterfrom
namloc2001:patch-1

Conversation

@namloc2001

Copy link
Copy Markdown
Contributor

Description

To fix issue #6579. Making it so that in platforms.py the check for "superuser privileges" is only looking for uid/euid=0, not including the root group (gid/egid=0) which does not have the superuser privileges associated with uid/euid=0.

@namloc2001 namloc2001 changed the title Update platforms.py Update platforms.py "superuser privileges" check Jan 17, 2021
@namloc2001

Copy link
Copy Markdown
Contributor Author

@auvipy I don't suppose you know why the tests would be failing, given this is such a minor change?

    c:\python37-x64\include\pyport.h(6) : fatal error C1083: Cannot open include file: 'inttypes.h': No such file or directory
    
        =============================DEBUG ASSISTANCE=============================
        If you are seeing a compilation error please try the following steps to
        successfully install cryptography:
        1) Upgrade to the latest pip and try again. This will fix errors for most
           users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
        2) Read https://cryptography.io/en/latest/installation.html for specific
           instructions for your platform.
        3) Check our frequently asked questions for more information:
           https://cryptography.io/en/latest/faq.html
        =============================DEBUG ASSISTANCE=============================
    
    error: command 'c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2
    
    ----------------------------------------
Command "C:\projects\celery\.tox\3.7-unit\Scripts\python.EXE -u -c "import setuptools, tokenize;__file__='C:\\Users\\appveyor\\AppData\\Local\\Temp\\1\\pip-install-tcc2n6j9\\cryptography\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\appveyor\AppData\Local\Temp\1\pip-record-umzf7tol\install-record.txt --single-version-externally-managed --compile --install-headers C:\projects\celery\.tox\3.7-unit\include\site\python3.7\cryptography" failed with error code 1 in C:\Users\appveyor\AppData\Local\Temp\1\pip-install-tcc2n6j9\cryptography\
You are using pip version 10.0.1, however version 20.3.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
=================================== log end ===================================
ERROR: could not install deps [-rC:\projects\celery/requirements/default.txt, -rC:\projects\celery/requirements/test.txt, -rC:\projects\celery/requirements/pkgutils.txt, -rC:\projects\celery/requirements/test-ci-default.txt, -rC:\projects\celery/requirements/docs.txt, -rC:\projects\celery/requirements/docs.txt]; v = InvocationError("'C:\\projects\\celery\\.tox\\3.7-unit\\Scripts\\python.EXE' -m pip install '-rC:\\projects\\celery/requirements/default.txt' '-rC:\\projects\\celery/requirements/test.txt' '-rC:\\projects\\celery/requirements/pkgutils.txt' '-rC:\\projects\\celery/requirements/test-ci-default.txt' '-rC:\\projects\\celery/requirements/docs.txt' '-rC:\\projects\\celery/requirements/docs.txt'", 1)
___________________________________ summary ___________________________________
ERROR:   3.7-unit: could not install deps [-rC:\projects\celery/requirements/default.txt, -rC:\projects\celery/requirements/test.txt, -rC:\projects\celery/requirements/pkgutils.txt, -rC:\projects\celery/requirements/test-ci-default.txt, -rC:\projects\celery/requirements/docs.txt, -rC:\projects\celery/requirements/docs.txt]; v = InvocationError("'C:\\projects\\celery\\.tox\\3.7-unit\\Scripts\\python.EXE' -m pip install '-rC:\\projects\\celery/requirements/default.txt' '-rC:\\projects\\celery/requirements/test.txt' '-rC:\\projects\\celery/requirements/pkgutils.txt' '-rC:\\projects\\celery/requirements/test-ci-default.txt' '-rC:\\projects\\celery/requirements/docs.txt' '-rC:\\projects\\celery/requirements/docs.txt'", 1)

@lgtm-com

lgtm-com Bot commented Jan 17, 2021

Copy link
Copy Markdown

This pull request fixes 2 alerts when merging 06d3968 into 855d551 - view on LGTM.com

fixed alerts:

  • 1 for Non-exception in 'except' clause
  • 1 for Module is imported with 'import' and 'import from'

@auvipy

auvipy commented Jan 17, 2021

Copy link
Copy Markdown
Member

fatal error C1083: Cannot open include file: 'inttypes.h': No such file or directory

fatal error C1083: Cannot open include file: 'inttypes.h': No such file or directory

our windows CI is not perfect & we have to adjust some settings in our github actions migration from travis. it now hangs while running the integration tests

Comment thread celery/platforms.py Outdated

@thedrow thedrow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The rest of my comments are mostly nitpicks.
After we address those, this is good to go.

Comment thread celery/platforms.py Outdated
Comment thread celery/platforms.py Outdated
Comment thread celery/platforms.py Outdated
Comment thread celery/platforms.py Outdated
Comment thread celery/platforms.py Outdated
Comment thread celery/platforms.py Outdated
Comment thread celery/platforms.py Outdated
Comment thread celery/platforms.py Outdated
Comment thread celery/platforms.py Outdated
Comment thread celery/platforms.py Outdated
@namloc2001
namloc2001 requested a review from thedrow January 19, 2021 11:46
@lgtm-com

lgtm-com Bot commented Jan 19, 2021

Copy link
Copy Markdown

This pull request introduces 1 alert when merging 56710f0 into 17eda8d - view on LGTM.com

new alerts:

  • 1 for Module is imported with 'import' and 'import from'

Comment thread celery/platforms.py Outdated
Comment thread celery/platforms.py Outdated
@thedrow

thedrow commented Jan 19, 2021

Copy link
Copy Markdown
Contributor

Before merging this PR we also need to fully unit test the code.
Please ensure the tests are up to date and are passing.
We're still working on our new CI.

@lgtm-com

lgtm-com Bot commented Jan 19, 2021

Copy link
Copy Markdown

This pull request fixes 1 alert when merging 0244382 into 2551162 - view on LGTM.com

fixed alerts:

  • 1 for Non-exception in 'except' clause

@namloc2001
namloc2001 requested a review from thedrow January 21, 2021 17:35
@thedrow

thedrow commented Feb 14, 2021

Copy link
Copy Markdown
Contributor

Looks OK, what about the tests?

@namloc2001

Copy link
Copy Markdown
Contributor Author

@thedrow what about the logger piece? I couldn't work out what you needed here?

@lgtm-com

lgtm-com Bot commented Feb 14, 2021

Copy link
Copy Markdown

This pull request fixes 2 alerts when merging cb91ae2 into a5357ca - view on LGTM.com

fixed alerts:

  • 1 for Non-exception in 'except' clause
  • 1 for Module is imported with 'import' and 'import from'

@thedrow

thedrow commented Feb 21, 2021

Copy link
Copy Markdown
Contributor

@namloc2001 I can't push to your branch since you didn't allow edits from a maintainer.
I'm working on this and I have begun writing tests. Can you please check the box so we can collaborate?

@thedrow thedrow self-assigned this Feb 21, 2021
@namloc2001

Copy link
Copy Markdown
Contributor Author

@namloc2001 I can't push to your branch since you didn't allow edits from a maintainer.
I'm working on this and I have begun writing tests. Can you please check the box so we can collaborate?

Hi, allow edits by maintainers is ticked on this PR already. I've also invited you as a collaborator to the branch in case that is needed

@thedrow

thedrow commented Feb 22, 2021

Copy link
Copy Markdown
Contributor

@auvipy Is codecov set up in CI?

@thedrow
thedrow marked this pull request as draft February 22, 2021 17:59
@thedrow

thedrow commented Feb 22, 2021

Copy link
Copy Markdown
Contributor

I'm marking this as a draft until we cover all code paths.

@lgtm-com

lgtm-com Bot commented Feb 22, 2021

Copy link
Copy Markdown

This pull request introduces 1 alert and fixes 1 when merging 08d7eb2 into 3384937 - view on LGTM.com

new alerts:

  • 1 for Unused import

fixed alerts:

  • 1 for Module is imported with 'import' and 'import from'

@codecov

codecov Bot commented Feb 23, 2021

Copy link
Copy Markdown

Codecov Report

Merging #6600 (1a50cbc) into master (0154422) will increase coverage by 0.00%.
The diff coverage is 33.96%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #6600   +/-   ##
=======================================
  Coverage   70.42%   70.42%           
=======================================
  Files         138      138           
  Lines       16437    16457   +20     
  Branches     2061     2060    -1     
=======================================
+ Hits        11575    11590   +15     
- Misses       4660     4666    +6     
+ Partials      202      201    -1     
Flag Coverage Δ
unittests 70.42% <33.96%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
celery/bin/worker.py 0.00% <0.00%> (ø)
celery/exceptions.py 32.25% <0.00%> (-0.71%) ⬇️
celery/platforms.py 67.60% <62.06%> (+1.65%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0154422...ea649a4. Read the comment docs.

@auvipy

auvipy commented Feb 24, 2021

Copy link
Copy Markdown
Member

@auvipy Is codecov set up in CI?

it wasn't. I had internet issues for the last 2 days. so couldn't reply in time, sorry, but you set it up in the meantime. thanks

@auvipy auvipy modified the milestones: 5.0.6, 5.1.0 Feb 24, 2021
@thedrow
thedrow marked this pull request as ready for review February 24, 2021 10:00
@thedrow
thedrow requested a review from a team February 27, 2021 21:10
@auvipy auvipy closed this Feb 28, 2021
@auvipy auvipy reopened this Feb 28, 2021
@thedrow
thedrow merged commit 8a40560 into celery:master Mar 4, 2021
@thedrow
thedrow deleted the patch-1 branch March 4, 2021 15:20
thedrow added a commit that referenced this pull request Jun 6, 2021
This fixes a regression introduced in #6600 which caused an import error on non-unix platforms.

Fixes #6797.
auvipy pushed a commit that referenced this pull request Jun 9, 2021
* grp is no longer imported unconditionally.

This fixes a regression introduced in #6600 which caused an import error on non-unix platforms.

Fixes #6797.

* Adjust tests to cover the new code paths.
thedrow added a commit that referenced this pull request Jun 27, 2021
* grp is no longer imported unconditionally.

This fixes a regression introduced in #6600 which caused an import error on non-unix platforms.

Fixes #6797.

* Adjust tests to cover the new code paths.
jeyrce pushed a commit to jeyrce/celery that referenced this pull request Aug 25, 2021
* Update platforms.py

Making it so that the check for "superuser privileges" is only looking for uid/euid=0, not including the root group (gid/egid=0) which does not have the superuser privileges associated with uid/euid=0.

* Update platforms.py

* Update platforms.py

* Update platforms.py

* Update platforms.py

* Update celery/platforms.py

Co-authored-by: Omer Katz <[email protected]>

* Update celery/platforms.py

Co-authored-by: Omer Katz <[email protected]>

* Update celery/platforms.py

Co-authored-by: Omer Katz <[email protected]>

* Update celery/platforms.py

Co-authored-by: Omer Katz <[email protected]>

* Update platforms.py

* Update celery/platforms.py

Co-authored-by: Omer Katz <[email protected]>

* Update platforms.py

* Update platforms.py

* Update celery/platforms.py

Co-authored-by: Omer Katz <[email protected]>

* Update platforms.py

* Refactor contribution.

* Basic tests.

* Catch the SecurityError and exit the program.

* More tests.

* Ensure no warnings are present.

* Cover the case where the platform doesn't have fchown available.

* Test that a security error is raised when suspicious group names are used.

* Remove unused import.

Co-authored-by: Omer Katz <[email protected]>
jeyrce pushed a commit to jeyrce/celery that referenced this pull request Aug 25, 2021
* grp is no longer imported unconditionally.

This fixes a regression introduced in celery#6600 which caused an import error on non-unix platforms.

Fixes celery#6797.

* Adjust tests to cover the new code paths.
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.

Why does Celery Worker think uid=1000640000 euid=1000640000 is superuser privilege?

3 participants