Skip to content

Accepting of os functions of (path, dir_fd) pair as argument #59408

Closed

Description

@serhiy-storchaka
BPO 15203
Nosy @ncoghlan, @larryhastings, @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2012-06-28.07:08:16.396>
created_at = <Date 2012-06-27.09:27:19.411>
labels = ['library']
title = 'Accepting of os functions of (path, dir_fd) pair as argument'
updated_at = <Date 2012-06-28.07:08:16.352>
user = 'https://github.com/serhiy-storchaka'

bugs.python.org fields:

activity = <Date 2012-06-28.07:08:16.352>
actor = 'ncoghlan'
assignee = 'none'
closed = True
closed_date = <Date 2012-06-28.07:08:16.396>
closer = 'ncoghlan'
components = ['Library (Lib)']
creation = <Date 2012-06-27.09:27:19.411>
creator = 'serhiy.storchaka'
dependencies = []
files = []
hgrepos = []
issue_num = 15203
keywords = []
message_count = 3.0
messages = ['164132', '164138', '164223']
nosy_count = 4.0
nosy_names = ['ncoghlan', 'larry', 'Arfrever', 'serhiy.storchaka']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue15203'
versions = ['Python 3.3']

Activity

  1. serhiy-storchaka commented on Jun 27, 2012

    @serhiy-storchaka
    MemberAuthor

    Since many of os functions were polymorphic in its first argument (path or fd), the logical continuation is to add a (path, dir_fd) pair as yet one case of this argument. In any case dir_fd is incopatible with fd. This simplifies the code of certain functions which takes patch and dir_fd and pass them to lower level without changes, or that use same patch and dir_fd in calls of several functions. This freely adds support of dir_fd to many functions, such as os.path.isdir. This solves the problem of naming multiple dir_fd arguments (src_dir_fd/dst_dir_fd looks ugly). This saves a pre-3.3 signature of some functions, which will facilitate the use of decorators and improve compatibility with alternative implementations.

  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Jun 27, 2012
  3. larryhastings commented on Jun 27, 2012

    @larryhastings
    Contributor

    I dislike this and always have. I think it would look ugly and be obnoxious to use.

    If you really think you can get this in for 3.3, you will have to bring it up with Georg. I think your chances are about zero.

  4. ncoghlan commented on Jun 28, 2012

    @ncoghlan
    Contributor

    Correctly avoiding symlink attacks, which is the whole reason the POSIX *at variants and the dir_fd parameters were added, is not trivial in general. os.fwalk and shutil.rmtree went through many iterations before reaching a state where they should successfully avoid the problem.

    Simply passing a (path, dir_fd) 2-tuple instead of a string and calling it done is highly unlikely to produce a secure result, thus rather missing the point of the exercise.

  5. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directory

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions