Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Your object is to save the world, while still leading a pleasant life.


comp / comp.lang.python / Re: shutil.rmtree() fails when used in Fedora (rpm) "mock" environment

SubjectAuthor
o Re: shutil.rmtree() fails when used in Fedora (rpm) "mock" environmentLeft Right

1
Subject: Re: shutil.rmtree() fails when used in Fedora (rpm) "mock" environment
From: Left Right
Newsgroups: comp.lang.python
Date: Thu, 24 Oct 2024 19:21 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: olegsivokon@gmail.com (Left Right)
Newsgroups: comp.lang.python
Subject: Re: shutil.rmtree() fails when used in Fedora (rpm) "mock" environment
Date: Thu, 24 Oct 2024 21:21:17 +0200
Lines: 25
Message-ID: <mailman.39.1729799086.4695.python-list@python.org>
References: <4a13731716200669342338ae409e73ca@posteo.de>
<CAJQBtg=kCr0VMGXvkBcj4U6CwatC2_G2dstO5pS56_koAXJurA@mail.gmail.com>
<0c080a7d-92de-4518-ac44-78d97fc9e3bb@mrabarnett.plus.com>
<CAJQBtg=ButLwvoA2USBEV8-q=taRhuC+t6D1HkJMbG9VzTvxnQ@mail.gmail.com>
<69934a74-6d04-40a0-a75f-b8024bd0af43@mrabarnett.plus.com>
<CAJQBtgm6Re8tj5hKAZ7Zz6+NC-0iqcBH-MKo8gaOMm8A4prZfA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de 5FXP08x3kGONBYZQ+cqNHAP2FKJebZ9LBZTGeWKsgETQ==
Cancel-Lock: sha1:o0N+hyYGW/uRiFgUZV2aR+lOMEI= sha256:XEDbOEz/iUL3PIa6dm94sEzGFBxsK2/rHhWsUqhM48I=
Return-Path: <olegsivokon@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=ZD9fuCD/;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'thread': 0.05;
'subject:when': 0.07; 'alternatives': 0.09; 'cc:addr:python-list':
0.09; 'comparison': 0.09; 'reference:': 0.09; 'resolved': 0.09;
'651': 0.16; '677': 0.16; '679': 0.16; '689': 0.16; '760': 0.16;
'appended': 0.16; 'assert': 0.16; 'comparison,': 0.16; 'failed.':
0.16; 'lambda': 0.16; 'received:mail-oi1-x22a.google.com': 0.16;
'subject:() ': 0.16; 'subject:Fedora': 0.16; 'subject:fails':
0.16; 'subject:used': 0.16; "can't": 0.17; 'cc:addr:python.org':
0.20; 'skip:_ 10': 0.22; 'lines': 0.23; 'cc:2**0': 0.25; 'object':
0.26; 'else': 0.27; 'modify': 0.31; 'module': 0.31; 'message-
id:@mail.gmail.com': 0.31; 'question': 0.32; 'modified': 0.32;
'but': 0.32; 'header:In-Reply-To:1': 0.34; 'received:google.com':
0.34; 'from:addr:gmail.com': 0.34; 'following': 0.35; 'those':
0.36; 'put': 0.38; 'added': 0.39; 'something': 0.40; 'reference':
0.60; 'between': 0.63; 'less': 0.64; 'that,': 0.68; 'skip:* 10':
0.73
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1729797688; x=1730402488; darn=python.org;
h=cc:to:subject:message-id:date:from:in-reply-to:references
:mime-version:from:to:cc:subject:date:message-id:reply-to;
bh=meG3MRegPBjtgL4uZyZ5RTrHRdaG/cwO5dy/3PhLjIQ=;
b=ZD9fuCD/szgbXK7Xwes9zquaCycbbX2GXzRnxZi8ErcHzlb7Rm8TBzcnkDsaH3nkq8
Nb05NpdJshlaX4Wine1IOQ465C54kO+yYKZ3zpwUs7SaZSuupsplufvQ/CiMq39bHrzm
NFyTAGg8xHBdBnujUSYYwuzUz6HAl3AoM9Ez77dpryVlgOFKvW9rxgTqqCf+zo+pzdQY
iMltKxZCYaWj6tHw96UrcpfNEi9D0KEjXz7jC47Pr86UOAU4KokiampcMAXCmtEBq/SW
vGrUX+HwYnI+AYOpUwiGGLPC3fXJq8wGp0Gm5vtAgZs4nQAlZxgoKB6O3QElddfbbbte
N1Yg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1729797688; x=1730402488;
h=cc:to:subject:message-id:date:from:in-reply-to:references
:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
:reply-to;
bh=meG3MRegPBjtgL4uZyZ5RTrHRdaG/cwO5dy/3PhLjIQ=;
b=xUv5RzCefTfVFwYIJjO8LQ+QmPiBqyDfirLBrY5aMIz2yf6+rQDqZJSQP6J7YW5c6R
D5ngFfeu2AFcSjQ5i6SDq5IyPasiBFZbJfhxyCp5G0PzPaocYIEEiZ+g/xWmZGGpP6hk
HlrnkDC9pusWzmnioqu9SoF4bFH0LsmYrC4dkpFX9fep7HIOvfOx+3WZ6Jl5a0m5tmmd
90nyRj64JFAIQp9dM5OHJJ4E1mWVh/V6eUjMs1Jof+5SQarFzEKmxhnj63yF2SzKVfrI
24zHpn94D3zP5zIuebDksqiAxt5VE9gi4o0vBkO8ddBqpu0RprL5twNotOvAPu1epMLz
9m/A==
X-Gm-Message-State: AOJu0Yzu1288dI5bB3lrFONFIaX0ZhCEaGJ1+AtdOONMh5NYd6GHnODX
sxt82vprDewjMsGtj8gsstoSz0lgrLDn9YOqVz9dKqUr/5mBJ3JYetMkJFd+XLoDH11Hs4I7rd2
S7Adg2cb1hmSuaDCn7gszPxN8yh4Zt9Q6
X-Google-Smtp-Source: AGHT+IHRmE9yc0Vu9Z6QucuIItjrXEm5BRIh4GYuXwLp8LmT4c+bzFxLtq2+vaxHG5LPhAdGHG8unnBevUXQCqliCPo=
X-Received: by 2002:a05:6808:1998:b0:3e6:16f7:9742 with SMTP id
5614622812f47-3e6245a66d3mr7603660b6e.33.1729797688100; Thu, 24 Oct 2024
12:21:28 -0700 (PDT)
In-Reply-To: <69934a74-6d04-40a0-a75f-b8024bd0af43@mrabarnett.plus.com>
X-Mailman-Approved-At: Thu, 24 Oct 2024 15:44:45 -0400
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAJQBtgm6Re8tj5hKAZ7Zz6+NC-0iqcBH-MKo8gaOMm8A4prZfA@mail.gmail.com>
X-Mailman-Original-References: <4a13731716200669342338ae409e73ca@posteo.de>
<CAJQBtg=kCr0VMGXvkBcj4U6CwatC2_G2dstO5pS56_koAXJurA@mail.gmail.com>
<0c080a7d-92de-4518-ac44-78d97fc9e3bb@mrabarnett.plus.com>
<CAJQBtg=ButLwvoA2USBEV8-q=taRhuC+t6D1HkJMbG9VzTvxnQ@mail.gmail.com>
<69934a74-6d04-40a0-a75f-b8024bd0af43@mrabarnett.plus.com>
View all headers

> > > The stack is created on line 760 with os.lstat and entries are appended
> > > on lines 677 (os.rmdir), 679 (os.close) and 689 (os.lstat).
> > >
> > > 'func' is popped off the stack on line 651 and check in the following lines.
> > >
> > > I can't see anywhere else where something else is put onto the stack or
> > > an entry is replaced.

But the _rmtree_safe_fd() compares func to a *dynamically* resolved
reference: os.lstat. If the reference to os changed (or os object was
modified to have new reference at lstat) between the time os.lstat was
added to the stack and the time of comparison, then comparison
would've failed. To illustrate my idea:

os.lstat = lambda x: x # thread 1
stack.append((os.lstat, ...)) # thread 1
os.lstat = lambda x: x # thread 2
func, *_ = stack.pop() # thread 1
assert func is os.lstat # thread 1 (failure!)

The only question is: is it possible to modify os.lstat like that, and
if so, how?

Other alternatives include a malfunctioning "is" operator,
malfunctioning module cache... all those are a lot less likely.

1

rocksolid light 0.9.8
clearnet tor