transmit group set to a child under SUN Solaris

Posted on 2002-03-13
Last Modified: 2013-12-26
SUN Solaris 'exec' system call reset the current group set.

Does anybody know aworkaround for this?

the following chunk of code well explain the problem: the child process does not inherit the additional group. Under Linux and AIX it does, that is the code below works fine.

  if ((ngroups=getgroups(NGROUPS_MAX,array_of_gids))==-1){
    if (!silent)
      perror("ERROR! getgroups");
    return 10;

  /* Add a group to array of groups */
  array_of_gids[ngroups++]= <any group number you like>;
  if (setgroups(ngroups,array_of_gids)==-1){
    if (!silent)
      perror("ERROR! setgroups");
    return 2;


thank you all
Question by:mliberi
  • 2
  • 2

Expert Comment

ID: 6868224
err, are you running as non-root with silent != 0

Author Comment

ID: 6876557
the chunk of code I submitted runs with effective user id ==0

silent is a flag used to optionally disable printing error messages to stderr. You can assume it to be FALSE.

The program executes the last command 'system("groups")', but the group previously added doesn't appear in the output generated by 'groups' command.

Accepted Solution

ecw earned 100 total points
ID: 6877036
Yep, I've checked it, and the man page for groups(1).  If you replace system("groups") with system("id -a") you might find it is in fact working.  groups(1) gets its info from /etc/passwd and /etc/group, not the current process context.

Author Comment

ID: 6890056

I'm glad to discover that my problem was so simple to solve.
thank you

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
wait notify demo infinite loop 3 95
Modbus - whats the maximum I can store in one register? 4 78
unix in java example 9 52
Shell Script on AIX 7 63
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now