mirror of
https://repo.or.cz/socat.git
synced 2025-05-24 13:42:42 +00:00
Procan: print saved set-user-ID
This commit is contained in:
parent
08d01c19ff
commit
568c26861b
4 changed files with 31 additions and 0 deletions
3
CHANGES
3
CHANGES
|
@ -98,6 +98,9 @@ Features:
|
|||
POSIXMQ is now an alias for POSIXMQ-BIDIRECTIONAL. It can also be used
|
||||
in unidirectional context.
|
||||
|
||||
Procan uses getresuid() and getresgid() when available, to determine
|
||||
the saved set-user-ID.
|
||||
|
||||
Building:
|
||||
Disabling certain features during configure could break build process.
|
||||
|
||||
|
|
|
@ -162,6 +162,12 @@
|
|||
/* Define if you have the clock_gettime function */
|
||||
#undef HAVE_CLOCK_GETTIME
|
||||
|
||||
/* Define if you have the getresuid function */
|
||||
#undef HAVE_GETRESUID
|
||||
|
||||
/* Define if you have the getresgid function */
|
||||
#undef HAVE_GETRESGID
|
||||
|
||||
/* Define if you have the strtoll function */
|
||||
#undef HAVE_STRTOLL
|
||||
|
||||
|
|
|
@ -1722,6 +1722,8 @@ AC_CHECK_PROTOTYPE_LIB(gettimeofday)
|
|||
|
||||
AC_CHECK_FUNC(clock_gettime, AC_DEFINE(HAVE_CLOCK_GETTIME), AC_CHECK_LIB(rt, clock_gettime, [LIBS="-lrt $LIBS"; AC_DEFINE(HAVE_CLOCK_GETTIME)]))
|
||||
|
||||
AC_CHECK_FUNCS(getresuid getresgid)
|
||||
|
||||
dnl Search for flock()
|
||||
# with Linux it's in libc, with AIX in libbsd
|
||||
AC_CHECK_FUNC(flock, AC_DEFINE(HAVE_FLOCK),
|
||||
|
|
20
procan.c
20
procan.c
|
@ -187,10 +187,30 @@ int procan(FILE *outfile) {
|
|||
fprintf(outfile, "process group id if fg process / stderr = "F_pid"\n", Tcgetpgrp(2));
|
||||
|
||||
/* process owner, groups */
|
||||
#if HAVE_GETRESUID
|
||||
{
|
||||
uid_t ruid, euid, suid;
|
||||
getresuid(&ruid, &euid, &suid);
|
||||
fprintf(outfile, "user id = "F_uid"\n", ruid);
|
||||
fprintf(outfile, "effective user id = "F_uid"\n", euid);
|
||||
fprintf(outfile, "saved set-user id = "F_uid"\n", suid);
|
||||
}
|
||||
#else /* !HAVE_GETRESUID */
|
||||
fprintf(outfile, "user id = "F_uid"\n", Getuid());
|
||||
fprintf(outfile, "effective user id = "F_uid"\n", Geteuid());
|
||||
#endif /* !HAVE_GETRESUID */
|
||||
#if HAVE_GETRESGID
|
||||
{
|
||||
gid_t rgid, egid, sgid;
|
||||
getresgid(&rgid, &egid, &sgid);
|
||||
fprintf(outfile, "group id = "F_gid"\n", rgid);
|
||||
fprintf(outfile, "effective group id = "F_gid"\n", egid);
|
||||
fprintf(outfile, "saved set-group id = "F_gid"\n", sgid);
|
||||
}
|
||||
#else /* !HAVE_GETRESGID */
|
||||
fprintf(outfile, "group id = "F_gid"\n", Getgid());
|
||||
fprintf(outfile, "effective group id = "F_gid"\n", Getegid());
|
||||
#endif /* !HAVE_GETRESGID */
|
||||
|
||||
/* Simple process features */
|
||||
fprintf(outfile, "\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue