You have to seteuid to the user, get the group, then return to uid 0. Because setuid() will change all of the uid settings (real, effective, etc.) you may think you can call seteuid() instead, so that you can later call setuid to root. But seteuid() does not change groups. Which does not work for what you want....
So, you have to exec(), setuid() to nobody, write the result of getgroups to shared memory, exit the child process.
IMO, It is probably less complicated to try this:
Then parse out the uids, usually nobody is a single group so one atoi call returns the group.
Last edited by jim mcnamara; 04-28-2011 at 02:15 PM..
Reason: change -g to -R see red text
when /var directory of my machine gets filled up (85%) i removed some old logs. but after cleaning df -k command still shows that /var is still 85% full.
It can detect the actual disk space only after I restart the machine. Is there a way to force df to reflect actual free space without... (1 Reply)
What's the best way to find out how much memory is being used/available? I tried using free, but I didn't quite understand the output. Can someone explain it?
$ free
total used free shared buffers cached
Mem: 16304536 16256376 48160 0 ... (6 Replies)
What is amount of free RAM i have now?
total used free shared buffers cached
Mem: 1010 963 46 0 215 256
-/+ buffers/cache: 491 518
Swap: 1983 0 1983
Above is the output of... (1 Reply)
how can I find cpu usage memory usage swap usage and
I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times
my final destination is monitor process
logical volume usage above X % and number of Logical voluage above
can I not to... (3 Replies)
Hi ,
As I am new to Linux server, I am facing some doubts like: On linux server virtual memory usage goes to 99%, but I have Threshold limit of 95%. So it crossed the threshold limit and alarmd.
Yesterday I moniterd the server using TOP command, and found some of Tibco process was consuming... (1 Reply)
I have installed Ubuntu and i want to monitor the internet usage.
Is there any software for linux for monitoring the internet usage?
(preferabaly opensource) (1 Reply)
Hi all
I was wondering if its possible to write a script to keep CPU usage at 90%-95%? for a single cpu linux server?
I have a perl script I run on servers with multple cpu's and all I do is max all but one cpu to get into the 90'% utilised area. I now need a script that raises the CPU to... (4 Replies)
Hello
We are in the process of migrating few of our applications in our linux boxes to new linux box to streamline our applications . In this context , i would like to know how we can calculate a particular application is used .?
This data will then be used to select which applications need... (7 Replies)
Hi,
My server is Centos 6 i686.
Is it possible get an openssl download from this site
"https://www.openssl.org/source/" (which is used for 64 bit platforms)
and use it on 32 bit platforms also?
Thx,
Aigini (5 Replies)
Discussion started by: anaigini45
5 Replies
LEARN ABOUT LINUX
getgroups32
GETGROUPS(2) Linux Programmer's Manual GETGROUPS(2)NAME
getgroups, setgroups - get/set list of supplementary group IDs
SYNOPSIS
#include <sys/types.h>
#include <unistd.h>
int getgroups(int size, gid_t list[]);
#include <grp.h>
int setgroups(size_t size, const gid_t *list);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
setgroups(): _BSD_SOURCE
DESCRIPTION
getgroups() returns the supplementary group IDs of the calling process in list. The argument size should be set to the maximum number of
items that can be stored in the buffer pointed to by list. If the calling process is a member of more than size supplementary groups, then
an error results. It is unspecified whether the effective group ID of the calling process is included in the returned list. (Thus, an
application should also call getegid(2) and add or remove the resulting value.)
If size is zero, list is not modified, but the total number of supplementary group IDs for the process is returned. This allows the caller
to determine the size of a dynamically allocated list to be used in a further call to getgroups().
setgroups() sets the supplementary group IDs for the calling process. Appropriate privileges (Linux: the CAP_SETGID capability) are
required. The size argument specifies the number of supplementary group IDs in the buffer pointed to by list.
RETURN VALUE
On success, getgroups() returns the number of supplementary group IDs. On error, -1 is returned, and errno is set appropriately.
On success, setgroups() returns 0. On error, -1 is returned, and errno is set appropriately.
ERRORS
EFAULT list has an invalid address.
getgroups() can additionally fail with the following error:
EINVAL size is less than the number of supplementary group IDs, but is not zero.
setgroups() can additionally fail with the following errors:
EINVAL size is greater than NGROUPS_MAX (32 before Linux 2.6.4; 65536 since Linux 2.6.4).
ENOMEM Out of memory.
EPERM The calling process has insufficient privilege.
CONFORMING TO
SVr4, 4.3BSD. The getgroups() function is in POSIX.1-2001. Since setgroups() requires privilege, it is not covered by POSIX.1-2001.
NOTES
A process can have up to NGROUPS_MAX supplementary group IDs in addition to the effective group ID. The set of supplementary group IDs is
inherited from the parent process, and preserved across an execve(2).
The maximum number of supplementary group IDs can be found using sysconf(3):
long ngroups_max;
ngroups_max = sysconf(_SC_NGROUPS_MAX);
The maximum return value of getgroups() cannot be larger than one more than this value.
SEE ALSO getgid(2), setgid(2), getgrouplist(3), initgroups(3), capabilities(7), credentials(7)COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2008-06-03 GETGROUPS(2)