[Mono.Posix] Parameters for chown should be signed integers not unsigned (#15828)
commit51aa4b019abdd61088968c4dac727c08f23df577
authorNicholas Schell <nschell@gmail.com>
Fri, 26 Jul 2019 18:07:38 +0000 (26 11:07 -0700)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Fri, 26 Jul 2019 18:07:38 +0000 (26 20:07 +0200)
treecc577ae3c77b337d6956e02c3e232ae754796aec
parent29428550c22384cfba20a0d2ab3f420caf082b73
[Mono.Posix] Parameters for chown should be signed integers not unsigned (#15828)

Fixes https://github.com/mono/mono/issues/10748

The calls for chown, lchown, fchown, and fchownat (from `Mono.Unix.Native.Syscall`) are all declared with unsigned integers for the `owner` and `group` parameters. This is incorrect.

Directly from the manpage
`man 2 chown`
<pre><code>
...
       int chown(const char *pathname, uid_t owner, gid_t group);
       int fchown(int fd, uid_t owner, gid_t group);
       int lchown(const char *pathname, uid_t owner, gid_t group);

...

       int fchownat(int dirfd, const char *pathname,
                    uid_t owner, gid_t group, int flags);

...
...
       <b>If the owner or group is specified as -1</b>, then that ID is not changed.
...
</pre></code>

Emphasis added on the documentation explaining how the parameters can take the value -1, clearly not an unsigned integer. The `uid_t` struct is not an unsigned integer. I am assuming this was just an oversite on whoever re-wrote `Mono.Unix.Native.Syscall`.

The original calls from `Mono.Posix.Syscall` (now marked as Obsolete) all correctly use signed integers.
```
                [DllImport ("libc", SetLastError=true)]
                public static extern int chown (string path, int owner, int group);
                [DllImport ("libc", SetLastError=true)]
                public static extern int lchown (string path, int owner, int group);
```

Even the documentation directly from `mcs/class/Mono.Posix/Documentation/en/Mono.Unix.Native/Syscall.xml`
```
          <para>
            One of the owner or group id's
            may be left unchanged by specifying it as -1.
          </para>
```
external/api-snapshot
mcs/class/Mono.Posix/Documentation/en/Mono.Unix.Native/Syscall.xml
mcs/class/Mono.Posix/Mono.Unix.Native/Syscall.cs
mcs/class/Mono.Posix/Mono.Unix/UnixFileSystemInfo.cs
mcs/class/Mono.Posix/Mono.Unix/UnixStream.cs
mcs/class/Mono.Posix/Mono.Unix/UnixSymbolicLinkInfo.cs