?????? ?????????????????????? ?????????????????????????? ?? ?????????????? ?????????????????????????? ?????????????????? ???????? uid[lowbar]t ?? gid[lowbar]t ???????????????? ?? long (32-?????????????????? ???????????????? ??????) ?? int (64-?????????????????? ???????????????? ??????) ???? ?????? uint32[lowbar]t. ?????? ?????????????????? ???????????????????????????? ???????????????????? ???? ???????? ?????????????? ????. ?????????????????? ???????? uid[lowbar]t ?? gid[lowbar]t ?? ?????????? ?????????????? ?? ?????????????????????? ?? Solaris Express Developer Edition.
???????? ?????????????????? ?????????????????????? ???????? ??????????????????:
?????? ???????????????????????????? ???????? ?????????? ????????????????, ???????????????????? ?????????????????????? ?????????? uid[lowbar]t ?? gid[lowbar]t ???????????? ?????????????????????????????? ???????????????????????? ?????????????????????????? ???????????????? ????????????????????.
???????????????????? ?????????????????? ?????????????????? ???????????????????? ??????????????:
1 #include <unistd.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4
5 int
6 main(void)
7 {
8 uid_t negone = -1;
9
10 if (getuid() < 0)
11 exit(1);
12
13 (void) setreuid(negone, getuid());
14
15 (void) printf("%ld\n", getuid());
16
17 return (0);
18 }
|
???????????????????? Sun Studio 11 ???????????? ?????????????????? ????????????????????????????:
"uid.c", line 8: warning: initializer does not fit or is out of range: -1" |
?????????????????? lint ???? Studio 11 ???????????? ?????????????????? ????????????????????????????:
((8) warning: constant truncated by assignment |
(8) warning: initializer will be sign-extended: -1 |
(10) warning: suspicious comparison of unsigned with 0: op "<" |
function argument ( number ) type inconsistent with format |
|
|
gcc -Wall -Wextra ???????????? ?????????????????? ????????????????????????????:
uid.c:10: warning: comparison of unsigned expression < 0 is always false |
uid.c:15: warning: long int format, uid_t arg (arg 2) |
?????????? ?????????????????????????? ???????????????? ?????? ?????????? ?????????????????? ???? ?????????????? ?????????????????? ?? ???????????????????? ??????????????????. ???????????? ???????? ???? ??????????????????.
?????????????????? ???????? uid[lowbar]t ?? gid[lowbar]t ???????????????? ?? ???????? ?????????????????????????? ???????? ?????? ?????????????? ?? ???????????????? C++.
?????????????? ???????????????? ???????????? C, ???????????????? ?????????? ?? ???????????????????? C++ ???????????????????? ?????????????????????????????? ?????? ????????????. ???????????????????? ???????????????????? ????????????, ?????????? uid[lowbar]t ?? gid[lowbar]t ???????????????????????? ????????????????????????, ?????????????????????????? ?? ????????????????????. ?? ???????? ???????????? ????????????????????, ???????????????????? ?????? ????????????????????, ?? ????????????????????, ???????????????????????? ?????? ????????????????????, ?????????????? ?????????????????????????? ????????????????????????????.
?????????????????? ?? ???? Solaris ???????????????????? C++ ?????????????????? ???????? ???? ????????????????????????, ?????????????????????? ?????????????????????????????? ?? ???????????????????????? Solaris ????????????????????????.