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

Lack of pw_gecos field in Android's struct passwd causes cross-compilation for the pwd module to fail #64505

Closed
shiz mannequin opened this issue Jan 19, 2014 · 9 comments
Assignees
Labels
build The build process and cross-build

Comments

@shiz
Copy link
Mannequin

shiz mannequin commented Jan 19, 2014

BPO 20306
Nosy @pitrou, @skrah, @freakboy3742, @xdegaye
Files
  • Python-3.4.0tip-workaround-android-missing-pw_gecos-field.patch: A patch that works around the lack of a pw_gecos field by setting the relevant value to None.
  • pw_gecos-field-workaround-with-config_ac-mods.patch: shiz's patch extended with the required addition to configure.ac
  • pw_gecos-field-workaround-with-config_ac-mods.patch: patch without mods to generated files (just mods pwdmodule.c and configure.ac)
  • 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 = 'https://github.com/skrah'
    closed_at = <Date 2016-04-26.00:04:14.754>
    created_at = <Date 2014-01-19.18:23:41.849>
    labels = ['build']
    title = "Lack of pw_gecos field in Android's struct passwd causes cross-compilation for the pwd module to fail"
    updated_at = <Date 2016-04-26.09:50:06.970>
    user = 'https://bugs.python.org/shiz'

    bugs.python.org fields:

    activity = <Date 2016-04-26.09:50:06.970>
    actor = 'skrah'
    assignee = 'skrah'
    closed = True
    closed_date = <Date 2016-04-26.00:04:14.754>
    closer = 'skrah'
    components = ['Build']
    creation = <Date 2014-01-19.18:23:41.849>
    creator = 'shiz'
    dependencies = []
    files = ['33550', '37009', '37930']
    hgrepos = []
    issue_num = 20306
    keywords = ['patch']
    message_count = 9.0
    messages = ['208487', '217356', '217368', '229964', '235061', '264201', '264229', '264243', '264244']
    nosy_count = 7.0
    nosy_names = ['pitrou', 'skrah', 'freakboy3742', 'xdegaye', 'python-dev', 'shiz', 'WanderingLogic']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'compile error'
    url = 'https://bugs.python.org/issue20306'
    versions = ['Python 3.6']

    @shiz
    Copy link
    Mannequin Author

    shiz mannequin commented Jan 19, 2014

    As the title states, mkpwent() in pwdmodule.c accesses pw_gecos, which is not defined for struct passwd in Bionic, Android's C library.

    Attached is a patch that works around the issue by setting the field to None on Android.

    @shiz shiz mannequin added build The build process and cross-build labels Jan 19, 2014
    @pitrou
    Copy link
    Member

    pitrou commented Apr 28, 2014

    Interesting. It seems pw_gecos isn't mandated by POSIX:
    http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/pwd.h.html

    I wonder if there's a better way to do this (autoconf check?) than an Android-specific #ifdef, though.

    @shiz
    Copy link
    Mannequin Author

    shiz mannequin commented Apr 28, 2014

    Ah, yes, if it's not actually mandated by POSIX, something like HAVE_PASSWD_PW_GECOS would be more appropriate. I'll rework the patch into something more generic.

    @WanderingLogic
    Copy link
    Mannequin

    WanderingLogic mannequin commented Oct 24, 2014

    Here is shiz's patch extended with the addition to configure.ac. I added the variable HAVE_PASSWD_GECOS_FIELD and the appropriate tests. Luckily this very problem (missing pw_gecos field) is the example used in the autoconf manual (https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Generic-Structures.html#Generic-Structures). (Otherwise I would have been as lost as I usually am with autoconf.)

    @WanderingLogic
    Copy link
    Mannequin

    WanderingLogic mannequin commented Jan 30, 2015

    Apologies. That last patch includes diffs to generated files (configure and pyconfig.h.in). This version just patches Modules/pwdmodule.c and configure.ac.

    After applying the patch please run "autoheader" and "autoconf" to correctly regenerate configure and pyconfig.h.in.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 25, 2016

    New changeset 0d74d4937ab9 by Stefan Krah in branch 'default':
    Issue bpo-20306: The pw_gecos and pw_passwd fields are not required by POSIX.
    https://hg.python.org/cpython/rev/0d74d4937ab9

    @skrah skrah mannequin added build The build process and cross-build and removed build The build process and cross-build labels Apr 26, 2016
    @skrah skrah mannequin closed this as completed Apr 26, 2016
    @skrah skrah mannequin self-assigned this Apr 26, 2016
    @xdegaye
    Copy link
    Mannequin

    xdegaye mannequin commented Apr 26, 2016

    With changeset 0d74d4937ab9, test_pwd fails on android API level 21 at test_values with:
      Traceback (most recent call last):
        File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/test_pwd.py", line 27, in test_values
          self.assertIsInstance(e.pw_passwd, str)
      AssertionError: None is not an instance of <class 'str'>

    On android API 21 HAVE_STRUCT_PASSWD_PW_PASSWD is defined but p->pw_passwd is set to NULL.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 26, 2016

    New changeset f0f519aca558 by Stefan Krah in branch 'default':
    Issue bpo-20306: Android is the only system that returns NULL for the pw_passwd
    https://hg.python.org/cpython/rev/f0f519aca558

    @skrah
    Copy link
    Mannequin

    skrah mannequin commented Apr 26, 2016

    Okay, for the record: I think that returning "None" would probably be
    more correct than the empty string, but I don't think users actually
    care to the point that they will introduce a case split in their
    applications.

    Realistically, probably no one cares about pw_passwd at all.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    build The build process and cross-build
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant