Skip to content
  • Zbigniew Jędrzejewski-Szmek's avatar
    Allow negative uids/gids in PolkitUnixUser and Group objects · 2cb40c4d
    Zbigniew Jędrzejewski-Szmek authored
    (uid_t) -1 is still used as placeholder to mean "unset". This is OK, since
    there should be no users with such number, see
    https://systemd.io/UIDS-GIDS#special-linux-uids.
    
    (uid_t) -1 is used as the default value in class initialization.
    
    When a user or group above INT32_MAX is created, the numeric uid or
    gid wraps around to negative when the value is assigned to gint, and
    polkit gets confused. Let's accept such gids, except for -1.
    
    A nicer fix would be to change the underlying type to e.g. uint32 to
    not have negative values. But this cannot be done without breaking the
    API, so likely new functions will have to be added (a
    polkit_unix_user_new variant that takes a unsigned, and the same for
    _group_new, _set_uid, _get_uid, _set_gid, _get_gid, etc.). This will
    require a bigger patch.
    
    Fixes #74.
    2cb40c4d