Commit Graph

64 Commits

Author SHA1 Message Date
Jaroslav Rohel c8dbe6ea40 Fix: No traceback when Python interpreter is running with -P
There was code in dnf and dnf-automatic to support running them from
the git tree. This was a developer-oriented hack that should not exist
in production code. It assumed that when running an installed dnf,
the `sys.path[0]` contains `/usr/bin`. If not, it overwrites
the contents of `sys.path[0]`.

This is a problem when running the Python interpreter with the `-P`
parameter (meaning: Don't automatically prepend a potentially unsafe
path to sys.path such as the current directory, the script's directory
or an empty string.)

The fix removes this developer-oriented hack. Developers should instead
set PYTHONPATH in the environment.
2024-04-29 12:48:30 +02:00
Miro Hrončok c68038ff12 Remove /usr/bin from sys.path to avoid accidentally importing garbage
See https://bugzilla.redhat.com/show_bug.cgi?id=2057340
and https://github.com/benjaminp/six/issues/359

dnf should never import Python modules from /usr/bin but users can
have files in there that look like Python modules and Python will
try to import them and fail.

Consider a tool that is *not* written in Python and is called "copy.pyc".
Naturally, it resides in /usr/bin/copy.pyc and dnf fails:

    Traceback (most recent call last):
      File "/usr/bin/dnf", line 57, in <module>
        from dnf.cli import main
      File "/usr/lib/python3.10/site-packages/dnf/__init__.py", line 30, in <module>
        import dnf.base
      File "/usr/lib/python3.10/site-packages/dnf/base.py", line 31, in <module>
        from copy import deepcopy
    ImportError: bad magic number in 'copy': b'...'

Similarly, a tool actually written in Python, called "copy.py"
might as well own /usr/bin/copy.py and dnf fails as well:

    Traceback (most recent call last):
      File "/usr/bin/dnf", line 57, in <module>
        from dnf.cli import main
      File "/usr/lib/python3.10/site-packages/dnf/__init__.py", line 30, in <module>
        import dnf.base
      File "/usr/lib/python3.10/site-packages/dnf/base.py", line 31, in <module>
        from copy import deepcopy
    ImportError: cannot import name 'deepcopy' from 'copy' (/usr/bin/copy.py)

Either problem can happen for a variety of names.
We better not let that happen.

A more general solution that would prevent Python doing this entirely
does not exists yet, see https://discuss.python.org/t/4235

Hence, proposing this to dnf, which is a critical piece of the system.
2022-02-25 10:35:54 +01:00
Marek Blaha 558e2d988b Ensure that correct python version is used for build - PYTHON_EXECUTABLE (RhBug:1598988) (#1129)
* Ensure that correct python version is used for build (RhBug:1598988)
* PYTHON_DESIRED can be either "2", "3" or a path to interpreter
2018-07-12 11:49:08 +02:00
Jaroslav Mracek 6c425c1903 Make yum compatible layer very minimal (RhBug:1476748)
The commit should provide identical dnf behavior with dnf and yum prefix. If any
changes in dnf behavior will be required, it should be handled on dnf.conf
level.

https://bugzilla.redhat.com/show_bug.cgi?id=1476748
2017-08-02 12:40:07 +02:00
Martin Hatina bc35456400 yum layer using python3
Closes: #715
Approved by: jrohel
2017-04-20 09:10:17 +00:00
Martin Hatina 64612e9728 introduce yum compatible layer
Closes: #641
Approved by: MichaelMraka
2016-11-01 14:04:32 +00:00
Michael Mraka 748a792ef3 updated copyright years 2016-06-08 10:42:57 +02:00
Jan Silhan ce9c4c3b30 cli: cosmetic: print less intrusive dnf redirection message
As DNF have to be more compatible with yum and /usr/bin/yum binary will
be supported longer than was originally planned, we will reduce the
annoying redirecting output
2016-06-08 10:18:29 +02:00
Michael Mraka b95e903208 updated copyrights for files changed this year 2016-04-28 14:47:44 +02:00
Michal Domonkos c78e3cf2e6 build: make python2/3 binaries at build time
Instead of having separate copies of the dnf and dnf-automatic binaries
for each python version, let's just generate those at build time using
.in files.
2016-02-03 10:56:26 +01:00
Jaroslav Mracek 5c099d1d5c Remove -OO from #!/usr/bin/python (RhBug:1230820)
To prevent incidents with .pyo files -OO options was removed.
2015-11-26 14:30:02 +01:00
Michal Luscon c3d4c3e585 cli: prevent tracebacks after C^ (RhBug:1274946) 2015-10-27 16:20:05 +01:00
Jan Silhan 9a75e43327 dnf-yum: cosmetic: lower case after comma 2015-04-16 11:43:13 +02:00
Jan Silhan 5c262dc6d7 dnf-yum: print how to install migrate plugin 2015-04-16 10:19:12 +02:00
Jan Silhan 6c39532999 dnf-yum: modified warning message (RhBug:1207965) 2015-04-02 11:44:28 +02:00
Jan Silhan 2c90342bc8 dnf-yum package does not conflict with yum 3.4.3-505+ 2015-03-31 11:07:48 +02:00
Jan Silhan aa712fd6cd dnf-automatic: fixed python_sitelib (RhBug:1199450) 2015-03-25 13:03:38 +01:00
Jan Silhan f9ec921f32 install dnf-3 only when python3 is enabled (thanks glensc) 2015-03-04 18:39:31 +01:00
Jan Silhan ac81b63763 spec: made python3-dnf package installed by default in f23 2015-02-23 20:02:05 +01:00
Ales Kozumplik e874f4888d packaging: add dnf-automatic subpackage. 2014-08-11 14:30:19 +02:00
Ales Kozumplik 526ab921fa dnf-automatic: tool supplying the yum-cron functionality.
Related: RhBug:1109915
2014-08-11 09:43:49 +02:00
Ales Kozumplik 41bbf95b07 Ship /usr/bin/dnf-3 to run DNF under Py3. (RhBug:1117678) 2014-07-16 08:56:47 +02:00
Ales Kozumplik 754f1ecde0 packaging: cosmetic: copyright years in bin/dnf. 2014-05-02 11:03:20 +02:00
Ales Kozumplik c0ab927c5e bin/dnf: run the python interpreter with -OO.
Cheaply shaves off <100 ms from e.g. 'dnf upgrade'.
2014-05-02 11:00:58 +02:00
Jan Silhan 1a1abe08e0 make all strings unicode_literals implicitly 2014-04-16 10:08:21 +02:00
Ales Kozumplik b61fddc6fa cosmetic: yummain.py is just main.py 2012-11-13 15:53:12 +01:00
Ales Kozumplik 3544ca1d9c packaging: some file licensing issues.
removes unlicensed, unused files in rpmUtils.

adds license to bin/dnf.
2012-07-09 09:52:31 +02:00
Ales Kozumplik f05e38fe7d get rid of yum-updatesd.
not supported by dnf in its current form and being reworked in the master
yum branch.
2012-06-04 12:19:45 +02:00
Ales Kozumplik 6166d1c835 cosmetic: further bin/dnf cleanup. 2012-05-31 10:29:28 +02:00
Ales Kozumplik 870490d5d4 move dnf/yum-cli to dnf/cli.
"yum-cli" is not a legal identifier for module.
2012-05-30 18:01:40 +02:00
Ales Kozumplik 165b86c363 Eliminate all sys.path hackery introduced in 5688b84.
sys.path hackery only causes pain, suffering and doubled imports.
2012-05-30 17:59:37 +02:00
Ales Kozumplik 45d2b4aff0 packaging: add cmake scripts providing 'make install' 2012-04-13 17:02:30 +02:00
Ales Kozumplik 5688b8457e packaging: sys.path magic to make the new directory layout work 2012-04-13 14:02:25 +02:00
Ales Kozumplik 88fe2d4c68 packaging: bin/dnf.
one file will launch git or rpm-installed dnf.
2012-04-13 13:27:46 +02:00
Seth Vidal c9bf66faa3 move some wiki.linux.duke.edu references to baseurl.org 2010-01-04 11:47:49 -05:00
James Antill 788f0cfbad Have user_mina() just call exit 2008-02-08 15:13:59 -05:00
James Antill 83628d8d72 Extend the profiling env options to generic bin/yum 2008-01-23 11:15:33 -05:00
Jeremy Katz 39d8dc5fae move option parsing around a little so that yum-updatesd will start
faster (rh#220614)
2007-05-03 01:24:34 +00:00
James Bowes 7bea9416ca pychecker related fixes, including unused imports, and removal of use of deprecated methods from the string module 2006-12-05 00:40:51 +00:00
Jeremy Katz 78eafc7098 * install yum-updatesd wrapper binary in /usr/sbin
* rename /usr/share/yum-cli/yum-updatesd.py to something that can be
  imported
2006-06-27 20:53:30 +00:00
Seth Vidal 4f88b3ed1f removed all the bits for yum-arch. This might show back up in yum-utils but
it's gone from yum as it no longer has anything to do with yum.
2006-03-07 06:16:13 +00:00
Seth Vidal b60006084c add link to the faq, not post to the list 2005-11-02 22:22:45 +00:00
Seth Vidal cebc54b97b check in Hans-Peter Jansen's patch to help make the error output when a
needed module is missing a bit easier.
2005-08-05 05:56:36 +00:00
Seth Vidal 6b2f6e38c7 rather funny little patch 2005-06-04 05:13:47 +00:00
Seth Vidal 4894d578a4 update to yum.py from Terrel Shumway - makes nicer output message if the yum
module doesn't exist.
2005-03-02 08:31:17 +00:00
Seth Vidal f70c64ecc7 try to catch keyboard interrupt earlier 2004-11-24 16:16:20 +00:00
Seth Vidal 4502b70899 damn it. 2004-10-18 12:58:01 +00:00
Seth Vidal 7661adf3fd removing shell script which caused pain, adding python script that removes
pain
2004-10-16 20:39:01 +00:00
Seth Vidal 9ac3422377 move yum-arch and yum.sh into bin/ dir 2004-10-13 05:57:34 +00:00
Seth Vidal 1ffec916ed remove obsolete yum bin file 2004-10-13 05:38:20 +00:00