printuid: fix uid_t decoding on 64-bit architectures
It was not a good idea to treat uid_t as a long int type because
the latter is twice larger than uid_t on 64-bit architectures.
* defs.h (printuid): Change uid argument type from "unsigned long"
to "unsigned int".
* util.c (printuid): Likewise. When uid equals to -1, print "-1".
* tests/uid.awk: New file.
* tests/uid.c: New file.
* tests/uid32.c: Likewise.
* tests/uid.test: New test.
* tests/uid32.test: Likewise.
* tests/Makefile.am (CHECK_PROGRAMS): Add uid and uid32.
(TESTS): Add uid.test and uid32.test.
(EXTRA_DIST): Add uid.awk.
* tests/.gitignore: Add uid and uid32.
diff --git a/tests/uid.c b/tests/uid.c
new file mode 100644
index 0000000..b4b9813
--- /dev/null
+++ b/tests/uid.c
@@ -0,0 +1,29 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+#include <assert.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+int
+main(void)
+{
+#if defined(__NR_getuid) \
+ && defined(__NR_setuid) \
+ && defined(__NR_getresuid) \
+ && defined(__NR_setreuid) \
+ && defined(__NR_setresuid) \
+ && defined(__NR_chown)
+ uid_t r, e, s;
+
+ e = syscall(__NR_getuid);
+ assert(syscall(__NR_setuid, e) == 0);
+ assert(syscall(__NR_getresuid, &r, &e, &s) == 0);
+ assert(syscall(__NR_setreuid, -1, -1L) == 0);
+ assert(syscall(__NR_setresuid, -1, e, -1L) == 0);
+ assert(syscall(__NR_chown, ".", -1, -1L) == 0);
+ return 0;
+#else
+ return 77;
+#endif
+}