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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MarkLogic 1 117
Unix Script: Loop over all days of a month 17 130
How do disable only TLSv1.0 in Oracle Sun One 7.1 Server 9 149
leap year shell script 10 50
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap ( Version 1.2 2.      Jpcap( Version 0.6 Prerequisite: 1.      GCC …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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…
Suggested Courses

732 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